@buffcore/cli 0.8.46 → 0.8.47
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 +56 -0
- package/dist/commands/change-merge-remove.d.ts +9 -2
- package/dist/commands/change-merge-remove.js +27 -15
- package/dist/commands/design/check.d.ts +1 -1
- package/dist/commands/design/check.js +2 -1
- package/dist/commands/design/contract-size.d.ts +7 -0
- package/dist/commands/design/contract-size.js +47 -0
- package/dist/commands/design/tells.en.d.ts +2 -0
- package/dist/commands/design/tells.en.js +2 -0
- package/dist/commands/design/tells.es.js +2 -0
- package/dist/commands/extension/places-approval.d.ts +4 -0
- package/dist/commands/process-paths.d.ts +14 -0
- package/dist/commands/process-paths.js +90 -0
- package/dist/commands/prototype/ai-approval.d.ts +27 -0
- package/dist/commands/prototype/ai-approval.js +60 -0
- package/dist/commands/prototype/approver.d.ts +71 -0
- package/dist/commands/prototype/approver.js +168 -0
- package/dist/commands/prototype/critique-gate.d.ts +14 -0
- package/dist/commands/prototype/critique-gate.js +48 -0
- package/dist/commands/prototype/fence.d.ts +1 -0
- package/dist/commands/prototype/fence.js +12 -0
- package/dist/commands/prototype/final-approval-grant.js +18 -0
- package/dist/commands/prototype/final-approval.js +4 -1
- package/dist/commands/prototype/index.js +3 -0
- package/dist/commands/prototype/layout-hints.d.ts +34 -0
- package/dist/commands/prototype/layout-hints.js +194 -0
- package/dist/commands/prototype/layout-measure.d.ts +39 -0
- package/dist/commands/prototype/layout-measure.js +97 -0
- package/dist/commands/prototype/layout-words.d.ts +2 -0
- package/dist/commands/prototype/layout-words.js +11 -0
- package/dist/commands/prototype/layout.en.d.ts +6 -0
- package/dist/commands/prototype/layout.en.js +7 -0
- package/dist/commands/prototype/load-location.js +2 -3
- package/dist/commands/prototype/messages.en.d.ts +14 -0
- package/dist/commands/prototype/messages.en.js +15 -1
- package/dist/commands/prototype/messages.js +15 -1
- package/dist/commands/prototype/milestone-versions.d.ts +4 -0
- package/dist/commands/prototype/prune-command.d.ts +5 -0
- package/dist/commands/prototype/prune-command.js +25 -0
- package/dist/commands/prototype/prune-words.d.ts +1 -0
- package/dist/commands/prototype/prune-words.js +7 -0
- package/dist/commands/prototype/prune.d.ts +16 -0
- package/dist/commands/prototype/prune.en.d.ts +9 -0
- package/dist/commands/prototype/prune.en.js +9 -0
- package/dist/commands/prototype/prune.es.d.ts +2 -0
- package/dist/commands/prototype/prune.es.js +9 -0
- package/dist/commands/prototype/prune.js +140 -0
- package/dist/commands/prototype/reopen-messages.d.ts +9 -0
- package/dist/commands/prototype/reopen-messages.js +19 -0
- package/dist/commands/prototype/report.d.ts +14 -0
- package/dist/commands/prototype/report.js +5 -1
- package/dist/commands/prototype/scene-layout.d.ts +17 -0
- package/dist/commands/prototype/scene-layout.js +57 -0
- package/dist/commands/prototype/scene-ready.js +8 -2
- package/dist/commands/prototype/scene.d.ts +15 -2
- package/dist/commands/prototype/scene.js +54 -42
- package/dist/commands/prototype/selector-answer.d.ts +43 -0
- package/dist/commands/prototype/selector-answer.js +73 -0
- package/dist/commands/prototype/selector-misses.d.ts +19 -0
- package/dist/commands/prototype/selector-misses.js +78 -0
- package/dist/commands/prototype/selector-prompt.d.ts +23 -0
- package/dist/commands/prototype/selector-prompt.js +32 -0
- package/dist/commands/prototype/selector-run.d.ts +13 -0
- package/dist/commands/prototype/selector-run.js +113 -0
- package/dist/commands/prototype/selector.d.ts +54 -0
- package/dist/commands/prototype/selector.js +96 -0
- package/dist/commands/prototype/snapshot-ancestor.js +2 -0
- package/dist/commands/prototype/snapshot-bundle.d.ts +17 -3
- package/dist/commands/prototype/snapshot-bundle.js +69 -7
- package/dist/commands/prototype/snapshot-check-files.d.ts +2 -0
- package/dist/commands/prototype/snapshot-check-files.js +41 -0
- package/dist/commands/prototype/snapshot-command.d.ts +2 -0
- package/dist/commands/prototype/snapshot-command.js +3 -0
- package/dist/commands/prototype/snapshot-completion.d.ts +4 -0
- package/dist/commands/prototype/snapshot-completion.js +30 -2
- package/dist/commands/prototype/snapshot-dependencies.d.ts +23 -2
- package/dist/commands/prototype/snapshot-dependencies.js +120 -14
- package/dist/commands/prototype/snapshot-hashes.d.ts +7 -0
- package/dist/commands/prototype/snapshot-hashes.js +28 -0
- package/dist/commands/prototype/snapshot-inputs.d.ts +15 -6
- package/dist/commands/prototype/snapshot-inputs.js +140 -197
- package/dist/commands/prototype/snapshot-matrix.d.ts +58 -0
- package/dist/commands/prototype/snapshot-matrix.js +95 -0
- package/dist/commands/prototype/snapshot-metro-inputs.d.ts +8 -0
- package/dist/commands/prototype/snapshot-metro-inputs.js +81 -0
- package/dist/commands/prototype/snapshot-owners.d.ts +6 -2
- package/dist/commands/prototype/snapshot-owners.js +12 -3
- package/dist/commands/prototype/snapshot-progress-entry.d.ts +14 -0
- package/dist/commands/prototype/snapshot-progress-entry.js +85 -0
- package/dist/commands/prototype/snapshot-progress.d.ts +19 -2
- package/dist/commands/prototype/snapshot-progress.js +54 -102
- package/dist/commands/prototype/snapshot-registry.d.ts +14 -0
- package/dist/commands/prototype/snapshot-registry.js +121 -0
- package/dist/commands/prototype/snapshot-report.d.ts +4 -0
- package/dist/commands/prototype/snapshot-report.js +77 -12
- package/dist/commands/prototype/snapshot-requests.d.ts +13 -3
- package/dist/commands/prototype/snapshot-requests.js +68 -30
- package/dist/commands/prototype/snapshot-reuse.d.ts +6 -1
- package/dist/commands/prototype/snapshot-reuse.js +17 -7
- package/dist/commands/prototype/snapshot-scene-inputs.d.ts +30 -0
- package/dist/commands/prototype/snapshot-scene-inputs.js +210 -0
- package/dist/commands/prototype/snapshot-served-inputs.d.ts +3 -0
- package/dist/commands/prototype/snapshot-served-inputs.js +12 -0
- package/dist/commands/prototype/snapshot-server-record.d.ts +26 -0
- package/dist/commands/prototype/snapshot-server-record.js +135 -0
- package/dist/commands/prototype/snapshot-servers.d.ts +3 -1
- package/dist/commands/prototype/snapshot-servers.js +50 -2
- package/dist/commands/prototype/snapshot-setup.d.ts +3 -1
- package/dist/commands/prototype/snapshot-setup.js +2 -1
- package/dist/commands/prototype/snapshot-surface-inputs.d.ts +23 -0
- package/dist/commands/prototype/snapshot-surface-inputs.js +161 -0
- package/dist/commands/prototype/snapshot-vite-inputs.d.ts +22 -0
- package/dist/commands/prototype/snapshot-vite-inputs.js +209 -0
- package/dist/commands/prototype/snapshot.d.ts +5 -0
- package/dist/commands/prototype/snapshot.js +72 -10
- package/dist/commands/prototype/version-commands.d.ts +4 -0
- package/dist/commands/prototype/version-commands.js +36 -8
- package/dist/commands/prototype/versions.d.ts +28 -2
- package/dist/commands/prototype/versions.js +25 -1
- package/dist/commands/prototype/vite-fs-path.d.ts +4 -0
- package/dist/commands/prototype/vite-fs-path.js +15 -0
- package/dist/commands/remove-links.d.ts +6 -0
- package/dist/commands/remove-links.js +17 -0
- package/dist/commands/size-docs.d.ts +9 -0
- package/dist/commands/size-docs.en.d.ts +6 -0
- package/dist/commands/size-docs.en.js +6 -0
- package/dist/commands/size-docs.es.d.ts +2 -0
- package/dist/commands/size-docs.es.js +6 -0
- package/dist/commands/size-docs.js +28 -0
- package/dist/commands/size.d.ts +5 -2
- package/dist/commands/size.js +27 -9
- package/dist/commands/ui/approval-authority.d.ts +10 -2
- package/dist/commands/ui/approval-authority.js +1 -0
- package/dist/commands/ui/autopilot-ai-approve.d.ts +18 -0
- package/dist/commands/ui/autopilot-ai-approve.js +68 -0
- package/dist/commands/ui/autopilot-loop.js +5 -6
- package/dist/commands/ui/autopilot-merge.js +3 -0
- package/dist/commands/ui/autopilot.en.d.ts +23 -0
- package/dist/commands/ui/autopilot.en.js +23 -0
- package/dist/commands/ui/autopilot.es.d.ts +23 -0
- package/dist/commands/ui/autopilot.es.js +23 -0
- package/dist/commands/ui/chat/find.d.ts +2 -0
- package/dist/commands/ui/chat/find.js +13 -0
- package/dist/commands/ui/chat/fresh-codex.d.ts +39 -0
- package/dist/commands/ui/chat/fresh-codex.js +175 -0
- package/dist/commands/ui/chat/fresh-critique.js +13 -5
- package/dist/commands/ui/chat/fresh-launch.d.ts +19 -0
- package/dist/commands/ui/chat/fresh-launch.js +67 -11
- package/dist/commands/ui/chat/fresh-prompts.d.ts +2 -0
- package/dist/commands/ui/chat/fresh-prompts.js +2 -0
- package/dist/commands/ui/chat/fresh-secrets.d.ts +6 -0
- package/dist/commands/ui/chat/fresh-secrets.js +172 -0
- package/dist/commands/ui/chat/fresh.en.d.ts +1 -0
- package/dist/commands/ui/chat/fresh.en.js +2 -1
- package/dist/commands/ui/chat/fresh.es.d.ts +1 -0
- package/dist/commands/ui/chat/fresh.es.js +2 -1
- package/dist/commands/ui/chat/worktree.js +25 -5
- package/dist/commands/ui/index.js +3 -0
- package/dist/commands/ui/loop-approve.d.ts +30 -1
- package/dist/commands/ui/loop-approve.js +2 -2
- package/dist/commands/ui/merge-route.js +3 -0
- package/dist/commands/ui/places-change.d.ts +4 -0
- package/dist/commands/ui/prototype-main.d.ts +4 -0
- package/dist/commands/ui/reopen-route.d.ts +117 -0
- package/dist/commands/ui/reopen-route.js +97 -0
- package/dist/commands/ui/save-route.d.ts +2 -0
- package/dist/commands/ui/save-route.js +4 -0
- package/dist/commands/ui/studio-routes.js +2 -0
- package/dist/commands/ui/studio-state.d.ts +33 -0
- package/dist/commands/ui/studio-versions.d.ts +24 -0
- package/dist/commands/ui/worktrees.d.ts +1 -1
- package/dist/commands/ui/worktrees.js +19 -3
- package/dist/commands/worktree-sweep.d.ts +45 -0
- package/dist/commands/worktree-sweep.js +188 -0
- package/dist/commands/worktrees-command.d.ts +32 -0
- package/dist/commands/worktrees-command.en.d.ts +25 -0
- package/dist/commands/worktrees-command.en.js +55 -0
- package/dist/commands/worktrees-command.js +96 -0
- package/dist/main.js +2 -0
- package/dist/ui/page.js +82 -82
- package/docs/PROTOTYPE.md +6 -3
- package/docs/WORKBENCH.md +11 -6
- package/package.json +11 -11
- package/skills/ape-critique/SKILL.md +41 -6
- package/skills/ape-design-system/SKILL.md +3 -0
- package/skills/ape-plan-change/SKILL.md +6 -0
- package/skills/ape-prototype/SKILL.md +8 -4
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
// The snapshot: every scene (or one) in every theme, mode and language, checked and screenshotted,
|
|
2
2
|
// from the development servers that are running; or a committed report's screenshots made again.
|
|
3
|
-
import { mkdir } from 'node:fs/promises';
|
|
3
|
+
import { mkdir, readFile } from 'node:fs/promises';
|
|
4
4
|
import { join, resolve } from 'node:path';
|
|
5
5
|
import { FRAME_SIZES, SURFACES } from '@buffcore/config';
|
|
6
6
|
import { PSEUDO_LOCALES } from '@buffcore/i18n';
|
|
7
|
+
import { checkTheme } from '@buffcore/tokens';
|
|
7
8
|
import { browserSession } from './browser.js';
|
|
8
9
|
import { intlWords } from './checks.js';
|
|
9
10
|
import { locale } from './messages.js';
|
|
10
11
|
import { renderRetries } from './report.js';
|
|
11
12
|
import { pickScenes } from './scene-selection.js';
|
|
13
|
+
import { afterFullRun, selectForRun } from './selector-run.js';
|
|
14
|
+
import { sceneCheckFiles } from './snapshot-check-files.js';
|
|
12
15
|
import { previousSnapshot } from './snapshot-completion.js';
|
|
16
|
+
import { sceneData, sha256 } from './snapshot-hashes.js';
|
|
13
17
|
import { snapshotInputs } from './snapshot-inputs.js';
|
|
18
|
+
import { runMatrix } from './snapshot-matrix.js';
|
|
14
19
|
import { withSnapshotProgress, } from './snapshot-progress.js';
|
|
15
20
|
import { writeSnapshot } from './snapshot-report.js';
|
|
16
21
|
import { snapAll } from './snapshot-runner.js';
|
|
@@ -54,7 +59,15 @@ export async function takeSnapshot(options) {
|
|
|
54
59
|
recoverForRun(options.dir);
|
|
55
60
|
const picked = pickScenes(options.scenes, options.scene);
|
|
56
61
|
const run = runOf(options);
|
|
57
|
-
|
|
62
|
+
const report = await writeRun(options, run, picked);
|
|
63
|
+
if (options.scene === undefined)
|
|
64
|
+
afterFullRun(options, report);
|
|
65
|
+
return report;
|
|
66
|
+
}
|
|
67
|
+
/** The code that draws and checks a scene (S1's in-place looks included), even for a scene with no fingerprint. */
|
|
68
|
+
async function drawingCode() {
|
|
69
|
+
const bytes = await Promise.all(sceneCheckFiles().map((file) => readFile(file)));
|
|
70
|
+
return sha256(JSON.stringify(bytes.map((data) => sha256(data))));
|
|
58
71
|
}
|
|
59
72
|
async function writeRun(options, run, picked) {
|
|
60
73
|
const previous = options.scene === undefined ? undefined : await previousSnapshot(run.out);
|
|
@@ -70,19 +83,42 @@ async function writeRun(options, run, picked) {
|
|
|
70
83
|
const inputs = options.root
|
|
71
84
|
? await snapshotInputs(options.root, canComplete ? options.scenes.scenes : picked, run, browserVersion, options.design, options.environment)
|
|
72
85
|
: undefined;
|
|
73
|
-
|
|
86
|
+
// The floor, or the full matrix (S3b); the inputs above don't depend on which.
|
|
87
|
+
Object.assign(run, runMatrix(options.full, inputs?.parts?.(), options.root, run.commit));
|
|
88
|
+
// Before drawing: the selector's picks join the floor (S3c).
|
|
89
|
+
await selectForRun(options, run);
|
|
90
|
+
if (options.scene !== undefined || !run.looks.some((theme) => checkTheme(theme).length))
|
|
91
|
+
await inputs?.prepare(options.prepare);
|
|
92
|
+
const write = (remaining, progress) => inSnapshotFolder(options.dir, options.commit, options.runId, (out) => writeSnapshot(options, {
|
|
93
|
+
...run,
|
|
94
|
+
out,
|
|
95
|
+
saveScene: progress?.draw,
|
|
96
|
+
session,
|
|
97
|
+
coversRequest: inputs?.coversRequest,
|
|
98
|
+
}, picked, remaining, progress, inputs, previous), () => {
|
|
74
99
|
progress?.check();
|
|
75
100
|
run.checkCheckout?.();
|
|
76
101
|
previous?.check();
|
|
77
102
|
});
|
|
78
|
-
|
|
103
|
+
// Without the inputs every picture shares (public values, settings, tools), nothing is kept.
|
|
104
|
+
// The studio can issue review proof: its pictures come from this run or a committed ancestor.
|
|
105
|
+
if (!options.progress || !inputs?.shared || options.runId)
|
|
79
106
|
return await write(picked);
|
|
107
|
+
// `--scene` keeps a journal too: a scene's entry serves any run of the same source that draws it.
|
|
108
|
+
const all = options.scenes.scenes;
|
|
80
109
|
return await withSnapshotProgress(options.progress, async () => {
|
|
81
110
|
return [
|
|
82
|
-
picked
|
|
83
|
-
|
|
111
|
+
// Each picked scene's own definition is bound to its entry; other scenes only by name.
|
|
112
|
+
all.map(({ key, surface, frame }) => [key, surface, run.frames[frame]]),
|
|
84
113
|
picked.length ? await browserVersion() : null,
|
|
85
114
|
run.looks,
|
|
115
|
+
run.redraw?.size || run.extraLooks?.size
|
|
116
|
+
? [
|
|
117
|
+
run.matrix,
|
|
118
|
+
[...(run.redraw ?? [])],
|
|
119
|
+
[...(run.extraLooks ?? [])].map(([k, v]) => [k, [...v]]),
|
|
120
|
+
]
|
|
121
|
+
: run.matrix,
|
|
86
122
|
run.fontTheme,
|
|
87
123
|
options.locales,
|
|
88
124
|
SURFACES,
|
|
@@ -90,9 +126,22 @@ async function writeRun(options, run, picked) {
|
|
|
90
126
|
options.artifacts?.['data.json'],
|
|
91
127
|
options.sceneTimeout,
|
|
92
128
|
locale(),
|
|
93
|
-
|
|
129
|
+
await drawingCode(),
|
|
130
|
+
inputs?.shared ?? null,
|
|
94
131
|
];
|
|
95
|
-
},
|
|
132
|
+
}, {
|
|
133
|
+
all,
|
|
134
|
+
picked,
|
|
135
|
+
inputs: new Map(picked.map((scene) => [
|
|
136
|
+
scene.key,
|
|
137
|
+
[
|
|
138
|
+
sceneData(scene),
|
|
139
|
+
inputs?.surfaces?.get(scene.surface) ?? null,
|
|
140
|
+
inputs?.fingerprints.get(scene.key) ?? null,
|
|
141
|
+
inputs?.reuse.get(scene.key) ?? null,
|
|
142
|
+
],
|
|
143
|
+
])),
|
|
144
|
+
}, run.commit, write, () => inputs?.runtime());
|
|
96
145
|
}
|
|
97
146
|
finally {
|
|
98
147
|
await session?.close();
|
|
@@ -107,10 +156,23 @@ export async function remakeScreenshots(options) {
|
|
|
107
156
|
recoverSnapshots(options.dir);
|
|
108
157
|
const { report } = options;
|
|
109
158
|
const keys = new Set(report.scenes.map((s) => s.key));
|
|
110
|
-
|
|
159
|
+
// Each scene's own looks: a floor scene's, or a full one's (reused, or from an older report).
|
|
160
|
+
const matrixOf = new Map(report.scenes.map((s) => [s.key, s.matrix ?? 'full']));
|
|
161
|
+
const extraLooks = new Map(report.scenes.map((s) => [s.key, new Set(s.extraLooks ?? [])]));
|
|
162
|
+
const scenes = pickScenes(options.scenes, options.scene).filter((s) => keys.has(s.key));
|
|
111
163
|
const run = { ...runOf({ ...options, commit: report.commit }), photosOnly: true };
|
|
112
164
|
await mkdir(run.out, { recursive: true });
|
|
113
|
-
const
|
|
165
|
+
const picked = [];
|
|
166
|
+
const snapped = [];
|
|
167
|
+
for (const matrix of ['floor', 'full']) {
|
|
168
|
+
const group = scenes.filter((scene) => matrixOf.get(scene.key) === matrix);
|
|
169
|
+
if (!group.length)
|
|
170
|
+
continue;
|
|
171
|
+
picked.push(...group);
|
|
172
|
+
snapped.push(...(await snapAll(group, { ...run, matrix, extraLooks }, undefined, {
|
|
173
|
+
pages: options.pages,
|
|
174
|
+
})));
|
|
175
|
+
}
|
|
114
176
|
return {
|
|
115
177
|
screenshots: snapped.flatMap((s) => Object.values(s.screenshots)),
|
|
116
178
|
retried: picked.filter((_, i) => snapped[i]?.retried).map((scene) => scene.key),
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { Command } from 'commander';
|
|
2
|
+
import { type VersionRow } from './versions.ts';
|
|
2
3
|
interface Flags {
|
|
3
4
|
json?: boolean;
|
|
4
5
|
version?: string;
|
|
5
6
|
why?: string;
|
|
6
7
|
}
|
|
8
|
+
export declare function printVersions(records: VersionRow[]): void;
|
|
9
|
+
/** A person reopens an AI approval (S4): the version waits for a person's approval again. */
|
|
10
|
+
export declare function reopen(change: string): Promise<void>;
|
|
7
11
|
/** Presence is checked at the terminal door; the shared write has no terminal dependency. */
|
|
8
12
|
export declare function approve(change: string, flags?: Flags): Promise<void>;
|
|
9
13
|
/** Register the repository's version doors. There is deliberately no MCP approval door. */
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { createInterface } from 'node:readline/promises';
|
|
2
|
-
import { approvalHolds } from '@buffcore/contracts/approvals';
|
|
2
|
+
import { approvalHolds, isAiSignature, } from '@buffcore/contracts/approvals';
|
|
3
3
|
import { findRoot } from '../../project.js';
|
|
4
4
|
import { ruleT } from '../approval-rules.js';
|
|
5
5
|
import { printJson } from '../json.js';
|
|
6
|
+
import { reopenAndSave } from '../ui/reopen-route.js';
|
|
6
7
|
import { captureCompareCommand, printCommandFailure } from '../ui/snapshot-diagnostics-command.js';
|
|
7
8
|
import { compareVersions, sameWords } from './compare.js';
|
|
8
9
|
import { parseVersion } from './compare-failure.js';
|
|
10
|
+
import { noCritique } from './critique-gate.js';
|
|
9
11
|
import { number, t } from './messages.js';
|
|
12
|
+
import { reopenT } from './reopen-messages.js';
|
|
10
13
|
import { git } from './report.js';
|
|
11
14
|
import { refuseOlder } from './supersede.js';
|
|
12
15
|
import { approveVersion, heldOnly, listVersions, pickVersion, readVersions, recordFromCommand, VersionRefusal, } from './versions.js';
|
|
@@ -37,7 +40,7 @@ async function run(flags, work, print) {
|
|
|
37
40
|
process.exitCode = 2;
|
|
38
41
|
}
|
|
39
42
|
}
|
|
40
|
-
function printVersions(records) {
|
|
43
|
+
export function printVersions(records) {
|
|
41
44
|
for (const record of records)
|
|
42
45
|
for (const version of record.versions) {
|
|
43
46
|
console.log(t('prototype.row', {
|
|
@@ -45,7 +48,9 @@ function printVersions(records) {
|
|
|
45
48
|
version: number(version.version),
|
|
46
49
|
approved: version.version === record.approved?.version &&
|
|
47
50
|
approvalHolds(record.approved.approval, new Date())
|
|
48
|
-
?
|
|
51
|
+
? record.approved.approval.signatures.some(isAiSignature)
|
|
52
|
+
? reopenT('reopen.aiMark')
|
|
53
|
+
: t('prototype.mark')
|
|
49
54
|
: '',
|
|
50
55
|
commit: version.commit,
|
|
51
56
|
why: version.why,
|
|
@@ -55,6 +60,23 @@ function printVersions(records) {
|
|
|
55
60
|
if (refusal)
|
|
56
61
|
console.log(refusal);
|
|
57
62
|
}
|
|
63
|
+
/** A person reopens an AI approval (S4): the version waits for a person's approval again. */
|
|
64
|
+
export async function reopen(change) {
|
|
65
|
+
return run({}, async () => {
|
|
66
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY)
|
|
67
|
+
throw new Error(t('prototype.person'));
|
|
68
|
+
const root = findRoot();
|
|
69
|
+
let by = '';
|
|
70
|
+
try {
|
|
71
|
+
by = git(root, ['config', 'user.email']);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// No identity: the shared write refuses with its own sentence.
|
|
75
|
+
}
|
|
76
|
+
// The same isolated commit as the studio's Reopen, saying who and when.
|
|
77
|
+
return { ok: true, record: await reopenAndSave(root, change, by) };
|
|
78
|
+
}, () => console.log(reopenT('reopen.done', { change })));
|
|
79
|
+
}
|
|
58
80
|
/** Presence is checked at the terminal door; the shared write has no terminal dependency. */
|
|
59
81
|
export async function approve(change, flags = {}) {
|
|
60
82
|
return run(flags, async () => {
|
|
@@ -120,6 +142,7 @@ export function addVersionCommands(prototype) {
|
|
|
120
142
|
.option('--version <n>', t('prototype.numberHelp'))
|
|
121
143
|
.option('--json', t('prototype.jsonHelp'))
|
|
122
144
|
.action(approve);
|
|
145
|
+
prototype.command('reopen <change>').description(reopenT('reopen.help')).action(reopen);
|
|
123
146
|
prototype
|
|
124
147
|
.command('versions [change]')
|
|
125
148
|
.description(t('prototype.versionsHelp'))
|
|
@@ -137,14 +160,19 @@ export function addVersionCommands(prototype) {
|
|
|
137
160
|
/** One change answers `record`, as before; several answer `records`, in the order named. */
|
|
138
161
|
function makeVersion(changes, flags) {
|
|
139
162
|
return run(flags, async () => {
|
|
140
|
-
const
|
|
163
|
+
const root = findRoot();
|
|
164
|
+
const records = await recordFromCommand(root, changes, flags.why ?? '');
|
|
141
165
|
const [record] = records;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
166
|
+
const answer = changes.length === 1 && record ? { ok: true, record } : { ok: true, records };
|
|
167
|
+
const note = noCritique(root);
|
|
168
|
+
if (note)
|
|
169
|
+
answer.note = note;
|
|
170
|
+
return answer;
|
|
171
|
+
}, ({ record, records = record ? [record] : [], note }) => {
|
|
146
172
|
for (const { change, versions } of records)
|
|
147
173
|
console.log(t('prototype.recorded', { change, version: number(versions.at(-1)?.version ?? 0) }));
|
|
174
|
+
if (note)
|
|
175
|
+
console.log(note);
|
|
148
176
|
});
|
|
149
177
|
}
|
|
150
178
|
async function compareCommand(change, a, b, flags) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PrototypeVersions } from '@buffcore/contracts/approvals';
|
|
1
|
+
import { type PrototypeVersions, type Signature } from '@buffcore/contracts/approvals';
|
|
2
2
|
import { ApprovalRefusal as VersionRefusal } from '../approval-rules.ts';
|
|
3
3
|
import { approvedIn, pickVersion } from './pick-version.ts';
|
|
4
4
|
import { versionSnapshot } from './version-snapshot.ts';
|
|
@@ -45,6 +45,10 @@ export declare const recordFromCommand: (root: string, changes: readonly string[
|
|
|
45
45
|
fingerprint: string;
|
|
46
46
|
role?: string | undefined;
|
|
47
47
|
agent?: string | undefined;
|
|
48
|
+
ai?: {
|
|
49
|
+
model?: string | undefined;
|
|
50
|
+
reason: string;
|
|
51
|
+
} | undefined;
|
|
48
52
|
}[];
|
|
49
53
|
rule?: {
|
|
50
54
|
kind: "one";
|
|
@@ -58,6 +62,10 @@ export declare const recordFromCommand: (root: string, changes: readonly string[
|
|
|
58
62
|
by: string;
|
|
59
63
|
} | undefined;
|
|
60
64
|
};
|
|
65
|
+
reopened?: {
|
|
66
|
+
by: string;
|
|
67
|
+
at: string;
|
|
68
|
+
} | undefined;
|
|
61
69
|
} | undefined;
|
|
62
70
|
pending?: {
|
|
63
71
|
version: number;
|
|
@@ -70,6 +78,10 @@ export declare const recordFromCommand: (root: string, changes: readonly string[
|
|
|
70
78
|
fingerprint: string;
|
|
71
79
|
role?: string | undefined;
|
|
72
80
|
agent?: string | undefined;
|
|
81
|
+
ai?: {
|
|
82
|
+
model?: string | undefined;
|
|
83
|
+
reason: string;
|
|
84
|
+
} | undefined;
|
|
73
85
|
}[];
|
|
74
86
|
rule?: {
|
|
75
87
|
kind: "one";
|
|
@@ -83,6 +95,10 @@ export declare const recordFromCommand: (root: string, changes: readonly string[
|
|
|
83
95
|
by: string;
|
|
84
96
|
} | undefined;
|
|
85
97
|
};
|
|
98
|
+
reopened?: {
|
|
99
|
+
by: string;
|
|
100
|
+
at: string;
|
|
101
|
+
} | undefined;
|
|
86
102
|
} | undefined;
|
|
87
103
|
superseded?: {
|
|
88
104
|
version: number;
|
|
@@ -95,6 +111,10 @@ export declare const recordFromCommand: (root: string, changes: readonly string[
|
|
|
95
111
|
fingerprint: string;
|
|
96
112
|
role?: string | undefined;
|
|
97
113
|
agent?: string | undefined;
|
|
114
|
+
ai?: {
|
|
115
|
+
model?: string | undefined;
|
|
116
|
+
reason: string;
|
|
117
|
+
} | undefined;
|
|
98
118
|
}[];
|
|
99
119
|
rule?: {
|
|
100
120
|
kind: "one";
|
|
@@ -108,12 +128,16 @@ export declare const recordFromCommand: (root: string, changes: readonly string[
|
|
|
108
128
|
by: string;
|
|
109
129
|
} | undefined;
|
|
110
130
|
};
|
|
131
|
+
reopened?: {
|
|
132
|
+
by: string;
|
|
133
|
+
at: string;
|
|
134
|
+
} | undefined;
|
|
111
135
|
}[] | undefined;
|
|
112
136
|
}[]>;
|
|
113
137
|
/** The studio's doors record one change, over a checkout with nothing waiting. */
|
|
114
138
|
export declare function recordVersion(root: string, change: string, why: string, now?: Date, write?: boolean): Promise<PrototypeVersions>;
|
|
115
139
|
/** One shared write for the person's terminal and the workbench's approval button. */
|
|
116
|
-
export declare function approveVersion(root: string, change: string, version: number | undefined, by: string, now: Date, role?: string, agent?: string, write?: boolean): PrototypeVersions;
|
|
140
|
+
export declare function approveVersion(root: string, change: string, version: number | undefined, by: string, now: Date, role?: string, agent?: string, write?: boolean, ai?: Signature['ai']): PrototypeVersions;
|
|
117
141
|
export declare const approvedVersion: (root: string, change: string, now?: Date) => {
|
|
118
142
|
version: number;
|
|
119
143
|
commit: string;
|
|
@@ -123,3 +147,5 @@ export declare const approvedVersion: (root: string, change: string, now?: Date)
|
|
|
123
147
|
why: string;
|
|
124
148
|
at: string;
|
|
125
149
|
};
|
|
150
|
+
/** A person reopens an AI approval (S4), at any level: it moves to `superseded`; the version waits. */
|
|
151
|
+
export declare function reopenVersion(root: string, change: string, by: string, now: Date, write?: boolean): PrototypeVersions;
|
|
@@ -4,13 +4,16 @@ import { join } from 'node:path';
|
|
|
4
4
|
import { approvalHolds, prototypeVersionsSchema, } from '@buffcore/contracts/approvals';
|
|
5
5
|
import { approvalRule, ruleT, signApproval, ApprovalRefusal as VersionRefusal, } from '../approval-rules.js';
|
|
6
6
|
import { readChanges } from '../change-file.js';
|
|
7
|
+
import { openP0Refusal } from './critique-gate.js';
|
|
7
8
|
import { t } from './messages.js';
|
|
8
9
|
import { MilestoneVersionsPending, requireLegacyChange } from './milestone-key.js';
|
|
9
10
|
import { approvedIn, pickVersion } from './pick-version.js';
|
|
10
11
|
import { appendVersion, isWhy, recordText, requireCleanCheckout } from './record-checkout.js';
|
|
11
12
|
import { refuseUnsavedVersion, requireSavedLook, requireSavedSnapshot } from './record-look.js';
|
|
13
|
+
import { reopenT } from './reopen-messages.js';
|
|
12
14
|
import { git } from './report.js';
|
|
13
15
|
import { requireReviewProof, snapshotSource } from './review-snapshot.js';
|
|
16
|
+
import { meetsFloor } from './snapshot-matrix.js';
|
|
14
17
|
import { requireReusedScenes } from './snapshot-reuse.js';
|
|
15
18
|
import { requireFinishedReport } from './snapshot-trust.js';
|
|
16
19
|
import { personHeld, signNewest } from './supersede.js';
|
|
@@ -135,6 +138,8 @@ async function provenSnapshot(root) {
|
|
|
135
138
|
}
|
|
136
139
|
const commit = snapshotSource(root, saved.report);
|
|
137
140
|
requireFinishedReport(saved.report, saved.snapshot);
|
|
141
|
+
if (!meetsFloor(saved.report))
|
|
142
|
+
throw new VersionRefusal(t('prototype.belowFloor'));
|
|
138
143
|
requireSavedSnapshot(saved.report);
|
|
139
144
|
requireReusedScenes(root, saved.report, true);
|
|
140
145
|
await requireSavedLook(root, commit, saved.report, saved.model);
|
|
@@ -149,6 +154,10 @@ export async function recordVersions(root, changes, why, { now = new Date(), wri
|
|
|
149
154
|
if (!isWhy(why))
|
|
150
155
|
throw new VersionRefusal(t('prototype.why'));
|
|
151
156
|
requireCleanCheckout(root, standing ? { recording: changes, known } : undefined);
|
|
157
|
+
// The critique on file, in the clean checkout: an open P0 holds every change back.
|
|
158
|
+
const p0 = openP0Refusal(root);
|
|
159
|
+
if (p0)
|
|
160
|
+
throw new VersionRefusal(p0);
|
|
152
161
|
const { commit, fingerprints } = await provenSnapshot(root);
|
|
153
162
|
for (const change of changes)
|
|
154
163
|
namedRefusal(changes, change, () => requireReviewProof(root, change, commit, fingerprints));
|
|
@@ -168,7 +177,7 @@ export async function recordVersion(root, change, why, now = new Date(), write =
|
|
|
168
177
|
return record;
|
|
169
178
|
}
|
|
170
179
|
/** One shared write for the person's terminal and the workbench's approval button. */
|
|
171
|
-
export function approveVersion(root, change, version, by, now, role, agent, write = true) {
|
|
180
|
+
export function approveVersion(root, change, version, by, now, role, agent, write = true, ai) {
|
|
172
181
|
return update(root, change, (record) => {
|
|
173
182
|
if (record.approved && !personHeld(record.approved.approval))
|
|
174
183
|
delete record.approved;
|
|
@@ -186,6 +195,8 @@ export function approveVersion(root, change, version, by, now, role, agent, writ
|
|
|
186
195
|
fingerprint,
|
|
187
196
|
...(role ? { role } : {}),
|
|
188
197
|
...(agent === undefined ? {} : { agent }),
|
|
198
|
+
// An AI approval (S4) always names its agent; a person's never carries `ai`.
|
|
199
|
+
...(ai && agent !== undefined ? { ai } : {}),
|
|
189
200
|
}, approvalRule(root, 'prototype'));
|
|
190
201
|
};
|
|
191
202
|
// A held approval stays in force while the newest version gathers its own signatures.
|
|
@@ -201,3 +212,16 @@ export function approveVersion(root, change, version, by, now, role, agent, writ
|
|
|
201
212
|
}, write);
|
|
202
213
|
}
|
|
203
214
|
export const approvedVersion = (root, change, now = new Date()) => approvedIn(readVersions(root, change), change, now);
|
|
215
|
+
/** A person reopens an AI approval (S4), at any level: it moves to `superseded`; the version waits. */
|
|
216
|
+
export function reopenVersion(root, change, by, now, write = true) {
|
|
217
|
+
return update(root, change, (record) => {
|
|
218
|
+
const held = record.approved;
|
|
219
|
+
if (!held?.approval.signatures.some((s) => s.ai))
|
|
220
|
+
throw new VersionRefusal(reopenT('reopen.none', { change }));
|
|
221
|
+
if (!by.trim())
|
|
222
|
+
throw new VersionRefusal(t('prototype.identity'));
|
|
223
|
+
const reopened = { by: by.trim(), at: now.toISOString() };
|
|
224
|
+
record.superseded = [...(record.superseded ?? []), { ...held, reopened }];
|
|
225
|
+
delete record.approved;
|
|
226
|
+
}, write);
|
|
227
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Vite serves a file outside its root at `/@fs/` and the file's own path: `/@fs/home/me/x.ts` on
|
|
2
|
+
// Linux and macOS, `/@fs/C:/me/x.ts` on Windows. Both directions, as Vite itself reads them.
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
const PREFIX = '/@fs/';
|
|
5
|
+
/** The path Vite serves `file` at. */
|
|
6
|
+
export function viteFsPath(file) {
|
|
7
|
+
return PREFIX + file.replaceAll('\\', '/').replace(/^\/+/, '');
|
|
8
|
+
}
|
|
9
|
+
/** The file a `/@fs/` path names, or undefined for any other path. */
|
|
10
|
+
export function viteFsFile(path) {
|
|
11
|
+
if (!path.startsWith(PREFIX))
|
|
12
|
+
return undefined;
|
|
13
|
+
const rest = path.slice(PREFIX.length).replace(/^\/+/, '');
|
|
14
|
+
return resolve(/^[a-z]:\//i.test(rest) ? rest : `/${rest}`);
|
|
15
|
+
}
|
|
@@ -6,3 +6,9 @@ export declare const removeLinks: (top: string) => Promise<void>;
|
|
|
6
6
|
* cannot delete without `core.longpaths`.
|
|
7
7
|
*/
|
|
8
8
|
export declare const emptyCheckout: (top: string) => Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* A checkout's top `node_modules`, emptied and removed without following a link. Nothing happens
|
|
11
|
+
* when it is missing; a link there is removed as itself; a folder whose real path is not its own
|
|
12
|
+
* (a junction a listing calls a folder) throws.
|
|
13
|
+
*/
|
|
14
|
+
export declare function removePackages(top: string): Promise<void>;
|
|
@@ -50,3 +50,20 @@ export const removeLinks = (top) => walk(top, false);
|
|
|
50
50
|
* cannot delete without `core.longpaths`.
|
|
51
51
|
*/
|
|
52
52
|
export const emptyCheckout = (top) => walk(top, true);
|
|
53
|
+
/**
|
|
54
|
+
* A checkout's top `node_modules`, emptied and removed without following a link. Nothing happens
|
|
55
|
+
* when it is missing; a link there is removed as itself; a folder whose real path is not its own
|
|
56
|
+
* (a junction a listing calls a folder) throws.
|
|
57
|
+
*/
|
|
58
|
+
export async function removePackages(top) {
|
|
59
|
+
const folder = join(top, 'node_modules');
|
|
60
|
+
const entry = await lstat(folder).catch(() => undefined);
|
|
61
|
+
if (!entry)
|
|
62
|
+
return;
|
|
63
|
+
if (entry.isSymbolicLink())
|
|
64
|
+
return removeLink(folder);
|
|
65
|
+
if (!same(realpathSync.native(folder), join(realpathSync.native(top), 'node_modules')))
|
|
66
|
+
throw new Error('linked folder');
|
|
67
|
+
await walk(folder, true);
|
|
68
|
+
await rmdir(folder);
|
|
69
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Whether `ape size` weighs this path as a process document. */
|
|
2
|
+
export declare const isProcessDoc: (path: string) => boolean;
|
|
3
|
+
/** One warning line per process document past its limit, in the person's language. */
|
|
4
|
+
export declare function docSizeWarnings(files: readonly {
|
|
5
|
+
path: string;
|
|
6
|
+
bytes: number;
|
|
7
|
+
}[], locale?: 'en' | 'es'): string[];
|
|
8
|
+
/** The person's language for the warnings, from the environment. */
|
|
9
|
+
export declare const docLocale: () => 'en' | 'es';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const en = {
|
|
2
|
+
'size.docWarning': 'Warning {path} {size} KB, over about {limit} KB: agents read this file; {advice}',
|
|
3
|
+
'size.docCritique': 'keep only the newest review, earlier ones stay in git.',
|
|
4
|
+
'size.docChange': 'keep the plan, not a log of rounds: what was built is in git.',
|
|
5
|
+
'size.docOther': 'split it by heading so agents read one section, and keep history in git, not in the file.',
|
|
6
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const es = {
|
|
2
|
+
'size.docWarning': 'Aviso {path} {size} KB, más de unos {limit} KB: los agentes leen este archivo; {advice}',
|
|
3
|
+
'size.docCritique': 'deja solo la revisión más reciente; las anteriores quedan en git.',
|
|
4
|
+
'size.docChange': 'guarda el plan, no un registro de rondas: lo construido está en git.',
|
|
5
|
+
'size.docOther': 'divídelo por encabezados para que los agentes lean una sección, y deja el historial en git, no en el archivo.',
|
|
6
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Process documents agents read again and again (the plan, the design, the critique, the change
|
|
2
|
+
// files) stay small enough to read. Past a size, `ape size` prints a warning; it never fails.
|
|
3
|
+
import { createI18n } from '@buffcore/i18n';
|
|
4
|
+
import { en } from './size-docs.en.js';
|
|
5
|
+
import { es } from './size-docs.es.js';
|
|
6
|
+
const messages = createI18n({ catalogs: [{ en, es }] });
|
|
7
|
+
const KB = 1024;
|
|
8
|
+
/** The first rule a path matches sets its limit and its advice. */
|
|
9
|
+
const RULES = [
|
|
10
|
+
{ match: /(^|\/)design\/critique\.md$/, limit: 40 * KB, advice: 'size.docCritique' },
|
|
11
|
+
{ match: /(^|\/)plan\/changes\/[^/]+\.md$/, limit: 15 * KB, advice: 'size.docChange' },
|
|
12
|
+
{ match: /(^|\/)(design|plan)\/.+\.md$/, limit: 50 * KB, advice: 'size.docOther' },
|
|
13
|
+
];
|
|
14
|
+
/** Whether `ape size` weighs this path as a process document. */
|
|
15
|
+
export const isProcessDoc = (path) => RULES.some((rule) => rule.match.test(path));
|
|
16
|
+
/** One warning line per process document past its limit, in the person's language. */
|
|
17
|
+
export function docSizeWarnings(files, locale = 'en') {
|
|
18
|
+
const t = (key, values) => messages.t(locale, key, values);
|
|
19
|
+
return files.flatMap(({ path, bytes }) => {
|
|
20
|
+
const rule = RULES.find((r) => r.match.test(path));
|
|
21
|
+
if (!rule || bytes <= rule.limit)
|
|
22
|
+
return [];
|
|
23
|
+
const size = Math.round(bytes / KB);
|
|
24
|
+
return [t('size.docWarning', { path, size, limit: rule.limit / KB, advice: t(rule.advice) })];
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/** The person's language for the warnings, from the environment. */
|
|
28
|
+
export const docLocale = () => /^es(?:[-_.]|$)/i.test(process.env.LC_ALL || process.env.LANG || '') ? 'es' : 'en';
|
package/dist/commands/size.d.ts
CHANGED
|
@@ -12,6 +12,9 @@ export declare function checkSizes(files: readonly {
|
|
|
12
12
|
text: string;
|
|
13
13
|
}[]): SizeReport;
|
|
14
14
|
/** The size report of the repository at `dir`: its tracked source files, and new ones not ignored. */
|
|
15
|
-
export declare function sizeReport(dir: string): SizeReport;
|
|
16
|
-
/**
|
|
15
|
+
export declare function sizeReport(dir: string, listed?: readonly string[]): SizeReport;
|
|
16
|
+
/**
|
|
17
|
+
* `ape size`: warn (never fail) on process documents past their size, and fail when a source file
|
|
18
|
+
* in this repository passes the limit.
|
|
19
|
+
*/
|
|
17
20
|
export declare function size(dir?: string): void;
|
package/dist/commands/size.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process';
|
|
2
|
-
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { readFileSync, statSync } from 'node:fs';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
+
import { docLocale, docSizeWarnings, isProcessDoc } from './size-docs.js';
|
|
4
5
|
/** Source files stay under this many lines (AGENTS.md: small files, one job each). */
|
|
5
6
|
export const MAX_LINES = 300;
|
|
6
7
|
/** A file over the limit may carry this marker near its top until it is split. */
|
|
@@ -25,14 +26,14 @@ export function checkSizes(files) {
|
|
|
25
26
|
}
|
|
26
27
|
return report;
|
|
27
28
|
}
|
|
29
|
+
/** The repository's tracked files, and new ones not ignored. */
|
|
30
|
+
const listFiles = (dir) => execFileSync('git', ['ls-files', '--cached', '--others', '--exclude-standard'], {
|
|
31
|
+
cwd: dir,
|
|
32
|
+
encoding: 'utf8',
|
|
33
|
+
}).split('\n');
|
|
28
34
|
/** The size report of the repository at `dir`: its tracked source files, and new ones not ignored. */
|
|
29
|
-
export function sizeReport(dir) {
|
|
30
|
-
const listed = execFileSync('git', ['ls-files', '--cached', '--others', '--exclude-standard'], {
|
|
31
|
-
cwd: dir,
|
|
32
|
-
encoding: 'utf8',
|
|
33
|
-
});
|
|
35
|
+
export function sizeReport(dir, listed = listFiles(dir)) {
|
|
34
36
|
const files = listed
|
|
35
|
-
.split('\n')
|
|
36
37
|
.filter((path) => SOURCE.test(path))
|
|
37
38
|
.flatMap((path) => {
|
|
38
39
|
try {
|
|
@@ -44,9 +45,26 @@ export function sizeReport(dir) {
|
|
|
44
45
|
});
|
|
45
46
|
return checkSizes(files);
|
|
46
47
|
}
|
|
47
|
-
/**
|
|
48
|
+
/** The process documents among `listed`, with their sizes in bytes. */
|
|
49
|
+
function docFiles(dir, listed) {
|
|
50
|
+
return listed.filter(isProcessDoc).flatMap((path) => {
|
|
51
|
+
try {
|
|
52
|
+
return [{ path, bytes: statSync(join(dir, path)).size }];
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return []; // deleted, still in the index
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* `ape size`: warn (never fail) on process documents past their size, and fail when a source file
|
|
61
|
+
* in this repository passes the limit.
|
|
62
|
+
*/
|
|
48
63
|
export function size(dir = process.cwd()) {
|
|
49
|
-
const
|
|
64
|
+
const listed = listFiles(dir);
|
|
65
|
+
const { over, pending } = sizeReport(dir, listed);
|
|
66
|
+
for (const line of docSizeWarnings(docFiles(dir, listed), docLocale()))
|
|
67
|
+
console.log(line);
|
|
50
68
|
if (pending.length > 0) {
|
|
51
69
|
const files = pending.length === 1 ? '1 file' : `${pending.length} files`;
|
|
52
70
|
console.log(`${files} over ${MAX_LINES} lines waiting to be split (marked "${PENDING}").`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Approval, type ApprovalKind } from '@buffcore/contracts/approvals';
|
|
1
|
+
import { type Approval, type ApprovalKind, type Signature } from '@buffcore/contracts/approvals';
|
|
2
2
|
import { type Viewer } from '@buffcore/contracts/workbench';
|
|
3
3
|
import { en } from './approval-authority.en.ts';
|
|
4
4
|
export type ApprovalArtifact = Readonly<{
|
|
@@ -20,8 +20,11 @@ export type HostApprovalAnswer = {
|
|
|
20
20
|
export type HostApproval = (input: Readonly<{
|
|
21
21
|
viewer: Readonly<Viewer>;
|
|
22
22
|
artifact: ApprovalArtifact;
|
|
23
|
-
|
|
23
|
+
/** `reopen` (S4): a person reopens an AI approval; a host that cannot answers not allowed. */
|
|
24
|
+
action: 'approve' | 'check' | 'reopen';
|
|
24
25
|
agent?: string;
|
|
26
|
+
/** An AI approval (S4): the approver's model and reason, for the host to keep on its signature. */
|
|
27
|
+
ai?: Signature['ai'];
|
|
25
28
|
signal: AbortSignal;
|
|
26
29
|
}>) => Promise<HostApprovalAnswer>;
|
|
27
30
|
/** Request/turn-owned capabilities; never serialized into a chat, prompt or signature file. */
|
|
@@ -29,6 +32,7 @@ export type ApprovalContext = Readonly<{
|
|
|
29
32
|
approval: HostApproval;
|
|
30
33
|
viewer: Readonly<Viewer>;
|
|
31
34
|
agent?: string;
|
|
35
|
+
ai?: Signature['ai'];
|
|
32
36
|
}>;
|
|
33
37
|
export declare function authorityFor(source: {
|
|
34
38
|
approval?: HostApproval;
|
|
@@ -69,6 +73,10 @@ export declare function hostedApproval(context: ApprovalContext, resolve: () =>
|
|
|
69
73
|
fingerprint: string;
|
|
70
74
|
role?: string | undefined;
|
|
71
75
|
agent?: string | undefined;
|
|
76
|
+
ai?: {
|
|
77
|
+
model?: string | undefined;
|
|
78
|
+
reason: string;
|
|
79
|
+
} | undefined;
|
|
72
80
|
}[];
|
|
73
81
|
rule?: {
|
|
74
82
|
kind: "one";
|
|
@@ -94,6 +94,7 @@ async function bounded(context, artifact, action, root) {
|
|
|
94
94
|
artifact,
|
|
95
95
|
action,
|
|
96
96
|
...(context.agent ? { agent: context.agent } : {}),
|
|
97
|
+
...(context.ai ? { ai: context.ai } : {}),
|
|
97
98
|
signal: controller.signal,
|
|
98
99
|
})))
|
|
99
100
|
.then((answer) => validated(answer, artifact, context, action, root), () => refused('approval_authority_error'));
|