@buffcore/cli 0.8.46 → 0.8.48
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 +74 -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-remove.d.ts +9 -2
- package/dist/commands/change-merge-remove.js +27 -15
- package/dist/commands/change-merge.d.ts +2 -2
- 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/dev.d.ts +9 -2
- package/dist/commands/dev.js +24 -5
- package/dist/commands/extension/places-approval.d.ts +4 -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/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/comp-record.d.ts +5 -0
- package/dist/commands/prototype/comp-record.js +22 -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/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.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/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/agents-route.js +2 -0
- package/dist/commands/ui/approval-authority.d.ts +10 -2
- 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 +8 -2
- package/dist/commands/ui/approve.js +2 -4
- 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-records.d.ts +2 -0
- package/dist/commands/ui/autopilot-records.js +5 -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/brand-approval.js +5 -1
- 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/permissions.js +1 -1
- package/dist/commands/ui/chat/routes.js +4 -0
- package/dist/commands/ui/chat/worktree.js +25 -5
- package/dist/commands/ui/comp-approval.d.ts +14 -2
- package/dist/commands/ui/comp-approval.js +45 -8
- package/dist/commands/ui/index.js +3 -0
- package/dist/commands/ui/level-route.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-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 +20 -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/places-change.d.ts +4 -0
- package/dist/commands/ui/plan-files.js +5 -2
- 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 +4 -0
- package/dist/commands/ui/real-file.d.ts +11 -0
- package/dist/commands/ui/real-file.js +84 -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 +8 -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 +34 -0
- package/dist/commands/ui/studio-versions.d.ts +24 -0
- package/dist/commands/ui/studio-versions.js +19 -3
- 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 +89 -89
- package/docs/PROTOTYPE.md +19 -3
- package/docs/WORKBENCH.md +41 -6
- package/package.json +11 -11
- package/skills/ape-critique/SKILL.md +41 -6
- package/skills/ape-deploy/SKILL.md +4 -2
- 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
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// The product's system packages (`server.systemPackages` in buffcore.config.ts): checked here,
|
|
2
|
+
// installed in the image's last stage as root before it drops to the API's user, and their
|
|
3
|
+
// installed versions read back from the built image so the build and the deploy record them.
|
|
4
|
+
import { spawnSync } from 'node:child_process';
|
|
5
|
+
import { SYSTEM_PACKAGE, serverProblems } from '@buffcore/config';
|
|
6
|
+
import { t } from '../build/server-text.js';
|
|
7
|
+
/** The list, refused with a plain sentence when a name isn't a Debian package name. */
|
|
8
|
+
export function systemPackagesOf(product) {
|
|
9
|
+
const problems = serverProblems(product.server);
|
|
10
|
+
if (problems.length)
|
|
11
|
+
throw new Error(t('build.server.packages', { problems: problems.join('; ') }));
|
|
12
|
+
return [...(product.server?.systemPackages ?? [])];
|
|
13
|
+
}
|
|
14
|
+
/** The image label that names the list, so a deploy that only has the image can read it. */
|
|
15
|
+
export const PACKAGES_LABEL = 'ape.system-packages';
|
|
16
|
+
/**
|
|
17
|
+
* The Dockerfile's lines that install them, or nothing for none (the image stays byte-identical).
|
|
18
|
+
* Each name is checked again here: nothing reaches the shell line unchecked. apt-get takes a name
|
|
19
|
+
* that matches no package as a pattern, so each is then checked as installed by its exact name.
|
|
20
|
+
*/
|
|
21
|
+
export function systemPackageLines(names = []) {
|
|
22
|
+
if (!names.length)
|
|
23
|
+
return '';
|
|
24
|
+
systemPackagesOf({ server: { systemPackages: names } });
|
|
25
|
+
return `# The product's system packages (server.systemPackages in buffcore.config.ts), installed as
|
|
26
|
+
# root before the image drops to the API's user. One that can't be installed fails the build, as
|
|
27
|
+
# does one not installed by its exact name.
|
|
28
|
+
RUN apt-get update \\
|
|
29
|
+
&& apt-get install -y --no-install-recommends ${names.join(' ')} \\
|
|
30
|
+
&& for p in ${names.join(' ')}; do \\
|
|
31
|
+
[ "$(dpkg-query -W -f='\${db:Status-Status}' "$p" 2>/dev/null)" = installed ] \\
|
|
32
|
+
|| { echo "ape: the system package $p is not installed by that exact name" >&2; exit 1; }; \\
|
|
33
|
+
done \\
|
|
34
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
35
|
+
`;
|
|
36
|
+
}
|
|
37
|
+
/** The label's part for the list (` ape.system-packages="a b"`), nothing for none. */
|
|
38
|
+
export const packagesLabel = (names = []) => names.length ? ` ${PACKAGES_LABEL}="${names.join(' ')}"` : '';
|
|
39
|
+
/** The sentence added to a failed build when the image installs system packages. */
|
|
40
|
+
export const packagesFailed = (names) => t('build.server.packagesFailed', { names: names.join(', ') });
|
|
41
|
+
/** dpkg-query's format (its own fields; a real tab and newline): `name<TAB>version` per line. */
|
|
42
|
+
// biome-ignore lint/suspicious/noTemplateCurlyInString: dpkg-query's placeholders, passed as is.
|
|
43
|
+
export const FORMAT = '-f=${Package}\t${Version}\n';
|
|
44
|
+
/** Docker's answer, or an error carrying its own last line (Docker down, no such image). */
|
|
45
|
+
const readDocker = (args) => {
|
|
46
|
+
const run = spawnSync('docker', args, { encoding: 'utf8', timeout: 120_000 });
|
|
47
|
+
if (run.status === 0)
|
|
48
|
+
return run.stdout;
|
|
49
|
+
const said = `${run.stderr ?? ''}`.trim().split('\n').pop();
|
|
50
|
+
throw new Error(said || run.error?.message || `docker exited with ${run.status}`);
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Each listed package's installed version in the built image, as `dpkg-query -W` reads it
|
|
54
|
+
* (never pulled, without network, as the image's own user). None listed, no Docker call and `{}`.
|
|
55
|
+
*/
|
|
56
|
+
export async function packageVersions(image, names, platform, read = readDocker) {
|
|
57
|
+
if (!names.length)
|
|
58
|
+
return {};
|
|
59
|
+
const args = ['run', '--rm', '--pull=never', '--network', 'none'];
|
|
60
|
+
if (platform)
|
|
61
|
+
args.push('--platform', platform);
|
|
62
|
+
args.push('--entrypoint', 'dpkg-query', image, '-W', FORMAT, ...names);
|
|
63
|
+
let out;
|
|
64
|
+
try {
|
|
65
|
+
out = await read(args);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
const cause = error instanceof Error ? error.message : String(error);
|
|
69
|
+
throw new Error(t('build.server.versionsRun', { image, cause }));
|
|
70
|
+
}
|
|
71
|
+
const found = new Map(out
|
|
72
|
+
.split('\n')
|
|
73
|
+
.map((line) => line.trim().split('\t'))
|
|
74
|
+
.filter((pair) => pair.length === 2 && Boolean(pair[1])));
|
|
75
|
+
const versions = {};
|
|
76
|
+
for (const name of names) {
|
|
77
|
+
const version = found.get(name);
|
|
78
|
+
if (!version)
|
|
79
|
+
throw new Error(t('build.server.versionsMissing', { image, name }));
|
|
80
|
+
versions[name] = version;
|
|
81
|
+
}
|
|
82
|
+
return versions;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The versions in an image that only the image says what it holds (`ape deploy --local`): the
|
|
86
|
+
* list from its label, checked again, then `packageVersions`. No label, `{}`.
|
|
87
|
+
*/
|
|
88
|
+
export async function imagePackages(image, read = readDocker) {
|
|
89
|
+
const format = `{{index .Config.Labels "${PACKAGES_LABEL}"}}`;
|
|
90
|
+
let label;
|
|
91
|
+
try {
|
|
92
|
+
label = `${await read(['image', 'inspect', '--format', format, image])}`.trim();
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
const cause = error instanceof Error ? error.message : String(error);
|
|
96
|
+
throw new Error(t('build.server.versionsRun', { image, cause }));
|
|
97
|
+
}
|
|
98
|
+
const names = label && label !== '<no value>' ? label.split(/\s+/) : [];
|
|
99
|
+
const bad = names.find((name) => !SYSTEM_PACKAGE.test(name));
|
|
100
|
+
if (bad !== undefined)
|
|
101
|
+
throw new Error(t('build.server.label', { image, name: bad }));
|
|
102
|
+
return packageVersions(image, names, undefined, read);
|
|
103
|
+
}
|
|
@@ -10,7 +10,7 @@ export type Where = {
|
|
|
10
10
|
dev: string;
|
|
11
11
|
} | 'server';
|
|
12
12
|
/** The containers' services, and their volumes' entries, for a compose file's two sections. */
|
|
13
|
-
export declare function containerServices(product: string, processes: readonly ProductProcess[] | undefined, where: Where): {
|
|
13
|
+
export declare function containerServices(product: string, processes: readonly ProductProcess[] | undefined, where: Where, coreDumps?: boolean): {
|
|
14
14
|
services: string[];
|
|
15
15
|
volumes: string[];
|
|
16
16
|
};
|
|
@@ -26,7 +26,7 @@ function imageLines(product, c, where) {
|
|
|
26
26
|
return [` build: ${quoted(slashes(folder))}`];
|
|
27
27
|
}
|
|
28
28
|
/** One container's service. */
|
|
29
|
-
function service(product, c, where) {
|
|
29
|
+
function service(product, c, where, coreDumps) {
|
|
30
30
|
const server = where === 'server';
|
|
31
31
|
const count = c.count ?? 1;
|
|
32
32
|
return [
|
|
@@ -45,13 +45,15 @@ function service(product, c, where) {
|
|
|
45
45
|
` mem_limit: ${c.size.memoryMb}m`,
|
|
46
46
|
...(server && count > 1 ? [` scale: ${count}`] : []),
|
|
47
47
|
...(server ? [' restart: unless-stopped'] : []),
|
|
48
|
+
// On a server a crash writes no core dump unless the product keeps them (hardening.coreDumps).
|
|
49
|
+
...(server && !coreDumps ? [' ulimits: { core: 0 }'] : []),
|
|
48
50
|
].join('\n');
|
|
49
51
|
}
|
|
50
52
|
/** The containers' services, and their volumes' entries, for a compose file's two sections. */
|
|
51
|
-
export function containerServices(product, processes, where) {
|
|
53
|
+
export function containerServices(product, processes, where, coreDumps = false) {
|
|
52
54
|
const containers = containersOf(processes);
|
|
53
55
|
return {
|
|
54
|
-
services: containers.map((c) => service(product, c, where)),
|
|
56
|
+
services: containers.map((c) => service(product, c, where, coreDumps)),
|
|
55
57
|
volumes: containers
|
|
56
58
|
.filter((c) => c.volume)
|
|
57
59
|
.map((c) => ` ${c.name}:\n name: ${volumeName(product, c.name)}`),
|
|
@@ -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}").`);
|
|
@@ -3,6 +3,7 @@ import { readAgentsFile, writeAgentsFile } from '../agents-file.js';
|
|
|
3
3
|
import { supportedChoices } from './chat/supported-choices.js';
|
|
4
4
|
import { modelForAgent } from './chat/turn-overrides.js';
|
|
5
5
|
import { factsChanged, mergeEvent } from './merge-events.js';
|
|
6
|
+
import { afterLevel } from './merge-withdraw.js';
|
|
6
7
|
async function saveAssignment(root, { role, agent }, local) {
|
|
7
8
|
const previous = await readAgentsFile(root).catch((error) => {
|
|
8
9
|
// The local route can still repair a damaged file.
|
|
@@ -37,6 +38,7 @@ async function saveAssignment(root, { role, agent }, local) {
|
|
|
37
38
|
factsChanged('levels', 'unsaved');
|
|
38
39
|
if (file.level !== 'auto')
|
|
39
40
|
mergeEvent('level', root);
|
|
41
|
+
await afterLevel(root);
|
|
40
42
|
}
|
|
41
43
|
const queues = new Map();
|
|
42
44
|
/** One queue per product for every write of plan/agents.md: each applies to the file the last left. */
|
|
@@ -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";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export const en = {
|
|
2
2
|
'ui.authority.elsewhere': "Approve this in the product's own console, then come back.",
|
|
3
3
|
'ui.authority.refused': 'The host did not approve this artifact. Ask again before continuing.',
|
|
4
|
+
'ui.authority.unread': "This change's version record can't be read here (a link out of the product, or not a valid record), so it shows no approval.",
|
|
4
5
|
'ui.authority.signIn': 'An approval authority requires hosted sign-in.',
|
|
5
6
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export const es = {
|
|
2
2
|
'ui.authority.elsewhere': 'Aprueba esto en la consola del propio producto y luego vuelve.',
|
|
3
3
|
'ui.authority.refused': 'El anfitrión no aprobó este artefacto. Vuelve a consultar antes de continuar.',
|
|
4
|
+
'ui.authority.unread': 'El registro de versiones de este cambio no se puede leer aquí (un enlace fuera del producto o un registro no válido), así que no muestra aprobación.',
|
|
4
5
|
'ui.authority.signIn': 'Una autoridad de aprobación requiere iniciar sesión con el anfitrión.',
|
|
5
6
|
};
|
|
@@ -41,7 +41,9 @@ export function approvalBound(approval, artifact, root) {
|
|
|
41
41
|
approval.signatures.length === 0 ||
|
|
42
42
|
approval.signatures.some((s) => s.fingerprint !== artifact.fingerprint ||
|
|
43
43
|
(s.agent !== undefined &&
|
|
44
|
-
(approval.rule !== undefined || !['brand', 'prototype'].includes(approval.kind)))
|
|
44
|
+
(approval.rule !== undefined || !['brand', 'prototype'].includes(approval.kind))) ||
|
|
45
|
+
// The look is a person's at every level: no agent's or AI's signature on a comp grant.
|
|
46
|
+
(approval.kind === 'comp' && s.ai !== undefined)))
|
|
45
47
|
return false;
|
|
46
48
|
if (approval.signatures.every((s) => s.commit === artifact.commit))
|
|
47
49
|
return true;
|
|
@@ -94,6 +96,7 @@ async function bounded(context, artifact, action, root) {
|
|
|
94
96
|
artifact,
|
|
95
97
|
action,
|
|
96
98
|
...(context.agent ? { agent: context.agent } : {}),
|
|
99
|
+
...(context.ai ? { ai: context.ai } : {}),
|
|
97
100
|
signal: controller.signal,
|
|
98
101
|
})))
|
|
99
102
|
.then((answer) => validated(answer, artifact, context, action, root), () => refused('approval_authority_error'));
|
|
@@ -127,8 +130,11 @@ export async function judge(context, resolve, action, root) {
|
|
|
127
130
|
let artifact;
|
|
128
131
|
try {
|
|
129
132
|
const found = resolve();
|
|
130
|
-
if (!['brand', 'prototype', 'release', 'places'].includes(found.kind))
|
|
133
|
+
if (!['brand', 'prototype', 'release', 'places', 'comp'].includes(found.kind))
|
|
131
134
|
return refused('approval_authority_invalid');
|
|
135
|
+
// Approve the look is a person's: an agent, an Autopilot turn or an AI approver never asks.
|
|
136
|
+
if (found.kind === 'comp' && (context.agent !== undefined || context.ai !== undefined))
|
|
137
|
+
return refused('approval_person_only');
|
|
132
138
|
artifact = Object.freeze({
|
|
133
139
|
...found,
|
|
134
140
|
version: found.version ? Object.freeze({ ...found.version }) : null,
|
|
@@ -4,7 +4,7 @@ import { ApprovalRefusal } from '../approval-rules.js';
|
|
|
4
4
|
import { requireLegacyChange } from '../prototype/milestone-key.js';
|
|
5
5
|
import { brandResolver, prototypeArtifact, releaseArtifact } from './approval-artifact.js';
|
|
6
6
|
import { authorityFor, hostedApproval } from './approval-authority.js';
|
|
7
|
-
import { compApproval
|
|
7
|
+
import { compApproval } from './comp-approval.js';
|
|
8
8
|
import { brandApproval, prototypeApproval } from './loop-approve.js';
|
|
9
9
|
import { placesApproval } from './places-approval.js';
|
|
10
10
|
import { approveChangePlaces } from './places-change-approval.js';
|
|
@@ -60,9 +60,7 @@ export function brandApprovalRoute(root) {
|
|
|
60
60
|
if (request.kind === 'places')
|
|
61
61
|
return placesApproval(root, request, signer, role, context, source);
|
|
62
62
|
if (request.kind === 'comp')
|
|
63
|
-
return context
|
|
64
|
-
? hostedApproval(context, await compResolver(root, request.fingerprint))
|
|
65
|
-
: compApproval(root, request.fingerprint, signer, role, undefined, source);
|
|
63
|
+
return compApproval(root, request.fingerprint, signer, role, undefined, source, context);
|
|
66
64
|
if (context) {
|
|
67
65
|
if (request.kind === 'brand') {
|
|
68
66
|
const resolve = await brandResolver(root, request.direction);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PrototypeVersion } from '@buffcore/contracts/approvals';
|
|
2
|
+
import type { Chat } from '@buffcore/contracts/workbench';
|
|
3
|
+
import { type Approver, type Critic } from '../prototype/approver.ts';
|
|
4
|
+
/** What an AI approval records beside its signature: the approver's agent, model and reason. */
|
|
5
|
+
export interface AiDecision {
|
|
6
|
+
agent: string;
|
|
7
|
+
ai: {
|
|
8
|
+
model?: string;
|
|
9
|
+
reason: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
/** The two fresh turns: the studio's critique for this report, then the approver. */
|
|
13
|
+
export interface AiTurns {
|
|
14
|
+
critic?: Critic;
|
|
15
|
+
approver?: Approver;
|
|
16
|
+
}
|
|
17
|
+
/** Approve by AI or throw the person's reason (AutoAsk); `chat` is the turn that built the change. */
|
|
18
|
+
export declare function aiApprove(root: string, change: string, version: PrototypeVersion, chat: Pick<Chat, 'session'>, allowed?: () => boolean, turns?: AiTurns): Promise<AiDecision>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { critiqueBlock, reportBlock } from '../prototype/ai-approval.js';
|
|
2
|
+
import { APPROVER_SECONDS, CRITIC_SECONDS, cliApprover, cliCritic, } from '../prototype/approver.js';
|
|
3
|
+
import { versionSnapshot } from '../prototype/versions.js';
|
|
4
|
+
import { hostGitBytes } from '../safe-git.js';
|
|
5
|
+
import { AutoAsk, autoT } from './autopilot-person.js';
|
|
6
|
+
const DIFF_CHARS = 40_000;
|
|
7
|
+
function versionDiff(root, commit) {
|
|
8
|
+
try {
|
|
9
|
+
const text = hostGitBytes(root, ['show', '--no-color', '--no-ext-diff', '--format=', commit]);
|
|
10
|
+
const diff = text.toString();
|
|
11
|
+
return diff.length > DIFF_CHARS ? `${diff.slice(0, DIFF_CHARS)}\n[diff cut]` : diff;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return '';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const waiting = (result, seconds) => new AutoAsk(autoT(`auto.ai.${result.state}`, {
|
|
18
|
+
agent: result.agent ?? '',
|
|
19
|
+
seconds,
|
|
20
|
+
file: result.file ?? '',
|
|
21
|
+
}));
|
|
22
|
+
/** Approve by AI or throw the person's reason (AutoAsk); `chat` is the turn that built the change. */
|
|
23
|
+
export async function aiApprove(root, change, version, chat, allowed = () => true, turns = {}) {
|
|
24
|
+
const { snapshot, report } = versionSnapshot(root, version.commit, version);
|
|
25
|
+
const block = reportBlock(report);
|
|
26
|
+
if (block)
|
|
27
|
+
throw new AutoAsk(autoT(`auto.ai.${block}`));
|
|
28
|
+
const folder = `prototype/snapshots/${snapshot}`;
|
|
29
|
+
// The critique is the studio's own fresh turn for this report, run here; a design/critique.md
|
|
30
|
+
// the building agent wrote is never read.
|
|
31
|
+
const critic = turns.critic ?? cliCritic(root);
|
|
32
|
+
const critique = await critic(folder).catch(() => ({ state: 'failed' }));
|
|
33
|
+
if (critique.state !== 'done')
|
|
34
|
+
throw critique.state === 'agent' || critique.state === 'codex-sandbox'
|
|
35
|
+
? waiting(critique, CRITIC_SECONDS)
|
|
36
|
+
: new AutoAsk(autoT('auto.ai.critic', {
|
|
37
|
+
why: autoT(`auto.ai.why.${critique.state}`, {
|
|
38
|
+
file: 'file' in critique ? (critique.file ?? '') : '',
|
|
39
|
+
}),
|
|
40
|
+
}));
|
|
41
|
+
if (!allowed())
|
|
42
|
+
throw new AutoAsk(autoT('auto.failed'));
|
|
43
|
+
const unfit = critiqueBlock(report, critique.text);
|
|
44
|
+
if (unfit)
|
|
45
|
+
throw new AutoAsk(autoT(`auto.ai.${unfit}`));
|
|
46
|
+
const approver = turns.approver ?? cliApprover(root);
|
|
47
|
+
const result = await approver({
|
|
48
|
+
change,
|
|
49
|
+
version: version.version,
|
|
50
|
+
report: folder,
|
|
51
|
+
diff: versionDiff(root, version.commit),
|
|
52
|
+
critique: critique.text,
|
|
53
|
+
}).catch(() => ({ state: 'failed' }));
|
|
54
|
+
if (result.state !== 'done')
|
|
55
|
+
throw waiting(result, APPROVER_SECONDS);
|
|
56
|
+
// The turn may take minutes: the person may have taken the loop back meanwhile.
|
|
57
|
+
if (!allowed())
|
|
58
|
+
throw new AutoAsk(autoT('auto.failed'));
|
|
59
|
+
// A fresh session, never the one that built the change.
|
|
60
|
+
if (!result.session || result.session === chat.session)
|
|
61
|
+
throw new AutoAsk(autoT('auto.ai.builder'));
|
|
62
|
+
if (result.decision !== 'approve')
|
|
63
|
+
throw new AutoAsk(autoT('auto.ai.declined', { reason: result.reason }));
|
|
64
|
+
return {
|
|
65
|
+
agent: result.agent,
|
|
66
|
+
ai: { ...(result.model ? { model: result.model } : {}), reason: result.reason },
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -6,12 +6,13 @@ import { personHeld, personOnly } from '../prototype/supersede.js';
|
|
|
6
6
|
import { pickVersion, readVersions, recordVersion, VersionRefusal, versionSnapshot, } from '../prototype/versions.js';
|
|
7
7
|
import { brandResolver, hostedVersions, prototypeArtifact } from './approval-artifact.js';
|
|
8
8
|
import { artifactCurrent, authorityFor, hostedApproval, judge } from './approval-authority.js';
|
|
9
|
+
import { aiApprove } from './autopilot-ai-approve.js';
|
|
9
10
|
import { AutoAsk, autoPerson, autoT } from './autopilot-person.js';
|
|
10
11
|
import { readAutoChoices } from './autopilot-records.js';
|
|
11
12
|
import { publishSave } from './host-save.js';
|
|
12
13
|
import { brandApproval, prototypeApproval } from './loop-approve.js';
|
|
13
14
|
import { readPlan } from './plan-files.js';
|
|
14
|
-
import { studioSave } from './save-route.js';
|
|
15
|
+
import { saveFiles, studioSave } from './save-route.js';
|
|
15
16
|
import { runPrototypeSnapshot } from './server.js';
|
|
16
17
|
import { diagnosticsText } from './snapshot-view.js';
|
|
17
18
|
import { prototypeChange } from './studio-state.js';
|
|
@@ -160,9 +161,10 @@ async function approvePrototype(root, chat, person, allowed, signal) {
|
|
|
160
161
|
const screen = versionSnapshot(root, version.commit, version).report.scenes[0]?.key;
|
|
161
162
|
if (!allowed())
|
|
162
163
|
throw new AutoAsk(autoT('auto.failed'));
|
|
164
|
+
const decision = await aiApprove(root, change, version, chat, allowed);
|
|
163
165
|
const result = context
|
|
164
|
-
? await hostedApproval(context, () => prototypeArtifact(root, change, version.version, true, true))
|
|
165
|
-
: await prototypeApproval(root, { change: record.change, version: version.version }, actor.by, actor.role,
|
|
166
|
+
? await hostedApproval({ ...context, agent: decision.agent, ai: decision.ai }, () => prototypeArtifact(root, change, version.version, true, true))
|
|
167
|
+
: await prototypeApproval(root, { change: record.change, version: version.version }, actor.by, actor.role, decision.agent, person, decision.ai);
|
|
166
168
|
if (result.status !== 201)
|
|
167
169
|
throw new AutoAsk(result.body && 'error' in result.body && typeof result.body.error === 'string'
|
|
168
170
|
? result.body.error
|
|
@@ -197,6 +199,3 @@ export async function automaticLoop(root, chat, person, allowed, signal) {
|
|
|
197
199
|
}
|
|
198
200
|
return { step, agent: chat.agent, by: actor.by, at: new Date().toISOString(), commit, ...detail };
|
|
199
201
|
}
|
|
200
|
-
function saveFiles(value) {
|
|
201
|
-
return Array.isArray(value) && value.every((file) => typeof file === 'string');
|
|
202
|
-
}
|
|
@@ -3,6 +3,7 @@ import { context, defaultMergeTools, mergeOne, } from '../change-merge.js';
|
|
|
3
3
|
import { unsavedPaths } from '../change-merge-clean.js';
|
|
4
4
|
import { mainCommit } from '../main-ref.js';
|
|
5
5
|
import { hostGit } from '../safe-git.js';
|
|
6
|
+
import { sweepAfterMerge } from '../worktree-sweep.js';
|
|
6
7
|
import { hostMergeAuthority } from './approval-artifact.js';
|
|
7
8
|
import { authorityFor } from './approval-authority.js';
|
|
8
9
|
import { protectAutoLinks } from './autopilot-links.js';
|
|
@@ -42,6 +43,8 @@ export async function automaticMerge(root, change, person, allowed, fixtureTools
|
|
|
42
43
|
const state = {};
|
|
43
44
|
const tools = automaticTools(root, person, allowed, base, authority, signal, state, Boolean(delegation), holdFile, observeDirty);
|
|
44
45
|
const result = await mergeOne(root, change, delegatedTools(root, { ...tools, expectedHead }, delegation, signal, () => allowed() && effectiveLevel(root) === 'auto', false, holdFile), authority);
|
|
46
|
+
if (result.ok)
|
|
47
|
+
sweepAfterMerge(root);
|
|
45
48
|
if (state.refusal)
|
|
46
49
|
throw state.refusal;
|
|
47
50
|
const mainDirty = state.mainDirty;
|
|
@@ -9,6 +9,7 @@ declare const pendingSchema: z.ZodObject<{
|
|
|
9
9
|
main: z.ZodString;
|
|
10
10
|
automatic: z.ZodOptional<z.ZodLiteral<true>>;
|
|
11
11
|
published: z.ZodOptional<z.ZodLiteral<true>>;
|
|
12
|
+
claimHash: z.ZodOptional<z.ZodString>;
|
|
12
13
|
}, z.core.$strip>;
|
|
13
14
|
/** What became of a head: the host's merge (seen in main) or its refusal of the ask. */
|
|
14
15
|
declare const outcomeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -77,6 +78,7 @@ declare const recordSchema: z.ZodObject<{
|
|
|
77
78
|
main: z.ZodString;
|
|
78
79
|
automatic: z.ZodOptional<z.ZodLiteral<true>>;
|
|
79
80
|
published: z.ZodOptional<z.ZodLiteral<true>>;
|
|
81
|
+
claimHash: z.ZodOptional<z.ZodString>;
|
|
80
82
|
}, z.core.$strip>>;
|
|
81
83
|
outcomes: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
82
84
|
change: z.ZodString;
|
|
@@ -19,6 +19,11 @@ const pendingSchema = z.object({
|
|
|
19
19
|
main: fullSha,
|
|
20
20
|
automatic: z.literal(true).optional(),
|
|
21
21
|
published: z.literal(true).optional(),
|
|
22
|
+
/** SHA-256 of the claim only the host was given; the claim itself is never kept. */
|
|
23
|
+
claimHash: z
|
|
24
|
+
.string()
|
|
25
|
+
.regex(/^[0-9a-f]{64}$/)
|
|
26
|
+
.optional(),
|
|
22
27
|
});
|
|
23
28
|
const outcomeFacts = { change, head: fullSha, at: z.iso.datetime() };
|
|
24
29
|
/** What became of a head: the host's merge (seen in main) or its refusal of the ask. */
|
|
@@ -36,4 +36,27 @@ export declare const en: {
|
|
|
36
36
|
'auto.merged': string;
|
|
37
37
|
'auto.revert': string;
|
|
38
38
|
'auto.failed': string;
|
|
39
|
+
'auto.ai.floor': string;
|
|
40
|
+
'auto.ai.selector': string;
|
|
41
|
+
'auto.ai.checks': string;
|
|
42
|
+
'auto.ai.critique': string;
|
|
43
|
+
'auto.ai.p0': string;
|
|
44
|
+
'auto.ai.agreement': string;
|
|
45
|
+
'auto.ai.agent': string;
|
|
46
|
+
'auto.ai.codex-sandbox': string;
|
|
47
|
+
'auto.ai.ci': string;
|
|
48
|
+
'auto.ai.launch': string;
|
|
49
|
+
'auto.ai.failed': string;
|
|
50
|
+
'auto.ai.timeout': string;
|
|
51
|
+
'auto.ai.shape': string;
|
|
52
|
+
'auto.ai.builder': string;
|
|
53
|
+
'auto.ai.declined': string;
|
|
54
|
+
'auto.ai.critic': string;
|
|
55
|
+
'auto.ai.secret': string;
|
|
56
|
+
'auto.ai.why.secret': string;
|
|
57
|
+
'auto.ai.why.ci': string;
|
|
58
|
+
'auto.ai.why.launch': string;
|
|
59
|
+
'auto.ai.why.failed': string;
|
|
60
|
+
'auto.ai.why.timeout': string;
|
|
61
|
+
'auto.ai.why.shape': string;
|
|
39
62
|
};
|