@buffcore/cli 0.8.42 → 0.8.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/commands/design/references.d.ts +9 -0
- package/dist/commands/design/references.js +20 -1
- package/dist/commands/extension/places-approval.d.ts +1 -1
- package/dist/commands/prototype/comp-record.d.ts +27 -0
- package/dist/commands/prototype/comp-record.js +85 -0
- package/dist/commands/prototype/comp-words.d.ts +12 -0
- package/dist/commands/prototype/comp-words.js +24 -0
- package/dist/commands/prototype/comp.d.ts +26 -0
- package/dist/commands/prototype/comp.js +71 -0
- package/dist/commands/prototype/milestone-versions.d.ts +1 -1
- package/dist/commands/prototype/record-look-child.js +4 -1
- package/dist/commands/prototype/snapshot-command.js +1 -1
- package/dist/commands/prototype/snapshot-setup.d.ts +11 -0
- package/dist/commands/prototype/snapshot-setup.js +29 -5
- package/dist/commands/prototype/versions.d.ts +3 -3
- package/dist/commands/ui/agents-route.d.ts +2 -0
- package/dist/commands/ui/agents-route.js +8 -5
- package/dist/commands/ui/approval-authority.d.ts +1 -1
- package/dist/commands/ui/approve.js +7 -1
- package/dist/commands/ui/chat/codex-idle.d.ts +1 -0
- package/dist/commands/ui/chat/fresh-critique.d.ts +28 -0
- package/dist/commands/ui/chat/fresh-critique.js +121 -0
- package/dist/commands/ui/chat/fresh-launch.d.ts +31 -0
- package/dist/commands/ui/chat/fresh-launch.js +122 -0
- package/dist/commands/ui/chat/fresh-prompts.d.ts +17 -0
- package/dist/commands/ui/chat/fresh-prompts.js +76 -0
- package/dist/commands/ui/chat/fresh-report.d.ts +8 -0
- package/dist/commands/ui/chat/fresh-report.js +36 -0
- package/dist/commands/ui/chat/fresh-routes.d.ts +3 -0
- package/dist/commands/ui/chat/fresh-routes.js +64 -0
- package/dist/commands/ui/chat/fresh-settings.d.ts +12 -0
- package/dist/commands/ui/chat/fresh-settings.js +66 -0
- package/dist/commands/ui/chat/fresh-store.d.ts +17 -0
- package/dist/commands/ui/chat/fresh-store.js +67 -0
- package/dist/commands/ui/chat/fresh.d.ts +31 -0
- package/dist/commands/ui/chat/fresh.en.d.ts +7 -0
- package/dist/commands/ui/chat/fresh.en.js +7 -0
- package/dist/commands/ui/chat/fresh.es.d.ts +7 -0
- package/dist/commands/ui/chat/fresh.es.js +7 -0
- package/dist/commands/ui/chat/fresh.js +112 -0
- package/dist/commands/ui/chat/limit-mentions.d.ts +2 -2
- package/dist/commands/ui/chat/limit-mentions.js +22 -2
- package/dist/commands/ui/chat/limits.d.ts +8 -1
- package/dist/commands/ui/chat/limits.en.d.ts +2 -0
- package/dist/commands/ui/chat/limits.en.js +2 -0
- package/dist/commands/ui/chat/limits.es.js +2 -0
- package/dist/commands/ui/chat/limits.js +13 -1
- package/dist/commands/ui/chat/parse-claude.js +7 -3
- package/dist/commands/ui/chat/permission-ask.js +3 -0
- package/dist/commands/ui/chat/planning-limits.js +15 -0
- package/dist/commands/ui/chat/publish-limits.d.ts +4 -0
- package/dist/commands/ui/chat/publish-limits.js +97 -0
- package/dist/commands/ui/chat/recorded-turn.js +3 -0
- package/dist/commands/ui/chat/stream.js +4 -1
- package/dist/commands/ui/chat/turn-guard.d.ts +2 -0
- package/dist/commands/ui/chat/turn-guard.js +12 -0
- package/dist/commands/ui/chat/turn-state.d.ts +5 -0
- package/dist/commands/ui/chat/turn.js +1 -0
- package/dist/commands/ui/comp-approval.d.ts +6 -0
- package/dist/commands/ui/comp-approval.js +42 -0
- package/dist/commands/ui/host.js +3 -0
- package/dist/commands/ui/index.js +18 -6
- package/dist/commands/ui/loop-approve.d.ts +4 -4
- package/dist/commands/ui/places-change.d.ts +1 -1
- package/dist/commands/ui/plan-structure.d.ts +3 -0
- package/dist/commands/ui/plan-structure.en.d.ts +3 -0
- package/dist/commands/ui/plan-structure.en.js +3 -0
- package/dist/commands/ui/plan-structure.es.d.ts +3 -0
- package/dist/commands/ui/plan-structure.es.js +3 -0
- package/dist/commands/ui/plan-structure.js +12 -4
- package/dist/commands/ui/prototype-comp-route.d.ts +7 -0
- package/dist/commands/ui/prototype-comp-route.js +109 -0
- package/dist/commands/ui/prototype-main.d.ts +2 -1
- package/dist/commands/ui/prototype-scenes-child.js +4 -1
- package/dist/commands/ui/prototype-snapshot-session.d.ts +1 -1
- package/dist/commands/ui/prototype-snapshot-session.js +3 -0
- package/dist/commands/ui/prototype-snapshot.d.ts +1 -1
- package/dist/commands/ui/routes.d.ts +6 -3
- package/dist/commands/ui/routes.js +3 -3
- package/dist/commands/ui/save-publish.js +3 -0
- package/dist/commands/ui/server.d.ts +7 -0
- package/dist/commands/ui/server.js +7 -3
- package/dist/commands/ui/structure-surface.d.ts +6 -0
- package/dist/commands/ui/structure-surface.js +94 -0
- package/dist/commands/ui/studio-routes.js +4 -0
- package/dist/commands/ui/studio-state.d.ts +6 -4
- package/dist/commands/ui/studio-versions.d.ts +3 -3
- package/dist/ui/page.js +81 -81
- package/docs/PROCESS.md +5 -0
- package/docs/PROTOTYPE.md +20 -0
- package/docs/WORKBENCH.md +2 -2
- package/package.json +11 -11
- package/skills/ape-critique/SKILL.md +9 -3
- package/skills/ape-design-system/SKILL.md +2 -1
- package/skills/ape-prototype/SKILL.md +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,17 @@ One section per release (a git tag). **Upgrade notes** list anything that breaks
|
|
|
4
4
|
|
|
5
5
|
## Unreleased
|
|
6
6
|
|
|
7
|
+
## v0.8.43 (2026-12-02)
|
|
8
|
+
|
|
9
|
+
- Publishing is a limit at every level, "Never ask" included: `npm publish` (and the short names npm accepts, `npm pu` to `npm publis`), `pnpm publish`, `yarn publish`, `yarn npm publish` and `gh release create|new|upload|edit|delete` are refused through every wrapper the limits read; `npm view`, `gh release list` and other reads still run, and a command that only asks for `--help` runs. A command a limit refused now shows a card in the step's chat, **This can't be allowed here**, naming the limit and the command, with **Copy the command** and no Allow (Claude Code turns; the card is marked from the hook's own refusal). The chat contract's refused event gains an optional `limit`. Not caught: `bun publish`, `lerna publish`, `changeset publish` and `gh api` release calls.
|
|
10
|
+
- A fresh look before Save on Brief, Plan, Journeys and Structure: when the step's agent finishes a turn that changed the step's files, the studio starts a second, read-only turn (Claude Code, a new session, the step's model) that reads the step, the earlier steps and AGENTS.md and lists at most seven findings beside Save, each with **Take** (sent to the step's chat) or **Leave**. Save never waits for it; on Autopilot the step saves as before and the findings stay beside it. Findings are kept in `.ape/fresh/`, never in git; Settings › Agents turns it off (`review: false` in `plan/agents.md`).
|
|
11
|
+
- The critique runs as its own turn: after a full snapshot passes on the Prototype page, the studio starts a fresh, read-only turn with the `ape-critique` skill (the validation agent, Claude Code) and writes its answer to `design/critique.md`; the page shows it running, then names the file. A passing full snapshot the Prototype step's agent took itself starts it too, when that turn ends. One runs at a time, and never twice for the same snapshot. Fresh turns run with Claude Code only; with Codex or OpenCode there is none.
|
|
12
|
+
|
|
13
|
+
**Upgrade notes** (hosts that build their own studio server): the fresh turns are wired in `ape ui` only. To offer them, create a `FreshLooks` with your agent start, pass it to `ChatEngine` as `fresh`, add `freshRoutes(fresh, root)` to the routes and `onFullSnapshot: (source, report) => fresh.afterSnapshot(source, report)` to `createUiServer`. Without them the studio shows no findings and no critique.
|
|
14
|
+
- The look is agreed on three screens first. Structure asks **Which surface comes first?** (Desktop or Phone) and keeps the answer as a `Surface:` line in `plan/structure.md`'s header (absent, desktop). The agent draws the comp, scenes keyed `comp/<name>`, and `ape prototype snapshot --scene 'comp/*'` shoots them at that surface's width into `prototype/snapshots/comp/<commit>/`, apart from the scenes: they never count toward totals, completeness, reuse or versions. The Prototype page shows **The look, on three screens** beside the pictures `design/references.md` lists (a placeholder when there are none), with **Approve the look**: a person's at every level, recorded in `prototype/versions/comp.json`, refused for an agent. The approval kinds gain `comp` (person only); the workbench contracts gain the comp read, its pictures and the surface answer ([PROTOTYPE.md](docs/PROTOTYPE.md#the-comp)). The `ape-prototype`, `ape-critique` and `ape-design-system` skills draw and judge against the approved comp. The approval is saved as its own commit (`prototype: approve the look`) in `prototype/versions/comp.json`, where agents' file tools, coding commands and merged branches cannot write, and a record made any other way does not count. Reference pictures are served with their own type (PNG, JPEG, WebP, GIF or AVIF); a host serves only those inside the product's folder, the local `ape ui` any listed path. Structure's `Surface:` line is read in any case, trimmed, and a wrong one is refused naming its line. The studio's scene list and default app screen leave `comp/` scenes out.
|
|
15
|
+
|
|
16
|
+
**Upgrade notes** (every product): a host whose authority approves the comp (`createUiServer({ approval })`) gets the comp approval sent to it as for other kinds (`kind: 'comp'`), but the studio shows the look as approved only from the product's `prototype/versions/comp.json`: write the approved record there, or the page keeps asking.
|
|
17
|
+
|
|
7
18
|
## v0.8.42 (2026-12-02)
|
|
8
19
|
|
|
9
20
|
- 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)).
|
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import type { Tell } from './tells.ts';
|
|
2
2
|
/** Each picture `design/references.md` names (in backticks or as a link) that is not there. */
|
|
3
3
|
export declare function missingReferences(root: string): Promise<Tell[]>;
|
|
4
|
+
/** One picture `design/references.md` lists, in its place: where it is, if on this computer. */
|
|
5
|
+
export interface ReferencePicture {
|
|
6
|
+
/** The file, when the line names one on this computer that exists; a web address has none. */
|
|
7
|
+
file?: string;
|
|
8
|
+
/** Whether the file is inside the product's folder (a host serves only those). */
|
|
9
|
+
inside: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** Every picture `design/references.md` lists, in its order, so screen n meets the nth. */
|
|
12
|
+
export declare function referencePictures(root: string): Promise<ReferencePicture[]>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { existsSync } from 'node:fs';
|
|
4
4
|
import { readFile } from 'node:fs/promises';
|
|
5
5
|
import { homedir } from 'node:os';
|
|
6
|
-
import { join, resolve } from 'node:path';
|
|
6
|
+
import { isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
7
7
|
const PICTURE = /`([^`\r\n]+?\.(?:png|jpe?g|webp|gif|avif))`|\]\(([^)\s]+?\.(?:png|jpe?g|webp|gif|avif))\)/gi;
|
|
8
8
|
/** Each picture `design/references.md` names (in backticks or as a link) that is not there. */
|
|
9
9
|
export async function missingReferences(root) {
|
|
@@ -23,3 +23,22 @@ export async function missingReferences(root) {
|
|
|
23
23
|
}
|
|
24
24
|
return tells;
|
|
25
25
|
}
|
|
26
|
+
/** Every picture `design/references.md` lists, in its order, so screen n meets the nth. */
|
|
27
|
+
export async function referencePictures(root) {
|
|
28
|
+
const file = join(root, 'design', 'references.md');
|
|
29
|
+
if (!existsSync(file))
|
|
30
|
+
return [];
|
|
31
|
+
const found = [];
|
|
32
|
+
for (const [, quoted, linked] of (await readFile(file, 'utf8')).matchAll(PICTURE)) {
|
|
33
|
+
const path = quoted ?? linked ?? '';
|
|
34
|
+
if (/^(?:https?:\/\/|\\\\|\/\/)/i.test(path)) {
|
|
35
|
+
found.push({ inside: false });
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const full = /^~[/]/.test(path) ? join(homedir(), path.slice(2)) : resolve(root, path);
|
|
39
|
+
const from = relative(root, full);
|
|
40
|
+
const inside = !!from && !isAbsolute(from) && from !== '..' && !from.startsWith(`..${sep}`);
|
|
41
|
+
found.push(existsSync(full) ? { file: full, inside } : { inside });
|
|
42
|
+
}
|
|
43
|
+
return found;
|
|
44
|
+
}
|
|
@@ -14,7 +14,7 @@ export declare const placesGit: (root: string, args: string[]) => string;
|
|
|
14
14
|
export declare function localSigner(root: string): string;
|
|
15
15
|
export declare const parsePlaces: (text?: string) => {
|
|
16
16
|
approvals: {
|
|
17
|
-
kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
|
|
17
|
+
kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
|
|
18
18
|
signatures: {
|
|
19
19
|
by: string;
|
|
20
20
|
at: string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Approval } from '@buffcore/contracts/approvals';
|
|
2
|
+
import { type CompSnapshot } from './comp.ts';
|
|
3
|
+
export declare const COMP_FILE = "prototype/versions/comp.json";
|
|
4
|
+
/** The subject of the one commit that may write the record (`stepMessage`). */
|
|
5
|
+
export declare const COMP_SUBJECT = "prototype: approve the look";
|
|
6
|
+
export interface CompRecord {
|
|
7
|
+
folder: string;
|
|
8
|
+
approval: Approval;
|
|
9
|
+
}
|
|
10
|
+
/** The record as the approval commit left it: committed at HEAD by that commit, unchanged on disk. */
|
|
11
|
+
export declare function readCompApproval(root: string): CompRecord | undefined;
|
|
12
|
+
/** Whether a person's approval holds for this comp: its folder and the pictures it showed. */
|
|
13
|
+
export declare function compApproved(record: CompRecord | undefined, comp: CompSnapshot | undefined): boolean;
|
|
14
|
+
export interface CompSigner {
|
|
15
|
+
by: string;
|
|
16
|
+
/** The commit checked out when the person approved. */
|
|
17
|
+
commit: string;
|
|
18
|
+
fingerprint: string;
|
|
19
|
+
role?: string;
|
|
20
|
+
/** Set when an agent asks: always refused, at every level. */
|
|
21
|
+
agent?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A person approves the comp the page showed; an agent never does. Writes the record when `write`
|
|
25
|
+
* (the studio's approval save commits it on its own); returns what the file holds.
|
|
26
|
+
*/
|
|
27
|
+
export declare function approveComp(root: string, signer: CompSigner, write?: boolean): CompRecord;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// The comp's approval record, `prototype/versions/comp.json`: inside the folder the file tools,
|
|
2
|
+
// the coding commands and the merge guard keep from agents, as version approvals are, and saved
|
|
3
|
+
// only as the studio's own isolated commit (`saveApprovalRecord`, subject COMP_SUBJECT). A record
|
|
4
|
+
// put there any other way, or edited after that commit, does not count.
|
|
5
|
+
import { randomUUID } from 'node:crypto';
|
|
6
|
+
import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { approvalHolds, approvalSchema } from '@buffcore/contracts/approvals';
|
|
9
|
+
import { ApprovalRefusal, approvalRule, signApproval } from '../approval-rules.js';
|
|
10
|
+
import { hostGitBytes } from '../safe-git.js';
|
|
11
|
+
import { newestComp } from './comp.js';
|
|
12
|
+
import { compT } from './comp-words.js';
|
|
13
|
+
export const COMP_FILE = 'prototype/versions/comp.json';
|
|
14
|
+
/** The subject of the one commit that may write the record (`stepMessage`). */
|
|
15
|
+
export const COMP_SUBJECT = 'prototype: approve the look';
|
|
16
|
+
const lf = (text) => text.replace(/\r\n/g, '\n');
|
|
17
|
+
/** The record as the approval commit left it: committed at HEAD by that commit, unchanged on disk. */
|
|
18
|
+
export function readCompApproval(root) {
|
|
19
|
+
try {
|
|
20
|
+
const git = (args) => hostGitBytes(root, args).toString('utf8');
|
|
21
|
+
const committed = git(['show', `HEAD:./${COMP_FILE}`]);
|
|
22
|
+
const subject = git(['log', '-1', '--format=%s', 'HEAD', '--', `./${COMP_FILE}`]).trim();
|
|
23
|
+
if (subject !== COMP_SUBJECT)
|
|
24
|
+
return;
|
|
25
|
+
if (lf(readFileSync(join(root, COMP_FILE), 'utf8')) !== lf(committed))
|
|
26
|
+
return;
|
|
27
|
+
const record = JSON.parse(committed);
|
|
28
|
+
const approval = approvalSchema.parse(record?.approval);
|
|
29
|
+
if (typeof record.folder !== 'string' || approval.kind !== 'comp')
|
|
30
|
+
return;
|
|
31
|
+
return { folder: record.folder, approval };
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** Whether a person's approval holds for this comp: its folder and the pictures it showed. */
|
|
38
|
+
export function compApproved(record, comp) {
|
|
39
|
+
return (!!record &&
|
|
40
|
+
!!comp &&
|
|
41
|
+
record.folder === comp.folder &&
|
|
42
|
+
approvalHolds(record.approval, new Date()) &&
|
|
43
|
+
record.approval.signatures.every((s) => s.fingerprint === comp.fingerprint));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A person approves the comp the page showed; an agent never does. Writes the record when `write`
|
|
47
|
+
* (the studio's approval save commits it on its own); returns what the file holds.
|
|
48
|
+
*/
|
|
49
|
+
export function approveComp(root, signer, write = true) {
|
|
50
|
+
if (signer.agent !== undefined)
|
|
51
|
+
throw new ApprovalRefusal(compT('comp.person'));
|
|
52
|
+
const comp = newestComp(root);
|
|
53
|
+
if (!comp)
|
|
54
|
+
throw new ApprovalRefusal(compT('comp.missing'));
|
|
55
|
+
if (!comp.report.scenes.length)
|
|
56
|
+
throw new ApprovalRefusal(compT('comp.empty'));
|
|
57
|
+
if (comp.fingerprint !== signer.fingerprint)
|
|
58
|
+
throw new ApprovalRefusal(compT('comp.changed'));
|
|
59
|
+
const earlier = readCompApproval(root);
|
|
60
|
+
if (compApproved(earlier, comp))
|
|
61
|
+
throw new ApprovalRefusal(compT('comp.approved'));
|
|
62
|
+
// A partial rule's signatures carry on for the same comp; a new comp starts a new approval.
|
|
63
|
+
const previous = earlier?.folder === comp.folder &&
|
|
64
|
+
earlier.approval.signatures.every((s) => s.fingerprint === comp.fingerprint)
|
|
65
|
+
? earlier.approval
|
|
66
|
+
: undefined;
|
|
67
|
+
const approval = signApproval(previous, 'comp', {
|
|
68
|
+
by: signer.by.trim(),
|
|
69
|
+
at: new Date().toISOString(),
|
|
70
|
+
commit: signer.commit,
|
|
71
|
+
fingerprint: comp.fingerprint,
|
|
72
|
+
...(signer.role ? { role: signer.role } : {}),
|
|
73
|
+
}, approvalRule(root, 'comp'));
|
|
74
|
+
const record = { folder: comp.folder, approval };
|
|
75
|
+
if (write)
|
|
76
|
+
writeRecord(root, record);
|
|
77
|
+
return record;
|
|
78
|
+
}
|
|
79
|
+
function writeRecord(root, record) {
|
|
80
|
+
const file = join(root, COMP_FILE);
|
|
81
|
+
mkdirSync(join(root, 'prototype', 'versions'), { recursive: true });
|
|
82
|
+
const temporary = `${file}.${randomUUID()}.tmp`;
|
|
83
|
+
writeFileSync(temporary, `${JSON.stringify(record, null, 2)}\n`);
|
|
84
|
+
renameSync(temporary, file);
|
|
85
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare const en: {
|
|
2
|
+
'comp.person': string;
|
|
3
|
+
'comp.missing': string;
|
|
4
|
+
'comp.changed': string;
|
|
5
|
+
'comp.empty': string;
|
|
6
|
+
'comp.approved': string;
|
|
7
|
+
'comp.identity': string;
|
|
8
|
+
'comp.commitFirst': string;
|
|
9
|
+
'comp.mixed': string;
|
|
10
|
+
};
|
|
11
|
+
export declare const compT: (key: keyof typeof en) => string;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createI18n } from '@buffcore/i18n';
|
|
2
|
+
import { locale } from './messages.js';
|
|
3
|
+
const en = {
|
|
4
|
+
'comp.person': 'A person approves the look, at every level. An agent cannot.',
|
|
5
|
+
'comp.missing': 'There is no comp to approve yet: ask the agent to draw the three screens and snapshot them.',
|
|
6
|
+
'comp.changed': 'The comp changed since this page showed it. Look at the new screens, then approve.',
|
|
7
|
+
'comp.empty': 'The comp snapshot lists no screens: snapshot the comp again.',
|
|
8
|
+
'comp.approved': 'This look is already approved.',
|
|
9
|
+
'comp.identity': 'Set your name in Git (git config user.email) so the approval can name you.',
|
|
10
|
+
'comp.commitFirst': 'Commit first, so the approval can name a commit.',
|
|
11
|
+
'comp.mixed': "Snapshot the comp on its own (--scene 'comp/*'): its screens are kept apart from the scenes.",
|
|
12
|
+
};
|
|
13
|
+
const es = {
|
|
14
|
+
'comp.person': 'Una persona aprueba el aspecto, en todos los niveles. Un agente no puede.',
|
|
15
|
+
'comp.missing': 'Aún no hay un boceto que aprobar: pide al agente que dibuje las tres pantallas y las capture.',
|
|
16
|
+
'comp.changed': 'El boceto cambió desde que esta página lo mostró. Mira las pantallas nuevas y luego aprueba.',
|
|
17
|
+
'comp.empty': 'La captura del boceto no tiene pantallas: vuelve a capturar el boceto.',
|
|
18
|
+
'comp.approved': 'Este aspecto ya está aprobado.',
|
|
19
|
+
'comp.identity': 'Pon tu nombre en Git (git config user.email) para que la aprobación te nombre.',
|
|
20
|
+
'comp.commitFirst': 'Haz un commit primero, para que la aprobación nombre uno.',
|
|
21
|
+
'comp.mixed': "Captura el boceto por separado (--scene 'comp/*'): sus pantallas se guardan aparte de las escenas.",
|
|
22
|
+
};
|
|
23
|
+
const translator = createI18n({ catalogs: [{ en, es }] });
|
|
24
|
+
export const compT = (key) => translator.t(locale(), key);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Frame } from '@buffcore/config';
|
|
2
|
+
import type { FirstSurface } from '@buffcore/contracts/workbench';
|
|
3
|
+
import { type SnapshotReport } from './report.ts';
|
|
4
|
+
export declare const COMP_PREFIX = "comp/";
|
|
5
|
+
/**
|
|
6
|
+
* `plan/structure.md`'s one header field, before its table; absent, desktop comes first. Any case,
|
|
7
|
+
* spaces around the value allowed. `SURFACE_FIELD` finds a line meant as one, right or wrong.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SURFACE_LINE: RegExp;
|
|
10
|
+
export declare const SURFACE_FIELD: RegExp;
|
|
11
|
+
export declare const isCompScene: (key: string) => boolean;
|
|
12
|
+
/** Where a snapshot folder's comp runs go: beside the commits, never inside one. */
|
|
13
|
+
export declare const compDir: (snapshots: string) => string;
|
|
14
|
+
/** The frame the comp is judged in: the product's desktop frame, or the phone's 390. */
|
|
15
|
+
export declare const compFrame: (surface: FirstSurface) => Frame;
|
|
16
|
+
/** Which surface comes first, as `plan/structure.md` says (the parser's rule); absent, desktop. */
|
|
17
|
+
export declare function firstSurface(root: string): FirstSurface;
|
|
18
|
+
export interface CompSnapshot {
|
|
19
|
+
/** `prototype/snapshots/comp/<commit>`, from the product's root. */
|
|
20
|
+
folder: string;
|
|
21
|
+
report: SnapshotReport;
|
|
22
|
+
/** What Approve the look signs: the comp report's bytes (they hold each picture's hash). */
|
|
23
|
+
fingerprint: string;
|
|
24
|
+
}
|
|
25
|
+
/** The newest finished comp snapshot, by its report's date. */
|
|
26
|
+
export declare function newestComp(root: string): CompSnapshot | undefined;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// The comp (docs/PROTOTYPE.md): the three deciding screens, scenes under `comp/`, shot at the first
|
|
2
|
+
// surface's width into their own folder (`prototype/snapshots/comp/<commit>/`), never into the
|
|
3
|
+
// scenes' report. A person approves the look; `comp-record.ts` keeps that approval.
|
|
4
|
+
import { readdirSync, readFileSync } from 'node:fs';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { snapshotsDir } from './report.js';
|
|
7
|
+
import { sha256 } from './snapshot-hashes.js';
|
|
8
|
+
export const COMP_PREFIX = 'comp/';
|
|
9
|
+
/**
|
|
10
|
+
* `plan/structure.md`'s one header field, before its table; absent, desktop comes first. Any case,
|
|
11
|
+
* spaces around the value allowed. `SURFACE_FIELD` finds a line meant as one, right or wrong.
|
|
12
|
+
*/
|
|
13
|
+
export const SURFACE_LINE = /^surface:[ \t]*(desktop|phone)[ \t]*$/i;
|
|
14
|
+
export const SURFACE_FIELD = /^surface[ \t]*:/i;
|
|
15
|
+
export const isCompScene = (key) => key.startsWith(COMP_PREFIX);
|
|
16
|
+
/** Where a snapshot folder's comp runs go: beside the commits, never inside one. */
|
|
17
|
+
export const compDir = (snapshots) => join(snapshots, 'comp');
|
|
18
|
+
/** The frame the comp is judged in: the product's desktop frame, or the phone's 390. */
|
|
19
|
+
export const compFrame = (surface) => surface === 'phone' ? 'phone' : 'desktop';
|
|
20
|
+
/** Which surface comes first, as `plan/structure.md` says (the parser's rule); absent, desktop. */
|
|
21
|
+
export function firstSurface(root) {
|
|
22
|
+
let text = '';
|
|
23
|
+
try {
|
|
24
|
+
text = readFileSync(join(root, 'plan', 'structure.md'), 'utf8');
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return 'desktop';
|
|
28
|
+
}
|
|
29
|
+
for (const line of text.replace(/^\uFEFF/, '').split(/\r\n|\r|\n/)) {
|
|
30
|
+
if (line.startsWith('|'))
|
|
31
|
+
break;
|
|
32
|
+
const found = SURFACE_LINE.exec(line);
|
|
33
|
+
if (found)
|
|
34
|
+
return found[1]?.toLowerCase();
|
|
35
|
+
}
|
|
36
|
+
return 'desktop';
|
|
37
|
+
}
|
|
38
|
+
/** The newest finished comp snapshot, by its report's date. */
|
|
39
|
+
export function newestComp(root) {
|
|
40
|
+
const dir = compDir(snapshotsDir(root));
|
|
41
|
+
let best;
|
|
42
|
+
let entries = [];
|
|
43
|
+
try {
|
|
44
|
+
entries = readdirSync(dir).filter((name) => /^[0-9a-f]{7,64}$/.test(name));
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
for (const name of entries) {
|
|
50
|
+
let bytes;
|
|
51
|
+
let report;
|
|
52
|
+
try {
|
|
53
|
+
bytes = readFileSync(join(dir, name, 'report.json'));
|
|
54
|
+
report = JSON.parse(String(bytes));
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const at = Date.parse(report?.createdAt ?? '');
|
|
60
|
+
if (!Array.isArray(report?.scenes) || report.commit !== name || !Number.isFinite(at))
|
|
61
|
+
continue;
|
|
62
|
+
if (best && best.at >= at)
|
|
63
|
+
continue;
|
|
64
|
+
const folder = `prototype/snapshots/comp/${name}`;
|
|
65
|
+
best = { folder, report, fingerprint: `comp:${sha256(bytes)}`, at };
|
|
66
|
+
}
|
|
67
|
+
if (!best)
|
|
68
|
+
return;
|
|
69
|
+
const { at: _at, ...comp } = best;
|
|
70
|
+
return comp;
|
|
71
|
+
}
|
|
@@ -22,7 +22,7 @@ export declare function readMilestoneVersions(root: string, milestone: string, r
|
|
|
22
22
|
at: string;
|
|
23
23
|
covers: string[];
|
|
24
24
|
approval?: {
|
|
25
|
-
kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
|
|
25
|
+
kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
|
|
26
26
|
signatures: {
|
|
27
27
|
by: string;
|
|
28
28
|
at: string;
|
|
@@ -45,7 +45,10 @@ async function sceneKeys(dir) {
|
|
|
45
45
|
if (!existsSync(file))
|
|
46
46
|
return undefined;
|
|
47
47
|
const module = await import(__rewriteRelativeImportExtension(pathToFileURL(file).href));
|
|
48
|
-
|
|
48
|
+
// The comp's scenes (`comp/`) are snapshotted apart and never belong to a version's report.
|
|
49
|
+
return module.default.scenes
|
|
50
|
+
.map((scene) => scene.key)
|
|
51
|
+
.filter((key) => !key.startsWith('comp/'));
|
|
49
52
|
}
|
|
50
53
|
try {
|
|
51
54
|
const design = (await designState(root, theme))?.hash ?? '';
|
|
@@ -104,7 +104,7 @@ async function drawn(flags, hints, servers) {
|
|
|
104
104
|
: `${run.scenes.scenes.length} scenes`;
|
|
105
105
|
console.log(`Snapshot of ${count}:`);
|
|
106
106
|
const report = await taken(run, commit);
|
|
107
|
-
if (own && report.scene === undefined && !report.problems.length)
|
|
107
|
+
if (own && !run.comp && report.scene === undefined && !report.problems.length)
|
|
108
108
|
await shareShots(root, join(dir, commit), report);
|
|
109
109
|
const selected = new Set(picked.map((scene) => scene.key));
|
|
110
110
|
const fresh = report.scenes.filter((scene) => selected.has(scene.key));
|
|
@@ -19,6 +19,8 @@ export interface SetupFlags {
|
|
|
19
19
|
}
|
|
20
20
|
export interface Setup {
|
|
21
21
|
root: string;
|
|
22
|
+
/** A run of the comp's scenes alone, into the comp's own folder (`comp.ts`). */
|
|
23
|
+
comp: boolean;
|
|
22
24
|
own: SnapshotEnvironment | undefined;
|
|
23
25
|
servers: Servers;
|
|
24
26
|
scene: SceneSelection | undefined;
|
|
@@ -39,3 +41,12 @@ export type Servers = {
|
|
|
39
41
|
};
|
|
40
42
|
/** Everything a run needs before it draws: the environment, the locks, the pin, the servers. */
|
|
41
43
|
export declare function setup(flags: SetupFlags, servers: Servers): Promise<Setup>;
|
|
44
|
+
/**
|
|
45
|
+
* The scenes a run draws: the comp's alone (every picked scene under `comp/`, shot in the first
|
|
46
|
+
* surface's frame), or the others with the comp left out, so it never counts toward their totals,
|
|
47
|
+
* completeness or fingerprints. A selection that mixes the two is refused.
|
|
48
|
+
*/
|
|
49
|
+
export declare function runScenes(root: string, scenes: Scenes, scene: SceneSelection | undefined): {
|
|
50
|
+
comp: boolean;
|
|
51
|
+
scenes: Scenes;
|
|
52
|
+
};
|
|
@@ -13,6 +13,8 @@ import { pathToFileURL } from 'node:url';
|
|
|
13
13
|
import { coreEnvSchema, defineEnv, frameSizes, isContainer, } from '@buffcore/config';
|
|
14
14
|
import { developmentOnly, findRoot, loadEnv, loadProduct } from '../../project.js';
|
|
15
15
|
import { loadTheme } from '../design/sources.js';
|
|
16
|
+
import { compDir, compFrame, firstSurface, isCompScene } from './comp.js';
|
|
17
|
+
import { compT } from './comp-words.js';
|
|
16
18
|
import { ownSceneKeys } from './own-scenes.js';
|
|
17
19
|
import { sceneTimeoutSeconds } from './scene-render.js';
|
|
18
20
|
import { sceneSelection } from './scene-selection.js';
|
|
@@ -69,8 +71,9 @@ export async function setup(flags, servers) {
|
|
|
69
71
|
await pruneShots(root);
|
|
70
72
|
}
|
|
71
73
|
const checkout = flags.remake ? undefined : pinSnapshotCheckout(root);
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
+
const [product, all] = await Promise.all([loadProduct(root), loadScenes(root)]);
|
|
75
|
+
const { comp, scenes } = runScenes(root, all, scene);
|
|
76
|
+
const progress = scene === undefined && !comp ? checkout?.progress() : undefined;
|
|
74
77
|
// A linked worktree's addresses are the run's own: they are filled in when its servers start.
|
|
75
78
|
const urls = own
|
|
76
79
|
? {}
|
|
@@ -82,7 +85,7 @@ export async function setup(flags, servers) {
|
|
|
82
85
|
urls[process.name] = `http://127.0.0.1:${process.port}`;
|
|
83
86
|
}
|
|
84
87
|
// An unknown scene is refused before anything runs; only the surfaces snapshotted must answer.
|
|
85
|
-
const picked = pickScenes(scenes, scene);
|
|
88
|
+
const picked = pickScenes(scenes, comp ? undefined : scene);
|
|
86
89
|
if (servers.own) {
|
|
87
90
|
if (scene !== undefined)
|
|
88
91
|
await servers.own.prepare(picked);
|
|
@@ -92,10 +95,11 @@ export async function setup(flags, servers) {
|
|
|
92
95
|
if (process.env.APE_SNAPSHOT_VALIDATION_COMMIT !== undefined)
|
|
93
96
|
checkout?.check();
|
|
94
97
|
const ownScenes = flags.ownFirst ? await ownSceneKeys(root, picked) : undefined;
|
|
95
|
-
const dir = validationDirectory(root);
|
|
98
|
+
const dir = comp ? compDir(validationDirectory(root)) : validationDirectory(root);
|
|
96
99
|
const started = performance.now();
|
|
97
100
|
return {
|
|
98
101
|
root,
|
|
102
|
+
comp,
|
|
99
103
|
own,
|
|
100
104
|
servers,
|
|
101
105
|
scene,
|
|
@@ -111,7 +115,8 @@ export async function setup(flags, servers) {
|
|
|
111
115
|
frames: frameSizes(product),
|
|
112
116
|
urls,
|
|
113
117
|
dir,
|
|
114
|
-
|
|
118
|
+
// The comp's run is whole: its own report, never a part of the scenes'.
|
|
119
|
+
scene: comp ? undefined : scene,
|
|
115
120
|
sceneTimeout,
|
|
116
121
|
root,
|
|
117
122
|
pages: flags.pages,
|
|
@@ -120,3 +125,22 @@ export async function setup(flags, servers) {
|
|
|
120
125
|
seconds: () => Math.round((performance.now() - started) / 1000),
|
|
121
126
|
};
|
|
122
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* The scenes a run draws: the comp's alone (every picked scene under `comp/`, shot in the first
|
|
130
|
+
* surface's frame), or the others with the comp left out, so it never counts toward their totals,
|
|
131
|
+
* completeness or fingerprints. A selection that mixes the two is refused.
|
|
132
|
+
*/
|
|
133
|
+
export function runScenes(root, scenes, scene) {
|
|
134
|
+
const picked = scene === undefined ? [] : pickScenes(scenes, scene);
|
|
135
|
+
const comp = picked.filter((s) => isCompScene(s.key));
|
|
136
|
+
if (comp.length && comp.length !== picked.length)
|
|
137
|
+
throw new Error(compT('comp.mixed'));
|
|
138
|
+
if (comp.length) {
|
|
139
|
+
const frame = compFrame(firstSurface(root));
|
|
140
|
+
return { comp: true, scenes: { ...scenes, scenes: comp.map((s) => ({ ...s, frame })) } };
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
comp: false,
|
|
144
|
+
scenes: { ...scenes, scenes: scenes.scenes.filter((s) => !isCompScene(s.key)) },
|
|
145
|
+
};
|
|
146
|
+
}
|
|
@@ -37,7 +37,7 @@ export declare const recordFromCommand: (root: string, changes: readonly string[
|
|
|
37
37
|
approved?: {
|
|
38
38
|
version: number;
|
|
39
39
|
approval: {
|
|
40
|
-
kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
|
|
40
|
+
kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
|
|
41
41
|
signatures: {
|
|
42
42
|
by: string;
|
|
43
43
|
at: string;
|
|
@@ -62,7 +62,7 @@ export declare const recordFromCommand: (root: string, changes: readonly string[
|
|
|
62
62
|
pending?: {
|
|
63
63
|
version: number;
|
|
64
64
|
approval: {
|
|
65
|
-
kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
|
|
65
|
+
kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
|
|
66
66
|
signatures: {
|
|
67
67
|
by: string;
|
|
68
68
|
at: string;
|
|
@@ -87,7 +87,7 @@ export declare const recordFromCommand: (root: string, changes: readonly string[
|
|
|
87
87
|
superseded?: {
|
|
88
88
|
version: number;
|
|
89
89
|
approval: {
|
|
90
|
-
kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
|
|
90
|
+
kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
|
|
91
91
|
signatures: {
|
|
92
92
|
by: string;
|
|
93
93
|
at: string;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { UiRoute } from './routes.ts';
|
|
2
|
+
/** One queue per product for every write of plan/agents.md: each applies to the file the last left. */
|
|
3
|
+
export declare function queueAgentsWrite(root: string, write: () => Promise<void>): Promise<void>;
|
|
2
4
|
/** The UI server checks the viewer's settings right before this handler. */
|
|
3
5
|
export declare function agentsRoute(root: string): UiRoute;
|
|
@@ -38,19 +38,22 @@ async function saveAssignment(root, { role, agent }, local) {
|
|
|
38
38
|
if (file.level !== 'auto')
|
|
39
39
|
mergeEvent('level', root);
|
|
40
40
|
}
|
|
41
|
+
const queues = new Map();
|
|
42
|
+
/** One queue per product for every write of plan/agents.md: each applies to the file the last left. */
|
|
43
|
+
export function queueAgentsWrite(root, write) {
|
|
44
|
+
const next = (queues.get(root) ?? Promise.resolve()).then(write);
|
|
45
|
+
queues.set(root, next.catch(() => { }));
|
|
46
|
+
return next;
|
|
47
|
+
}
|
|
41
48
|
/** The UI server checks the viewer's settings right before this handler. */
|
|
42
49
|
export function agentsRoute(root) {
|
|
43
|
-
// Each request applies to the file left by the preceding assignment.
|
|
44
|
-
let pending = Promise.resolve();
|
|
45
50
|
return {
|
|
46
51
|
method: 'POST',
|
|
47
52
|
path: '/api/agents',
|
|
48
53
|
right: 'settings',
|
|
49
54
|
handle: async ({ body, level }) => {
|
|
50
55
|
const assignment = agentAssignmentSchema.parse(await body());
|
|
51
|
-
|
|
52
|
-
pending = write.catch(() => { });
|
|
53
|
-
await write;
|
|
56
|
+
await queueAgentsWrite(root, () => saveAssignment(root, assignment, !level));
|
|
54
57
|
return { status: 202, body: { ok: true } };
|
|
55
58
|
},
|
|
56
59
|
};
|
|
@@ -61,7 +61,7 @@ export declare function hostedApproval(context: ApprovalContext, resolve: () =>
|
|
|
61
61
|
} | {
|
|
62
62
|
status: number;
|
|
63
63
|
body: {
|
|
64
|
-
kind: "brand" | "money" | "places" | "plan" | "prototype" | "release";
|
|
64
|
+
kind: "brand" | "comp" | "money" | "places" | "plan" | "prototype" | "release";
|
|
65
65
|
signatures: {
|
|
66
66
|
by: string;
|
|
67
67
|
at: string;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { brandApprovalBody, changePlacesApprovalBody } from '@buffcore/contracts/workbench';
|
|
1
|
+
import { brandApprovalBody, changePlacesApprovalBody, compApprovalBodySchema, } from '@buffcore/contracts/workbench';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { ApprovalRefusal } from '../approval-rules.js';
|
|
4
4
|
import { requireLegacyChange } from '../prototype/milestone-key.js';
|
|
5
5
|
import { brandResolver, prototypeArtifact, releaseArtifact } from './approval-artifact.js';
|
|
6
6
|
import { authorityFor, hostedApproval } from './approval-authority.js';
|
|
7
|
+
import { compApproval, compResolver } from './comp-approval.js';
|
|
7
8
|
import { brandApproval, prototypeApproval } from './loop-approve.js';
|
|
8
9
|
import { placesApproval } from './places-approval.js';
|
|
9
10
|
import { approveChangePlaces } from './places-change-approval.js';
|
|
@@ -21,6 +22,7 @@ const approvalBody = z.union([
|
|
|
21
22
|
z.discriminatedUnion('kind', [
|
|
22
23
|
brandApprovalBody,
|
|
23
24
|
prototypeBody,
|
|
25
|
+
compApprovalBodySchema,
|
|
24
26
|
z.strictObject({ kind: z.literal('release') }),
|
|
25
27
|
z.strictObject({
|
|
26
28
|
kind: z.literal('places'),
|
|
@@ -57,6 +59,10 @@ export function brandApprovalRoute(root) {
|
|
|
57
59
|
const role = hosted ? identity?.viewer.role : undefined;
|
|
58
60
|
if (request.kind === 'places')
|
|
59
61
|
return placesApproval(root, request, signer, role, context, source);
|
|
62
|
+
if (request.kind === 'comp')
|
|
63
|
+
return context
|
|
64
|
+
? hostedApproval(context, await compResolver(root, request.fingerprint))
|
|
65
|
+
: compApproval(root, request.fingerprint, signer, role, undefined, source);
|
|
60
66
|
if (context) {
|
|
61
67
|
if (request.kind === 'brand') {
|
|
62
68
|
const resolve = await brandResolver(root, request.direction);
|
|
@@ -25,6 +25,7 @@ export declare function watchCodexIdle(child: ChildProcess, adapter: ChatAdapter
|
|
|
25
25
|
kind: "refused";
|
|
26
26
|
id: string;
|
|
27
27
|
reason?: "command" | "monitor" | "permission" | "redirect" | "taskOutput" | undefined;
|
|
28
|
+
limit?: "deploy" | "publish" | "push" | "release" | "secrets" | "settings" | undefined;
|
|
28
29
|
} | {
|
|
29
30
|
kind: "file";
|
|
30
31
|
path: string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type AgentsFile } from '@buffcore/contracts/workbench';
|
|
2
|
+
import type { Start, stopTree } from '../runner.ts';
|
|
3
|
+
import type { FreshStore } from './fresh-store.ts';
|
|
4
|
+
export interface CritiqueSource {
|
|
5
|
+
change?: string;
|
|
6
|
+
checkout: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class CritiqueTurns {
|
|
9
|
+
private run?;
|
|
10
|
+
private queued?;
|
|
11
|
+
private closed;
|
|
12
|
+
private readonly root;
|
|
13
|
+
private readonly start;
|
|
14
|
+
private readonly stop;
|
|
15
|
+
private readonly store;
|
|
16
|
+
private readonly settings;
|
|
17
|
+
constructor(root: string, start: Start, stop: typeof stopTree, store: FreshStore, settings: () => AgentsFile | undefined);
|
|
18
|
+
/** A Prototype turn ended: a passing full snapshot it took itself (since it began) starts one. */
|
|
19
|
+
afterTurn(startedAt: number): Promise<void>;
|
|
20
|
+
/** A full snapshot passed: start its critique, or queue it behind the one running. */
|
|
21
|
+
after(source: CritiqueSource, report?: string): boolean;
|
|
22
|
+
private agent;
|
|
23
|
+
private begin;
|
|
24
|
+
running(): boolean;
|
|
25
|
+
close(): void;
|
|
26
|
+
}
|
|
27
|
+
/** A record that cannot be written never fails the turn that started it. */
|
|
28
|
+
export declare function keep(write: () => void): boolean;
|