@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,172 @@
|
|
|
1
|
+
// No secret leaves a fresh turn (S3d): a Codex turn can read every file its sandbox reads (it has no
|
|
2
|
+
// deny-read rule), and a diff could steer any agent into quoting one. Before an answer is kept,
|
|
3
|
+
// shown or passed on, it is compared with the values in the secret files such a turn can read: the
|
|
4
|
+
// files Claude's deny rules name (LINKED_SECRETS, SECRET_FOLDERS) in the turn's folder, in the main
|
|
5
|
+
// checkout when the folder is a linked worktree, and the home's secret folders (`.ssh`, `.aws`, …).
|
|
6
|
+
// An answer holding one is dropped. The values are read only to compare: never printed, stored or
|
|
7
|
+
// returned. Only the file's path is.
|
|
8
|
+
import { existsSync, globSync, readFileSync, statSync } from 'node:fs';
|
|
9
|
+
import { homedir } from 'node:os';
|
|
10
|
+
import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
|
|
11
|
+
import { LINKED_SECRETS } from './linked.js';
|
|
12
|
+
import { SECRET_FOLDERS } from './secret-folders.js';
|
|
13
|
+
/** Shorter values match ordinary words; they are not compared. */
|
|
14
|
+
const MIN_LENGTH = 8;
|
|
15
|
+
/** A larger file (a database or a dump) is not a list of values. */
|
|
16
|
+
const MAX_BYTES = 256 * 1024;
|
|
17
|
+
/** At most this many files from one place: a scan stays quick. */
|
|
18
|
+
const MAX_FILES = 400;
|
|
19
|
+
const PATTERNS = [
|
|
20
|
+
...LINKED_SECRETS.filter((pattern) => pattern !== '**/.git/**'),
|
|
21
|
+
...[...SECRET_FOLDERS].map((folder) => `**/${folder}/**`),
|
|
22
|
+
];
|
|
23
|
+
/** A key that names a secret: its plain words are compared too. */
|
|
24
|
+
const SECRET_KEY = /PASSWORD|SECRET|TOKEN|KEY|CREDENTIAL/i;
|
|
25
|
+
const LOOPBACK = /^(?:localhost|127(?:\.\d{1,3}){3}|\[::1\])$/i;
|
|
26
|
+
/**
|
|
27
|
+
* A value that is no secret: a short plain lowercase word (`development`) under a key that names
|
|
28
|
+
* no secret, or a URL without user info on the loopback host, or with no query, no fragment and no
|
|
29
|
+
* path beyond `/`.
|
|
30
|
+
*/
|
|
31
|
+
function ordinary(value, key) {
|
|
32
|
+
if (/^[a-z]+(?:[-_][a-z]+)*$/.test(value))
|
|
33
|
+
return value.length <= 12 && !SECRET_KEY.test(key);
|
|
34
|
+
try {
|
|
35
|
+
const url = new URL(value);
|
|
36
|
+
if (!/^[a-z]+:$/.test(url.protocol) || url.username || url.password)
|
|
37
|
+
return false;
|
|
38
|
+
if (LOOPBACK.test(url.hostname))
|
|
39
|
+
return true;
|
|
40
|
+
return !url.search && !url.hash && (url.pathname === '' || url.pathname === '/');
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** Every string in a JSON document, with the nearest key above it. */
|
|
47
|
+
function jsonStrings(value, key = '') {
|
|
48
|
+
if (typeof value === 'string')
|
|
49
|
+
return [{ key, value }];
|
|
50
|
+
if (Array.isArray(value))
|
|
51
|
+
return value.flatMap((item) => jsonStrings(item, key));
|
|
52
|
+
if (value && typeof value === 'object')
|
|
53
|
+
return Object.entries(value).flatMap(([name, item]) => jsonStrings(item, name));
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
/** One line's value: a `KEY=value`'s value (an unquoted one ends at ` #`), else the line. */
|
|
57
|
+
function lineValue(raw) {
|
|
58
|
+
const line = raw.trim();
|
|
59
|
+
if (!line || line.startsWith('#') || line.startsWith('-----'))
|
|
60
|
+
return [];
|
|
61
|
+
const assignment = /^(?:export\s+)?([A-Za-z_][A-Za-z0-9_.-]*)\s*[=:]\s*(.*)$/.exec(line);
|
|
62
|
+
if (!assignment) {
|
|
63
|
+
// A registry line in .npmrc (a path, then a name and `=`): the line, and what follows its last `=`.
|
|
64
|
+
const tail = /=\s*([^=\s]+)\s*$/.exec(line)?.[1];
|
|
65
|
+
return [{ key: '', value: line }, ...(tail ? [{ key: line, value: tail }] : [])];
|
|
66
|
+
}
|
|
67
|
+
const key = assignment[1];
|
|
68
|
+
const value = assignment[2].trim();
|
|
69
|
+
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
70
|
+
return [{ key, value: quoted ? quoted[2] : value.replace(/\s+#.*$/, '') }];
|
|
71
|
+
}
|
|
72
|
+
/** The values one secret file holds: a JSON file's strings, else each line's value. */
|
|
73
|
+
export function valuesOf(text, file = '') {
|
|
74
|
+
let values;
|
|
75
|
+
if (file.endsWith('.json')) {
|
|
76
|
+
try {
|
|
77
|
+
values = jsonStrings(JSON.parse(text));
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
values = [];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else
|
|
84
|
+
values = text.split(/\r?\n/).flatMap(lineValue);
|
|
85
|
+
return values
|
|
86
|
+
.map(({ key, value }) => ({ key, value: value.trim() }))
|
|
87
|
+
.filter(({ key, value }) => value.length >= MIN_LENGTH && !ordinary(value, key))
|
|
88
|
+
.map(({ value }) => value);
|
|
89
|
+
}
|
|
90
|
+
/** The main checkout of a linked worktree the folder lies in, read from Git's own files. */
|
|
91
|
+
export function mainCheckout(folder) {
|
|
92
|
+
for (let dir = resolve(folder);; dir = dirname(dir)) {
|
|
93
|
+
const dotGit = join(dir, '.git');
|
|
94
|
+
if (existsSync(dotGit)) {
|
|
95
|
+
try {
|
|
96
|
+
if (statSync(dotGit).isDirectory())
|
|
97
|
+
return;
|
|
98
|
+
const gitdir = /^gitdir:\s*(.+)$/m.exec(readFileSync(dotGit, 'utf8'))?.[1]?.trim();
|
|
99
|
+
if (!gitdir)
|
|
100
|
+
return;
|
|
101
|
+
const linked = resolve(dir, gitdir);
|
|
102
|
+
const common = readFileSync(join(linked, 'commondir'), 'utf8').trim();
|
|
103
|
+
return dirname(isAbsolute(common) ? common : resolve(linked, common));
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (dirname(dir) === dir)
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/** The sign-in files a home keeps outside its secret folders. */
|
|
114
|
+
const HOME_FILES = [
|
|
115
|
+
'.npmrc',
|
|
116
|
+
'.git-credentials',
|
|
117
|
+
'.netrc',
|
|
118
|
+
'.config/gh/hosts.yml',
|
|
119
|
+
'.pypirc',
|
|
120
|
+
'.claude/.credentials.json',
|
|
121
|
+
];
|
|
122
|
+
const depth = (file) => file.split(/[/\\]/).length;
|
|
123
|
+
/** The secret files under one place, at most MAX_FILES, the shallowest first. */
|
|
124
|
+
function secretFiles(base, patterns) {
|
|
125
|
+
try {
|
|
126
|
+
const files = globSync(patterns, {
|
|
127
|
+
cwd: base,
|
|
128
|
+
// Caches and saved commands are not where secrets are kept.
|
|
129
|
+
exclude: (path) => /(?:^|[/\\])(?:node_modules|\.git|cache|buildx|commands)$/.test(String(path)),
|
|
130
|
+
});
|
|
131
|
+
return [...new Set(files)]
|
|
132
|
+
.filter((file) => !file.endsWith('.example'))
|
|
133
|
+
.sort((a, b) => depth(a) - depth(b) || a.localeCompare(b))
|
|
134
|
+
.slice(0, MAX_FILES)
|
|
135
|
+
.map((file) => join(base, file));
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
return [];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/** How a file is named in a reason: from the folder, or `~/` for the home's. */
|
|
142
|
+
function nameOf(path, folder, home) {
|
|
143
|
+
const inHome = relative(home, path);
|
|
144
|
+
const name = inHome.startsWith('..') || isAbsolute(inHome) ? relative(folder, path) : `~/${inHome}`;
|
|
145
|
+
return name.replaceAll('\\', '/');
|
|
146
|
+
}
|
|
147
|
+
/** The secret file whose value the answer holds, or undefined. */
|
|
148
|
+
export function leakedSecret(folder, answer, home = homedir()) {
|
|
149
|
+
const main = mainCheckout(folder);
|
|
150
|
+
const homeFolders = [...SECRET_FOLDERS].map((name) => join(home, name)).filter(existsSync);
|
|
151
|
+
// Codex's sign-in lives in CODEX_HOME, which the turn can read.
|
|
152
|
+
const codexHome = process.env.CODEX_HOME || join(home, '.codex');
|
|
153
|
+
const files = [
|
|
154
|
+
...secretFiles(folder, PATTERNS),
|
|
155
|
+
...(main && resolve(main) !== resolve(folder) ? secretFiles(main, PATTERNS) : []),
|
|
156
|
+
...homeFolders.flatMap((dir) => secretFiles(dir, ['**/*'])),
|
|
157
|
+
...[...HOME_FILES.map((file) => join(home, file)), join(codexHome, 'auth.json')].filter((file) => existsSync(file)),
|
|
158
|
+
];
|
|
159
|
+
for (const path of files) {
|
|
160
|
+
try {
|
|
161
|
+
const stat = statSync(path);
|
|
162
|
+
if (!stat.isFile() || stat.size > MAX_BYTES)
|
|
163
|
+
continue;
|
|
164
|
+
const values = valuesOf(readFileSync(path, 'utf8'), path);
|
|
165
|
+
if (values.some((value) => answer.includes(value)))
|
|
166
|
+
return nameOf(path, folder, home);
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
/* A file that cannot be read holds nothing to compare. */
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export const en = {
|
|
2
|
-
'fresh.review': 'You are a fresh reviewer, not the agent that wrote this step. Follow AGENTS.md. Read only: change no file and run no command. The step: {step}. Its files: {files}. The earlier steps’ files: {earlier}. Read
|
|
2
|
+
'fresh.review': 'You are a fresh reviewer, not the agent that wrote this step. Follow AGENTS.md. Read only: change no file and run no command. The step: {step}. Its files: {files}. The earlier steps’ files: {earlier}. Read the step’s files; of the earlier steps’ files, list each one’s headings first (lines starting “## ”) and read only the sections this step depends on. Then check the step against the brief, the earlier steps and the product’s rules in AGENTS.md: what is missing, what contradicts an earlier step, what breaks a rule. Reply with only one JSON object, nothing before or after it, in this shape:',
|
|
3
3
|
'fresh.reviewLimit': 'At most seven findings, each one plain sentence the person can act on; an empty list when the step holds up.',
|
|
4
4
|
'fresh.example': 'One sentence the person can act on.',
|
|
5
5
|
'fresh.none': 'none yet',
|
|
6
|
+
'fresh.secret': 'The fresh turn’s answer quoted a value from {file}, so the studio dropped it.',
|
|
6
7
|
'fresh.critique': 'Follow AGENTS.md and the ape-critique skill: read .claude/skills/ape-critique/SKILL.md first, since this turn loads no skills by itself. You are the fresh agent it asks for: you did not draw these scenes, so read the repository and the passing full snapshot ({report}), not anyone’s account of them. Read only: change no file; you may run exactly `pnpm ape design check` and `pnpm ape i18n check`. In this fresh studio turn you do not write design/critique.md: reply with the report’s full Markdown in the skill’s shape (from “# Critique” through Scores, the seven dimensions, Keep, Fix and Quick wins) and nothing else, and the studio writes the file.',
|
|
7
8
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export const es = {
|
|
2
|
-
'fresh.review': 'Eres un revisor nuevo, no el agente que escribió este paso. Sigue AGENTS.md. Solo lectura: no cambies ningún archivo ni ejecutes ningún comando. El paso: {step}. Sus archivos: {files}. Los archivos de los pasos anteriores: {earlier}.
|
|
2
|
+
'fresh.review': 'Eres un revisor nuevo, no el agente que escribió este paso. Sigue AGENTS.md. Solo lectura: no cambies ningún archivo ni ejecutes ningún comando. El paso: {step}. Sus archivos: {files}. Los archivos de los pasos anteriores: {earlier}. Lee los archivos del paso; de los archivos de los pasos anteriores, lista primero los encabezados de cada uno (las líneas que empiezan por «## ») y lee solo las secciones de las que depende este paso. Después revisa el paso frente al resumen, los pasos anteriores y las reglas del producto en AGENTS.md: qué falta, qué contradice un paso anterior, qué rompe una regla. Responde solo con un objeto JSON, sin nada antes ni después, con esta forma:',
|
|
3
3
|
'fresh.reviewLimit': 'Como mucho siete hallazgos, cada uno una frase sencilla sobre la que la persona pueda actuar; una lista vacía cuando el paso se sostiene.',
|
|
4
4
|
'fresh.example': 'Una frase sobre la que la persona pueda actuar.',
|
|
5
|
+
'fresh.secret': 'La respuesta del turno nuevo citaba un valor de {file}, así que el estudio la descartó.',
|
|
5
6
|
'fresh.none': 'ninguno aún',
|
|
6
7
|
'fresh.critique': 'Sigue AGENTS.md y la habilidad ape-critique: lee primero .claude/skills/ape-critique/SKILL.md, porque este turno no carga habilidades por sí solo. Eres el agente nuevo que pide: no dibujaste estas escenas, así que lee el repositorio y la captura completa que pasó ({report}), no el relato de nadie sobre ellas. Solo lectura: no cambies ningún archivo; puedes ejecutar exactamente `pnpm ape design check` y `pnpm ape i18n check`. En este turno nuevo del estudio no escribes design/critique.md: responde con el Markdown completo del informe con la forma de la habilidad (desde “# Critique” con Scores, las siete dimensiones, Keep, Fix y Quick wins) y nada más, y el estudio escribe el archivo.',
|
|
7
8
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { matchesGlob } from 'node:path';
|
|
2
2
|
import { branchChange } from '../../change-trailers.js';
|
|
3
|
-
import { mergeHoldName } from '../merge-hold.js';
|
|
3
|
+
import { mergeHoldName } from '../merge-hold-name.js';
|
|
4
4
|
import { LINKED_SECRETS, linkedPackages } from './linked.js';
|
|
5
5
|
import { verificationShimRules } from './verification.js';
|
|
6
6
|
const PLANNING = ['pnpm ape change', 'pnpm ape change new:*'];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { chatIdSchema, newChatBody, sendBody, stopAnswer, stopBody, } from '@buffcore/contracts/workbench';
|
|
2
|
+
import { withdrawAutopilotClaims } from '../merge-withdraw.js';
|
|
2
3
|
import { allowFolderRoute } from './allow-folder-route.js';
|
|
3
4
|
import { readSendBody } from './attachments.js';
|
|
4
5
|
import { CodingApprovalRefusal } from './coding-approval.js';
|
|
@@ -111,6 +112,9 @@ function stopRoute(engine) {
|
|
|
111
112
|
return guarded('POST', '/api/chats/:id/stop', forChat(engine, async (chat, request) => {
|
|
112
113
|
const body = await parsedBody(request, stopBody);
|
|
113
114
|
const result = await engine.stop(chat.id, body.confirm === true);
|
|
115
|
+
// Stop ends Autopilot's waiting merge for this change too (main not holding it).
|
|
116
|
+
if (chat.change)
|
|
117
|
+
await withdrawAutopilotClaims(engine.root, [chat.change]).catch(() => 0);
|
|
114
118
|
return result === 'confirm'
|
|
115
119
|
? {
|
|
116
120
|
status: 202,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
1
2
|
import { existsSync } from 'node:fs';
|
|
2
|
-
import { mkdir, readdir } from 'node:fs/promises';
|
|
3
|
+
import { mkdir, readdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
3
4
|
import { join, resolve } from 'node:path';
|
|
4
5
|
import { prototypeVersionsSchema } from '@buffcore/contracts/approvals';
|
|
5
6
|
import { MilestoneVersionsPending, requireLegacyChangeAt } from '../../prototype/milestone-key.js';
|
|
@@ -13,13 +14,32 @@ const CHANGE = /^C-\d{3,}$/;
|
|
|
13
14
|
/** Creating a change's worktree runs none of its branch's hooks (a `post-checkout`, say). */
|
|
14
15
|
const git = async (root, args, maxBuffer = 1024 * 1024) => (await hostGit(root, args, { maxBuffer })).trim();
|
|
15
16
|
/**
|
|
16
|
-
* A product's worktree (it has a lockfile)
|
|
17
|
-
*
|
|
17
|
+
* A product's worktree (it has a lockfile) gets its packages when it has none, or when its
|
|
18
|
+
* lockfile or workspace file changed since its last install (a catch-up merged main's, say). pnpm
|
|
19
|
+
* writes node_modules/.modules.yaml only when an install finishes, so a failed one is tried again;
|
|
20
|
+
* ape then writes the hash of what it installed from in node_modules/.ape-lockfile.
|
|
18
21
|
*/
|
|
19
22
|
async function installed(path, install) {
|
|
23
|
+
if (!existsSync(join(path, 'pnpm-lock.yaml')))
|
|
24
|
+
return;
|
|
20
25
|
const done = join(path, 'node_modules', '.modules.yaml');
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
const stamp = join(path, 'node_modules', '.ape-lockfile');
|
|
27
|
+
const want = await lockHash(path);
|
|
28
|
+
const had = await readFile(stamp, 'utf8').catch(() => undefined);
|
|
29
|
+
if (existsSync(done) && had === want)
|
|
30
|
+
return;
|
|
31
|
+
await install(path);
|
|
32
|
+
// Written as a new file, never through a link left in its place; a failed write only means the
|
|
33
|
+
// next turn installs again.
|
|
34
|
+
await rm(stamp, { force: true })
|
|
35
|
+
.then(() => writeFile(stamp, want, { flag: 'wx' }))
|
|
36
|
+
.catch(() => { });
|
|
37
|
+
}
|
|
38
|
+
async function lockHash(path) {
|
|
39
|
+
const hash = createHash('sha256');
|
|
40
|
+
for (const name of ['pnpm-lock.yaml', 'pnpm-workspace.yaml'])
|
|
41
|
+
hash.update(name).update(await readFile(join(path, name)).catch(() => Buffer.alloc(0)));
|
|
42
|
+
return hash.digest('hex');
|
|
23
43
|
}
|
|
24
44
|
/**
|
|
25
45
|
* The one rule for what writes in a change's worktree: coding, tests and fixes. Planning, design
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Approval } from '@buffcore/contracts/approvals';
|
|
2
|
+
import { type CompSnapshot } from '../prototype/comp.ts';
|
|
3
|
+
import { type CompRecord } from '../prototype/comp-record.ts';
|
|
4
|
+
import { type ApprovalArtifact, type ApprovalContext } from './approval-authority.ts';
|
|
2
5
|
import { type SaveSource } from './host-save.ts';
|
|
3
6
|
import type { UiAnswer } from './routes.ts';
|
|
4
|
-
export declare function compApproval(root: string, fingerprint: string, signer?: string, role?: string, agent?: string, source?: SaveSource): Promise<UiAnswer>;
|
|
7
|
+
export declare function compApproval(root: string, fingerprint: string, signer?: string, role?: string, agent?: string, source?: SaveSource, context?: ApprovalContext): Promise<UiAnswer>;
|
|
5
8
|
/** What a host's authority judges: the comp the page showed, at the commit checked out. */
|
|
6
9
|
export declare function compResolver(root: string, fingerprint: string): Promise<() => ApprovalArtifact>;
|
|
10
|
+
/**
|
|
11
|
+
* Under a host's authority the comp read says approved only when the host confirms the grant the
|
|
12
|
+
* record names (`action: 'check'`); a refusal, error or timeout leaves it unapproved, with the reason.
|
|
13
|
+
*/
|
|
14
|
+
export declare function hostedComp(root: string, record: CompRecord | undefined, comp: CompSnapshot | undefined, context: ApprovalContext): Promise<{
|
|
15
|
+
approved: boolean;
|
|
16
|
+
approval: Approval | null;
|
|
17
|
+
approvalRefusal?: string;
|
|
18
|
+
}>;
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
// Approve the look: the guarded approval route's door for the comp. A person's only, at every level;
|
|
2
|
-
// there is no agent, MCP or Autopilot door, and `approveComp` refuses an agent's name. The record is
|
|
3
|
-
// saved as its own isolated commit, as a version approval is (`saveApprovalRecord`).
|
|
4
1
|
import { ApprovalRefusal } from '../approval-rules.js';
|
|
5
2
|
import { newestComp } from '../prototype/comp.js';
|
|
6
|
-
import { approveComp, COMP_FILE } from '../prototype/comp-record.js';
|
|
3
|
+
import { approveComp, COMP_FILE, compApproved, compGrantRecord, } from '../prototype/comp-record.js';
|
|
7
4
|
import { compT } from '../prototype/comp-words.js';
|
|
8
5
|
import { VersionRefusal } from '../prototype/versions.js';
|
|
9
6
|
import { hostGit } from '../safe-git.js';
|
|
10
|
-
import {
|
|
7
|
+
import { authorityMessage, authorityRefusal, judge, } from './approval-authority.js';
|
|
8
|
+
import { HostSaveRefusal, saveRefused } from './host-save.js';
|
|
11
9
|
import { saveApprovalRecord } from './save-route.js';
|
|
12
10
|
const git = async (root, args) => (await hostGit(root, args)).trim();
|
|
13
|
-
export async function compApproval(root, fingerprint, signer, role, agent, source) {
|
|
14
|
-
if (agent !== undefined)
|
|
11
|
+
export async function compApproval(root, fingerprint, signer, role, agent, source, context) {
|
|
12
|
+
if (agent !== undefined || context?.agent !== undefined || context?.ai !== undefined)
|
|
15
13
|
return { status: 409, body: { error: compT('comp.person') } };
|
|
16
14
|
const by = signer ?? (await git(root, ['config', 'user.email']).catch(() => ''));
|
|
17
15
|
if (!by)
|
|
@@ -20,7 +18,25 @@ export async function compApproval(root, fingerprint, signer, role, agent, sourc
|
|
|
20
18
|
if (!commit)
|
|
21
19
|
return { status: 409, body: { error: compT('comp.commitFirst') } };
|
|
22
20
|
try {
|
|
23
|
-
|
|
21
|
+
// Under a host's authority the host decides, once; its grant is recorded as the studio's own.
|
|
22
|
+
const resolve = context ? await compResolver(root, fingerprint) : undefined;
|
|
23
|
+
const answer = context && resolve ? await judge(context, resolve, 'approve') : undefined;
|
|
24
|
+
if (answer && !answer.allowed)
|
|
25
|
+
return authorityRefusal(answer.code);
|
|
26
|
+
if (answer?.allowed && !answer.approval)
|
|
27
|
+
return { status: 202, body: null };
|
|
28
|
+
const granted = answer?.allowed ? answer.approval : null;
|
|
29
|
+
const record = await saveApprovalRecord(root, COMP_FILE, (write = true) => granted
|
|
30
|
+
? compGrantRecord(root, granted, write)
|
|
31
|
+
: approveComp(root, { by, commit, fingerprint, role }, write), by, undefined, source, resolve &&
|
|
32
|
+
(() => {
|
|
33
|
+
try {
|
|
34
|
+
resolve();
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
throw saveRefused('save_artifact_changed');
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
24
40
|
return { status: 201, body: record.approval };
|
|
25
41
|
}
|
|
26
42
|
catch (error) {
|
|
@@ -40,3 +56,24 @@ export async function compResolver(root, fingerprint) {
|
|
|
40
56
|
return { kind: 'comp', version: null, commit, fingerprint };
|
|
41
57
|
};
|
|
42
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Under a host's authority the comp read says approved only when the host confirms the grant the
|
|
61
|
+
* record names (`action: 'check'`); a refusal, error or timeout leaves it unapproved, with the reason.
|
|
62
|
+
*/
|
|
63
|
+
export async function hostedComp(root, record, comp, context) {
|
|
64
|
+
const commit = record?.approval.signatures[0]?.commit;
|
|
65
|
+
if (!record || !comp || !commit)
|
|
66
|
+
return { approved: false, approval: null };
|
|
67
|
+
const fingerprint = comp.fingerprint;
|
|
68
|
+
const answer = await judge(context, () => {
|
|
69
|
+
if (newestComp(root)?.fingerprint !== fingerprint)
|
|
70
|
+
throw new Error();
|
|
71
|
+
return { kind: 'comp', version: null, commit, fingerprint };
|
|
72
|
+
}, 'check', root);
|
|
73
|
+
if (!answer.allowed)
|
|
74
|
+
return { approved: false, approval: null, approvalRefusal: authorityMessage(answer.code) };
|
|
75
|
+
if (!answer.approval)
|
|
76
|
+
return { approved: false, approval: null };
|
|
77
|
+
const held = { folder: record.folder, approval: answer.approval };
|
|
78
|
+
return { approved: compApproved(held, comp), approval: answer.approval };
|
|
79
|
+
}
|
|
@@ -5,6 +5,7 @@ import { spawn } from 'node:child_process';
|
|
|
5
5
|
import { createI18n } from '@buffcore/i18n';
|
|
6
6
|
import { InvalidArgumentError } from 'commander';
|
|
7
7
|
import { findRoot, loadEnv, loadProduct } from '../../project.js';
|
|
8
|
+
import { startSweeps } from '../worktree-sweep.js';
|
|
8
9
|
import { FreshLooks } from './chat/fresh.js';
|
|
9
10
|
import { freshRoutes } from './chat/fresh-routes.js';
|
|
10
11
|
import { hostLaunchedEnv } from './chat/host-launched.js';
|
|
@@ -68,6 +69,8 @@ export async function ui(options) {
|
|
|
68
69
|
const fresh = new FreshLooks(root, agentStart(root, agentEnvironment));
|
|
69
70
|
const chats = new ChatEngine(root, { environment: agentEnvironment, migrations, fresh });
|
|
70
71
|
await chats.ready;
|
|
72
|
+
// Merged, clean, unused change worktrees go now and after each merge.
|
|
73
|
+
startSweeps(root);
|
|
71
74
|
const stack = new Stack(root, {
|
|
72
75
|
app: env.APE_APP_URL,
|
|
73
76
|
admin: env.APE_ADMIN_URL,
|
|
@@ -4,6 +4,7 @@ import { personForTurn } from './chat/person.js';
|
|
|
4
4
|
import { hostT, levelElsewhere } from './host.js';
|
|
5
5
|
import { publishSave } from './host-save.js';
|
|
6
6
|
import { factsChanged, mergeEvent } from './merge-events.js';
|
|
7
|
+
import { afterLevel } from './merge-withdraw.js';
|
|
7
8
|
import { studioSave } from './save-route.js';
|
|
8
9
|
/** A person's settings action: save only this selection, even while a turn is running. */
|
|
9
10
|
export function levelRoute(root) {
|
|
@@ -43,6 +44,8 @@ export function levelRoute(root) {
|
|
|
43
44
|
prepare: () => publishSave(target, 'level', 'plan/agents.md', content, request),
|
|
44
45
|
}
|
|
45
46
|
: undefined);
|
|
47
|
+
if (level !== 'auto')
|
|
48
|
+
await afterLevel(target);
|
|
46
49
|
return { status: result.ok ? 202 : 409, body: result };
|
|
47
50
|
},
|
|
48
51
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Signature } from '@buffcore/contracts/approvals';
|
|
1
2
|
import type { themes } from '@buffcore/tokens';
|
|
2
3
|
import { type SaveSource } from './host-save.ts';
|
|
3
4
|
export declare function brandApproval(root: string, direction: keyof typeof themes, signer?: string, role?: string, agent?: string, fingerprint?: string, source?: SaveSource): Promise<{
|
|
@@ -17,6 +18,10 @@ export declare function brandApproval(root: string, direction: keyof typeof them
|
|
|
17
18
|
fingerprint: string;
|
|
18
19
|
role?: string | undefined;
|
|
19
20
|
agent?: string | undefined;
|
|
21
|
+
ai?: {
|
|
22
|
+
model?: string | undefined;
|
|
23
|
+
reason: string;
|
|
24
|
+
} | undefined;
|
|
20
25
|
}[];
|
|
21
26
|
rule?: {
|
|
22
27
|
kind: "one";
|
|
@@ -54,7 +59,7 @@ export declare function brandApproval(root: string, direction: keyof typeof them
|
|
|
54
59
|
export declare function prototypeApproval(root: string, request: {
|
|
55
60
|
change: string;
|
|
56
61
|
version: number;
|
|
57
|
-
}, signer?: string, role?: string, agent?: string, source?: SaveSource): Promise<{
|
|
62
|
+
}, signer?: string, role?: string, agent?: string, source?: SaveSource, ai?: Signature['ai']): Promise<{
|
|
58
63
|
status: number;
|
|
59
64
|
body: {
|
|
60
65
|
error: string;
|
|
@@ -83,6 +88,10 @@ export declare function prototypeApproval(root: string, request: {
|
|
|
83
88
|
fingerprint: string;
|
|
84
89
|
role?: string | undefined;
|
|
85
90
|
agent?: string | undefined;
|
|
91
|
+
ai?: {
|
|
92
|
+
model?: string | undefined;
|
|
93
|
+
reason: string;
|
|
94
|
+
} | undefined;
|
|
86
95
|
}[];
|
|
87
96
|
rule?: {
|
|
88
97
|
kind: "one";
|
|
@@ -96,6 +105,10 @@ export declare function prototypeApproval(root: string, request: {
|
|
|
96
105
|
by: string;
|
|
97
106
|
} | undefined;
|
|
98
107
|
};
|
|
108
|
+
reopened?: {
|
|
109
|
+
by: string;
|
|
110
|
+
at: string;
|
|
111
|
+
} | undefined;
|
|
99
112
|
} | undefined;
|
|
100
113
|
pending?: {
|
|
101
114
|
version: number;
|
|
@@ -108,6 +121,10 @@ export declare function prototypeApproval(root: string, request: {
|
|
|
108
121
|
fingerprint: string;
|
|
109
122
|
role?: string | undefined;
|
|
110
123
|
agent?: string | undefined;
|
|
124
|
+
ai?: {
|
|
125
|
+
model?: string | undefined;
|
|
126
|
+
reason: string;
|
|
127
|
+
} | undefined;
|
|
111
128
|
}[];
|
|
112
129
|
rule?: {
|
|
113
130
|
kind: "one";
|
|
@@ -121,6 +138,10 @@ export declare function prototypeApproval(root: string, request: {
|
|
|
121
138
|
by: string;
|
|
122
139
|
} | undefined;
|
|
123
140
|
};
|
|
141
|
+
reopened?: {
|
|
142
|
+
by: string;
|
|
143
|
+
at: string;
|
|
144
|
+
} | undefined;
|
|
124
145
|
} | undefined;
|
|
125
146
|
superseded?: {
|
|
126
147
|
version: number;
|
|
@@ -133,6 +154,10 @@ export declare function prototypeApproval(root: string, request: {
|
|
|
133
154
|
fingerprint: string;
|
|
134
155
|
role?: string | undefined;
|
|
135
156
|
agent?: string | undefined;
|
|
157
|
+
ai?: {
|
|
158
|
+
model?: string | undefined;
|
|
159
|
+
reason: string;
|
|
160
|
+
} | undefined;
|
|
136
161
|
}[];
|
|
137
162
|
rule?: {
|
|
138
163
|
kind: "one";
|
|
@@ -146,6 +171,10 @@ export declare function prototypeApproval(root: string, request: {
|
|
|
146
171
|
by: string;
|
|
147
172
|
} | undefined;
|
|
148
173
|
};
|
|
174
|
+
reopened?: {
|
|
175
|
+
by: string;
|
|
176
|
+
at: string;
|
|
177
|
+
} | undefined;
|
|
149
178
|
}[] | undefined;
|
|
150
179
|
};
|
|
151
180
|
} | {
|
|
@@ -67,7 +67,7 @@ const reasonOf = (error) => !(error instanceof Error)
|
|
|
67
67
|
: 'status' in error && typeof error.status === 'number'
|
|
68
68
|
? 'command'
|
|
69
69
|
: (error.code ?? error.name);
|
|
70
|
-
export async function prototypeApproval(root, request, signer, role, agent, source) {
|
|
70
|
+
export async function prototypeApproval(root, request, signer, role, agent, source, ai) {
|
|
71
71
|
let stage = 'unexpected';
|
|
72
72
|
try {
|
|
73
73
|
if (agent === '')
|
|
@@ -103,7 +103,7 @@ export async function prototypeApproval(root, request, signer, role, agent, sour
|
|
|
103
103
|
}
|
|
104
104
|
const approve = (write = true) => held
|
|
105
105
|
? record
|
|
106
|
-
: approveVersion(root, request.change, request.version, by, new Date(), role, agent, write);
|
|
106
|
+
: approveVersion(root, request.change, request.version, by, new Date(), role, agent, write, ai);
|
|
107
107
|
const body = await savePrototypeApproval(root, request.change, approve, by, agent, source);
|
|
108
108
|
return { status: 201, body };
|
|
109
109
|
}
|
|
@@ -19,6 +19,8 @@ export type HostMergeInput = MergeFacts & Readonly<{
|
|
|
19
19
|
signal: AbortSignal;
|
|
20
20
|
/** Run the final write here, including when publishing a queued request. */
|
|
21
21
|
publish: HostPublish;
|
|
22
|
+
/** Autopilot's ask only: names it to `settleHostMerge` when a queue merges it later. */
|
|
23
|
+
claim?: string;
|
|
22
24
|
}>;
|
|
23
25
|
export type HostMergeAnswer = {
|
|
24
26
|
status: 'merged';
|
|
@@ -46,6 +48,7 @@ export type MergeContext = Readonly<{
|
|
|
46
48
|
agent?: string;
|
|
47
49
|
}>;
|
|
48
50
|
export declare const mergeT: (key: keyof typeof en, values?: Record<string, unknown>) => string;
|
|
51
|
+
export declare const reservedCode: (code: string) => boolean;
|
|
49
52
|
export declare const mergeHeldCode = "autopilot_merge_held";
|
|
50
53
|
export declare const mergeMessage: (code: string) => string;
|
|
51
54
|
export declare const mergeRefusal: (code: string) => {
|
|
@@ -74,4 +77,4 @@ export declare const refusalCode: z.ZodString;
|
|
|
74
77
|
export declare const receiptText: z.ZodString;
|
|
75
78
|
export declare function immutableFacts(facts: MergeFacts): MergeFacts;
|
|
76
79
|
/** One bounded call, with late settlements consumed and no fallback or retry. */
|
|
77
|
-
export declare function callMerge(context: MergeContext, facts: MergeFacts, publication: 'person' | HostPublish, signal?: AbortSignal, current?: () => boolean): Promise<HostMergeAnswer>;
|
|
80
|
+
export declare function callMerge(context: MergeContext, facts: MergeFacts, publication: 'person' | HostPublish, signal?: AbortSignal, current?: () => boolean, claim?: string): Promise<HostMergeAnswer>;
|
|
@@ -6,6 +6,10 @@ export declare const en: {
|
|
|
6
6
|
'ui.merge.stopped': string;
|
|
7
7
|
'ui.merge.pending': string;
|
|
8
8
|
'ui.merge.since': string;
|
|
9
|
+
'ui.merge.settleRefused': string;
|
|
10
|
+
'ui.merge.settleHeld': string;
|
|
11
|
+
'ui.merge.withdrawn': string;
|
|
12
|
+
'ui.merge.notWithdrawn': string;
|
|
9
13
|
'ui.merge.refused': string;
|
|
10
14
|
'ui.merge.error': string;
|
|
11
15
|
'ui.merge.timeout': string;
|
|
@@ -5,7 +5,11 @@ export const en = {
|
|
|
5
5
|
'ui.merge.config': 'The host merge configuration conflicts or its timeout is not an integer from 1 to 30000 milliseconds.',
|
|
6
6
|
'ui.merge.stopped': 'The last merge of this change ended without an answer (the studio stopped). Merge again.',
|
|
7
7
|
'ui.merge.pending': 'Waiting for the host to merge.',
|
|
8
|
-
'ui.merge.since': 'Waiting for the host to merge. Asked {at}.',
|
|
8
|
+
'ui.merge.since': 'Waiting for the host to merge. Asked {at}, {hours, plural, =0 {{minutes, plural, one {# minute} other {# minutes}}} one {# hour} other {# hours}} ago.',
|
|
9
|
+
'ui.merge.settleRefused': 'The host could not settle this merge request. Reason: {code}.',
|
|
10
|
+
'ui.merge.settleHeld': 'Autopilot merges are held, so the host could not settle this merge request.',
|
|
11
|
+
'ui.merge.withdrawn': 'The merge request was withdrawn. The change can be merged again.',
|
|
12
|
+
'ui.merge.notWithdrawn': 'There is no merge request to withdraw, or main already holds the change.',
|
|
9
13
|
'ui.merge.refused': 'The host did not merge this change. Reason: {code}.',
|
|
10
14
|
'ui.merge.error': 'The host merge could not be confirmed. Check its result before continuing.',
|
|
11
15
|
'ui.merge.timeout': 'The host did not answer in time. Check its result before continuing.',
|
|
@@ -6,6 +6,10 @@ export declare const es: {
|
|
|
6
6
|
'ui.merge.stopped': string;
|
|
7
7
|
'ui.merge.pending': string;
|
|
8
8
|
'ui.merge.since': string;
|
|
9
|
+
'ui.merge.settleRefused': string;
|
|
10
|
+
'ui.merge.settleHeld': string;
|
|
11
|
+
'ui.merge.withdrawn': string;
|
|
12
|
+
'ui.merge.notWithdrawn': string;
|
|
9
13
|
'ui.merge.refused': string;
|
|
10
14
|
'ui.merge.error': string;
|
|
11
15
|
'ui.merge.timeout': string;
|
|
@@ -5,7 +5,11 @@ export const es = {
|
|
|
5
5
|
'ui.merge.config': 'La configuración de integración del anfitrión entra en conflicto o su tiempo límite no es un entero de 1 a 30000 milisegundos.',
|
|
6
6
|
'ui.merge.stopped': 'La última integración de este cambio terminó sin respuesta (el estudio se detuvo). Vuelve a integrar.',
|
|
7
7
|
'ui.merge.pending': 'Esperando a que el anfitrión integre el cambio.',
|
|
8
|
-
'ui.merge.since': 'Esperando a que el anfitrión integre el cambio. Solicitado {at}.',
|
|
8
|
+
'ui.merge.since': 'Esperando a que el anfitrión integre el cambio. Solicitado {at}, hace {hours, plural, =0 {{minutes, plural, one {# minuto} other {# minutos}}} one {# hora} other {# horas}}.',
|
|
9
|
+
'ui.merge.settleRefused': 'El anfitrión no pudo resolver esta solicitud de integración. Motivo: {code}.',
|
|
10
|
+
'ui.merge.settleHeld': 'Las integraciones de Autopilot están en pausa, así que el anfitrión no pudo resolver esta solicitud.',
|
|
11
|
+
'ui.merge.withdrawn': 'Se retiró la solicitud de integración. El cambio se puede volver a integrar.',
|
|
12
|
+
'ui.merge.notWithdrawn': 'No hay ninguna solicitud de integración que retirar, o main ya contiene el cambio.',
|
|
9
13
|
'ui.merge.refused': 'El anfitrión no integró este cambio. Motivo: {code}.',
|
|
10
14
|
'ui.merge.error': 'No se pudo confirmar la integración del anfitrión. Revisa el resultado antes de continuar.',
|
|
11
15
|
'ui.merge.timeout': 'El anfitrión no respondió a tiempo. Revisa el resultado antes de continuar.',
|
|
@@ -14,7 +14,10 @@ const reserved = {
|
|
|
14
14
|
merge_not_observed: 'ui.merge.unobserved',
|
|
15
15
|
merge_record_failed: 'ui.merge.record',
|
|
16
16
|
merge_publication_lock: 'ui.merge.publicationLock',
|
|
17
|
+
merge_settle_invalid: 'ui.merge.settleRefused',
|
|
18
|
+
merge_settle_unknown: 'ui.merge.settleRefused',
|
|
17
19
|
};
|
|
20
|
+
export const reservedCode = (code) => Object.hasOwn(reserved, code) || code === mergeHeldCode;
|
|
18
21
|
export const mergeHeldCode = 'autopilot_merge_held';
|
|
19
22
|
export const mergeMessage = (code) => mergeT(Object.hasOwn(reserved, code) ? reserved[code] : 'ui.merge.refused', {
|
|
20
23
|
code,
|
|
@@ -102,8 +105,7 @@ function validated(value, head) {
|
|
|
102
105
|
const parsed = answerSchema.safeParse(value);
|
|
103
106
|
if (!parsed.success || (parsed.data.status === 'merged' && parsed.data.head !== head))
|
|
104
107
|
return refused('merge_authority_invalid');
|
|
105
|
-
if (parsed.data.status === 'not_merged' &&
|
|
106
|
-
(Object.hasOwn(reserved, parsed.data.code) || parsed.data.code === mergeHeldCode))
|
|
108
|
+
if (parsed.data.status === 'not_merged' && reservedCode(parsed.data.code))
|
|
107
109
|
return refused('merge_authority_invalid');
|
|
108
110
|
return parsed.data;
|
|
109
111
|
}
|
|
@@ -125,7 +127,7 @@ export function immutableFacts(facts) {
|
|
|
125
127
|
});
|
|
126
128
|
}
|
|
127
129
|
/** One bounded call, with late settlements consumed and no fallback or retry. */
|
|
128
|
-
export async function callMerge(context, facts, publication, signal, current = () => true) {
|
|
130
|
+
export async function callMerge(context, facts, publication, signal, current = () => true, claim) {
|
|
129
131
|
try {
|
|
130
132
|
if (signal?.aborted)
|
|
131
133
|
return refused('merge_authority_error');
|
|
@@ -133,6 +135,7 @@ export async function callMerge(context, facts, publication, signal, current = (
|
|
|
133
135
|
...immutableFacts(facts),
|
|
134
136
|
viewer: context.viewer,
|
|
135
137
|
...(context.agent ? { agent: context.agent } : {}),
|
|
138
|
+
...(claim ? { claim } : {}),
|
|
136
139
|
};
|
|
137
140
|
if (!current())
|
|
138
141
|
return refused('merge_artifact_changed');
|