@12ui/design 0.2.15 → 0.2.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -1
- package/dist/branch-client.d.ts +6 -1
- package/dist/branch-client.d.ts.map +1 -1
- package/dist/branch-client.js +6 -1
- package/dist/branch-client.js.map +1 -1
- package/dist/branch-execution.d.ts +5 -0
- package/dist/branch-execution.d.ts.map +1 -1
- package/dist/branch-execution.js +26 -8
- package/dist/branch-execution.js.map +1 -1
- package/dist/branch-page-conversion.d.ts +18 -2
- package/dist/branch-page-conversion.d.ts.map +1 -1
- package/dist/branch-page-conversion.js +36 -16
- package/dist/branch-page-conversion.js.map +1 -1
- package/dist/branch-run-record.d.ts +3 -0
- package/dist/branch-run-record.d.ts.map +1 -1
- package/dist/branch-run-record.js.map +1 -1
- package/dist/branch-status.d.ts.map +1 -1
- package/dist/branch-status.js +3 -2
- package/dist/branch-status.js.map +1 -1
- package/dist/branch-winner.d.ts +31 -0
- package/dist/branch-winner.d.ts.map +1 -0
- package/dist/branch-winner.js +121 -0
- package/dist/branch-winner.js.map +1 -0
- package/dist/cli-arguments.d.ts +1 -0
- package/dist/cli-arguments.d.ts.map +1 -1
- package/dist/cli-arguments.js +4 -3
- package/dist/cli-arguments.js.map +1 -1
- package/dist/cli-branch-command.d.ts +3 -0
- package/dist/cli-branch-command.d.ts.map +1 -1
- package/dist/cli-branch-command.js +66 -98
- package/dist/cli-branch-command.js.map +1 -1
- package/dist/cli-capabilities.d.ts +33 -5
- package/dist/cli-capabilities.d.ts.map +1 -1
- package/dist/cli-capabilities.js +42 -5
- package/dist/cli-capabilities.js.map +1 -1
- package/dist/cli-convert-command.d.ts +10 -0
- package/dist/cli-convert-command.d.ts.map +1 -0
- package/dist/cli-convert-command.js +307 -0
- package/dist/cli-convert-command.js.map +1 -0
- package/dist/cli-corpus-command.d.ts +6 -1
- package/dist/cli-corpus-command.d.ts.map +1 -1
- package/dist/cli-corpus-command.js +17 -21
- package/dist/cli-corpus-command.js.map +1 -1
- package/dist/cli-create-command.d.ts +5 -1
- package/dist/cli-create-command.d.ts.map +1 -1
- package/dist/cli-create-command.js +28 -12
- package/dist/cli-create-command.js.map +1 -1
- package/dist/cli-detach.d.ts.map +1 -1
- package/dist/cli-detach.js +10 -2
- package/dist/cli-detach.js.map +1 -1
- package/dist/cli-draft-command.d.ts +9 -0
- package/dist/cli-draft-command.d.ts.map +1 -1
- package/dist/cli-draft-command.js +28 -8
- package/dist/cli-draft-command.js.map +1 -1
- package/dist/cli-export-command.d.ts +24 -1
- package/dist/cli-export-command.d.ts.map +1 -1
- package/dist/cli-export-command.js +6 -3
- package/dist/cli-export-command.js.map +1 -1
- package/dist/cli-image-batch-command.d.ts +8 -2
- package/dist/cli-image-batch-command.d.ts.map +1 -1
- package/dist/cli-image-batch-command.js +15 -11
- package/dist/cli-image-batch-command.js.map +1 -1
- package/dist/cli-image-batch-resume.d.ts +3 -1
- package/dist/cli-image-batch-resume.d.ts.map +1 -1
- package/dist/cli-image-batch-resume.js +1 -0
- package/dist/cli-image-batch-resume.js.map +1 -1
- package/dist/cli-image-command.d.ts +3 -1
- package/dist/cli-image-command.d.ts.map +1 -1
- package/dist/cli-image-command.js +4 -2
- package/dist/cli-image-command.js.map +1 -1
- package/dist/cli-package-command.d.ts +2 -0
- package/dist/cli-package-command.d.ts.map +1 -1
- package/dist/cli-package-command.js +15 -3
- package/dist/cli-package-command.js.map +1 -1
- package/dist/cli-refusal.d.ts +20 -0
- package/dist/cli-refusal.d.ts.map +1 -0
- package/dist/cli-refusal.js +29 -0
- package/dist/cli-refusal.js.map +1 -0
- package/dist/cli-run.d.ts +4 -0
- package/dist/cli-run.d.ts.map +1 -0
- package/dist/cli-run.js +215 -0
- package/dist/cli-run.js.map +1 -0
- package/dist/cli-select-command.d.ts +6 -1
- package/dist/cli-select-command.d.ts.map +1 -1
- package/dist/cli-select-command.js +9 -7
- package/dist/cli-select-command.js.map +1 -1
- package/dist/cli-skill-command.d.ts.map +1 -1
- package/dist/cli-skill-command.js +27 -12
- package/dist/cli-skill-command.js.map +1 -1
- package/dist/cli-usage.d.ts +17 -0
- package/dist/cli-usage.d.ts.map +1 -0
- package/dist/cli-usage.js +69 -0
- package/dist/cli-usage.js.map +1 -0
- package/dist/cli-version.d.ts +2 -0
- package/dist/cli-version.d.ts.map +1 -0
- package/dist/cli-version.js +8 -0
- package/dist/cli-version.js.map +1 -0
- package/dist/cli.js +9 -491
- package/dist/cli.js.map +1 -1
- package/dist/concept-input.d.ts +34 -0
- package/dist/concept-input.d.ts.map +1 -0
- package/dist/concept-input.js +41 -0
- package/dist/concept-input.js.map +1 -0
- package/dist/conversion-receipt-store.d.ts +75 -0
- package/dist/conversion-receipt-store.d.ts.map +1 -0
- package/dist/conversion-receipt-store.js +143 -0
- package/dist/conversion-receipt-store.js.map +1 -0
- package/dist/conversion-receipt.d.ts +139 -43
- package/dist/conversion-receipt.d.ts.map +1 -1
- package/dist/conversion-receipt.js +241 -73
- package/dist/conversion-receipt.js.map +1 -1
- package/dist/draft-adoption.d.ts +48 -0
- package/dist/draft-adoption.d.ts.map +1 -0
- package/dist/draft-adoption.js +237 -0
- package/dist/draft-adoption.js.map +1 -0
- package/dist/draft-run.d.ts +10 -0
- package/dist/draft-run.d.ts.map +1 -1
- package/dist/draft-run.js +16 -4
- package/dist/draft-run.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/legacy-skill-catalog.d.ts.map +1 -1
- package/dist/legacy-skill-catalog.js +40 -0
- package/dist/legacy-skill-catalog.js.map +1 -1
- package/dist/package-client.d.ts +13 -0
- package/dist/package-client.d.ts.map +1 -1
- package/dist/package-client.js +32 -0
- package/dist/package-client.js.map +1 -1
- package/dist/package-submission.d.ts +12 -1
- package/dist/package-submission.d.ts.map +1 -1
- package/dist/package-submission.js +2 -0
- package/dist/package-submission.js.map +1 -1
- package/dist/run-journal-commands.d.ts +54 -0
- package/dist/run-journal-commands.d.ts.map +1 -0
- package/dist/run-journal-commands.js +258 -0
- package/dist/run-journal-commands.js.map +1 -0
- package/dist/run-journal.d.ts +231 -0
- package/dist/run-journal.d.ts.map +1 -0
- package/dist/run-journal.js +453 -0
- package/dist/run-journal.js.map +1 -0
- package/dist/skill-clients.d.ts +39 -0
- package/dist/skill-clients.d.ts.map +1 -0
- package/dist/skill-clients.js +156 -0
- package/dist/skill-clients.js.map +1 -0
- package/dist/skill-installer.d.ts +2 -3
- package/dist/skill-installer.d.ts.map +1 -1
- package/dist/skill-installer.js +9 -101
- package/dist/skill-installer.js.map +1 -1
- package/package.json +1 -1
- package/skills/design/SKILL.md +2 -2
- package/skills/design-branch/SKILL.md +3 -3
- package/skills/design-convert/SKILL.md +3 -3
- package/skills/design-draft/SKILL.md +3 -3
- package/skills/design-search/SKILL.md +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branch-run-record.js","sourceRoot":"","sources":["../src/branch-run-record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,IAAI,MAAM,WAAW,CAAC;AAK7B;;;;;;;;;;GAUG;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AAC7D,MAAM,CAAC,MAAM,0BAA0B,GAAG,sBAAsB,CAAC;AACjE,MAAM,CAAC,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AACvD,MAAM,CAAC,MAAM,wBAAwB,GAAG,SAAS,CAAC;AAClD,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAC;AAuC9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,CAC3D,IAAI,CAAC,IA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],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"branch-status.d.ts","sourceRoot":"","sources":["../src/branch-status.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAG5D,OAAO,EAKL,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACxB,MAAM,sBAAsB,CAAC;AAmC9B,6DAA6D;AAC7D,eAAO,MAAM,sBAAsB,GACjC,SAAS,SAAS,oBAAoB,EAAE,EACxC,UAAU,iBAAiB,KAC1B,oBAAoB,EAkBtB,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAU,MAAM;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IAC/D,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,KAAG,OAAO,CAAC,kBAAkB,CA0E7B,CAAC"}
|
package/dist/branch-status.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { branchBlockedSlots } from './branch-schedule.js';
|
|
3
|
+
import { CliRefusal } from './cli-refusal.js';
|
|
3
4
|
import { branchProgressPath, readBranchProgress, summarizeBranchProgress, } from './branch-progress.js';
|
|
4
5
|
import { branchAttemptPath, branchCompletionPath, branchPlanPath, readBranchAttempt, readBranchCompletion, } from './branch-run-record.js';
|
|
5
6
|
/**
|
|
@@ -53,11 +54,11 @@ export const readBranchStatus = async (args) => {
|
|
|
53
54
|
if (!attempt && !completion && !progress) {
|
|
54
55
|
// Never started is not a failure and not a stall. Name the command that
|
|
55
56
|
// starts it rather than reporting an absence the caller has to interpret.
|
|
56
|
-
throw new
|
|
57
|
+
throw new CliRefusal(`This branch run has never been started — there is nothing to report, and nothing has`
|
|
57
58
|
+ ` failed. ${outDir} holds no branch attempt, progress, or completion record.`
|
|
58
59
|
+ ' Start one with `12ui branch execute --winner-run <crt-id> --winner-slot <slot>'
|
|
59
60
|
+ ' --concept <text> --scope page|site --out-dir <directory>`, which blocks for the whole'
|
|
60
|
-
+ ' run and streams progress.');
|
|
61
|
+
+ ' run and streams progress.', 'branch_never_started');
|
|
61
62
|
}
|
|
62
63
|
if (completion) {
|
|
63
64
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branch-status.js","sourceRoot":"","sources":["../src/branch-status.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,GAIxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,EACd,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;GAOG;AAEH,MAAM,QAAQ,GAAG,CACf,aAAiC,EACjC,aAA8C,EACzB,EAAE;IACvB,IAAI,aAAa;QAAE,OAAO,aAAa,CAAC;IACxC,QAAQ,aAAa,EAAE,CAAC;QACtB,KAAK,aAAa,CAAC,CAAC,OAAO,aAAa,CAAC;QACzC,KAAK,YAAY,CAAC,CAAC,OAAO,YAAY,CAAC;QACvC,KAAK,aAAa,CAAC,CAAC,OAAO,aAAa,CAAC;QACzC,KAAK,WAAW,CAAC;QACjB,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ;YACX,OAAO,UAAU,CAAC;QACpB,OAAO,CAAC,CAAC,OAAO,UAAU,CAAC;IAC7B,CAAC;AACH,CAAC,CAAC;AAEF,6DAA6D;AAC7D,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,OAAwC,EACxC,QAA2B,EACH,EAAE;IAC1B,MAAM,IAAI,GAA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,uEAAuE;YACvE,yDAAyD;YACzD,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9D,GAAG,CAAC,QAAQ,EAAE,SAAS,IAAI,OAAO,EAAE,SAAS;gBAC3C,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,IAAI,OAAQ,CAAC,SAAS,EAAE;gBAC1D,CAAC,CAAC,EAAE,CAAC;YACP,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACjE,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE;SAC5B,CAAC;QACF,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC;KACjC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { BranchWinnerInput } from './branch-execution-types.js';
|
|
2
|
+
import { type CliFlags } from './cli-arguments.js';
|
|
3
|
+
export declare const imageWinner: (imagePath: string, label?: string) => Promise<BranchWinnerInput>;
|
|
4
|
+
/**
|
|
5
|
+
* The winner the run already recorded. Restating a decision is how the two
|
|
6
|
+
* records drift apart, so a run directory that holds a selection needs no flag.
|
|
7
|
+
*/
|
|
8
|
+
export declare const winnerFromSelection: (runDir: string) => Promise<BranchWinnerInput | null>;
|
|
9
|
+
/**
|
|
10
|
+
* Both accepted forms and a command the caller can paste. A refusal that only
|
|
11
|
+
* says a starting design is required costs another round trip to find out how
|
|
12
|
+
* to give one, and this one already cost a paid run on 2026-08-12.
|
|
13
|
+
*/
|
|
14
|
+
export declare const missingWinnerMessage: (args: {
|
|
15
|
+
/** The draft run directory this command addressed, when it addressed one. */
|
|
16
|
+
runDir: string | null;
|
|
17
|
+
outDir: string;
|
|
18
|
+
}) => string;
|
|
19
|
+
export type BranchWinnerFlags = {
|
|
20
|
+
flags: CliFlags;
|
|
21
|
+
/** The draft run directory addressed, when the caller named one. */
|
|
22
|
+
runDir: string | null;
|
|
23
|
+
outDir: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Resolve the starting design, or refuse with everything needed to fix it.
|
|
27
|
+
* Reaches the network never and the filesystem only for a design it was told to
|
|
28
|
+
* read, so it is safe to run before any client is built.
|
|
29
|
+
*/
|
|
30
|
+
export declare const resolveBranchWinner: (args: BranchWinnerFlags) => Promise<BranchWinnerInput>;
|
|
31
|
+
//# sourceMappingURL=branch-winner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branch-winner.d.ts","sourceRoot":"","sources":["../src/branch-winner.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AA4B/D,eAAO,MAAM,WAAW,GACtB,WAAW,MAAM,EACjB,cAAoB,KACnB,OAAO,CAAC,iBAAiB,CAc3B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAU,QAAQ,MAAM,KAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAM1F,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,MAAM;IACzC,6EAA6E;IAC7E,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB,KAAG,MAmBH,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,QAAQ,CAAC;IAChB,oEAAoE;IACpE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAU,MAAM,iBAAiB,KAAG,OAAO,CAAC,iBAAiB,CAmD5F,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { stringFlag } from './cli-arguments.js';
|
|
5
|
+
import { CliRefusal } from './cli-refusal.js';
|
|
6
|
+
import { draftPaths } from './draft-workspace.js';
|
|
7
|
+
import { classifyLocalConversionInput } from './local-conversion-input.js';
|
|
8
|
+
import { readSelectionRecord } from './selection-record.js';
|
|
9
|
+
/**
|
|
10
|
+
* Which design a branch run grows from, resolved and proved before the run
|
|
11
|
+
* claims anything.
|
|
12
|
+
*
|
|
13
|
+
* The claim is not free: the service's build claim spends a metered plan call
|
|
14
|
+
* on the winning image before a single screen is dispatched. So the winner is
|
|
15
|
+
* the FIRST input this command settles, ahead of scope and concept, and a run
|
|
16
|
+
* that cannot name one stops here rather than one round trip later.
|
|
17
|
+
*
|
|
18
|
+
* There is exactly one implicit default, and it is a record rather than a
|
|
19
|
+
* guess: `12ui select` wrote which candidate won, so `branch execute <run-dir>`
|
|
20
|
+
* reads it instead of making the caller restate a decision. Nothing else is
|
|
21
|
+
* inferred. Picking a candidate because it happens to be the only file on disk
|
|
22
|
+
* would spend the plan call on a design nobody approved, which is worse than
|
|
23
|
+
* asking.
|
|
24
|
+
*/
|
|
25
|
+
const RUN_ID = /^crt-[a-f0-9]{40}$/u;
|
|
26
|
+
const SLOT = /^[a-z]{1,2}$/u;
|
|
27
|
+
const EXAMPLE_RUN_ID = `crt-${'0'.repeat(40)}`;
|
|
28
|
+
export const imageWinner = async (imagePath, label = 'The winner') => {
|
|
29
|
+
const resolved = path.resolve(imagePath);
|
|
30
|
+
const classified = classifyLocalConversionInput(resolved);
|
|
31
|
+
if (classified.kind !== 'image') {
|
|
32
|
+
throw new CliRefusal(`${label} must be a PNG, JPEG, or WebP`, 'branch_winner_not_an_image');
|
|
33
|
+
}
|
|
34
|
+
const bytes = new Uint8Array(await readFile(resolved));
|
|
35
|
+
return {
|
|
36
|
+
kind: 'image',
|
|
37
|
+
imagePath: resolved,
|
|
38
|
+
bytes,
|
|
39
|
+
mediaType: classified.mediaType,
|
|
40
|
+
sha256: createHash('sha256').update(bytes).digest('hex'),
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* The winner the run already recorded. Restating a decision is how the two
|
|
45
|
+
* records drift apart, so a run directory that holds a selection needs no flag.
|
|
46
|
+
*/
|
|
47
|
+
export const winnerFromSelection = async (runDir) => {
|
|
48
|
+
const selection = await readSelectionRecord(draftPaths(runDir).selection);
|
|
49
|
+
if (!selection)
|
|
50
|
+
return null;
|
|
51
|
+
const chosen = selection.candidates.find((candidate) => candidate.id === selection.winner);
|
|
52
|
+
if (!chosen?.path)
|
|
53
|
+
return null;
|
|
54
|
+
return imageWinner(chosen.path);
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Both accepted forms and a command the caller can paste. A refusal that only
|
|
58
|
+
* says a starting design is required costs another round trip to find out how
|
|
59
|
+
* to give one, and this one already cost a paid run on 2026-08-12.
|
|
60
|
+
*/
|
|
61
|
+
export const missingWinnerMessage = (args) => {
|
|
62
|
+
const target = args.runDir ?? `--out-dir ${args.outDir}`;
|
|
63
|
+
const example = args.runDir
|
|
64
|
+
? `12ui branch execute ${args.runDir} --scope page --concept "<what the surface must cover>"`
|
|
65
|
+
+ ` --winner-image ${path.join(args.runDir, 'candidates', 'b.png')}`
|
|
66
|
+
: `12ui branch execute --out-dir ${args.outDir} --scope page`
|
|
67
|
+
+ ' --concept "<what the surface must cover>" --winner-image ./winner.png';
|
|
68
|
+
return [
|
|
69
|
+
`A branch run grows from one approved design and ${target} named none.`,
|
|
70
|
+
args.runDir
|
|
71
|
+
? `Record the choice once with \`12ui select ${args.runDir} --winner <id> --reason "<why>"\``
|
|
72
|
+
+ ' and this command reads it, or name the design here:'
|
|
73
|
+
: 'Name the design, or pass the draft run directory as `12ui branch execute <run-dir>` and'
|
|
74
|
+
+ ' the winner `12ui select` recorded is used:',
|
|
75
|
+
' --winner-image <file> a PNG, JPEG, or WebP on disk',
|
|
76
|
+
' --winner-run <crt-id> --winner-slot <slot> a candidate from a create run',
|
|
77
|
+
`Example:\n ${example}`,
|
|
78
|
+
'Nothing was claimed and nothing was bought.',
|
|
79
|
+
].join('\n');
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Resolve the starting design, or refuse with everything needed to fix it.
|
|
83
|
+
* Reaches the network never and the filesystem only for a design it was told to
|
|
84
|
+
* read, so it is safe to run before any client is built.
|
|
85
|
+
*/
|
|
86
|
+
export const resolveBranchWinner = async (args) => {
|
|
87
|
+
const runId = stringFlag(args.flags, 'winner-run')?.trim();
|
|
88
|
+
const slot = stringFlag(args.flags, 'winner-slot')?.trim();
|
|
89
|
+
const image = stringFlag(args.flags, 'winner-image')?.trim();
|
|
90
|
+
if (image && runId) {
|
|
91
|
+
throw new CliRefusal('A branch run starts from exactly one design, and both --winner-image and --winner-run were'
|
|
92
|
+
+ ' given. Drop one.', 'branch_winner_ambiguous');
|
|
93
|
+
}
|
|
94
|
+
if (image)
|
|
95
|
+
return imageWinner(image, '--winner-image');
|
|
96
|
+
if (runId) {
|
|
97
|
+
if (!RUN_ID.test(runId)) {
|
|
98
|
+
throw new CliRefusal(`--winner-run must be a crt- run id such as ${EXAMPLE_RUN_ID}, not ${runId}`, 'branch_winner_run_invalid');
|
|
99
|
+
}
|
|
100
|
+
if (!slot) {
|
|
101
|
+
throw new CliRefusal(`--winner-run names the create run and --winner-slot names which candidate in it won;`
|
|
102
|
+
+ ` ${runId} on its own does not say. Add --winner-slot <slot>, for example`
|
|
103
|
+
+ ` \`--winner-run ${runId} --winner-slot a\`. Nothing was claimed and nothing was bought.`, 'branch_winner_slot_missing');
|
|
104
|
+
}
|
|
105
|
+
if (!SLOT.test(slot)) {
|
|
106
|
+
throw new CliRefusal(`--winner-slot must be a candidate slot such as a, not ${slot}`, 'branch_winner_slot_invalid');
|
|
107
|
+
}
|
|
108
|
+
return { kind: 'run', runId, slot };
|
|
109
|
+
}
|
|
110
|
+
if (slot) {
|
|
111
|
+
throw new CliRefusal(`--winner-slot ${slot} names a candidate but not the run holding it. Add`
|
|
112
|
+
+ ` \`--winner-run <crt-id>\`, or point at the design directly with \`--winner-image <file>\`.`
|
|
113
|
+
+ ' Nothing was claimed and nothing was bought.', 'branch_winner_run_missing');
|
|
114
|
+
}
|
|
115
|
+
// No flag at all. The one recorded decision counts; nothing else is guessed.
|
|
116
|
+
const recorded = args.runDir ? await winnerFromSelection(args.runDir) : null;
|
|
117
|
+
if (recorded)
|
|
118
|
+
return recorded;
|
|
119
|
+
throw new CliRefusal(missingWinnerMessage({ runDir: args.runDir, outDir: args.outDir }), 'branch_winner_missing');
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=branch-winner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branch-winner.js","sourceRoot":"","sources":["../src/branch-winner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,UAAU,EAAiB,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,MAAM,GAAG,qBAAqB,CAAC;AACrC,MAAM,IAAI,GAAG,eAAe,CAAC;AAE7B,MAAM,cAAc,GAAG,OAAO,GAAG,CAAC,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ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-arguments.d.ts","sourceRoot":"","sources":["../src/cli-arguments.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"cli-arguments.d.ts","sourceRoot":"","sources":["../src/cli-arguments.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;AAKrD,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAYhD,CAAC;AAEH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,MAAM,EAAE,KACb;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,QAAQ,CAAA;CAqBtC,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,OAAO,QAAQ,EAAE,MAAM,MAAM,KAAG,MAAM,GAAG,SAGnE,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,OAAO,QAAQ,EAAE,MAAM,MAAM,KAAG,OAA+B,CAAC"}
|
package/dist/cli-arguments.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Every value-less flag must be listed here or the parser swallows the next
|
|
2
|
-
// token as its value.
|
|
3
|
-
|
|
2
|
+
// token as its value. Exported because the run journal normalizes argv without
|
|
3
|
+
// the parser — a digest must never throw on an argv the parser would reject.
|
|
4
|
+
export const CLI_BOOLEAN_FLAGS = new Set([
|
|
4
5
|
'detach',
|
|
5
6
|
'dry-run',
|
|
6
7
|
'force',
|
|
@@ -26,7 +27,7 @@ export const parseCliArguments = (argv) => {
|
|
|
26
27
|
const name = value.slice(2);
|
|
27
28
|
if (!name)
|
|
28
29
|
throw new Error('Invalid empty flag');
|
|
29
|
-
if (
|
|
30
|
+
if (CLI_BOOLEAN_FLAGS.has(name)) {
|
|
30
31
|
flags[name] = true;
|
|
31
32
|
continue;
|
|
32
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-arguments.js","sourceRoot":"","sources":["../src/cli-arguments.ts"],"names":[],"mappings":"AAEA,4EAA4E;AAC5E,
|
|
1
|
+
{"version":3,"file":"cli-arguments.js","sourceRoot":"","sources":["../src/cli-arguments.ts"],"names":[],"mappings":"AAEA,4EAA4E;AAC5E,+EAA+E;AAC/E,6EAA6E;AAC7E,MAAM,CAAC,MAAM,iBAAiB,GAAwB,IAAI,GAAG,CAAC;IAC5D,QAAQ;IACR,SAAS;IACT,OAAO;IACP,MAAM;IACN,MAAM;IACN,OAAO;IACP,QAAQ;IACR,WAAW;IACX,UAAU;IACV,SAAS;IACT,MAAM;CACP,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,IAAc,EAC0B,EAAE;IAC1C,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YAC7B,IAAI,KAAK;gBAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC/B,SAAS;QACX,CAAC;QACD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC5B,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACjD,IAAI,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAChC,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;YACnB,SAAS;QACX,CAAC;QACD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAC7B,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,KAAK,IAAI,mBAAmB,CAAC,CAAC;QAClF,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QACnB,KAAK,IAAI,CAAC,CAAC;IACb,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC5B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAe,EAAE,IAAY,EAAsB,EAAE;IAC9E,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAe,EAAE,IAAY,EAAW,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type CliFlags } from './cli-arguments.js';
|
|
2
2
|
import { readConversionConfig } from './config.js';
|
|
3
|
+
import type { RunJournalNotes } from './run-journal.js';
|
|
3
4
|
import { TwelveUiBranchClient } from './branch-client.js';
|
|
4
5
|
import { TwelveUiConversionPackageClient } from './package-client.js';
|
|
5
6
|
export declare const BRANCH_USAGE = "Usage:\n 12ui branch execute --winner-run <crt-id> --winner-slot <slot>|--winner-image <file>\n --concept <text>|--concept-file <file> --scope page|site\n --out-dir <directory> [--convert html] [--convert-model fast|standard|pro]\n [--convert-quality standard|pro] [--source-conversion-id <id>]\n [--max-screens <n>] [--page-concurrency <n>] [--idempotency-key <key>]\n [--resume] [--dry-run] [--wait] [--quiet] [--origin <url>] [--api-key <key>]\n 12ui branch resume --out-dir <directory> [--quiet] [--origin <url>] [--api-key <key>]\n 12ui branch status --out-dir <directory> [--json] [--origin <url>] [--api-key <key>]";
|
|
@@ -51,5 +52,7 @@ export declare const runBranchCommand: (action: string | undefined, flags: CliFl
|
|
|
51
52
|
createPackageClient?: (config: ReturnType<typeof readConversionConfig>) => TwelveUiConversionPackageClient;
|
|
52
53
|
/** The positional `<run-dir>` from `12ui branch execute <run-dir>`. */
|
|
53
54
|
runDirArgument?: string;
|
|
55
|
+
/** Where this command writes down what it did. */
|
|
56
|
+
journal?: RunJournalNotes;
|
|
54
57
|
}) => Promise<void>;
|
|
55
58
|
//# sourceMappingURL=cli-branch-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-branch-command.d.ts","sourceRoot":"","sources":["../src/cli-branch-command.ts"],"names":[],"mappings":"AAIA,OAAO,EAA2B,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli-branch-command.d.ts","sourceRoot":"","sources":["../src/cli-branch-command.ts"],"names":[],"mappings":"AAIA,OAAO,EAA2B,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAqB,MAAM,oBAAoB,CAAC;AA0B7E,OAAO,EAAE,+BAA+B,EAAE,MAAM,qBAAqB,CAAC;AAMtE,eAAO,MAAM,YAAY,guBAQ+D,CAAC;AAIzF;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GAAI,QAAQ,MAAM,KAAG,MAAM,GAAG,IAOnE,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,GAAU,MAAM;IACjD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,KAAG,OAAO,CAAC,uBAAuB,CAwBlC,CAAC;AAyFF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM;IACxC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,KAAG,MA4BH,CAAC;AAaF,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,MAAM,GAAG,SAAS,EAC1B,OAAO,QAAQ,EACf,eAAc;IACZ,UAAU,CAAC,EAAE,OAAO,oBAAoB,CAAC;IACzC,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,KAAK,oBAAoB,CAAC;IAC/F,mBAAmB,CAAC,EAAE,CACpB,MAAM,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,KAC5C,+BAA+B,CAAC;IACrC,uEAAuE;IACvE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kDAAkD;IAClD,OAAO,CAAC,EAAE,eAAe,CAAC;CACtB,KACL,OAAO,CAAC,IAAI,CAiQd,CAAC"}
|
|
@@ -2,17 +2,18 @@ import { createHash } from 'node:crypto';
|
|
|
2
2
|
import { readFile, stat } from 'node:fs/promises';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { booleanFlag, stringFlag } from './cli-arguments.js';
|
|
5
|
+
import { CliRefusal } from './cli-refusal.js';
|
|
5
6
|
import { readConversionConfig } from './config.js';
|
|
6
|
-
import { TwelveUiBranchClient
|
|
7
|
+
import { TwelveUiBranchClient } from './branch-client.js';
|
|
7
8
|
import { deriveBranchRunKey, executeBranchRun } from './branch-execution.js';
|
|
9
|
+
import { resolveBranchWinner } from './branch-winner.js';
|
|
10
|
+
import { readConceptValue } from './concept-input.js';
|
|
8
11
|
import { readBranchStatus } from './branch-status.js';
|
|
9
12
|
import { BRANCH_ATTEMPT_FILENAME, BRANCH_COMPLETION_FILENAME, branchAttemptPath, readBranchAttempt, } from './branch-run-record.js';
|
|
10
13
|
import { BRANCH_PROGRESS_FILENAME } from './branch-progress.js';
|
|
11
|
-
import { DRAFT_BRANCH_DIRECTORY
|
|
12
|
-
import { readSelectionRecord } from './selection-record.js';
|
|
14
|
+
import { DRAFT_BRANCH_DIRECTORY } from './draft-workspace.js';
|
|
13
15
|
import { BRANCH_PAGE_CONCURRENCY_DEFAULT, BRANCH_TYPICAL_SITE_PAGES, OPERATION_DURATION_HINTS, branchRunEstimateSeconds, createPackageProgressReporter, formatDuration, narrateCounts, nextActionLine, } from './cli-progress.js';
|
|
14
16
|
import { isConversionModel } from './conversion-models.js';
|
|
15
|
-
import { classifyLocalConversionInput } from './local-conversion-input.js';
|
|
16
17
|
import { normalizeOptionalIdempotencyKey } from './idempotency-key.js';
|
|
17
18
|
import { TwelveUiConversionPackageClient } from './package-client.js';
|
|
18
19
|
import { isResponsiveConversionQuality, } from './responsive-quality.js';
|
|
@@ -56,8 +57,8 @@ export const resolveBranchDirectory = async (args) => {
|
|
|
56
57
|
if (args.outDirFlag)
|
|
57
58
|
return { branchDir: path.resolve(args.outDirFlag), runDir: null };
|
|
58
59
|
if (!args.runDirArgument) {
|
|
59
|
-
throw new
|
|
60
|
-
+ ' printed), or `--out-dir <directory>` to name the branch directory outright.');
|
|
60
|
+
throw new CliRefusal('A run directory is required: `12ui branch execute <run-dir>` (the directory `12ui draft`'
|
|
61
|
+
+ ' printed), or `--out-dir <directory>` to name the branch directory outright.', 'branch_run_directory_missing');
|
|
61
62
|
}
|
|
62
63
|
const given = path.resolve(args.runDirArgument);
|
|
63
64
|
const holdsBranchRecords = await Promise.all([
|
|
@@ -90,74 +91,14 @@ const readConcept = async (flags) => {
|
|
|
90
91
|
const inline = stringFlag(flags, 'concept')?.trim();
|
|
91
92
|
const file = stringFlag(flags, 'concept-file')?.trim();
|
|
92
93
|
if (Boolean(inline) === Boolean(file)) {
|
|
93
|
-
throw new
|
|
94
|
+
throw new CliRefusal('Provide exactly one --concept or --concept-file', 'branch_concept_missing');
|
|
94
95
|
}
|
|
95
|
-
|
|
96
|
-
.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
throw new Error(`--concept must be at most ${BRANCH_MAX_CONCEPT_CHARACTERS} characters`);
|
|
102
|
-
}
|
|
103
|
-
return value;
|
|
104
|
-
};
|
|
105
|
-
const imageWinner = async (imagePath) => {
|
|
106
|
-
const classified = classifyLocalConversionInput(imagePath);
|
|
107
|
-
if (classified.kind !== 'image')
|
|
108
|
-
throw new Error('The winner must be a PNG, JPEG, or WebP');
|
|
109
|
-
const bytes = new Uint8Array(await readFile(imagePath));
|
|
110
|
-
return {
|
|
111
|
-
kind: 'image',
|
|
112
|
-
imagePath,
|
|
113
|
-
bytes,
|
|
114
|
-
mediaType: classified.mediaType,
|
|
115
|
-
sha256: createHash('sha256').update(bytes).digest('hex'),
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
/**
|
|
119
|
-
* The winner the run already recorded. `12ui select` wrote which candidate was
|
|
120
|
-
* chosen and why, so `branch execute <run-dir>` should not make the caller say
|
|
121
|
-
* it again — restating a decision is how the two records drift apart.
|
|
122
|
-
*/
|
|
123
|
-
const winnerFromSelection = async (runDir) => {
|
|
124
|
-
const paths = draftPaths(runDir);
|
|
125
|
-
const selection = await readSelectionRecord(paths.selection);
|
|
126
|
-
if (!selection)
|
|
127
|
-
return null;
|
|
128
|
-
const chosen = selection.candidates.find((candidate) => candidate.id === selection.winner);
|
|
129
|
-
if (!chosen?.path)
|
|
130
|
-
return null;
|
|
131
|
-
return imageWinner(chosen.path);
|
|
132
|
-
};
|
|
133
|
-
const readWinner = async (flags) => {
|
|
134
|
-
const runId = stringFlag(flags, 'winner-run')?.trim();
|
|
135
|
-
const slot = stringFlag(flags, 'winner-slot')?.trim();
|
|
136
|
-
const image = stringFlag(flags, 'winner-image')?.trim();
|
|
137
|
-
if (Boolean(image) === Boolean(runId)) {
|
|
138
|
-
throw new Error('A branch run starts from exactly one of --winner-run/--winner-slot or --winner-image');
|
|
139
|
-
}
|
|
140
|
-
if (runId) {
|
|
141
|
-
if (!slot)
|
|
142
|
-
throw new Error('--winner-run requires --winner-slot');
|
|
143
|
-
if (!/^crt-[a-f0-9]{40}$/u.test(runId))
|
|
144
|
-
throw new Error('--winner-run must be a crt- run id');
|
|
145
|
-
if (!/^[a-z]{1,2}$/u.test(slot))
|
|
146
|
-
throw new Error('--winner-slot must be a candidate slot such as a');
|
|
147
|
-
return { kind: 'run', runId, slot };
|
|
148
|
-
}
|
|
149
|
-
const imagePath = path.resolve(image);
|
|
150
|
-
const classified = classifyLocalConversionInput(imagePath);
|
|
151
|
-
if (classified.kind !== 'image')
|
|
152
|
-
throw new Error('--winner-image must be a PNG, JPEG, or WebP');
|
|
153
|
-
const bytes = new Uint8Array(await readFile(imagePath));
|
|
154
|
-
return {
|
|
155
|
-
kind: 'image',
|
|
156
|
-
imagePath,
|
|
157
|
-
bytes,
|
|
158
|
-
mediaType: classified.mediaType,
|
|
159
|
-
sha256: createHash('sha256').update(bytes).digest('hex'),
|
|
160
|
-
};
|
|
96
|
+
return readConceptValue({
|
|
97
|
+
value: inline ?? (await readFile(path.resolve(file), 'utf8')),
|
|
98
|
+
flag: '--concept',
|
|
99
|
+
trimHint: 'Keep what the rest of the surface must cover; the approved design already carries'
|
|
100
|
+
+ ' the styling.',
|
|
101
|
+
});
|
|
161
102
|
};
|
|
162
103
|
const readConvert = (flags) => {
|
|
163
104
|
const convert = stringFlag(flags, 'convert')?.trim();
|
|
@@ -166,17 +107,17 @@ const readConvert = (flags) => {
|
|
|
166
107
|
const sourceConversionId = stringFlag(flags, 'source-conversion-id')?.trim();
|
|
167
108
|
if (convert === undefined) {
|
|
168
109
|
if (model || quality || sourceConversionId) {
|
|
169
|
-
throw new
|
|
110
|
+
throw new CliRefusal('--convert-model, --convert-quality, and --source-conversion-id require --convert html', 'branch_convert_flags_without_convert');
|
|
170
111
|
}
|
|
171
112
|
return undefined;
|
|
172
113
|
}
|
|
173
114
|
if (convert !== 'html')
|
|
174
|
-
throw new
|
|
115
|
+
throw new CliRefusal('--convert must be html', 'branch_convert_invalid');
|
|
175
116
|
if (model !== undefined && !isConversionModel(model)) {
|
|
176
|
-
throw new
|
|
117
|
+
throw new CliRefusal('--convert-model must be fast, standard, or pro', 'branch_convert_model_invalid');
|
|
177
118
|
}
|
|
178
119
|
if (quality !== undefined && !isResponsiveConversionQuality(quality)) {
|
|
179
|
-
throw new
|
|
120
|
+
throw new CliRefusal('--convert-quality must be standard or pro', 'branch_convert_quality_invalid');
|
|
180
121
|
}
|
|
181
122
|
return {
|
|
182
123
|
output: 'html',
|
|
@@ -188,8 +129,8 @@ const readConvert = (flags) => {
|
|
|
188
129
|
const readScope = (flags) => {
|
|
189
130
|
const scope = stringFlag(flags, 'scope')?.trim();
|
|
190
131
|
if (scope !== 'page' && scope !== 'site') {
|
|
191
|
-
throw new
|
|
192
|
-
+ ' the planned sibling pages)');
|
|
132
|
+
throw new CliRefusal('--scope must be page (grow the approved screen into its whole page) or site (trunk plus'
|
|
133
|
+
+ ' the planned sibling pages)', 'branch_scope_invalid');
|
|
193
134
|
}
|
|
194
135
|
return scope;
|
|
195
136
|
};
|
|
@@ -198,8 +139,9 @@ const readMaxScreens = (flags) => {
|
|
|
198
139
|
if (value === undefined)
|
|
199
140
|
return undefined;
|
|
200
141
|
const parsed = Number(value);
|
|
201
|
-
if (!Number.isSafeInteger(parsed) || parsed < 1)
|
|
202
|
-
throw new
|
|
142
|
+
if (!Number.isSafeInteger(parsed) || parsed < 1) {
|
|
143
|
+
throw new CliRefusal('--max-screens must be a positive integer', 'branch_max_screens_invalid');
|
|
144
|
+
}
|
|
203
145
|
return parsed;
|
|
204
146
|
};
|
|
205
147
|
const plannedPages = (scope) => (scope === 'page' ? 1 : BRANCH_TYPICAL_SITE_PAGES);
|
|
@@ -252,13 +194,13 @@ const readPageConcurrency = (flags) => {
|
|
|
252
194
|
const parsed = Number(value);
|
|
253
195
|
if (!Number.isSafeInteger(parsed) || parsed < 1 || parsed > 10) {
|
|
254
196
|
// Ten is the account's active-conversion cap, so more than that only queues.
|
|
255
|
-
throw new
|
|
197
|
+
throw new CliRefusal('--page-concurrency must be an integer between 1 and 10', 'branch_page_concurrency_invalid');
|
|
256
198
|
}
|
|
257
199
|
return parsed;
|
|
258
200
|
};
|
|
259
201
|
export const runBranchCommand = async (action, flags, dependencies = {}) => {
|
|
260
202
|
if (action !== 'execute' && action !== 'resume' && action !== 'status') {
|
|
261
|
-
throw new
|
|
203
|
+
throw new CliRefusal(BRANCH_USAGE, 'branch_usage');
|
|
262
204
|
}
|
|
263
205
|
const outDirFlag = stringFlag(flags, 'out-dir')?.trim();
|
|
264
206
|
const resolvedDirectory = await resolveBranchDirectory({
|
|
@@ -289,6 +231,13 @@ export const runBranchCommand = async (action, flags, dependencies = {}) => {
|
|
|
289
231
|
outDir,
|
|
290
232
|
...(client ? { refresh: async (runId) => client.getRun(runId) } : {}),
|
|
291
233
|
});
|
|
234
|
+
// The one command whose whole answer is the run's state, so it is the one
|
|
235
|
+
// command whose journal line can settle whether the run is over.
|
|
236
|
+
dependencies.journal?.note({
|
|
237
|
+
terminal: report.complete,
|
|
238
|
+
...(report.runId ? { runId: report.runId } : {}),
|
|
239
|
+
...(report.completionPath ? { artifacts: [report.completionPath] } : {}),
|
|
240
|
+
});
|
|
292
241
|
console.log(JSON.stringify(report, null, 2));
|
|
293
242
|
return;
|
|
294
243
|
}
|
|
@@ -299,10 +248,10 @@ export const runBranchCommand = async (action, flags, dependencies = {}) => {
|
|
|
299
248
|
if (action === 'resume') {
|
|
300
249
|
const attempt = await readBranchAttempt(branchAttemptPath(outDir));
|
|
301
250
|
if (!attempt) {
|
|
302
|
-
throw new
|
|
251
|
+
throw new CliRefusal(`This branch run has never been started — there is nothing to resume, and nothing has`
|
|
303
252
|
+ ` failed. There is no branch attempt at ${branchAttemptPath(outDir)}. Start it with`
|
|
304
253
|
+ ' `12ui branch execute --winner-run <crt-id> --winner-slot <slot> --concept <text>'
|
|
305
|
-
+ ' --scope page|site --out-dir <directory>`.');
|
|
254
|
+
+ ' --scope page|site --out-dir <directory>`.', 'branch_nothing_to_resume');
|
|
306
255
|
}
|
|
307
256
|
const recorded = attempt.winner;
|
|
308
257
|
let winner;
|
|
@@ -313,8 +262,8 @@ export const runBranchCommand = async (action, flags, dependencies = {}) => {
|
|
|
313
262
|
const bytes = new Uint8Array(await readFile(recorded.imagePath));
|
|
314
263
|
const sha256 = createHash('sha256').update(bytes).digest('hex');
|
|
315
264
|
if (sha256 !== recorded.sha256) {
|
|
316
|
-
throw new
|
|
317
|
-
+ ` branched from (${recorded.sha256} then, ${sha256} now)
|
|
265
|
+
throw new CliRefusal(`Refusing to resume: ${recorded.imagePath} no longer holds the starting design this run`
|
|
266
|
+
+ ` branched from (${recorded.sha256} then, ${sha256} now).`, 'branch_winner_changed');
|
|
318
267
|
}
|
|
319
268
|
winner = { kind: 'image', imagePath: recorded.imagePath, bytes, mediaType: recorded.mediaType, sha256 };
|
|
320
269
|
}
|
|
@@ -343,22 +292,24 @@ export const runBranchCommand = async (action, flags, dependencies = {}) => {
|
|
|
343
292
|
else {
|
|
344
293
|
const aspect = stringFlag(flags, 'aspect')?.trim();
|
|
345
294
|
if (aspect !== undefined && !['landscape', 'portrait', 'square'].includes(aspect)) {
|
|
346
|
-
throw new
|
|
347
|
-
}
|
|
348
|
-
const named = stringFlag(flags, 'winner-run') ?? stringFlag(flags, 'winner-image');
|
|
349
|
-
const recorded = named || !resolvedDirectory.runDir
|
|
350
|
-
? null
|
|
351
|
-
: await winnerFromSelection(resolvedDirectory.runDir);
|
|
352
|
-
if (!named && !recorded && resolvedDirectory.runDir) {
|
|
353
|
-
throw new Error(`No winner is recorded in ${resolvedDirectory.runDir}. Choose one first with`
|
|
354
|
-
+ ` \`12ui select ${resolvedDirectory.runDir} --winner <id> --reason "<why>"\`, or name a`
|
|
355
|
-
+ ' starting design with --winner-image or --winner-run/--winner-slot.');
|
|
295
|
+
throw new CliRefusal('--aspect must be landscape, portrait, or square', 'branch_aspect_invalid');
|
|
356
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* The winner is settled first because it is the input a run cannot recover
|
|
299
|
+
* from getting wrong: the service's claim spends a metered plan call on
|
|
300
|
+
* this image before any screen is dispatched. Scope and concept are cheap
|
|
301
|
+
* to re-ask for; a plan call on the wrong design is not.
|
|
302
|
+
*/
|
|
303
|
+
const winner = await resolveBranchWinner({
|
|
304
|
+
flags,
|
|
305
|
+
runDir: resolvedDirectory.runDir,
|
|
306
|
+
outDir,
|
|
307
|
+
});
|
|
357
308
|
inputs = {
|
|
358
309
|
outDir,
|
|
359
310
|
scope: readScope(flags),
|
|
360
311
|
concept: await readConcept(flags),
|
|
361
|
-
winner
|
|
312
|
+
winner,
|
|
362
313
|
...(aspect ? { aspect: aspect } : {}),
|
|
363
314
|
...(readMaxScreens(flags) === undefined ? {} : { maxScreens: readMaxScreens(flags) }),
|
|
364
315
|
...(readConvert(flags) ? { convert: readConvert(flags) } : {}),
|
|
@@ -371,7 +322,11 @@ export const runBranchCommand = async (action, flags, dependencies = {}) => {
|
|
|
371
322
|
origin: stringFlag(flags, 'origin'),
|
|
372
323
|
apiKey: stringFlag(flags, 'api-key'),
|
|
373
324
|
});
|
|
325
|
+
// Known before anything is claimed, and the one value a retry has to reuse.
|
|
326
|
+
dependencies.journal?.note({ idempotencyKey: deriveBranchRunKey(inputs) });
|
|
374
327
|
if (booleanFlag(flags, 'dry-run')) {
|
|
328
|
+
// Nothing was claimed, so the run is exactly where it was.
|
|
329
|
+
dependencies.journal?.note({ terminal: false });
|
|
375
330
|
console.log(JSON.stringify({
|
|
376
331
|
dryRun: true,
|
|
377
332
|
outDir,
|
|
@@ -465,6 +420,19 @@ export const runBranchCommand = async (action, flags, dependencies = {}) => {
|
|
|
465
420
|
write(`[${elapsed()}] stopped: ${event.code} — ${event.message}`);
|
|
466
421
|
},
|
|
467
422
|
});
|
|
423
|
+
// The completion sentinel names every screen and page; the journal names the
|
|
424
|
+
// sentinel. A run is terminal here whatever its status: `partial` and
|
|
425
|
+
// `failed` are settled answers, not states to keep polling.
|
|
426
|
+
dependencies.journal?.note({
|
|
427
|
+
runId: result.completion.runId,
|
|
428
|
+
idempotencyKey: result.completion.runKey,
|
|
429
|
+
artifacts: [result.completionPath],
|
|
430
|
+
purchased: [
|
|
431
|
+
result.completion.runId,
|
|
432
|
+
...result.completion.pages.flatMap((page) => (page.conversion?.conversionId ? [page.conversion.conversionId] : [])),
|
|
433
|
+
],
|
|
434
|
+
terminal: true,
|
|
435
|
+
});
|
|
468
436
|
console.log(JSON.stringify({
|
|
469
437
|
completionPath: result.completionPath,
|
|
470
438
|
...result.completion,
|