@buffcore/cli 0.8.47 → 0.8.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +52 -0
- package/dist/commands/build/server-text.en.d.ts +5 -0
- package/dist/commands/build/server-text.en.js +5 -0
- package/dist/commands/build/server-text.js +5 -0
- package/dist/commands/build/server.d.ts +4 -0
- package/dist/commands/build/server.js +10 -1
- package/dist/commands/change-merge-serial.d.ts +6 -2
- package/dist/commands/change-merge-serial.js +5 -1
- package/dist/commands/change-merge.d.ts +2 -2
- package/dist/commands/change.js +3 -0
- package/dist/commands/check-skills.d.ts +16 -0
- package/dist/commands/check-skills.en.d.ts +14 -0
- package/dist/commands/check-skills.en.js +14 -0
- package/dist/commands/check-skills.es.d.ts +2 -0
- package/dist/commands/check-skills.es.js +14 -0
- package/dist/commands/check-skills.js +146 -0
- package/dist/commands/check.js +5 -0
- package/dist/commands/dev.d.ts +9 -2
- package/dist/commands/dev.js +24 -5
- package/dist/commands/extension/config-text.d.ts +2 -0
- package/dist/commands/extension/config-text.js +2 -0
- package/dist/commands/extension/index.js +14 -2
- package/dist/commands/extension/new.d.ts +16 -0
- package/dist/commands/extension/new.js +52 -0
- package/dist/commands/extension/pack-files.d.ts +23 -0
- package/dist/commands/extension/pack-files.js +78 -0
- package/dist/commands/extension/pack-scan.d.ts +24 -0
- package/dist/commands/extension/pack-scan.js +131 -0
- package/dist/commands/extension/pack.d.ts +48 -0
- package/dist/commands/extension/pack.js +142 -0
- package/dist/commands/extension/share-text.d.ts +3 -0
- package/dist/commands/extension/share-text.js +6 -0
- package/dist/commands/extension/share.en.d.ts +32 -0
- package/dist/commands/extension/share.en.js +32 -0
- package/dist/commands/extension/share.es.d.ts +2 -0
- package/dist/commands/extension/share.es.js +32 -0
- package/dist/commands/hardening.d.ts +3 -0
- package/dist/commands/hardening.en.d.ts +3 -0
- package/dist/commands/hardening.en.js +3 -0
- package/dist/commands/hardening.es.d.ts +2 -0
- package/dist/commands/hardening.es.js +3 -0
- package/dist/commands/hardening.js +19 -0
- package/dist/commands/prototype/comp-record.d.ts +5 -0
- package/dist/commands/prototype/comp-record.js +22 -0
- package/dist/commands/server/build.d.ts +2 -1
- package/dist/commands/server/build.js +10 -2
- package/dist/commands/server/deploy-local.d.ts +3 -0
- package/dist/commands/server/deploy-local.js +9 -0
- package/dist/commands/server/deploy-plan.d.ts +5 -0
- package/dist/commands/server/deploy-plan.js +56 -0
- package/dist/commands/server/deploy-result.d.ts +7 -0
- package/dist/commands/server/deploy-result.js +1 -0
- package/dist/commands/server/deploy-script.d.ts +2 -0
- package/dist/commands/server/deploy-script.js +3 -2
- package/dist/commands/server/deploy.d.ts +9 -6
- package/dist/commands/server/deploy.js +39 -61
- package/dist/commands/server/files.d.ts +9 -1
- package/dist/commands/server/files.js +25 -5
- package/dist/commands/server/image.d.ts +4 -2
- package/dist/commands/server/image.js +6 -5
- package/dist/commands/server/setup.d.ts +1 -0
- package/dist/commands/server/setup.js +4 -0
- package/dist/commands/server/system-packages.d.ts +29 -0
- package/dist/commands/server/system-packages.js +103 -0
- package/dist/commands/services/compose.d.ts +1 -1
- package/dist/commands/services/compose.js +5 -3
- package/dist/commands/ui/agents-route.js +2 -0
- package/dist/commands/ui/approval-authority.en.d.ts +1 -0
- package/dist/commands/ui/approval-authority.en.js +1 -0
- package/dist/commands/ui/approval-authority.es.d.ts +1 -0
- package/dist/commands/ui/approval-authority.es.js +1 -0
- package/dist/commands/ui/approval-authority.js +7 -2
- package/dist/commands/ui/approve.js +2 -4
- package/dist/commands/ui/autopilot-records.d.ts +2 -0
- package/dist/commands/ui/autopilot-records.js +5 -0
- package/dist/commands/ui/brand-approval.js +5 -1
- package/dist/commands/ui/chat/permissions.js +1 -1
- package/dist/commands/ui/chat/routes.js +4 -0
- package/dist/commands/ui/comp-approval.d.ts +14 -2
- package/dist/commands/ui/comp-approval.js +45 -8
- package/dist/commands/ui/index.d.ts +1 -0
- package/dist/commands/ui/level-route.js +3 -0
- package/dist/commands/ui/merge-authority.d.ts +4 -1
- package/dist/commands/ui/merge-authority.en.d.ts +4 -0
- package/dist/commands/ui/merge-authority.en.js +5 -1
- package/dist/commands/ui/merge-authority.es.d.ts +4 -0
- package/dist/commands/ui/merge-authority.es.js +5 -1
- package/dist/commands/ui/merge-authority.js +6 -3
- package/dist/commands/ui/merge-claims.d.ts +7 -0
- package/dist/commands/ui/merge-claims.js +21 -0
- package/dist/commands/ui/merge-delegation.js +8 -3
- package/dist/commands/ui/merge-hold-name.d.ts +5 -0
- package/dist/commands/ui/merge-hold-name.js +5 -0
- package/dist/commands/ui/merge-hold.d.ts +6 -1
- package/dist/commands/ui/merge-hold.js +23 -5
- package/dist/commands/ui/merge-publish-host.d.ts +1 -0
- package/dist/commands/ui/merge-publish-host.js +2 -2
- package/dist/commands/ui/merge-record.d.ts +2 -0
- package/dist/commands/ui/merge-record.js +1 -1
- package/dist/commands/ui/merge-route.js +17 -1
- package/dist/commands/ui/merge-settle.d.ts +32 -0
- package/dist/commands/ui/merge-settle.js +133 -0
- package/dist/commands/ui/merge-state.d.ts +5 -0
- package/dist/commands/ui/merge-state.js +7 -1
- package/dist/commands/ui/merge-withdraw.d.ts +9 -0
- package/dist/commands/ui/merge-withdraw.js +29 -0
- package/dist/commands/ui/outside-merge.d.ts +13 -0
- package/dist/commands/ui/outside-merge.js +84 -0
- package/dist/commands/ui/outside.d.ts +7 -4
- package/dist/commands/ui/outside.js +3 -0
- package/dist/commands/ui/plan-extensions.d.ts +34 -0
- package/dist/commands/ui/plan-extensions.en.d.ts +4 -0
- package/dist/commands/ui/plan-extensions.en.js +4 -0
- package/dist/commands/ui/plan-extensions.es.d.ts +2 -0
- package/dist/commands/ui/plan-extensions.es.js +4 -0
- package/dist/commands/ui/plan-extensions.js +86 -0
- package/dist/commands/ui/plan-files.js +9 -3
- package/dist/commands/ui/plan-structure.js +5 -7
- package/dist/commands/ui/prototype-comp-route.d.ts +12 -3
- package/dist/commands/ui/prototype-comp-route.js +35 -17
- package/dist/commands/ui/prototype-main.d.ts +6 -0
- package/dist/commands/ui/real-file.d.ts +11 -0
- package/dist/commands/ui/real-file.js +84 -0
- package/dist/commands/ui/save-route.js +4 -1
- package/dist/commands/ui/server.d.ts +1 -0
- package/dist/commands/ui/server.js +1 -0
- package/dist/commands/ui/studio-routes.js +2 -0
- package/dist/commands/ui/studio-state.d.ts +8 -0
- package/dist/commands/ui/studio-versions.js +19 -3
- package/dist/commands/ui/studio.en.d.ts +2 -0
- package/dist/commands/ui/studio.en.js +2 -0
- package/dist/commands/ui/studio.es.d.ts +2 -0
- package/dist/commands/ui/studio.es.js +2 -0
- package/dist/commands/upgrade.js +1 -1
- package/dist/ui/page.js +91 -91
- package/docs/EXTENSIONS.md +6 -0
- package/docs/PROTOTYPE.md +13 -0
- package/docs/WORKBENCH.md +55 -2
- package/package.json +11 -11
- package/skills/ape-add-ai-purpose/SKILL.md +1 -1
- package/skills/ape-add-event/SKILL.md +1 -1
- package/skills/ape-add-extension/SKILL.md +5 -1
- package/skills/ape-add-feature/SKILL.md +1 -1
- package/skills/ape-add-generator/SKILL.md +1 -1
- package/skills/ape-add-module/SKILL.md +1 -1
- package/skills/ape-add-route/SKILL.md +3 -1
- package/skills/ape-add-service/SKILL.md +1 -1
- package/skills/ape-add-translations/SKILL.md +2 -2
- package/skills/ape-admin-screen/SKILL.md +1 -1
- package/skills/ape-app-screen/SKILL.md +1 -1
- package/skills/ape-critique/SKILL.md +11 -32
- package/skills/ape-critique/references/after.md +15 -0
- package/skills/ape-critique/references/spacing-pass.md +20 -0
- package/skills/ape-deploy/SKILL.md +8 -3
- package/skills/ape-design-system/SKILL.md +15 -15
- package/skills/ape-design-system/references/by-hand.md +7 -0
- package/skills/ape-design-system/references/reference-study.md +11 -0
- package/skills/ape-diagnose/SKILL.md +24 -0
- package/skills/ape-migration/SKILL.md +1 -1
- package/skills/ape-plan-change/SKILL.md +37 -31
- package/skills/ape-plan-change/references/change-file-fields.md +5 -0
- package/skills/ape-plan-change/references/extensions.md +25 -0
- package/skills/ape-plan-change/references/finishing.md +3 -0
- package/skills/ape-plan-change/references/fix-from-error.md +3 -0
- package/skills/ape-plan-change/references/refactor.md +9 -0
- package/skills/ape-plan-change/references/structure.md +19 -0
- package/skills/ape-prototype/SKILL.md +13 -23
- package/skills/ape-prototype/references/comp.md +3 -0
- package/skills/ape-prototype/references/scope-and-export.md +5 -0
- package/skills/ape-prototype/references/snapshot.md +3 -0
- package/skills/ape-prototype/references/structure.md +11 -0
- package/skills/ape-prototype/references/working-app.md +7 -0
- package/skills/ape-request/SKILL.md +1 -1
- package/skills/ape-upgrade/SKILL.md +4 -1
- package/templates/product/package.json +1 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { outsideActAnswerSchema, outsideMergeBodySchema, workbenchApi, } from '@buffcore/contracts/workbench';
|
|
2
|
+
import { defaultMergeTools } from '../change-merge.js';
|
|
3
|
+
import { serialized } from '../change-merge-serial.js';
|
|
4
|
+
import { hostCall } from './host-call.js';
|
|
5
|
+
import { studioT } from './studio-messages.js';
|
|
6
|
+
const DEFAULT_TIMEOUT = 5_000;
|
|
7
|
+
/** After a timeout or a closed studio, the lock waits this many time limits for `act` to settle. */
|
|
8
|
+
export const HOLD_FACTOR = 4;
|
|
9
|
+
const status = { merged: 200, pending: 202 };
|
|
10
|
+
/**
|
|
11
|
+
* One call to the host's `act`, in the studio's one merge queue: it waits for no one and refuses
|
|
12
|
+
* while another merge holds the lock (as a studio merge does). The Autopilot merge hold stops only
|
|
13
|
+
* Autopilot, so it does not refuse a person's outside Merge, as it does not refuse an inside one.
|
|
14
|
+
*/
|
|
15
|
+
export async function outsideMerge(root, outside, viewer, change, stop) {
|
|
16
|
+
const act = outside.changes?.act;
|
|
17
|
+
if (!act)
|
|
18
|
+
return { status: 'error' };
|
|
19
|
+
// The same frozen viewer the reads get: the host's code cannot widen its own rights.
|
|
20
|
+
const verified = {
|
|
21
|
+
...viewer,
|
|
22
|
+
rights: viewer.rights === 'all' ? 'all' : [...viewer.rights],
|
|
23
|
+
};
|
|
24
|
+
if (verified.rights !== 'all')
|
|
25
|
+
Object.freeze(verified.rights);
|
|
26
|
+
Object.freeze(verified);
|
|
27
|
+
const timeout = outside.timeoutMs ?? DEFAULT_TIMEOUT;
|
|
28
|
+
const answered = Promise.withResolvers();
|
|
29
|
+
const queued = serialized(root, `outside ${change}`, defaultMergeTools, async () => {
|
|
30
|
+
let running = Promise.resolve();
|
|
31
|
+
const reply = await hostCall((signal) => {
|
|
32
|
+
running = Promise.resolve().then(() => act(Object.freeze({ viewer: verified, change, signal })));
|
|
33
|
+
return running;
|
|
34
|
+
}, (answer) => {
|
|
35
|
+
const parsed = outsideActAnswerSchema.safeParse(answer);
|
|
36
|
+
return parsed.success ? parsed.data : { status: 'error' };
|
|
37
|
+
}, (reason) => ({ status: reason }), timeout, stop);
|
|
38
|
+
// A settled `act` frees the queue before the answer is sent. One still running (a timeout, a
|
|
39
|
+
// closed studio) has its signal aborted, but the host may still be merging: the answer goes out
|
|
40
|
+
// now and the queue stays taken until it settles, for at most HOLD_FACTOR time limits.
|
|
41
|
+
if (await settledWithin(running, 0))
|
|
42
|
+
return reply;
|
|
43
|
+
answered.resolve(reply);
|
|
44
|
+
if (!(await settledWithin(running, timeout * HOLD_FACTOR)))
|
|
45
|
+
console.error(studioT('ui.outside.lockReleased', { change, ms: timeout * HOLD_FACTOR }));
|
|
46
|
+
return reply;
|
|
47
|
+
}).then((result) => ('ok' in result ? { status: 'busy' } : result), () => ({ status: 'error' }));
|
|
48
|
+
return Promise.race([answered.promise, queued]);
|
|
49
|
+
}
|
|
50
|
+
async function settledWithin(running, bound) {
|
|
51
|
+
let timer;
|
|
52
|
+
const late = new Promise((done) => {
|
|
53
|
+
timer = setTimeout(() => done(false), bound);
|
|
54
|
+
});
|
|
55
|
+
try {
|
|
56
|
+
return await Promise.race([
|
|
57
|
+
running.then(() => true, () => true),
|
|
58
|
+
late,
|
|
59
|
+
]);
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
clearTimeout(timer);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Person-only, like `/api/merge`: no MCP tool and no Autopilot path calls it. */
|
|
66
|
+
export function outsideMergeRoute(root) {
|
|
67
|
+
return {
|
|
68
|
+
method: 'POST',
|
|
69
|
+
path: workbenchApi.outsideMerge,
|
|
70
|
+
right: 'build',
|
|
71
|
+
origin: true,
|
|
72
|
+
handle: async ({ hosted, outside, identity, body, stop, signal }) => {
|
|
73
|
+
if (!hosted || !outside?.changes?.act || !identity)
|
|
74
|
+
return { status: 404, body: { error: studioT('ui.outside.unavailable') } };
|
|
75
|
+
const parsed = outsideMergeBodySchema.safeParse(await body());
|
|
76
|
+
if (!parsed.success)
|
|
77
|
+
return { status: 400, body: { error: studioT('ui.outside.invalid') } };
|
|
78
|
+
// Only the studio closing stops the host's merge: a closed connection does not.
|
|
79
|
+
const reply = await outsideMerge(root, outside, identity.viewer, parsed.data.change, stop ?? signal);
|
|
80
|
+
return { status: answered(reply) ? status[reply.status] : 409, body: reply };
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const answered = (reply) => reply.status === 'merged' || reply.status === 'pending';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type OutsideReply, type OutsideState, type Viewer } from '@buffcore/contracts/workbench';
|
|
1
|
+
import { type OutsideActAnswer, type OutsideReply, type OutsideState, type Viewer } from '@buffcore/contracts/workbench';
|
|
2
2
|
export type HostOutsideReadInput = Readonly<{
|
|
3
3
|
viewer: Readonly<Viewer>;
|
|
4
4
|
signal: AbortSignal;
|
|
@@ -25,10 +25,13 @@ export type HostOutside = Readonly<{
|
|
|
25
25
|
}>) => Promise<AnswerResult>;
|
|
26
26
|
};
|
|
27
27
|
changes?: HostSource & {
|
|
28
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* A person pressed Merge on this change: merge it (the host checks the id is one it listed and
|
|
30
|
+
* that this viewer may merge it), or answer `refused` with a code, or `pending`.
|
|
31
|
+
*/
|
|
29
32
|
act?: (input: HostOutsideReadInput & Readonly<{
|
|
30
33
|
change: string;
|
|
31
|
-
}>) => Promise<
|
|
34
|
+
}>) => Promise<OutsideActAnswer>;
|
|
32
35
|
};
|
|
33
36
|
timeoutMs?: number;
|
|
34
37
|
}>;
|
|
@@ -50,7 +53,7 @@ export declare function checkedOutside(outside: HostOutside | undefined, signedI
|
|
|
50
53
|
read: (input: HostOutsideReadInput) => Promise<unknown>;
|
|
51
54
|
act: ((input: HostOutsideReadInput & Readonly<{
|
|
52
55
|
change: string;
|
|
53
|
-
}>) => Promise<
|
|
56
|
+
}>) => Promise<OutsideActAnswer>) | undefined;
|
|
54
57
|
} | undefined;
|
|
55
58
|
timeoutMs: number;
|
|
56
59
|
} | undefined;
|
|
@@ -17,6 +17,8 @@ export function checkedOutside(outside, signedIn) {
|
|
|
17
17
|
typeof registration.read !== 'function')
|
|
18
18
|
throw new Error(studioT('ui.outside.source'));
|
|
19
19
|
}
|
|
20
|
+
if (changes?.act !== undefined && typeof changes.act !== 'function')
|
|
21
|
+
throw new Error(studioT('ui.outside.source'));
|
|
20
22
|
if (!issues && !changes)
|
|
21
23
|
return;
|
|
22
24
|
return {
|
|
@@ -32,6 +34,7 @@ export function outsideState(outside) {
|
|
|
32
34
|
...(outside.issues ? { issues: { source: outside.issues.source } } : {}),
|
|
33
35
|
...(outside.changes ? { changes: { source: outside.changes.source } } : {}),
|
|
34
36
|
...(typeof outside.issues?.answer === 'function' ? { answers: true } : {}),
|
|
37
|
+
...(typeof outside.changes?.act === 'function' ? { merges: true } : {}),
|
|
35
38
|
};
|
|
36
39
|
}
|
|
37
40
|
async function readSource(registration, schema, viewer, timeoutMs, stop) {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type PlanFacts } from '@buffcore/contracts/workbench';
|
|
2
|
+
/**
|
|
3
|
+
* `plan/extensions.md`: one line per capability the product needs, with the plan's answer for it.
|
|
4
|
+
*
|
|
5
|
+
* - use: uploads - photos on each job
|
|
6
|
+
* - build to share: sms - texting customers, as any shop would (extra: about half a day)
|
|
7
|
+
*
|
|
8
|
+
* Only bullet lines are read; headings, prose and comments are the person's and stay as written,
|
|
9
|
+
* so an edit anywhere else keeps every kind. An unknown kind is a problem, never a guess.
|
|
10
|
+
*/
|
|
11
|
+
export type PlanExtension = NonNullable<PlanFacts['extensions']>[number];
|
|
12
|
+
export interface PlanExtensionProblem {
|
|
13
|
+
line: number;
|
|
14
|
+
message: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Close to a kind: a typo of one, at most one edit for a kind of four letters or fewer (`use`),
|
|
18
|
+
* two for a longer one (`requst`, `improv`, `build to shre`). `note`, `todo` and `ask` stay prose.
|
|
19
|
+
*/
|
|
20
|
+
export declare const nearKind: (head: string) => boolean;
|
|
21
|
+
export declare function parsePlanExtensions(text: string): {
|
|
22
|
+
extensions: PlanExtension[];
|
|
23
|
+
problems: PlanExtensionProblem[];
|
|
24
|
+
};
|
|
25
|
+
/** One line in the file's form; `parsePlanExtensions` reads back exactly what it was given. */
|
|
26
|
+
export declare function planExtensionLine(e: PlanExtension): string;
|
|
27
|
+
/** The studio's read: the known lines, or absent when the file is missing, linked or too big. */
|
|
28
|
+
export declare function readPlanExtensions(root: string): Promise<PlanExtension[] | null>;
|
|
29
|
+
/** `ape change`'s check of the file: each line it cannot read, as a change file's problems are. */
|
|
30
|
+
export declare function planExtensionProblems(root: string): Promise<{
|
|
31
|
+
file: string;
|
|
32
|
+
field: string;
|
|
33
|
+
message: string;
|
|
34
|
+
}[]>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const en: {
|
|
2
|
+
readonly 'planExtensions.kind': '"{kind}" is not a kind. Write one of: use, improve, build to share, request, product only (as "- build to share: <name> - <why>")';
|
|
3
|
+
readonly 'planExtensions.form': 'not in the form "- <kind>: <name> - <why>", with "(extra: <cost>)" at the end when it is built to share';
|
|
4
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export const en = {
|
|
2
|
+
'planExtensions.kind': '"{kind}" is not a kind. Write one of: use, improve, build to share, request, product only (as "- build to share: <name> - <why>")',
|
|
3
|
+
'planExtensions.form': 'not in the form "- <kind>: <name> - <why>", with "(extra: <cost>)" at the end when it is built to share',
|
|
4
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export const es = {
|
|
2
|
+
'planExtensions.kind': '"{kind}" no es un tipo. Escriba uno de: use, improve, build to share, request, product only (como "- build to share: <nombre> - <por qué>")',
|
|
3
|
+
'planExtensions.form': 'no tiene la forma "- <tipo>: <nombre> - <por qué>", con "(extra: <costo>)" al final cuando se construye para compartir',
|
|
4
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { PLAN_EXTENSION_KINDS, } from '@buffcore/contracts/workbench';
|
|
4
|
+
import { createI18n } from '@buffcore/i18n';
|
|
5
|
+
import { artifact } from './plan-artifact.js';
|
|
6
|
+
import { en } from './plan-extensions.en.js';
|
|
7
|
+
import { es } from './plan-extensions.es.js';
|
|
8
|
+
const messages = createI18n({ catalogs: [{ en, es }] });
|
|
9
|
+
const t = (key, values) => messages.t(/^es(?:[-_.]|$)/i.test(process.env.LC_ALL || process.env.LANG || '') ? 'es' : 'en', key, values);
|
|
10
|
+
const LINE = /^\s*[-*]\s+([^:]+?):\s+(\S+)(?:\s+[-–—]\s+(.*?))?(?:\s*\(extra:\s*([^)]*)\))?\s*$/i;
|
|
11
|
+
const MAX = 100;
|
|
12
|
+
const isKind = (kind) => PLAN_EXTENSION_KINDS.includes(kind);
|
|
13
|
+
/** Edits (insert, delete, change one letter) to turn one word into the other. */
|
|
14
|
+
function distance(a, b) {
|
|
15
|
+
let row = Array.from({ length: b.length + 1 }, (_, i) => i);
|
|
16
|
+
for (let i = 1; i <= a.length; i++) {
|
|
17
|
+
const next = [i];
|
|
18
|
+
for (let j = 1; j <= b.length; j++)
|
|
19
|
+
next[j] = Math.min((row[j] ?? 0) + 1, (next[j - 1] ?? 0) + 1, (row[j - 1] ?? 0) + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
20
|
+
row = next;
|
|
21
|
+
}
|
|
22
|
+
return row[b.length] ?? 0;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Close to a kind: a typo of one, at most one edit for a kind of four letters or fewer (`use`),
|
|
26
|
+
* two for a longer one (`requst`, `improv`, `build to shre`). `note`, `todo` and `ask` stay prose.
|
|
27
|
+
*/
|
|
28
|
+
export const nearKind = (head) => PLAN_EXTENSION_KINDS.some((kind) => distance(head, kind) <= (kind.length <= 4 ? 1 : 2));
|
|
29
|
+
export function parsePlanExtensions(text) {
|
|
30
|
+
const extensions = [];
|
|
31
|
+
const problems = [];
|
|
32
|
+
// Comments become blank lines of the same count, so line numbers stay the file's own.
|
|
33
|
+
const lines = text
|
|
34
|
+
.replace(/<!--[\s\S]*?-->/g, (comment) => comment.replace(/[^\n]/g, ''))
|
|
35
|
+
.split(/\r?\n/);
|
|
36
|
+
for (const [index, raw] of lines.entries()) {
|
|
37
|
+
// Only a top-level bullet whose words before the colon are a kind, or close to one (a typo), is a
|
|
38
|
+
// line of the list. Any other bullet (`- note: …`, `- todo: …`), and a nested sub-point, is the
|
|
39
|
+
// person's prose and stays as written.
|
|
40
|
+
const head = /^[-*]\s+([a-z]+(?: [a-z]+){0,2}):(?:\s|$)/i.exec(raw)?.[1];
|
|
41
|
+
if (!head || !nearKind(head.toLowerCase()))
|
|
42
|
+
continue;
|
|
43
|
+
const line = index + 1;
|
|
44
|
+
const match = LINE.exec(raw);
|
|
45
|
+
if (!match) {
|
|
46
|
+
problems.push({ line, message: t('planExtensions.form') });
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const kind = (match[1] ?? '').trim().toLowerCase().replace(/\s+/g, ' ');
|
|
50
|
+
if (!isKind(kind)) {
|
|
51
|
+
problems.push({ line, message: t('planExtensions.kind', { kind }) });
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (extensions.length === MAX)
|
|
55
|
+
continue;
|
|
56
|
+
const why = match[3]?.trim();
|
|
57
|
+
const extra = match[4]?.trim();
|
|
58
|
+
extensions.push({
|
|
59
|
+
kind,
|
|
60
|
+
name: match[2].slice(0, 4000),
|
|
61
|
+
...(why ? { why: why.slice(0, 4000) } : {}),
|
|
62
|
+
...(extra ? { extra: extra.slice(0, 4000) } : {}),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return { extensions, problems };
|
|
66
|
+
}
|
|
67
|
+
/** One line in the file's form; `parsePlanExtensions` reads back exactly what it was given. */
|
|
68
|
+
export function planExtensionLine(e) {
|
|
69
|
+
return `- ${e.kind}: ${e.name}${e.why ? ` - ${e.why}` : ''}${e.extra ? ` (extra: ${e.extra})` : ''}`;
|
|
70
|
+
}
|
|
71
|
+
/** The studio's read: the known lines, or absent when the file is missing, linked or too big. */
|
|
72
|
+
export async function readPlanExtensions(root) {
|
|
73
|
+
return artifact(root, 'extensions.md', (text) => parsePlanExtensions(text).extensions);
|
|
74
|
+
}
|
|
75
|
+
/** `ape change`'s check of the file: each line it cannot read, as a change file's problems are. */
|
|
76
|
+
export async function planExtensionProblems(root) {
|
|
77
|
+
const file = 'plan/extensions.md';
|
|
78
|
+
const text = await readFile(join(root, file), 'utf8').catch(() => null);
|
|
79
|
+
if (text === null)
|
|
80
|
+
return [];
|
|
81
|
+
return parsePlanExtensions(text).problems.map((p) => ({
|
|
82
|
+
file,
|
|
83
|
+
field: String(p.line),
|
|
84
|
+
message: p.message,
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readdir
|
|
1
|
+
import { readdir } from 'node:fs/promises';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { approvalHolds, approvalSchema } from '@buffcore/contracts/approvals';
|
|
4
4
|
import { readChange } from '../change-file.js';
|
|
@@ -7,16 +7,20 @@ import { resolveMode } from '../design/state.js';
|
|
|
7
7
|
import { brandMatches, brandPreview } from './brand-approval.js';
|
|
8
8
|
import { answer, parseBrief, plain, withoutComments } from './plan-brief.js';
|
|
9
9
|
import { changeDetail } from './plan-details.js';
|
|
10
|
+
import { readPlanExtensions } from './plan-extensions.js';
|
|
10
11
|
import { planHistory } from './plan-history.js';
|
|
11
12
|
import { parseJourneys } from './plan-journeys.js';
|
|
12
13
|
import { readNotThis } from './plan-not.js';
|
|
13
14
|
import { structureFacts } from './plan-structure.js';
|
|
15
|
+
import { readInside } from './real-file.js';
|
|
14
16
|
import { stepFiles } from './save-ownership.js';
|
|
15
17
|
export { answer, briefSection, parseBrief, plain, planSections, withoutComments, } from './plan-brief.js';
|
|
16
18
|
export { parseJourneys } from './plan-journeys.js';
|
|
19
|
+
/** A plan file's text, only when it is a regular file whose real path stays in the product. */
|
|
17
20
|
async function rawTextAt(root, file) {
|
|
18
21
|
try {
|
|
19
|
-
|
|
22
|
+
const read = await readInside(join(root, file), [root]);
|
|
23
|
+
return read === undefined ? null : read.bytes.toString('utf8');
|
|
20
24
|
}
|
|
21
25
|
catch {
|
|
22
26
|
return null;
|
|
@@ -163,7 +167,7 @@ async function readBrand(root, hostedAuthority = false) {
|
|
|
163
167
|
}
|
|
164
168
|
}
|
|
165
169
|
export async function readPlan(root, hostedAuthority = false) {
|
|
166
|
-
const [brief, milestones, journeys, changes, brand, structure, notThis] = await Promise.all([
|
|
170
|
+
const [brief, milestones, journeys, changes, brand, structure, notThis, extensions] = await Promise.all([
|
|
167
171
|
readBrief(root),
|
|
168
172
|
readRoadmap(root),
|
|
169
173
|
readJourneys(root),
|
|
@@ -171,10 +175,12 @@ export async function readPlan(root, hostedAuthority = false) {
|
|
|
171
175
|
readBrand(root, hostedAuthority),
|
|
172
176
|
structureFacts(root),
|
|
173
177
|
readNotThis(root),
|
|
178
|
+
readPlanExtensions(root),
|
|
174
179
|
]);
|
|
175
180
|
return {
|
|
176
181
|
brief,
|
|
177
182
|
milestones,
|
|
183
|
+
...(extensions ? { extensions } : {}),
|
|
178
184
|
journeys,
|
|
179
185
|
notThis,
|
|
180
186
|
...(structure ? { structure } : {}),
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
2
1
|
import { join } from 'node:path';
|
|
3
2
|
import { createI18n } from '@buffcore/i18n';
|
|
4
3
|
import { readChanges } from '../change-file.js';
|
|
@@ -6,6 +5,7 @@ import { adminScreens, appScreens } from '../inventory-screens.js';
|
|
|
6
5
|
import { SURFACE_FIELD, SURFACE_LINE } from '../prototype/comp.js';
|
|
7
6
|
import { en } from './plan-structure.en.js';
|
|
8
7
|
import { es } from './plan-structure.es.js';
|
|
8
|
+
import { readInside } from './real-file.js';
|
|
9
9
|
/** `/billing (planned, C-020)`: a first screen a change adds, before its route exists. */
|
|
10
10
|
const PLANNED = /^(.*\S) \(planned, (C-\d{3,})\)$/u;
|
|
11
11
|
const messages = createI18n({ catalogs: [{ en, es }] });
|
|
@@ -162,13 +162,11 @@ export function parseStructure(text, screens, changes) {
|
|
|
162
162
|
}
|
|
163
163
|
/** Reuse the inventory's discovery; no product code is loaded and no navigation is inferred. */
|
|
164
164
|
export async function readStructure(root) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
throw error;
|
|
169
|
-
});
|
|
170
|
-
if (text === null)
|
|
165
|
+
// Missing, or a link, hard link or junction leading out of the product: no structure to show.
|
|
166
|
+
const read = await readInside(join(root, 'plan/structure.md'), [root]);
|
|
167
|
+
if (!read)
|
|
171
168
|
return null;
|
|
169
|
+
const text = read.bytes.toString('utf8');
|
|
172
170
|
const [app, admin, planned] = await Promise.all([
|
|
173
171
|
appScreens(root, root),
|
|
174
172
|
adminScreens(root, root),
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { type PrototypeCompReply } from '@buffcore/contracts/workbench';
|
|
2
|
+
import { type ApprovalContext } from './approval-authority.ts';
|
|
2
3
|
import type { ImageType, UiRoute } from './routes.ts';
|
|
3
4
|
export declare const pictureType: (file: string) => ImageType | undefined;
|
|
4
|
-
export declare function compReply(root: string, hosted?: boolean): Promise<PrototypeCompReply>;
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
export declare function compReply(root: string, hosted?: boolean, context?: ApprovalContext): Promise<PrototypeCompReply>;
|
|
6
|
+
/**
|
|
7
|
+
* The real file a picture name stands for, or undefined: only the comp's own shots and the
|
|
8
|
+
* references, and only a regular file whose real path (links followed) stays where it was listed:
|
|
9
|
+
* a shot inside the comp snapshot folder, a reference inside the product's folder unless the person's
|
|
10
|
+
* own studio lists it outside.
|
|
11
|
+
*/
|
|
12
|
+
export declare function compPicture(root: string, name: string, hosted?: boolean): Promise<{
|
|
13
|
+
bytes: Buffer;
|
|
14
|
+
type: ImageType;
|
|
15
|
+
} | undefined>;
|
|
7
16
|
export declare function prototypeCompRoutes(root: string): UiRoute[];
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// The comp page's reads: the newest comp snapshot's screens, the references beside them and the
|
|
2
2
|
// approval; and each picture by its name (never by a path from the request).
|
|
3
|
-
import { readFile } from 'node:fs/promises';
|
|
4
3
|
import { extname, join } from 'node:path';
|
|
5
4
|
import { frameSizes } from '@buffcore/config';
|
|
6
5
|
import { workbenchApi } from '@buffcore/contracts/workbench';
|
|
@@ -9,6 +8,9 @@ import { referencePictures } from '../design/references.js';
|
|
|
9
8
|
import { compDir, firstSurface, newestComp } from '../prototype/comp.js';
|
|
10
9
|
import { compApproved, readCompApproval } from '../prototype/comp-record.js';
|
|
11
10
|
import { snapshotsDir } from '../prototype/report.js';
|
|
11
|
+
import { authorityFor } from './approval-authority.js';
|
|
12
|
+
import { hostedComp } from './comp-approval.js';
|
|
13
|
+
import { readInside } from './real-file.js';
|
|
12
14
|
const MAX = 12;
|
|
13
15
|
/** The picture types the page shows, by extension; any other file is never served. */
|
|
14
16
|
const TYPES = {
|
|
@@ -43,12 +45,15 @@ async function desktopWidth(root) {
|
|
|
43
45
|
async function shownReferences(root, hosted) {
|
|
44
46
|
return (await referencePictures(root))
|
|
45
47
|
.slice(0, MAX)
|
|
46
|
-
.map(({ file, inside }) => file && (inside || !hosted) && pictureType(file) ? file : undefined);
|
|
48
|
+
.map(({ file, inside }) => file && (inside || !hosted) && pictureType(file) ? { file, inside } : undefined);
|
|
47
49
|
}
|
|
48
|
-
export async function compReply(root, hosted = false) {
|
|
50
|
+
export async function compReply(root, hosted = false, context) {
|
|
49
51
|
const surface = firstSurface(root);
|
|
50
52
|
const comp = newestComp(root);
|
|
51
53
|
const record = readCompApproval(root);
|
|
54
|
+
const approval = context
|
|
55
|
+
? await hostedComp(root, record, comp, context)
|
|
56
|
+
: { approved: compApproved(record, comp), approval: record?.approval ?? null };
|
|
52
57
|
const references = await shownReferences(root, hosted);
|
|
53
58
|
const screens = (comp?.report.scenes ?? []).slice(0, MAX).map((scene, index) => {
|
|
54
59
|
const { light, dark } = screenShots(scene);
|
|
@@ -63,13 +68,17 @@ export async function compReply(root, hosted = false) {
|
|
|
63
68
|
surface,
|
|
64
69
|
width: surface === 'phone' ? frameSizes().phone.width : await desktopWidth(root),
|
|
65
70
|
screens,
|
|
66
|
-
references: references.map((
|
|
71
|
+
references: references.map((shown, index) => (shown ? `reference-${index}` : null)),
|
|
67
72
|
...(comp ? { fingerprint: comp.fingerprint } : {}),
|
|
68
|
-
|
|
69
|
-
approval: record?.approval ?? null,
|
|
73
|
+
...approval,
|
|
70
74
|
};
|
|
71
75
|
}
|
|
72
|
-
/**
|
|
76
|
+
/**
|
|
77
|
+
* The real file a picture name stands for, or undefined: only the comp's own shots and the
|
|
78
|
+
* references, and only a regular file whose real path (links followed) stays where it was listed:
|
|
79
|
+
* a shot inside the comp snapshot folder, a reference inside the product's folder unless the person's
|
|
80
|
+
* own studio lists it outside.
|
|
81
|
+
*/
|
|
73
82
|
export async function compPicture(root, name, hosted = false) {
|
|
74
83
|
const screen = /^screen-(\d{1,2})-(light|dark)$/.exec(name);
|
|
75
84
|
if (screen) {
|
|
@@ -78,11 +87,19 @@ export async function compPicture(root, name, hosted = false) {
|
|
|
78
87
|
return;
|
|
79
88
|
const look = screenShots(scene)[screen[2]];
|
|
80
89
|
const path = look ? scene.screenshots[look] : undefined;
|
|
81
|
-
|
|
90
|
+
const folder = compDir(snapshotsDir(root));
|
|
91
|
+
return path && SHOT.test(path) ? picture(join(folder, path), [root, folder]) : undefined;
|
|
82
92
|
}
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
93
|
+
const index = /^reference-(\d{1,2})$/.exec(name)?.[1];
|
|
94
|
+
const shown = index === undefined ? undefined : (await shownReferences(root, hosted))[+index];
|
|
95
|
+
if (shown)
|
|
96
|
+
return picture(shown.file, shown.inside ? [root] : []);
|
|
97
|
+
}
|
|
98
|
+
/** The bytes read from the opened file, typed by its real name; any other file is never served. */
|
|
99
|
+
async function picture(file, folders) {
|
|
100
|
+
const read = await readInside(file, folders);
|
|
101
|
+
const type = read && pictureType(read.real);
|
|
102
|
+
return read && type ? { bytes: read.bytes, type } : undefined;
|
|
86
103
|
}
|
|
87
104
|
export function prototypeCompRoutes(root) {
|
|
88
105
|
return [
|
|
@@ -90,18 +107,19 @@ export function prototypeCompRoutes(root) {
|
|
|
90
107
|
method: 'GET',
|
|
91
108
|
path: workbenchApi.prototypeComp,
|
|
92
109
|
right: 'read:runs',
|
|
93
|
-
handle: async ({ hosted }) => ({
|
|
110
|
+
handle: async ({ hosted, identity, approval }) => ({
|
|
111
|
+
status: 200,
|
|
112
|
+
body: await compReply(root, !!hosted, authorityFor({ identity, approval })),
|
|
113
|
+
}),
|
|
94
114
|
},
|
|
95
115
|
{
|
|
96
116
|
method: 'GET',
|
|
97
117
|
path: `${workbenchApi.prototypeComp}/picture/:name`,
|
|
98
118
|
right: 'read:runs',
|
|
99
119
|
handle: async ({ params, hosted }) => {
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return bytes && type
|
|
104
|
-
? { status: 200, body: bytes, type }
|
|
120
|
+
const shown = await compPicture(root, params.name ?? '', !!hosted);
|
|
121
|
+
return shown
|
|
122
|
+
? { status: 200, body: shown.bytes, type: shown.type }
|
|
105
123
|
: { status: 404, body: { error: 'missing' } };
|
|
106
124
|
},
|
|
107
125
|
},
|
|
@@ -16,6 +16,12 @@ export declare function planPrototypeOnMain(root: string, plan: PlanFacts | unde
|
|
|
16
16
|
name: string;
|
|
17
17
|
changes: string[];
|
|
18
18
|
}[];
|
|
19
|
+
extensions?: {
|
|
20
|
+
kind: "build to share" | "improve" | "product only" | "request" | "use";
|
|
21
|
+
name: string;
|
|
22
|
+
why?: string | undefined;
|
|
23
|
+
extra?: string | undefined;
|
|
24
|
+
}[] | undefined;
|
|
19
25
|
changes: {
|
|
20
26
|
id: string;
|
|
21
27
|
title: string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type InsideFile = {
|
|
2
|
+
bytes: Buffer;
|
|
3
|
+
real: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* The bytes of `file` and its real path, or undefined. `afterOpen` is for tests only: it runs
|
|
7
|
+
* between the open and the checks, where a folder swap would happen.
|
|
8
|
+
*/
|
|
9
|
+
export declare function readInside(file: string, folders: readonly string[], afterOpen?: () => void | Promise<void>): Promise<InsideFile | undefined>;
|
|
10
|
+
/** `readInside` for synchronous readers: the bytes, or undefined. */
|
|
11
|
+
export declare function readInsideSync(file: string, folders: readonly string[]): Buffer | undefined;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Read a file a route may show: open it first, then prove the open handle is the regular file, with
|
|
2
|
+
// one link, whose real path (links and junctions followed) stays inside every given folder, and read
|
|
3
|
+
// the bytes from that handle (as app-icon.ts does). A link or junction leading out, a hard link, a
|
|
4
|
+
// folder, a missing file or a path swapped while it was checked gives undefined.
|
|
5
|
+
import { closeSync, existsSync, fstatSync, openSync, readFileSync, realpathSync, statSync, } from 'node:fs';
|
|
6
|
+
import { open, realpath, stat } from 'node:fs/promises';
|
|
7
|
+
import { isAbsolute, relative, sep } from 'node:path';
|
|
8
|
+
/** Linux names an open file's true path; elsewhere (Windows, macOS) Node has no such name. */
|
|
9
|
+
const FDS = '/proc/self/fd';
|
|
10
|
+
const byHandle = existsSync(FDS);
|
|
11
|
+
const within = (folder, file) => {
|
|
12
|
+
const from = relative(folder, file);
|
|
13
|
+
return !!from && !isAbsolute(from) && from !== '..' && !from.startsWith(`..${sep}`);
|
|
14
|
+
};
|
|
15
|
+
/** The handle is that path's file: same device and file id, a regular file with one link. */
|
|
16
|
+
const same = (handle, path) => handle.isFile() && handle.nlink === 1n && handle.dev === path.dev && handle.ino === path.ino;
|
|
17
|
+
/**
|
|
18
|
+
* The bytes of `file` and its real path, or undefined. `afterOpen` is for tests only: it runs
|
|
19
|
+
* between the open and the checks, where a folder swap would happen.
|
|
20
|
+
*/
|
|
21
|
+
export async function readInside(file, folders, afterOpen) {
|
|
22
|
+
const handle = await open(file, 'r').catch(() => undefined);
|
|
23
|
+
if (!handle)
|
|
24
|
+
return;
|
|
25
|
+
try {
|
|
26
|
+
const opened = await handle.stat({ bigint: true });
|
|
27
|
+
await afterOpen?.();
|
|
28
|
+
const real = await realpath(file);
|
|
29
|
+
for (const folder of folders)
|
|
30
|
+
if (!within(await realpath(folder), real))
|
|
31
|
+
return;
|
|
32
|
+
const checked = await stat(real, { bigint: true });
|
|
33
|
+
// The real path again: a swap during the checks changes it or the file id.
|
|
34
|
+
if (!same(opened, checked) || (await realpath(file)) !== real)
|
|
35
|
+
return;
|
|
36
|
+
// Where the system names the open file itself, that name must be inside too: no race left.
|
|
37
|
+
if (byHandle) {
|
|
38
|
+
const held = await realpath(`${FDS}/${handle.fd}`);
|
|
39
|
+
for (const folder of folders)
|
|
40
|
+
if (!within(await realpath(folder), held))
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
return { bytes: await handle.readFile(), real };
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
await handle.close().catch(() => { });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** `readInside` for synchronous readers: the bytes, or undefined. */
|
|
53
|
+
export function readInsideSync(file, folders) {
|
|
54
|
+
let fd;
|
|
55
|
+
try {
|
|
56
|
+
fd = openSync(file, 'r');
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const opened = fstatSync(fd, { bigint: true });
|
|
63
|
+
const real = realpathSync.native(file);
|
|
64
|
+
for (const folder of folders)
|
|
65
|
+
if (!within(realpathSync.native(folder), real))
|
|
66
|
+
return;
|
|
67
|
+
const checked = statSync(real, { bigint: true });
|
|
68
|
+
if (!same(opened, checked) || realpathSync.native(file) !== real)
|
|
69
|
+
return;
|
|
70
|
+
if (byHandle) {
|
|
71
|
+
const held = realpathSync.native(`${FDS}/${fd}`);
|
|
72
|
+
for (const folder of folders)
|
|
73
|
+
if (!within(realpathSync.native(folder), held))
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
return readFileSync(fd);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
closeSync(fd);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -9,6 +9,7 @@ import { autoProtection } from './autopilot-protection.js';
|
|
|
9
9
|
import { requestRefusal } from './host.js';
|
|
10
10
|
import { HostSaveRefusal } from './host-save.js';
|
|
11
11
|
import { factsChanged, mergeEvent } from './merge-events.js';
|
|
12
|
+
import { afterLevel } from './merge-withdraw.js';
|
|
12
13
|
import { reviewedStep, saveBody } from './save-body.js';
|
|
13
14
|
import { saveBuildCompletion } from './save-build-completion.js';
|
|
14
15
|
import { saveChangeStep } from './save-change-step.js';
|
|
@@ -102,8 +103,10 @@ export async function studioSave(root, body, viewer, automatic, options = {}) {
|
|
|
102
103
|
factsChanged('levels');
|
|
103
104
|
// Automatic saves already wake parked work when their turn finishes.
|
|
104
105
|
if (!automatic && result.ok) {
|
|
105
|
-
if (body.step === 'level' && effectiveLevel(root) !== 'auto')
|
|
106
|
+
if (body.step === 'level' && effectiveLevel(root) !== 'auto') {
|
|
106
107
|
mergeEvent('level', root);
|
|
108
|
+
await afterLevel(root);
|
|
109
|
+
}
|
|
107
110
|
mergeEvent('save', root);
|
|
108
111
|
}
|
|
109
112
|
return result;
|
|
@@ -21,6 +21,7 @@ export { ChatEngine, type ChatEngineOptions } from './chat/turn.ts';
|
|
|
21
21
|
export type { HostLevel, SignIn, UiIdentity } from './host.ts';
|
|
22
22
|
export type { HostSave, HostSaveAnswer, HostSaveInput } from './host-save.ts';
|
|
23
23
|
export type { HostMerge, HostMergeAnswer, HostMergeInput } from './merge-authority.ts';
|
|
24
|
+
export { type HostMergeSettled, type HostMergeSettlement, settleHostMerge, } from './merge-settle.ts';
|
|
24
25
|
export type { AnswerResult, HostOutside, HostOutsideReadInput } from './outside.ts';
|
|
25
26
|
export { pageScript } from './page.ts';
|
|
26
27
|
export { readProductPlan } from './product-plan.ts';
|
|
@@ -21,6 +21,7 @@ export { FreshLooks } from './chat/fresh.js';
|
|
|
21
21
|
export { freshRoutes } from './chat/fresh-routes.js';
|
|
22
22
|
export { chatRoutes } from './chat/routes.js';
|
|
23
23
|
export { ChatEngine } from './chat/turn.js';
|
|
24
|
+
export { settleHostMerge, } from './merge-settle.js';
|
|
24
25
|
export { pageScript } from './page.js';
|
|
25
26
|
export { readProductPlan } from './product-plan.js';
|
|
26
27
|
export { Runner } from './runner.js';
|