@buffcore/cli 0.8.41 → 0.8.43
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.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 +12 -0
- package/dist/commands/design/references.js +44 -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/extension/places-approval.d.ts +1 -1
- 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/comp-record.d.ts +27 -0
- package/dist/commands/prototype/comp-record.js +85 -0
- package/dist/commands/prototype/comp-words.d.ts +12 -0
- package/dist/commands/prototype/comp-words.js +24 -0
- package/dist/commands/prototype/comp.d.ts +26 -0
- package/dist/commands/prototype/comp.js +71 -0
- 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/milestone-versions.d.ts +1 -1
- package/dist/commands/prototype/record-look-child.js +4 -1
- package/dist/commands/prototype/scene.d.ts +3 -1
- package/dist/commands/prototype/scene.js +22 -6
- package/dist/commands/prototype/snapshot-command.js +1 -1
- package/dist/commands/prototype/snapshot-inputs.js +35 -7
- package/dist/commands/prototype/snapshot-setup.d.ts +12 -1
- package/dist/commands/prototype/snapshot-setup.js +31 -6
- package/dist/commands/prototype/snapshot.d.ts +2 -0
- package/dist/commands/prototype/snapshot.js +2 -1
- package/dist/commands/prototype/versions.d.ts +3 -3
- package/dist/commands/ui/agents-route.d.ts +2 -0
- package/dist/commands/ui/agents-route.js +8 -5
- package/dist/commands/ui/approval-authority.d.ts +1 -1
- package/dist/commands/ui/approve.js +7 -1
- package/dist/commands/ui/chat/allow-folder.js +23 -77
- 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 +2 -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/fresh-critique.d.ts +28 -0
- package/dist/commands/ui/chat/fresh-critique.js +121 -0
- package/dist/commands/ui/chat/fresh-launch.d.ts +31 -0
- package/dist/commands/ui/chat/fresh-launch.js +122 -0
- package/dist/commands/ui/chat/fresh-prompts.d.ts +17 -0
- package/dist/commands/ui/chat/fresh-prompts.js +76 -0
- package/dist/commands/ui/chat/fresh-report.d.ts +8 -0
- package/dist/commands/ui/chat/fresh-report.js +36 -0
- package/dist/commands/ui/chat/fresh-routes.d.ts +3 -0
- package/dist/commands/ui/chat/fresh-routes.js +64 -0
- package/dist/commands/ui/chat/fresh-settings.d.ts +12 -0
- package/dist/commands/ui/chat/fresh-settings.js +66 -0
- package/dist/commands/ui/chat/fresh-store.d.ts +17 -0
- package/dist/commands/ui/chat/fresh-store.js +67 -0
- package/dist/commands/ui/chat/fresh.d.ts +31 -0
- package/dist/commands/ui/chat/fresh.en.d.ts +7 -0
- package/dist/commands/ui/chat/fresh.en.js +7 -0
- package/dist/commands/ui/chat/fresh.es.d.ts +7 -0
- package/dist/commands/ui/chat/fresh.es.js +7 -0
- package/dist/commands/ui/chat/fresh.js +112 -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 +94 -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 +44 -0
- package/dist/commands/ui/chat/limits.en.d.ts +20 -0
- package/dist/commands/ui/chat/limits.en.js +20 -0
- package/dist/commands/ui/chat/limits.es.d.ts +2 -0
- package/dist/commands/ui/chat/limits.es.js +19 -0
- package/dist/commands/ui/chat/limits.js +236 -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 +25 -5
- package/dist/commands/ui/chat/permission-ask.d.ts +44 -0
- package/dist/commands/ui/chat/permission-ask.js +145 -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 +46 -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/publish-limits.d.ts +4 -0
- package/dist/commands/ui/chat/publish-limits.js +97 -0
- package/dist/commands/ui/chat/recorded-turn.js +6 -0
- package/dist/commands/ui/chat/routes.js +2 -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.js +11 -2
- package/dist/commands/ui/chat/stream.en.d.ts +6 -0
- package/dist/commands/ui/chat/stream.en.js +6 -0
- package/dist/commands/ui/chat/stream.es.d.ts +6 -0
- package/dist/commands/ui/chat/stream.es.js +6 -0
- package/dist/commands/ui/chat/stream.js +8 -2
- package/dist/commands/ui/chat/turn-guard.d.ts +27 -0
- package/dist/commands/ui/chat/turn-guard.js +86 -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-scenes.d.ts +19 -0
- package/dist/commands/ui/chat/turn-scenes.js +44 -0
- package/dist/commands/ui/chat/turn-state.d.ts +11 -0
- package/dist/commands/ui/chat/turn.js +9 -3
- package/dist/commands/ui/comp-approval.d.ts +6 -0
- package/dist/commands/ui/comp-approval.js +42 -0
- package/dist/commands/ui/host.js +3 -0
- package/dist/commands/ui/index.js +18 -6
- package/dist/commands/ui/level-route.js +8 -3
- package/dist/commands/ui/loop-approve.d.ts +4 -4
- package/dist/commands/ui/page.d.ts +19 -1
- package/dist/commands/ui/page.js +9 -6
- package/dist/commands/ui/places-change.d.ts +1 -1
- package/dist/commands/ui/plan-structure.d.ts +12 -2
- package/dist/commands/ui/plan-structure.en.d.ts +4 -0
- package/dist/commands/ui/plan-structure.en.js +4 -0
- package/dist/commands/ui/plan-structure.es.d.ts +4 -0
- package/dist/commands/ui/plan-structure.es.js +4 -0
- package/dist/commands/ui/plan-structure.js +48 -14
- package/dist/commands/ui/prototype-comp-route.d.ts +7 -0
- package/dist/commands/ui/prototype-comp-route.js +109 -0
- package/dist/commands/ui/prototype-main.d.ts +3 -1
- package/dist/commands/ui/prototype-scenes-child.js +6 -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/prototype-snapshot-session.d.ts +1 -1
- package/dist/commands/ui/prototype-snapshot-session.js +3 -0
- package/dist/commands/ui/prototype-snapshot.d.ts +1 -1
- package/dist/commands/ui/routes.d.ts +6 -3
- package/dist/commands/ui/routes.js +3 -3
- package/dist/commands/ui/save-commit.js +6 -2
- package/dist/commands/ui/save-publish.js +3 -0
- package/dist/commands/ui/server-options.js +2 -0
- package/dist/commands/ui/server.d.ts +12 -22
- package/dist/commands/ui/server.js +10 -48
- package/dist/commands/ui/snapshot-runners.d.ts +22 -0
- package/dist/commands/ui/snapshot-runners.js +45 -0
- package/dist/commands/ui/structure-surface.d.ts +6 -0
- package/dist/commands/ui/structure-surface.js +94 -0
- package/dist/commands/ui/studio-routes.d.ts +1 -0
- package/dist/commands/ui/studio-routes.js +5 -0
- package/dist/commands/ui/studio-state.d.ts +9 -4
- package/dist/commands/ui/studio-state.js +1 -0
- package/dist/commands/ui/studio-versions.d.ts +3 -3
- 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 +94 -94
- package/docs/PROCESS.md +5 -0
- package/docs/PROTOTYPE.md +24 -1
- package/docs/WORKBENCH.md +76 -22
- package/package.json +11 -11
- package/skills/ape-critique/SKILL.md +16 -6
- package/skills/ape-design-system/SKILL.md +4 -3
- package/skills/ape-plan-change/SKILL.md +7 -3
- package/skills/ape-prototype/SKILL.md +12 -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/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
|
@@ -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,46 @@
|
|
|
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
|
+
'npm publish',
|
|
18
|
+
// npm resolves a shortened command name: from `npm pu`, it can only mean `npm publish`.
|
|
19
|
+
'npm pu',
|
|
20
|
+
'npm pub',
|
|
21
|
+
'npm publ',
|
|
22
|
+
'npm publi',
|
|
23
|
+
'npm publis',
|
|
24
|
+
'pnpm publish',
|
|
25
|
+
'yarn publish',
|
|
26
|
+
'yarn npm publish',
|
|
27
|
+
'gh release create',
|
|
28
|
+
'gh release new',
|
|
29
|
+
'gh release upload',
|
|
30
|
+
'gh release edit',
|
|
31
|
+
'gh release delete',
|
|
32
|
+
];
|
|
33
|
+
/** The production settings files the limits hook refuses (`.env.production`, `.env.prod`, `.env.staging`). */
|
|
34
|
+
export const PRODUCTION_FILES = ['.env.prod*', '.env.staging*'];
|
|
35
|
+
/**
|
|
36
|
+
* The limits as Claude deny rules, for planning turns below Autopilot. Those run `dontAsk` with
|
|
37
|
+
* every hook off, the limits hook included, so `dontAsk` refuses everything outside their two
|
|
38
|
+
* commands; these rules hold the limits against a person's own allow rules too. Deny rules hold
|
|
39
|
+
* in every mode. Autopilot's planning turns run the limits hook instead, which sends a download
|
|
40
|
+
* to the person's card, so they get none of these.
|
|
41
|
+
*/
|
|
42
|
+
export const PLANNING_LIMITS = [
|
|
43
|
+
...LIMIT_COMMANDS.flatMap((command) => [`Bash(${command}:*)`, `PowerShell(${command}:*)`]),
|
|
44
|
+
...PRODUCTION_FILES.flatMap((file) => [`Read(//**/${file})`, `Edit(//**/${file})`]),
|
|
45
|
+
'WebFetch',
|
|
46
|
+
];
|
|
@@ -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))
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Every option above, for the text fallback: their values are values, not a subcommand. */
|
|
2
|
+
export declare const VALUED_OPTIONS: string[];
|
|
3
|
+
/** The publishing limit a part's words cross: a package or a release; nothing otherwise. */
|
|
4
|
+
export declare function publishLimit(words: string[]): 'publish' | 'release' | undefined;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The publishing commands the limits refuse: a package (`npm publish`, and npm's shortened names
|
|
3
|
+
* down to `npm pu`; `pnpm publish`, `yarn publish`, `yarn npm publish`) and a release
|
|
4
|
+
* (`gh release create|new|upload|edit|delete`, and `delete-asset`). Every package manager or `gh`
|
|
5
|
+
* named in a part is read, so `npx npm publish`, `pnpm exec npm publish` and `env X=1 npm publish`
|
|
6
|
+
* count too. Before the subcommand, the options each tool takes a value for skip that value
|
|
7
|
+
* (`npm --registry x publish`, `gh -R owner/repo release create`); after any other option the next
|
|
8
|
+
* word is the subcommand, so `pnpm --filter publish build` runs (a shape the parse does not follow
|
|
9
|
+
* still goes to the card through the text fallback). Asking only for help (`pnpm publish --help`)
|
|
10
|
+
* runs. Plain Node only: the hook runs it.
|
|
11
|
+
*/
|
|
12
|
+
import { programName } from './command-parts.js';
|
|
13
|
+
/** The options before the subcommand that take the next word as their value, per tool. */
|
|
14
|
+
const VALUED = {
|
|
15
|
+
npm: new Set([
|
|
16
|
+
'--registry',
|
|
17
|
+
'--prefix',
|
|
18
|
+
'-C',
|
|
19
|
+
'--workspace',
|
|
20
|
+
'-w',
|
|
21
|
+
'--userconfig',
|
|
22
|
+
'--globalconfig',
|
|
23
|
+
'--cache',
|
|
24
|
+
'--loglevel',
|
|
25
|
+
'--otp',
|
|
26
|
+
'--tag',
|
|
27
|
+
'--access',
|
|
28
|
+
'--scope',
|
|
29
|
+
'--location',
|
|
30
|
+
]),
|
|
31
|
+
pnpm: new Set([
|
|
32
|
+
'-C',
|
|
33
|
+
'--dir',
|
|
34
|
+
'--filter',
|
|
35
|
+
'-F',
|
|
36
|
+
'--filter-prod',
|
|
37
|
+
'--workspace-dir',
|
|
38
|
+
'--registry',
|
|
39
|
+
'--reporter',
|
|
40
|
+
'--loglevel',
|
|
41
|
+
'--store-dir',
|
|
42
|
+
'--modules-dir',
|
|
43
|
+
'--lockfile-dir',
|
|
44
|
+
'--tag',
|
|
45
|
+
'--access',
|
|
46
|
+
'--otp',
|
|
47
|
+
'--publish-branch',
|
|
48
|
+
]),
|
|
49
|
+
yarn: new Set(['--cwd', '--registry', '--otp', '--tag', '--access', '--modules-folder']),
|
|
50
|
+
gh: new Set(['-R', '--repo', '--hostname']),
|
|
51
|
+
};
|
|
52
|
+
/** Every option above, for the text fallback: their values are values, not a subcommand. */
|
|
53
|
+
export const VALUED_OPTIONS = [
|
|
54
|
+
...new Set(Object.values(VALUED).flatMap((options) => [...options])),
|
|
55
|
+
];
|
|
56
|
+
const RELEASE = new Set(['create', 'new', 'upload', 'edit', 'delete', 'delete-asset']);
|
|
57
|
+
/** npm resolves a shortened command name: from `pu`, the only name it can mean is `publish`. */
|
|
58
|
+
const PUBLISHES = {
|
|
59
|
+
npm: (word) => word.length >= 2 && 'publish'.startsWith(word),
|
|
60
|
+
pnpm: (word) => word === 'publish',
|
|
61
|
+
yarn: (word) => word === 'publish',
|
|
62
|
+
};
|
|
63
|
+
const HELP = new Set(['--help', '-h']);
|
|
64
|
+
/** The program a word names, without a pinned version (`npm@10`, `pnpm@latest`). */
|
|
65
|
+
const toolName = (word) => programName(word).replace(/(?<=.)@[^@]*$/, '');
|
|
66
|
+
/** The index of the subcommand after `from` when `wanted` accepts it; -1 otherwise. */
|
|
67
|
+
function subcommandIs(words, from, valued, wanted) {
|
|
68
|
+
for (let index = from; index < words.length; index++) {
|
|
69
|
+
const word = words[index];
|
|
70
|
+
if (!word.startsWith('-'))
|
|
71
|
+
return wanted(word.toLowerCase()) ? index : -1;
|
|
72
|
+
if (valued.has(word))
|
|
73
|
+
index++;
|
|
74
|
+
}
|
|
75
|
+
return -1;
|
|
76
|
+
}
|
|
77
|
+
/** A subcommand followed only by `--help` or `-h` shows its help and does nothing else. */
|
|
78
|
+
const helpOnly = (words, at) => words.length === at + 2 && HELP.has(words[at + 1]);
|
|
79
|
+
/** The publishing limit a part's words cross: a package or a release; nothing otherwise. */
|
|
80
|
+
export function publishLimit(words) {
|
|
81
|
+
for (let index = 0; index < words.length; index++) {
|
|
82
|
+
const name = toolName(words[index]);
|
|
83
|
+
const publishes = PUBLISHES[name];
|
|
84
|
+
if (publishes) {
|
|
85
|
+
const at = subcommandIs(words, index + 1, VALUED[name], publishes);
|
|
86
|
+
if (at >= 0 && !helpOnly(words, at))
|
|
87
|
+
return 'publish';
|
|
88
|
+
}
|
|
89
|
+
if (name !== 'gh')
|
|
90
|
+
continue;
|
|
91
|
+
const valued = VALUED.gh;
|
|
92
|
+
const release = subcommandIs(words, index + 1, valued, (word) => word === 'release');
|
|
93
|
+
const at = release < 0 ? -1 : subcommandIs(words, release + 1, valued, (w) => RELEASE.has(w));
|
|
94
|
+
if (at >= 0 && !helpOnly(words, at))
|
|
95
|
+
return 'release';
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -9,11 +9,17 @@ import { lineLocale, lineText } from './stream-text.js';
|
|
|
9
9
|
export function recordTurnEnd(run, failed, unsaved) {
|
|
10
10
|
if (!run.launched || run.startedAt === undefined)
|
|
11
11
|
return;
|
|
12
|
+
const startedAt = run.startedAt;
|
|
12
13
|
endTurn(run.chat, run.startedAt, run.firstMessage ?? 0, failed, unsaved, run.stopped === true);
|
|
14
|
+
const end = run.chat.messages.at(-1)?.end;
|
|
15
|
+
if (end && !failed && !run.stopped && run.scenes?.length)
|
|
16
|
+
end.scenes = run.scenes;
|
|
13
17
|
endWaiting(run.chat, run.selection?.asked, failed || run.stopped === true);
|
|
14
18
|
// The turn may have edited files: the unsaved list the studio holds is from before it.
|
|
15
19
|
factsChanged('unsaved');
|
|
16
20
|
delete run.startedAt;
|
|
21
|
+
if (!failed && !run.stopped)
|
|
22
|
+
run.fresh?.afterTurn(run.chat, run.firstMessage ?? 0, startedAt);
|
|
17
23
|
}
|
|
18
24
|
/** End facts come from the studio clock and stored calls, never agent usage or timing. */
|
|
19
25
|
export function endTurn(chat, startedAt, firstMessage, failed, unsaved, stopped = false) {
|
|
@@ -2,6 +2,7 @@ import { chatIdSchema, newChatBody, sendBody, stopAnswer, stopBody, } from '@buf
|
|
|
2
2
|
import { allowFolderRoute } from './allow-folder-route.js';
|
|
3
3
|
import { readSendBody } from './attachments.js';
|
|
4
4
|
import { CodingApprovalRefusal } from './coding-approval.js';
|
|
5
|
+
import { permissionRoute } from './permission-route.js';
|
|
5
6
|
import { t } from './prompt.js';
|
|
6
7
|
import { message } from './store.js';
|
|
7
8
|
import { chatSummary, turnFact, withTurn } from './turn-fact.js';
|
|
@@ -90,6 +91,7 @@ export function chatRoutes(engine) {
|
|
|
90
91
|
}),
|
|
91
92
|
stopRoute(engine),
|
|
92
93
|
allowFolderRoute(engine),
|
|
94
|
+
permissionRoute(engine),
|
|
93
95
|
];
|
|
94
96
|
}
|
|
95
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;
|