@buffcore/cli 0.8.40 → 0.8.42
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 +36 -0
- package/dist/commands/agents-file.d.ts +5 -0
- package/dist/commands/agents-file.js +30 -7
- package/dist/commands/change.d.ts +4 -0
- package/dist/commands/change.js +12 -5
- package/dist/commands/create-block.d.ts +2 -1
- package/dist/commands/create-block.js +7 -5
- package/dist/commands/create-steps.en.js +1 -1
- package/dist/commands/create-steps.js +1 -1
- package/dist/commands/create.d.ts +3 -2
- package/dist/commands/create.en.js +1 -1
- package/dist/commands/create.es.js +1 -1
- package/dist/commands/create.js +8 -6
- package/dist/commands/design/check.d.ts +2 -0
- package/dist/commands/design/check.js +6 -0
- package/dist/commands/design/journey-roles.d.ts +6 -0
- package/dist/commands/design/journey-roles.js +60 -0
- package/dist/commands/design/references.d.ts +3 -0
- package/dist/commands/design/references.js +25 -0
- package/dist/commands/design/tells-text.js +2 -2
- package/dist/commands/design/tells.d.ts +3 -1
- 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/design/tells.js +10 -7
- package/dist/commands/dev.js +3 -0
- package/dist/commands/port-claims.d.ts +23 -0
- package/dist/commands/port-claims.js +95 -0
- package/dist/commands/prototype/browser.d.ts +9 -4
- package/dist/commands/prototype/browser.js +26 -18
- package/dist/commands/prototype/export-base.d.ts +27 -0
- package/dist/commands/prototype/export-base.js +80 -0
- package/dist/commands/prototype/export.d.ts +3 -2
- package/dist/commands/prototype/export.js +13 -6
- package/dist/commands/prototype/index.js +1 -0
- package/dist/commands/prototype/media-ready.d.ts +8 -0
- package/dist/commands/prototype/media-ready.js +36 -0
- package/dist/commands/prototype/messages.en.d.ts +6 -0
- package/dist/commands/prototype/messages.en.js +6 -0
- package/dist/commands/prototype/messages.js +6 -0
- package/dist/commands/prototype/scene.d.ts +3 -1
- package/dist/commands/prototype/scene.js +22 -6
- package/dist/commands/prototype/snapshot-inputs.js +35 -7
- package/dist/commands/prototype/snapshot-setup.d.ts +1 -1
- package/dist/commands/prototype/snapshot-setup.js +2 -1
- package/dist/commands/prototype/snapshot-themes.js +3 -1
- package/dist/commands/prototype/snapshot.d.ts +2 -0
- package/dist/commands/prototype/snapshot.js +2 -1
- package/dist/commands/ui/autopilot-records.d.ts +3 -0
- package/dist/commands/ui/chat/allow-folder-route.d.ts +9 -0
- package/dist/commands/ui/chat/allow-folder-route.js +56 -0
- package/dist/commands/ui/chat/allow-folder.d.ts +18 -0
- package/dist/commands/ui/chat/allow-folder.js +76 -0
- package/dist/commands/ui/chat/ask-person.d.ts +17 -0
- package/dist/commands/ui/chat/ask-person.en.d.ts +4 -0
- package/dist/commands/ui/chat/ask-person.en.js +4 -0
- package/dist/commands/ui/chat/ask-person.es.d.ts +4 -0
- package/dist/commands/ui/chat/ask-person.es.js +4 -0
- package/dist/commands/ui/chat/ask-person.js +60 -0
- package/dist/commands/ui/chat/claude-permissions.d.ts +21 -0
- package/dist/commands/ui/chat/claude-permissions.js +69 -0
- package/dist/commands/ui/chat/codex-idle.d.ts +1 -0
- package/dist/commands/ui/chat/codex-overrides.js +2 -1
- package/dist/commands/ui/chat/codex-permissions.d.ts +12 -0
- package/dist/commands/ui/chat/codex-permissions.js +97 -0
- package/dist/commands/ui/chat/command-parts.d.ts +33 -0
- package/dist/commands/ui/chat/command-parts.js +219 -0
- package/dist/commands/ui/chat/command-wrappers.d.ts +21 -0
- package/dist/commands/ui/chat/command-wrappers.js +100 -0
- package/dist/commands/ui/chat/design-deletes.d.ts +1 -0
- package/dist/commands/ui/chat/design-deletes.js +39 -0
- package/dist/commands/ui/chat/launch-input.d.ts +4 -2
- package/dist/commands/ui/chat/launch-input.js +16 -3
- package/dist/commands/ui/chat/limit-mentions.d.ts +5 -0
- package/dist/commands/ui/chat/limit-mentions.js +74 -0
- package/dist/commands/ui/chat/limit-patterns.d.ts +15 -0
- package/dist/commands/ui/chat/limit-patterns.js +182 -0
- package/dist/commands/ui/chat/limits-hook.d.ts +1 -0
- package/dist/commands/ui/chat/limits-hook.js +30 -0
- package/dist/commands/ui/chat/limits.d.ts +37 -0
- package/dist/commands/ui/chat/limits.en.d.ts +18 -0
- package/dist/commands/ui/chat/limits.en.js +18 -0
- package/dist/commands/ui/chat/limits.es.d.ts +2 -0
- package/dist/commands/ui/chat/limits.es.js +17 -0
- package/dist/commands/ui/chat/limits.js +224 -0
- package/dist/commands/ui/chat/local-settings.d.ts +17 -0
- package/dist/commands/ui/chat/local-settings.js +73 -0
- package/dist/commands/ui/chat/opencode-config.d.ts +22 -0
- package/dist/commands/ui/chat/opencode-config.js +83 -0
- package/dist/commands/ui/chat/parse-claude.js +18 -2
- package/dist/commands/ui/chat/permission-ask.d.ts +44 -0
- package/dist/commands/ui/chat/permission-ask.js +142 -0
- package/dist/commands/ui/chat/permission-channel.d.ts +18 -0
- package/dist/commands/ui/chat/permission-channel.js +67 -0
- package/dist/commands/ui/chat/permission-route.d.ts +10 -0
- package/dist/commands/ui/chat/permission-route.js +47 -0
- package/dist/commands/ui/chat/permission-tool.d.ts +1 -0
- package/dist/commands/ui/chat/permission-tool.js +86 -0
- package/dist/commands/ui/chat/permissions.d.ts +11 -12
- package/dist/commands/ui/chat/permissions.js +20 -102
- package/dist/commands/ui/chat/planning-limits.d.ts +12 -0
- package/dist/commands/ui/chat/planning-limits.js +31 -0
- package/dist/commands/ui/chat/process.js +4 -1
- package/dist/commands/ui/chat/prompt.d.ts +8 -1
- package/dist/commands/ui/chat/prompt.en.d.ts +4 -0
- package/dist/commands/ui/chat/prompt.en.js +4 -0
- package/dist/commands/ui/chat/prompt.es.d.ts +4 -0
- package/dist/commands/ui/chat/prompt.es.js +4 -0
- package/dist/commands/ui/chat/prompt.js +18 -50
- package/dist/commands/ui/chat/recorded-turn.js +5 -0
- package/dist/commands/ui/chat/routes.js +4 -0
- package/dist/commands/ui/chat/secret-folders.d.ts +16 -0
- package/dist/commands/ui/chat/secret-folders.js +35 -0
- package/dist/commands/ui/chat/stdin-shells.d.ts +8 -0
- package/dist/commands/ui/chat/stdin-shells.js +102 -0
- package/dist/commands/ui/chat/step-rules.d.ts +13 -0
- package/dist/commands/ui/chat/step-rules.js +47 -0
- package/dist/commands/ui/chat/store.d.ts +2 -0
- package/dist/commands/ui/chat/store.js +25 -3
- package/dist/commands/ui/chat/stream.en.d.ts +17 -0
- package/dist/commands/ui/chat/stream.en.js +18 -1
- package/dist/commands/ui/chat/stream.es.d.ts +17 -0
- package/dist/commands/ui/chat/stream.es.js +18 -1
- package/dist/commands/ui/chat/stream.js +4 -1
- package/dist/commands/ui/chat/turn-guard.d.ts +25 -0
- package/dist/commands/ui/chat/turn-guard.js +74 -0
- package/dist/commands/ui/chat/turn-input.d.ts +3 -2
- package/dist/commands/ui/chat/turn-input.js +3 -1
- package/dist/commands/ui/chat/turn-reserve.js +2 -0
- package/dist/commands/ui/chat/turn-scenes.d.ts +19 -0
- package/dist/commands/ui/chat/turn-scenes.js +44 -0
- package/dist/commands/ui/chat/turn-selection.d.ts +3 -0
- package/dist/commands/ui/chat/turn-selection.js +9 -3
- package/dist/commands/ui/chat/turn-state.d.ts +6 -0
- package/dist/commands/ui/chat/turn.js +8 -3
- package/dist/commands/ui/level-route.js +8 -3
- package/dist/commands/ui/page.d.ts +19 -1
- package/dist/commands/ui/page.js +9 -6
- package/dist/commands/ui/plan-structure.d.ts +9 -2
- package/dist/commands/ui/plan-structure.en.d.ts +1 -0
- package/dist/commands/ui/plan-structure.en.js +1 -0
- package/dist/commands/ui/plan-structure.es.d.ts +1 -0
- package/dist/commands/ui/plan-structure.es.js +1 -0
- package/dist/commands/ui/plan-structure.js +36 -10
- package/dist/commands/ui/prototype-main.d.ts +1 -0
- package/dist/commands/ui/prototype-scenes-child.js +3 -1
- package/dist/commands/ui/prototype-scenes-read.d.ts +1 -0
- package/dist/commands/ui/prototype-scenes-route.js +7 -1
- package/dist/commands/ui/save-commit.js +6 -2
- package/dist/commands/ui/server-options.js +2 -0
- package/dist/commands/ui/server.d.ts +5 -22
- package/dist/commands/ui/server.js +3 -45
- package/dist/commands/ui/snapshot-runners.d.ts +22 -0
- package/dist/commands/ui/snapshot-runners.js +45 -0
- package/dist/commands/ui/studio-routes.d.ts +1 -0
- package/dist/commands/ui/studio-routes.js +1 -0
- package/dist/commands/ui/studio-state.d.ts +4 -1
- package/dist/commands/ui/studio-state.js +1 -0
- package/dist/commands/ui/studio.en.d.ts +13 -0
- package/dist/commands/ui/studio.en.js +13 -0
- package/dist/commands/ui/studio.es.d.ts +13 -0
- package/dist/commands/ui/studio.es.js +13 -0
- package/dist/commands/ui/theme-option.d.ts +8 -0
- package/dist/commands/ui/theme-option.js +40 -0
- package/dist/commands/ui/theme-values.d.ts +5 -0
- package/dist/commands/ui/theme-values.js +113 -0
- package/dist/ui/page.js +86 -86
- package/docs/PROTOTYPE.md +4 -1
- package/docs/WORKBENCH.md +90 -26
- package/package.json +11 -11
- package/skills/ape-critique/SKILL.md +8 -4
- package/skills/ape-design-system/SKILL.md +14 -3
- package/skills/ape-plan-change/SKILL.md +9 -5
- package/skills/ape-prototype/SKILL.md +8 -1
- package/templates/example/apps/app/src/i18n/en.ts +2 -0
- package/templates/example/apps/app/src/i18n/es.json +2 -0
- package/templates/product/README.md +1 -1
- package/templates/product/apps/admin/src/fonts.ts +2 -1
- package/templates/product/apps/app/src/fonts.ts +5 -1
- package/templates/product/apps/app/src/i18n/en.ts +2 -0
- package/templates/product/apps/app/src/i18n/es.json +2 -0
- package/templates/product/prototype/journeys.ts +3 -0
|
@@ -5,28 +5,27 @@ export declare const codingCommands: (change: string) => string[];
|
|
|
5
5
|
export declare function claudeRules(work?: Chat['work'], folder?: string): string[];
|
|
6
6
|
export declare const inTree: (work: Chat['work']) => boolean;
|
|
7
7
|
export declare const isPlanning: (work: Chat['work']) => work is "loop" | "planning";
|
|
8
|
+
export declare const COMMAND_PATHS: string[];
|
|
9
|
+
export declare const CHAT_PATH = ".ape/chats";
|
|
10
|
+
export declare const COMMENT_PATH = ".ape/comments";
|
|
11
|
+
export declare const APPROVAL_PATH = "prototype/versions";
|
|
8
12
|
export declare const turnWriteDenials: (work: Chat['work']) => string[];
|
|
9
13
|
export declare const holdFiles: string[];
|
|
14
|
+
export declare const LEVEL_PATHS: string[];
|
|
10
15
|
/** Studio's coding commands cannot write into the folders guarded by the file tools. */
|
|
11
16
|
export declare function codingWriteDenied(path: string): boolean;
|
|
12
17
|
export declare const PLANNING_SETTINGS = "{\"disableAllHooks\":true}";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
/**
|
|
19
|
+
* A turn's edit denies. Planning below Autopilot may edit only plan/, so its own list is enough;
|
|
20
|
+
* planning on Autopilot (`open`) may edit anywhere, so it also keeps the chats, the commands'
|
|
21
|
+
* files and hooks (`.claude/**`, `.githooks/**`, `package.json` and the rest) as design turns do.
|
|
22
|
+
*/
|
|
23
|
+
export declare function claudeDenied(work?: Chat['work'], open?: boolean): string[];
|
|
16
24
|
/** Exact code-owned arguments only: never admit arbitrary path or permission text to cmd. */
|
|
17
25
|
export declare function claudeLinked(product: string): {
|
|
18
26
|
allowed: string[];
|
|
19
27
|
denied: string[];
|
|
20
28
|
};
|
|
21
|
-
/** Share a scan between argument construction and shim validation, only for this launch. */
|
|
22
|
-
export declare function withLinkedPermissions<T>(launch: () => T): T;
|
|
23
|
-
/**
|
|
24
|
-
* Every turn denies comments and the approval record; design and validation, which write the
|
|
25
|
-
* product folder, also the change trees (planning writes plan/ only). Codex takes absolute
|
|
26
|
-
* paths only (0.166 rejects read globs), so a nested product's prototype/versions is not
|
|
27
|
-
* named here; Claude's rule covers it. Design/validation expand read paths.
|
|
28
|
-
*/
|
|
29
|
-
export declare function codexFilesystem(work: Chat['work'], folder: string, product?: string, examples?: string): string[];
|
|
30
29
|
/** Only these code-owned values can be quoted when launching a Windows CLI shim. */
|
|
31
30
|
export declare const SHIM_PERMISSION_ARGS: Set<string>;
|
|
32
31
|
/** A launch gets its own exact allow set; no linked rule survives unlinking. */
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { globSync, readdirSync, realpathSync } from 'node:fs';
|
|
3
|
-
import { join, matchesGlob, resolve } from 'node:path';
|
|
1
|
+
import { matchesGlob } from 'node:path';
|
|
4
2
|
import { branchChange } from '../../change-trailers.js';
|
|
5
|
-
import { mergeHoldName
|
|
6
|
-
import { windowsExampleDenials } from './codex-examples.js';
|
|
3
|
+
import { mergeHoldName } from '../merge-hold.js';
|
|
7
4
|
import { LINKED_SECRETS, linkedPackages } from './linked.js';
|
|
8
5
|
import { verificationShimRules } from './verification.js';
|
|
9
6
|
const PLANNING = ['pnpm ape change', 'pnpm ape change new:*'];
|
|
@@ -15,6 +12,7 @@ const DESIGN = [
|
|
|
15
12
|
'pnpm ape prototype data:*',
|
|
16
13
|
'pnpm ape prototype version:*',
|
|
17
14
|
'pnpm ape prototype export:*',
|
|
15
|
+
'pnpm format',
|
|
18
16
|
];
|
|
19
17
|
const VALIDATION = [
|
|
20
18
|
'pnpm ape design check:*',
|
|
@@ -78,7 +76,7 @@ function checkChange(folder) {
|
|
|
78
76
|
export const inTree = (work) => ['coding', 'tests', 'fixes'].includes(work);
|
|
79
77
|
export const isPlanning = (work) => work === 'planning' || work === 'loop';
|
|
80
78
|
// Edit path denies cover both Edit and Write; Write(path) rules do not match in Claude Code.
|
|
81
|
-
const COMMAND_PATHS = [
|
|
79
|
+
export const COMMAND_PATHS = [
|
|
82
80
|
'package.json',
|
|
83
81
|
'package.yaml',
|
|
84
82
|
'package.json5',
|
|
@@ -94,10 +92,10 @@ const COMMAND_PATHS = [
|
|
|
94
92
|
'.mcp.json',
|
|
95
93
|
];
|
|
96
94
|
const COMMAND_FILES = COMMAND_PATHS.map((path) => `Edit(//**/${path})`);
|
|
97
|
-
const CHAT_PATH = '.ape/chats';
|
|
98
|
-
const COMMENT_PATH = '.ape/comments';
|
|
95
|
+
export const CHAT_PATH = '.ape/chats';
|
|
96
|
+
export const COMMENT_PATH = '.ape/comments';
|
|
99
97
|
const CHAT_FILES = `Edit(//**/${CHAT_PATH}/**)`;
|
|
100
|
-
const APPROVAL_PATH = 'prototype/versions';
|
|
98
|
+
export const APPROVAL_PATH = 'prototype/versions';
|
|
101
99
|
const WORKTREE_PATH = '.ape/worktrees';
|
|
102
100
|
// File tools deny writes to the approval gate; commands are outside edit rules (all in OpenCode).
|
|
103
101
|
// Coding, tests and fixes must keep writing their own change tree.
|
|
@@ -109,7 +107,7 @@ const claudeWriteDenials = (work) => turnWriteDenials(work).map((path) => `Edit(
|
|
|
109
107
|
const COMMENT_FILES = [`Read(//**/${COMMENT_PATH}/**)`, `Edit(//**/${COMMENT_PATH}/**)`];
|
|
110
108
|
export const holdFiles = [mergeHoldName, `${mergeHoldName}.lock`];
|
|
111
109
|
const HOLD_EDITS = holdFiles.map((path) => `Edit(//**/${path})`);
|
|
112
|
-
const LEVEL_PATHS = ['plan/agents.md', 'plan/places.json'];
|
|
110
|
+
export const LEVEL_PATHS = ['plan/agents.md', 'plan/places.json'];
|
|
113
111
|
const LEVEL_FILES = LEVEL_PATHS.flatMap((path) => [`Edit(${path})`, `Edit(//**/${path})`]);
|
|
114
112
|
/** Studio's coding commands cannot write into the folders guarded by the file tools. */
|
|
115
113
|
export function codingWriteDenied(path) {
|
|
@@ -133,9 +131,19 @@ const PLAN_DENIED = [
|
|
|
133
131
|
'Edit(plan/**/biome.json*)',
|
|
134
132
|
];
|
|
135
133
|
export const PLANNING_SETTINGS = '{"disableAllHooks":true}';
|
|
136
|
-
|
|
134
|
+
/**
|
|
135
|
+
* A turn's edit denies. Planning below Autopilot may edit only plan/, so its own list is enough;
|
|
136
|
+
* planning on Autopilot (`open`) may edit anywhere, so it also keeps the chats, the commands'
|
|
137
|
+
* files and hooks (`.claude/**`, `.githooks/**`, `package.json` and the rest) as design turns do.
|
|
138
|
+
*/
|
|
139
|
+
export function claudeDenied(work = 'loop', open = false) {
|
|
137
140
|
if (isPlanning(work))
|
|
138
|
-
return [
|
|
141
|
+
return [
|
|
142
|
+
...COMMENT_FILES,
|
|
143
|
+
...HOLD_EDITS,
|
|
144
|
+
...PLAN_DENIED,
|
|
145
|
+
...(open ? [CHAT_FILES, ...COMMAND_FILES] : []),
|
|
146
|
+
];
|
|
139
147
|
return [
|
|
140
148
|
...COMMENT_FILES,
|
|
141
149
|
...HOLD_EDITS,
|
|
@@ -145,10 +153,6 @@ export function claudeDenied(work = 'loop') {
|
|
|
145
153
|
...(inTree(work) ? [] : COMMAND_FILES),
|
|
146
154
|
];
|
|
147
155
|
}
|
|
148
|
-
/** JSON's string escaping is also valid for TOML basic keys, including quotes and backslashes. */
|
|
149
|
-
export function codexTrust(folder) {
|
|
150
|
-
return `projects={${JSON.stringify(realpathSync.native(folder))}={trust_level="trusted"}}`;
|
|
151
|
-
}
|
|
152
156
|
/** Exact code-owned arguments only: never admit arbitrary path or permission text to cmd. */
|
|
153
157
|
export function claudeLinked(product) {
|
|
154
158
|
const packages = linkedPackages(product);
|
|
@@ -164,92 +168,6 @@ export function claudeLinked(product) {
|
|
|
164
168
|
];
|
|
165
169
|
return { allowed: [`Read(${pattern}/**)`], denied };
|
|
166
170
|
}
|
|
167
|
-
const linkedScans = new AsyncLocalStorage();
|
|
168
|
-
/** Share a scan between argument construction and shim validation, only for this launch. */
|
|
169
|
-
export function withLinkedPermissions(launch) {
|
|
170
|
-
return linkedScans.run(new Map(), launch);
|
|
171
|
-
}
|
|
172
|
-
function linkedSecrets(packages) {
|
|
173
|
-
const denied = new Set([join(packages, '.ape/comments')]);
|
|
174
|
-
const pending = [packages];
|
|
175
|
-
while (pending.length) {
|
|
176
|
-
const folder = pending.pop();
|
|
177
|
-
for (const entry of readdirSync(folder, { withFileTypes: true })) {
|
|
178
|
-
const path = join(folder, entry.name);
|
|
179
|
-
if (entry.name === 'node_modules')
|
|
180
|
-
continue;
|
|
181
|
-
if (entry.name === '.ape') {
|
|
182
|
-
denied.add(join(path, 'comments'));
|
|
183
|
-
continue;
|
|
184
|
-
}
|
|
185
|
-
if (entry.name === '.git' || entry.name === '.secrets') {
|
|
186
|
-
denied.add(path);
|
|
187
|
-
continue;
|
|
188
|
-
}
|
|
189
|
-
// Dirent does not classify junctions/symlinks as directories; never follow one.
|
|
190
|
-
if (entry.isDirectory() && !entry.isSymbolicLink())
|
|
191
|
-
pending.push(path);
|
|
192
|
-
else if (LINKED_SECRETS.some((pattern) => matchesGlob(entry.name, pattern)))
|
|
193
|
-
denied.add(path);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return [...denied].sort();
|
|
197
|
-
}
|
|
198
|
-
function codexLinked(product) {
|
|
199
|
-
const cache = linkedScans.getStore();
|
|
200
|
-
const key = resolve(product);
|
|
201
|
-
const cached = cache?.get(key);
|
|
202
|
-
if (cached)
|
|
203
|
-
return cached;
|
|
204
|
-
const packages = linkedPackages(product);
|
|
205
|
-
const entries = packages
|
|
206
|
-
? [
|
|
207
|
-
`${JSON.stringify(packages)}="read"`,
|
|
208
|
-
...linkedSecrets(packages).map((secret) => `${JSON.stringify(secret)}="deny"`),
|
|
209
|
-
]
|
|
210
|
-
: [];
|
|
211
|
-
cache?.set(key, entries);
|
|
212
|
-
return entries;
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Every turn denies comments and the approval record; design and validation, which write the
|
|
216
|
-
* product folder, also the change trees (planning writes plan/ only). Codex takes absolute
|
|
217
|
-
* paths only (0.166 rejects read globs), so a nested product's prototype/versions is not
|
|
218
|
-
* named here; Claude's rule covers it. Design/validation expand read paths.
|
|
219
|
-
*/
|
|
220
|
-
export function codexFilesystem(work, folder, product = folder, examples) {
|
|
221
|
-
const root = realpathSync.native(folder);
|
|
222
|
-
const bases = [...new Set([root, realpathSync.native(product)])];
|
|
223
|
-
const open = work === 'design' || work === 'validation';
|
|
224
|
-
// A change tree keeps its own copy of the record (git merge main writes it); the product's is guarded.
|
|
225
|
-
const guards = open
|
|
226
|
-
? bases.flatMap((base) => turnWriteDenials(work).map((path) => join(base, path)))
|
|
227
|
-
: [join(realpathSync.native(product), APPROVAL_PATH)];
|
|
228
|
-
const hold = mergeHoldPath(product);
|
|
229
|
-
const denied = [
|
|
230
|
-
...windowsExampleDenials,
|
|
231
|
-
...(examples ? [`${JSON.stringify(examples)}="read"`] : []),
|
|
232
|
-
...codexLinked(product),
|
|
233
|
-
...bases.map((base) => `${JSON.stringify(join(base, COMMENT_PATH))}="deny"`),
|
|
234
|
-
...bases.flatMap((base) => LEVEL_PATHS.map((path) => `${JSON.stringify(join(base, path))}="read"`)),
|
|
235
|
-
...guards.map((path) => `${JSON.stringify(path)}="read"`),
|
|
236
|
-
...(hold ? [hold, `${hold}.lock`].map((path) => `${JSON.stringify(path)}="deny"`) : []),
|
|
237
|
-
].join(',');
|
|
238
|
-
if (!open)
|
|
239
|
-
return [`permissions.ape.filesystem={${denied}}`];
|
|
240
|
-
const roots = [...COMMAND_PATHS.map((path) => path.replace(/\/\*\*$/, '')), CHAT_PATH];
|
|
241
|
-
const nested = globSync(roots.map((path) => `**/${path}`), {
|
|
242
|
-
cwd: root,
|
|
243
|
-
exclude: (path) => /(?:^|[/\\])(?:node_modules|\.git|\.ape)[/\\]/.test(path),
|
|
244
|
-
});
|
|
245
|
-
const paths = [...new Set([...roots, ...nested.map((path) => path.replaceAll('\\', '/'))])];
|
|
246
|
-
const entries = paths
|
|
247
|
-
.sort()
|
|
248
|
-
.map((path) => `${JSON.stringify(join(root, path))}="read"`)
|
|
249
|
-
.join(',');
|
|
250
|
-
// Absolute entries leave the product's :workspace_roots deny table untouched, including overlaps.
|
|
251
|
-
return [`permissions.ape.filesystem={${entries},${denied}}`];
|
|
252
|
-
}
|
|
253
171
|
/** Only these code-owned values can be quoted when launching a Windows CLI shim. */
|
|
254
172
|
export const SHIM_PERMISSION_ARGS = new Set([
|
|
255
173
|
'approval_policy="never"',
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** The commands the limits refuse, as their common prefixes; OpenCode's rules use them too. */
|
|
2
|
+
export declare const LIMIT_COMMANDS: string[];
|
|
3
|
+
/** The production settings files the limits hook refuses (`.env.production`, `.env.prod`, `.env.staging`). */
|
|
4
|
+
export declare const PRODUCTION_FILES: string[];
|
|
5
|
+
/**
|
|
6
|
+
* The limits as Claude deny rules, for planning turns below Autopilot. Those run `dontAsk` with
|
|
7
|
+
* every hook off, the limits hook included, so `dontAsk` refuses everything outside their two
|
|
8
|
+
* commands; these rules hold the limits against a person's own allow rules too. Deny rules hold
|
|
9
|
+
* in every mode. Autopilot's planning turns run the limits hook instead, which sends a download
|
|
10
|
+
* to the person's card, so they get none of these.
|
|
11
|
+
*/
|
|
12
|
+
export declare const PLANNING_LIMITS: string[];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** The commands the limits refuse, as their common prefixes; OpenCode's rules use them too. */
|
|
2
|
+
export const LIMIT_COMMANDS = [
|
|
3
|
+
'git push',
|
|
4
|
+
'curl',
|
|
5
|
+
'wget',
|
|
6
|
+
'iwr',
|
|
7
|
+
'irm',
|
|
8
|
+
'Invoke-WebRequest',
|
|
9
|
+
'Invoke-RestMethod',
|
|
10
|
+
'Start-BitsTransfer',
|
|
11
|
+
'ape deploy',
|
|
12
|
+
'ape server deploy',
|
|
13
|
+
'pnpm ape deploy',
|
|
14
|
+
'pnpm ape server deploy',
|
|
15
|
+
'npx ape deploy',
|
|
16
|
+
'npx ape server deploy',
|
|
17
|
+
];
|
|
18
|
+
/** The production settings files the limits hook refuses (`.env.production`, `.env.prod`, `.env.staging`). */
|
|
19
|
+
export const PRODUCTION_FILES = ['.env.prod*', '.env.staging*'];
|
|
20
|
+
/**
|
|
21
|
+
* The limits as Claude deny rules, for planning turns below Autopilot. Those run `dontAsk` with
|
|
22
|
+
* every hook off, the limits hook included, so `dontAsk` refuses everything outside their two
|
|
23
|
+
* commands; these rules hold the limits against a person's own allow rules too. Deny rules hold
|
|
24
|
+
* in every mode. Autopilot's planning turns run the limits hook instead, which sends a download
|
|
25
|
+
* to the person's card, so they get none of these.
|
|
26
|
+
*/
|
|
27
|
+
export const PLANNING_LIMITS = [
|
|
28
|
+
...LIMIT_COMMANDS.flatMap((command) => [`Bash(${command}:*)`, `PowerShell(${command}:*)`]),
|
|
29
|
+
...PRODUCTION_FILES.flatMap((file) => [`Read(//**/${file})`, `Edit(//**/${file})`]),
|
|
30
|
+
'WebFetch',
|
|
31
|
+
];
|
|
@@ -6,10 +6,12 @@ import { migrationTurnEnv } from '../../migrate-create-protocol.js';
|
|
|
6
6
|
import { worktreeGitTrust } from '../../worktree-git-trust.js';
|
|
7
7
|
import { CODEX_EXAMPLES_ENV } from './codex-examples.js';
|
|
8
8
|
import { CODEX_WINDOWS_OVERRIDES, codexGitShell } from './codex-overrides.js';
|
|
9
|
+
import { codexFilesystem, codexTrust } from './codex-permissions.js';
|
|
9
10
|
import { AGENT_DEFS } from './defs.js';
|
|
10
|
-
import {
|
|
11
|
+
import { shimPermissionArgs } from './permissions.js';
|
|
11
12
|
import { chatError } from './prompt.js';
|
|
12
13
|
import { resolveShim, shellChild } from './shims.js';
|
|
14
|
+
import { guardArgument } from './turn-guard.js';
|
|
13
15
|
import { isOverrideArgument } from './turn-overrides.js';
|
|
14
16
|
/**
|
|
15
17
|
* What pnpm and Node set to reach the product's own code (`NODE_PATH` names its `node_modules`,
|
|
@@ -129,6 +131,7 @@ function shimArguments(args, root, cwd, examples) {
|
|
|
129
131
|
if (/^[A-Za-z0-9_-]+$/.test(arg))
|
|
130
132
|
return arg;
|
|
131
133
|
if (allowed.has(arg) ||
|
|
134
|
+
guardArgument(arg) ||
|
|
132
135
|
isOverrideArgument(args[index - 1], arg) ||
|
|
133
136
|
(args[index - 1] === '-c' &&
|
|
134
137
|
(arg === codexTrust(cwd) ||
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { AgentId, Chat, ChatEvent } from '@buffcore/contracts/workbench';
|
|
1
|
+
import type { AgentId, Chat, ChatEvent, Level } from '@buffcore/contracts/workbench';
|
|
2
2
|
import { type ChatImage } from './defs.ts';
|
|
3
|
+
import type { TurnGuard } from './turn-guard.ts';
|
|
3
4
|
import { type AgentOverrides } from './turn-overrides.ts';
|
|
4
5
|
export declare const t: (key: string, values?: Record<string, unknown>) => string;
|
|
5
6
|
export interface TurnOptions extends AgentOverrides {
|
|
@@ -12,6 +13,10 @@ export interface TurnOptions extends AgentOverrides {
|
|
|
12
13
|
page?: Chat['page'];
|
|
13
14
|
change?: Chat['change'];
|
|
14
15
|
examples?: string;
|
|
16
|
+
/** The launch's level, Never ask, limits hook and permission tool (Claude only). */
|
|
17
|
+
guard?: TurnGuard;
|
|
18
|
+
/** The level in effect, read once per launch: OpenCode's Autopilot approves its own asks. */
|
|
19
|
+
level?: Level;
|
|
15
20
|
}
|
|
16
21
|
export interface ChatAdapter {
|
|
17
22
|
id: AgentId;
|
|
@@ -19,6 +24,8 @@ export interface ChatAdapter {
|
|
|
19
24
|
parse: (line: string) => ChatEvent[];
|
|
20
25
|
/** Only identified top-level assistant text may report this launch's Auto choice. */
|
|
21
26
|
reply?: (line: string) => string | undefined;
|
|
27
|
+
/** A plain line the studio adds to the chat, read from the CLI's own output. */
|
|
28
|
+
notice?: (line: string) => string | undefined;
|
|
22
29
|
}
|
|
23
30
|
export declare class TranslatedChatError extends Error {
|
|
24
31
|
constructor(message: string);
|
|
@@ -11,11 +11,15 @@ export declare const en: {
|
|
|
11
11
|
'chat.level.lead': string;
|
|
12
12
|
'chat.boundaries': string;
|
|
13
13
|
'chat.refused': string;
|
|
14
|
+
'chat.asks': string;
|
|
15
|
+
'chat.limits': string;
|
|
14
16
|
'chat.linkedPackages': string;
|
|
15
17
|
'chat.planningUnavailable': string;
|
|
16
18
|
'chat.planningFolder': string;
|
|
17
19
|
'chat.codexSettings': string;
|
|
18
20
|
'chat.planningCommands': string;
|
|
21
|
+
'chat.planningAutopilot': string;
|
|
22
|
+
'chat.autoUnavailable': string;
|
|
19
23
|
'chat.codingCommands': string;
|
|
20
24
|
'chat.codingCheckOutput': string;
|
|
21
25
|
'chat.codexGitWrite': string;
|
|
@@ -11,11 +11,15 @@ export const en = {
|
|
|
11
11
|
'chat.level.lead': 'Lead: the person leads. Draft only what the person asks for, then wait for their next request.',
|
|
12
12
|
'chat.boundaries': 'Never edit plan/agents.md or raise your own level. Coding, tests and fixes may git add, git commit and git merge main only in the change’s own worktree. Never commit on main, sign approvals or merge a change into main yourself; the studio owns those actions. Release approvals, deploys, money approvals and anything in production always wait for the person, at every level. A call this step does not allow is refused in this step: it is not run and nobody is asked; tell the person it was refused, and ask them or do it in another step.',
|
|
13
13
|
'chat.refused': "If a tool result says “Permission to use Bash has been denied” or “Claude requested permissions to use Bash, but you haven't granted it yet”, this step refused that call before it ran: it was not run, it will not run and nobody will be asked. Tell the person the call was refused in this step, then carry on with what this step allows. If a tool result shows a call that ran and failed, or gives another reason (a person's decline, a rule that blocked it, an operating system permission error), keep that real cause and report it as it is.",
|
|
14
|
+
'chat.asks': 'In this step a command outside the list is not refused outright: the turn pauses and the person answers Allow or not, then you hear the outcome. Run each command alone, without pipes, &&, ; or redirects: their output is short.',
|
|
15
|
+
'chat.limits': 'At every level, some calls are always refused: reading folders of sign-ins or keys, deploying, production settings files and git push; a network download waits for the person. A refusal names the part refused.',
|
|
14
16
|
'chat.linkedPackages': "BuffCore's packages are linked from {folder}; read them there by that path because reads through node_modules/@buffcore/ are refused; you may read them but must not change them.",
|
|
15
17
|
'chat.planningUnavailable': "{agent} can't take planning turns here yet; Claude Code can.",
|
|
16
18
|
'chat.planningFolder': "Planning can't start while {folder} exists; remove that .claude folder first.",
|
|
17
19
|
'chat.codexSettings': "Codex didn't start: this change's repository-root .codex/config.toml differs from main's committed file or could not be checked. Restore it with `git checkout refs/heads/main -- .codex/config.toml` from the change's repository root, or delete it if main has no file. User and project execpolicy .rules files are not loaded (`--ignore-rules`). You can also use Claude Code.",
|
|
18
20
|
'chat.planningCommands': 'You can run only `pnpm ape change` and `pnpm ape change new`; `pnpm ape change` reports each change file’s header problems. Read existing modules, screens and tables from the product’s files with your read tools.',
|
|
21
|
+
'chat.planningAutopilot': 'Change only files under plan/, never plan/agents.md: the studio saves nothing else from this step. Read existing modules, screens and tables from the product’s files with your read tools.',
|
|
22
|
+
'chat.autoUnavailable': 'Auto mode isn’t available for this model; the agent will ask instead.',
|
|
19
23
|
'chat.codingCommands': 'In this change’s worktree you can run, one command per call: {commands}. To see each package’s coverage, run `pnpm test`, then `pnpm ape coverage` (`pnpm coverage` runs both). To check the sample data against the approved version, run `pnpm ape prototype data --check --change <id>`. Other pnpm, npx and node commands, such as `pnpm exec vitest` or `biome --write`, are refused in this step: they are not run; name the one you need in your reply and carry on with these.',
|
|
20
24
|
'chat.codingCheckOutput': 'Run `pnpm typecheck`, `pnpm lint`, `pnpm verify` and `pnpm test` in the foreground without output redirects or Monitor. If you already started a check in the background, use Read on the task output path Claude gives you.',
|
|
21
25
|
'chat.codexGitWrite': 'If the sandbox denies git add or git commit access to Git’s metadata, report which command was denied and ask the person to commit from this change’s worktree in their own terminal.',
|
|
@@ -11,11 +11,15 @@ export declare const es: {
|
|
|
11
11
|
'chat.level.lead': string;
|
|
12
12
|
'chat.boundaries': string;
|
|
13
13
|
'chat.refused': string;
|
|
14
|
+
'chat.asks': string;
|
|
15
|
+
'chat.limits': string;
|
|
14
16
|
'chat.linkedPackages': string;
|
|
15
17
|
'chat.planningUnavailable': string;
|
|
16
18
|
'chat.planningFolder': string;
|
|
17
19
|
'chat.codexSettings': string;
|
|
18
20
|
'chat.planningCommands': string;
|
|
21
|
+
'chat.planningAutopilot': string;
|
|
22
|
+
'chat.autoUnavailable': string;
|
|
19
23
|
'chat.codingCommands': string;
|
|
20
24
|
'chat.codingCheckOutput': string;
|
|
21
25
|
'chat.codexGitWrite': string;
|
|
@@ -11,11 +11,15 @@ export const es = {
|
|
|
11
11
|
'chat.level.lead': 'Tú lideras: la persona dirige. Redacta solo lo que te pida y espera su siguiente solicitud.',
|
|
12
12
|
'chat.boundaries': 'Nunca edites plan/agents.md ni subas tu propio nivel. Los trabajos de código, pruebas y correcciones pueden ejecutar git add, git commit y git merge main solo en el árbol de trabajo del cambio. Nunca crees commits en main, firmes aprobaciones ni integres un cambio en main por tu cuenta; esas acciones pertenecen al estudio. Las aprobaciones de versiones y dinero, los despliegues y cualquier acción en producción siempre esperan a la persona, en todos los niveles. Una llamada que este paso no permite se rechaza en este paso: no se ejecuta y no se le pregunta a nadie; dile a la persona que se rechazó, y pregúntale o hazlo en otro paso.',
|
|
13
13
|
'chat.refused': "Si un resultado de herramienta dice “Permission to use Bash has been denied” o “Claude requested permissions to use Bash, but you haven't granted it yet”, este paso rechazó esa llamada antes de ejecutarla: no se ejecutó, no se ejecutará y no se le preguntará a nadie. Dile a la persona que la llamada se rechazó en este paso y sigue con lo que este paso permite. Si un resultado de herramienta muestra una llamada que sí se ejecutó y falló, o da otro motivo (el rechazo de una persona, una regla que la bloqueó, un error de permisos del sistema operativo), conserva esa causa real e infórmala tal como es.",
|
|
14
|
+
'chat.asks': 'En este paso, un comando fuera de la lista no se rechaza sin más: el turno se pausa, la persona responde si lo permite o no, y luego conoces el resultado. Ejecuta cada comando solo, sin tuberías, &&, ; ni redirecciones: su salida es corta.',
|
|
15
|
+
'chat.limits': 'En todos los niveles se rechazan siempre algunas llamadas: leer carpetas de accesos o claves, publicar, los archivos de ajustes de producción y git push; una descarga de la red espera a la persona. Un rechazo nombra la parte rechazada.',
|
|
14
16
|
'chat.linkedPackages': 'Los paquetes de BuffCore están enlazados desde {folder}; léelos allí por esa ruta porque las lecturas a través de node_modules/@buffcore/ se rechazan; puedes leerlos pero no cambiarlos.',
|
|
15
17
|
'chat.planningUnavailable': '{agent} aún no puede hacer turnos de planificación aquí; Claude Code sí puede.',
|
|
16
18
|
'chat.planningFolder': 'La planificación no puede empezar mientras exista {folder}; elimina primero esa carpeta .claude.',
|
|
17
19
|
'chat.codexSettings': 'Codex no empezó: el .codex/config.toml de la raíz del repositorio de este cambio difiere del archivo confirmado en main o no se pudo comprobar. Restáuralo con `git checkout refs/heads/main -- .codex/config.toml` desde la raíz del repositorio del cambio, o elimínalo si main no tiene el archivo. No se cargan los archivos execpolicy .rules del usuario ni del proyecto (`--ignore-rules`). También puedes usar Claude Code.',
|
|
18
20
|
'chat.planningCommands': 'Solo puedes ejecutar `pnpm ape change` y `pnpm ape change new`; `pnpm ape change` informa de los problemas de cabecera de cada archivo de cambio. Lee los módulos, las pantallas y las tablas existentes en los archivos del producto con tus herramientas de lectura.',
|
|
21
|
+
'chat.planningAutopilot': 'Cambia solo archivos dentro de plan/, nunca plan/agents.md: el estudio no guarda nada más de este paso. Lee los módulos, las pantallas y las tablas existentes en los archivos del producto con tus herramientas de lectura.',
|
|
22
|
+
'chat.autoUnavailable': 'El modo automático no está disponible para este modelo; el agente preguntará en su lugar.',
|
|
19
23
|
'chat.codingCommands': 'En el árbol de trabajo de este cambio puedes ejecutar, un comando por llamada: {commands}. Para ver la cobertura de cada paquete, ejecuta `pnpm test` y después `pnpm ape coverage` (`pnpm coverage` ejecuta ambos). Para comprobar los datos de ejemplo con la versión aprobada, ejecuta `pnpm ape prototype data --check --change <id>`. Los demás comandos de pnpm, npx y node, como `pnpm exec vitest` o `biome --write`, se rechazan en este paso: no se ejecutan; nombra el que necesitas en tu respuesta y sigue con estos.',
|
|
20
24
|
'chat.codingCheckOutput': 'Ejecuta `pnpm typecheck`, `pnpm lint`, `pnpm verify` y `pnpm test` en primer plano, sin redirigir la salida ni usar Monitor. Si ya iniciaste una comprobación en segundo plano, usa Read con la ruta de salida que te indique Claude.',
|
|
21
25
|
'chat.codexGitWrite': 'Si el entorno aislado impide a git add o git commit acceder a los metadatos de Git, indica qué comando se denegó y pide a la persona que haga el commit en su terminal desde el árbol de trabajo del cambio.',
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { createI18n, matchLocale } from '@buffcore/i18n';
|
|
2
|
-
import { openCodeWildcard } from '../../agents/patterns.js';
|
|
3
2
|
import { effectiveLevel } from '../../agents-file.js';
|
|
4
3
|
import { changeWorktreeGit } from '../../worktree-git-trust.js';
|
|
4
|
+
import { claudePermissions } from './claude-permissions.js';
|
|
5
5
|
import { codexOverrides } from './codex-overrides.js';
|
|
6
6
|
import { codexSettingsChanged } from './codex-settings.js';
|
|
7
7
|
import { AGENT_DEFS } from './defs.js';
|
|
8
8
|
import { scrubLaunchIds } from './launch-ids.js';
|
|
9
9
|
import { linkedPackages } from './linked.js';
|
|
10
|
-
import {
|
|
10
|
+
import { openCodeConfig } from './opencode-config.js';
|
|
11
|
+
import { codingCommands, inTree, isPlanning } from './permissions.js';
|
|
11
12
|
import { planningClaudeFolder } from './planning.js';
|
|
12
13
|
import { en } from './prompt.en.js';
|
|
13
14
|
import { es } from './prompt.es.js';
|
|
14
15
|
import { turnOverrides } from './turn-overrides.js';
|
|
15
|
-
import { productVerification, verificationCommands,
|
|
16
|
+
import { productVerification, verificationCommands, verifiesProduct } from './verification.js';
|
|
16
17
|
const messages = createI18n({ catalogs: [{ en, es }] });
|
|
17
18
|
export const t = (key, values) => messages.t(matchLocale((process.env.LC_ALL || process.env.LC_MESSAGES || process.env.LANG || 'en')
|
|
18
19
|
.replace('_', '-')
|
|
@@ -34,14 +35,6 @@ export function safeSession(session) {
|
|
|
34
35
|
throw chatError('chat.session');
|
|
35
36
|
return session;
|
|
36
37
|
}
|
|
37
|
-
function claudePermissions(args, work, product, folder, verification) {
|
|
38
|
-
const linked = claudeLinked(product);
|
|
39
|
-
args.splice(5, 0, '--permission-mode', isPlanning(work) ? 'dontAsk' : 'acceptEdits', ...(isPlanning(work) ? ['--settings', PLANNING_SETTINGS] : []));
|
|
40
|
-
args.push('--allowedTools', ...claudeRules(work, folder), ...verificationRules(verification), ...linked.allowed);
|
|
41
|
-
const denied = [...claudeDenied(work), ...linked.denied];
|
|
42
|
-
if (denied.length)
|
|
43
|
-
args.push('--disallowedTools', ...denied);
|
|
44
|
-
}
|
|
45
38
|
export function buildArgs(id, options) {
|
|
46
39
|
const { session, images = [], work = 'loop', folder = process.cwd(), contained = false, } = options;
|
|
47
40
|
const turn = AGENT_DEFS.find((def) => def.id === id)?.turn;
|
|
@@ -58,14 +51,14 @@ export function buildArgs(id, options) {
|
|
|
58
51
|
? []
|
|
59
52
|
: images.flatMap(({ path }) => [turn.images, path]);
|
|
60
53
|
const args = [...(session ? [...turn.resume, safeSession(session)] : turn.start)];
|
|
61
|
-
if (id === 'opencode' && contained)
|
|
54
|
+
if (id === 'opencode' && (contained || options.level === 'auto'))
|
|
62
55
|
args.push('--auto');
|
|
63
56
|
if (id === 'codex' && options.root && codexSettingsChanged(options.root, folder))
|
|
64
57
|
throw chatError('chat.codexSettings');
|
|
65
58
|
if (id === 'codex')
|
|
66
59
|
args.splice(2, 0, ...codexOverrides(work, folder, options.root, options.examples));
|
|
67
60
|
if (id === 'claude')
|
|
68
|
-
claudePermissions(args, work, options.root ?? folder, folder, verificationCommands(options.root ?? folder, options));
|
|
61
|
+
claudePermissions(args, work, options.root ?? folder, folder, verificationCommands(options.root ?? folder, options), options.guard);
|
|
69
62
|
args.splice(id === 'codex' ? args.indexOf('--json') : args.length, 0, ...turnOverrides(id, options).args);
|
|
70
63
|
// --json ends Codex's image value list before the session and stdin marker.
|
|
71
64
|
args.splice(turn.images === '--image' ? args.indexOf('--json') : args.length, 0, ...imageArgs);
|
|
@@ -77,40 +70,7 @@ export function buildEnv(id, options) {
|
|
|
77
70
|
return changeWorktreeGit(options.folder, options.root);
|
|
78
71
|
if (id !== 'opencode')
|
|
79
72
|
return undefined;
|
|
80
|
-
|
|
81
|
-
const verification = verificationCommands(root, options);
|
|
82
|
-
const commands = claudeRules(work, folder)
|
|
83
|
-
.filter((rule) => rule.startsWith('Bash('))
|
|
84
|
-
.flatMap((rule) => {
|
|
85
|
-
const command = rule.slice(5, -1);
|
|
86
|
-
return command.endsWith(':*')
|
|
87
|
-
? [command.slice(0, -2), command.replace(/:\*$/, ' *')]
|
|
88
|
-
: [command];
|
|
89
|
-
});
|
|
90
|
-
const comments = { [openCodeWildcard('.ape/comments/')]: 'deny' };
|
|
91
|
-
return {
|
|
92
|
-
OPENCODE_CONFIG_CONTENT: JSON.stringify({
|
|
93
|
-
...(contained ? { mcp: { ape: { enabled: false } } } : {}),
|
|
94
|
-
permission: {
|
|
95
|
-
...(verifiesProduct(options)
|
|
96
|
-
? {
|
|
97
|
-
bash: {
|
|
98
|
-
'*': 'deny',
|
|
99
|
-
...Object.fromEntries([...commands, ...verification].map((command) => [command, 'allow'])),
|
|
100
|
-
},
|
|
101
|
-
}
|
|
102
|
-
: {}),
|
|
103
|
-
read: comments,
|
|
104
|
-
edit: {
|
|
105
|
-
...comments,
|
|
106
|
-
[openCodeWildcard('plan/agents.md')]: 'deny',
|
|
107
|
-
[openCodeWildcard('plan/places.json')]: 'deny',
|
|
108
|
-
...Object.fromEntries(holdFiles.map((path) => [openCodeWildcard(path), 'deny'])),
|
|
109
|
-
...Object.fromEntries(turnWriteDenials(work).map((path) => [openCodeWildcard(`${path}/`), 'deny'])),
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
}),
|
|
113
|
-
};
|
|
73
|
+
return { OPENCODE_CONFIG_CONTENT: openCodeConfig(options) };
|
|
114
74
|
}
|
|
115
75
|
export function object(value) {
|
|
116
76
|
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
@@ -179,14 +139,22 @@ export function composePrompt(chat, product = process.cwd(), retryMessage) {
|
|
|
179
139
|
text: scrubLaunchIds(text),
|
|
180
140
|
}));
|
|
181
141
|
const skill = chat.page === 'prototype' && chat.work === 'design' ? 'ape-prototype' : skills[chat.work];
|
|
182
|
-
const
|
|
142
|
+
const current = effectiveLevel(product);
|
|
143
|
+
// Autopilot's planning has no command list: its edits stay in plan/ by the studio's save.
|
|
144
|
+
const listed = isPlanning(chat.work) && current !== 'auto';
|
|
145
|
+
const planning = isPlanning(chat.work)
|
|
146
|
+
? `${t(listed ? 'chat.planningCommands' : 'chat.planningAutopilot')}\n`
|
|
147
|
+
: '';
|
|
148
|
+
// Autopilot has no list to pause on; the limits hold at every level.
|
|
149
|
+
const pauses = current === 'auto' ? '' : `${t('chat.asks')}\n`;
|
|
150
|
+
const asks = chat.agent === 'claude' && !listed ? `${pauses}${t('chat.limits')}\n` : '';
|
|
183
151
|
const packages = chat.agent === 'claude' || chat.agent === 'codex' ? linkedPackages(product) : undefined;
|
|
184
152
|
const linked = packages
|
|
185
153
|
? `${t('chat.linkedPackages', { folder: packages.replaceAll('\\', '/') })}\n`
|
|
186
154
|
: '';
|
|
187
|
-
const level = t(`chat.level.${
|
|
155
|
+
const level = t(`chat.level.${current}`);
|
|
188
156
|
const verification = verificationPrompt(chat, product);
|
|
189
|
-
return `${t('chat.instructions', { skill })}\n${level}\n${t('chat.boundaries')}\n${t('chat.refused')}\n${linked}${planning}${codingPrompt(chat)}${verification}Context: ${context}\nConversation: ${JSON.stringify(history)}\n`;
|
|
157
|
+
return `${t('chat.instructions', { skill })}\n${level}\n${t('chat.boundaries')}\n${t('chat.refused')}\n${asks}${linked}${planning}${codingPrompt(chat)}${verification}Context: ${context}\nConversation: ${JSON.stringify(history)}\n`;
|
|
190
158
|
}
|
|
191
159
|
function codingPrompt({ work, change, agent }) {
|
|
192
160
|
if (!change || !inTree(work))
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { factsChanged } from '../merge-events.js';
|
|
2
2
|
import { stopTree } from '../runner.js';
|
|
3
|
+
import { endWaiting } from './ask-person.js';
|
|
3
4
|
import { watchCodexIdle } from './codex-idle.js';
|
|
4
5
|
import { recordTurn } from './orphans.js';
|
|
5
6
|
import { message } from './store.js';
|
|
@@ -9,6 +10,10 @@ export function recordTurnEnd(run, failed, unsaved) {
|
|
|
9
10
|
if (!run.launched || run.startedAt === undefined)
|
|
10
11
|
return;
|
|
11
12
|
endTurn(run.chat, run.startedAt, run.firstMessage ?? 0, failed, unsaved, run.stopped === true);
|
|
13
|
+
const end = run.chat.messages.at(-1)?.end;
|
|
14
|
+
if (end && !failed && !run.stopped && run.scenes?.length)
|
|
15
|
+
end.scenes = run.scenes;
|
|
16
|
+
endWaiting(run.chat, run.selection?.asked, failed || run.stopped === true);
|
|
12
17
|
// The turn may have edited files: the unsaved list the studio holds is from before it.
|
|
13
18
|
factsChanged('unsaved');
|
|
14
19
|
delete run.startedAt;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { chatIdSchema, newChatBody, sendBody, stopAnswer, stopBody, } from '@buffcore/contracts/workbench';
|
|
2
|
+
import { allowFolderRoute } from './allow-folder-route.js';
|
|
2
3
|
import { readSendBody } from './attachments.js';
|
|
3
4
|
import { CodingApprovalRefusal } from './coding-approval.js';
|
|
5
|
+
import { permissionRoute } from './permission-route.js';
|
|
4
6
|
import { t } from './prompt.js';
|
|
5
7
|
import { message } from './store.js';
|
|
6
8
|
import { chatSummary, turnFact, withTurn } from './turn-fact.js';
|
|
@@ -88,6 +90,8 @@ export function chatRoutes(engine) {
|
|
|
88
90
|
return { status: 409, body: { error: busy.message } };
|
|
89
91
|
}),
|
|
90
92
|
stopRoute(engine),
|
|
93
|
+
allowFolderRoute(engine),
|
|
94
|
+
permissionRoute(engine),
|
|
91
95
|
];
|
|
92
96
|
}
|
|
93
97
|
function commentsRoute(engine) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Folders that hold sign-ins and keys. The folder an agent was refused comes from what the agent
|
|
3
|
+
* tried to read, so one click must never hand it these, at any depth;
|
|
4
|
+
* and the limits refuse every read of them, at every level.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SECRET_FOLDERS: Set<string>;
|
|
7
|
+
export declare const holdsSecrets: (path: string) => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The secret folders the turn's own folder lies in, as in a product kept under `secrets/`. The
|
|
10
|
+
* limits count only what lies below the turn's folder (limits.ts), so the deny rules for these
|
|
11
|
+
* names reach inside the product and the person's own home folder of that name, not the folders
|
|
12
|
+
* the product sits in. Plain Node only.
|
|
13
|
+
*/
|
|
14
|
+
export declare const enclosingSecrets: (folder: string) => string[];
|
|
15
|
+
/** The person's home folder of that name, unless the turn's folder lies inside it. */
|
|
16
|
+
export declare function homeSecret(name: string, folder: string): string | undefined;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import { isAbsolute, join, relative, resolve } from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Folders that hold sign-ins and keys. The folder an agent was refused comes from what the agent
|
|
5
|
+
* tried to read, so one click must never hand it these, at any depth;
|
|
6
|
+
* and the limits refuse every read of them, at every level.
|
|
7
|
+
*/
|
|
8
|
+
export const SECRET_FOLDERS = new Set([
|
|
9
|
+
'.ssh',
|
|
10
|
+
'.gnupg',
|
|
11
|
+
'.aws',
|
|
12
|
+
'.azure',
|
|
13
|
+
'.kube',
|
|
14
|
+
'.docker',
|
|
15
|
+
'.gcloud',
|
|
16
|
+
'.password-store',
|
|
17
|
+
'secrets',
|
|
18
|
+
]);
|
|
19
|
+
export const holdsSecrets = (path) => path.split(/[\\/]+/).some((part) => SECRET_FOLDERS.has(part.toLowerCase()));
|
|
20
|
+
/**
|
|
21
|
+
* The secret folders the turn's own folder lies in, as in a product kept under `secrets/`. The
|
|
22
|
+
* limits count only what lies below the turn's folder (limits.ts), so the deny rules for these
|
|
23
|
+
* names reach inside the product and the person's own home folder of that name, not the folders
|
|
24
|
+
* the product sits in. Plain Node only.
|
|
25
|
+
*/
|
|
26
|
+
export const enclosingSecrets = (folder) => [...SECRET_FOLDERS].filter((name) => pathParts(folder).includes(name));
|
|
27
|
+
const pathParts = (folder) => resolve(folder)
|
|
28
|
+
.split(/[\\/]+/)
|
|
29
|
+
.map((part) => part.toLowerCase());
|
|
30
|
+
/** The person's home folder of that name, unless the turn's folder lies inside it. */
|
|
31
|
+
export function homeSecret(name, folder) {
|
|
32
|
+
const path = join(homedir(), name);
|
|
33
|
+
const below = relative(path, resolve(folder));
|
|
34
|
+
return below === '' || (!below.startsWith('..') && !isAbsolute(below)) ? undefined : path;
|
|
35
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A shell or interpreter that reads its script from standard input: `echo … | sh`, `bash <<'EOF'`,
|
|
3
|
+
* `sh <<< '…'`, `python -`, `pwsh -Command -`, `cmd` with no `/c`. What it runs is data the limits
|
|
4
|
+
* never see as a command, so the limits ask the person instead (limits.ts). Plain Node only: the
|
|
5
|
+
* hook runs it.
|
|
6
|
+
*/
|
|
7
|
+
/** Whether the part runs a shell or interpreter, as its program, that reads standard input. */
|
|
8
|
+
export declare function readsStdin(words: string[]): boolean;
|