@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
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** The deny rules of the product's and the person's settings, as plain values a launch can quote. */
|
|
2
|
+
export declare function settingDenies(folder: string, home?: string): string[];
|
|
3
|
+
/** The turn's flag settings: hooks off, and the person's sign-in keys when they have any. */
|
|
4
|
+
export declare function freshSettings(home?: string): Record<string, unknown>;
|
|
5
|
+
/**
|
|
6
|
+
* The `--settings` value for one launch: the fixed JSON when the person has no sign-in keys, else
|
|
7
|
+
* a file of the launch's own (their values never pass through a command line), removed with it.
|
|
8
|
+
*/
|
|
9
|
+
export declare function openFreshSettings(home?: string): {
|
|
10
|
+
value: string;
|
|
11
|
+
close: () => void;
|
|
12
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// What a fresh turn keeps of the person's and the product's Claude settings, though it loads none
|
|
2
|
+
// of their files (`--setting-sources=`, so no allow rule can widen what it runs): their deny rules,
|
|
3
|
+
// and the person's sign-in setup. Never their allow rules, hooks or MCP servers.
|
|
4
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { homedir, tmpdir } from 'node:os';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
import { PLANNING_SETTINGS } from './permissions.js';
|
|
8
|
+
/** The product's settings files, under its folder. */
|
|
9
|
+
const PROJECT_SETTINGS = ['.claude/settings.json', '.claude/settings.local.json'];
|
|
10
|
+
/** The person's settings keys that only say how Claude Code signs in or reports. */
|
|
11
|
+
const SIGN_IN_KEYS = [
|
|
12
|
+
'env',
|
|
13
|
+
'apiKeyHelper',
|
|
14
|
+
'awsAuthRefresh',
|
|
15
|
+
'awsCredentialExport',
|
|
16
|
+
'otelHeadersHelper',
|
|
17
|
+
];
|
|
18
|
+
function settingsFile(path) {
|
|
19
|
+
try {
|
|
20
|
+
const value = JSON.parse(readFileSync(path, 'utf8'));
|
|
21
|
+
return value && typeof value === 'object' && !Array.isArray(value)
|
|
22
|
+
? value
|
|
23
|
+
: {};
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const denies = (settings) => {
|
|
30
|
+
const deny = settings.permissions?.deny;
|
|
31
|
+
return Array.isArray(deny)
|
|
32
|
+
? deny.filter((rule) => typeof rule === 'string' && rule.length <= 300 && !/["%!\r\n]/.test(rule))
|
|
33
|
+
: [];
|
|
34
|
+
};
|
|
35
|
+
/** The deny rules of the product's and the person's settings, as plain values a launch can quote. */
|
|
36
|
+
export function settingDenies(folder, home = homedir()) {
|
|
37
|
+
return [
|
|
38
|
+
...PROJECT_SETTINGS.map((file) => join(folder, file)),
|
|
39
|
+
join(home, '.claude', 'settings.json'),
|
|
40
|
+
]
|
|
41
|
+
.flatMap((file) => denies(settingsFile(file)))
|
|
42
|
+
.slice(0, 200);
|
|
43
|
+
}
|
|
44
|
+
/** The turn's flag settings: hooks off, and the person's sign-in keys when they have any. */
|
|
45
|
+
export function freshSettings(home = homedir()) {
|
|
46
|
+
const user = settingsFile(join(home, '.claude', 'settings.json'));
|
|
47
|
+
const signIn = Object.fromEntries(SIGN_IN_KEYS.filter((key) => user[key] !== undefined).map((key) => [key, user[key]]));
|
|
48
|
+
return { ...JSON.parse(PLANNING_SETTINGS), ...signIn };
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The `--settings` value for one launch: the fixed JSON when the person has no sign-in keys, else
|
|
52
|
+
* a file of the launch's own (their values never pass through a command line), removed with it.
|
|
53
|
+
*/
|
|
54
|
+
export function openFreshSettings(home = homedir()) {
|
|
55
|
+
const settings = freshSettings(home);
|
|
56
|
+
if (Object.keys(settings).length === 1)
|
|
57
|
+
return { value: PLANNING_SETTINGS, close: () => { } };
|
|
58
|
+
const folder = mkdtempSync(join(tmpdir(), 'ape-fresh-'));
|
|
59
|
+
const file = join(folder, 'settings.json');
|
|
60
|
+
if (/["%!\r\n]/.test(file)) {
|
|
61
|
+
rmSync(folder, { recursive: true, force: true });
|
|
62
|
+
return { value: PLANNING_SETTINGS, close: () => { } };
|
|
63
|
+
}
|
|
64
|
+
writeFileSync(file, JSON.stringify(settings), { mode: 0o600 });
|
|
65
|
+
return { value: file, close: () => rmSync(folder, { recursive: true, force: true }) };
|
|
66
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type FreshCritique, type FreshReview, type ReviewStep } from '@buffcore/contracts/workbench';
|
|
2
|
+
export declare class FreshStore {
|
|
3
|
+
private readonly root;
|
|
4
|
+
constructor(root: string);
|
|
5
|
+
private file;
|
|
6
|
+
private read;
|
|
7
|
+
private write;
|
|
8
|
+
review(step: ReviewStep): FreshReview | undefined;
|
|
9
|
+
saveReview(step: ReviewStep, review: FreshReview): void;
|
|
10
|
+
critique(): FreshCritique | undefined;
|
|
11
|
+
saveCritique(critique: FreshCritique): void;
|
|
12
|
+
/** A studio that died left turns marked running: none runs now, so they failed. */
|
|
13
|
+
recover(): void;
|
|
14
|
+
/** Every report already critiqued, as `<checkout>|<report>`: none runs twice. */
|
|
15
|
+
critiqued(key: string): boolean;
|
|
16
|
+
markCritiqued(key: string): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Where fresh turns' answers are kept: beside the chats, in `.ape/fresh/` (never in git). One small
|
|
2
|
+
// file per planning step's review and one for the latest critique, replaced atomically.
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { freshCritiqueSchema, freshReviewSchema, REVIEW_STEPS, } from '@buffcore/contracts/workbench';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { plainPath } from './store.js';
|
|
9
|
+
const critiquedSchema = z.array(z.string().max(4000)).max(500);
|
|
10
|
+
export class FreshStore {
|
|
11
|
+
root;
|
|
12
|
+
constructor(root) {
|
|
13
|
+
this.root = root;
|
|
14
|
+
}
|
|
15
|
+
file(name) {
|
|
16
|
+
const ape = plainPath(join(this.root, '.ape'));
|
|
17
|
+
const folder = plainPath(join(ape, 'fresh'));
|
|
18
|
+
return plainPath(join(folder, `${name}.json`));
|
|
19
|
+
}
|
|
20
|
+
read(name, schema) {
|
|
21
|
+
try {
|
|
22
|
+
const parsed = schema.safeParse(JSON.parse(readFileSync(this.file(name), 'utf8')));
|
|
23
|
+
return parsed.success ? parsed.data : undefined;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
write(name, record) {
|
|
30
|
+
const file = this.file(name);
|
|
31
|
+
mkdirSync(join(file, '..'), { recursive: true, mode: 0o700 });
|
|
32
|
+
const temp = plainPath(`${file}.${randomUUID()}.tmp`);
|
|
33
|
+
writeFileSync(temp, JSON.stringify(record), { mode: 0o600 });
|
|
34
|
+
renameSync(temp, file);
|
|
35
|
+
}
|
|
36
|
+
review(step) {
|
|
37
|
+
return this.read(`review-${step}`, freshReviewSchema);
|
|
38
|
+
}
|
|
39
|
+
saveReview(step, review) {
|
|
40
|
+
this.write(`review-${step}`, freshReviewSchema.parse(review));
|
|
41
|
+
}
|
|
42
|
+
critique() {
|
|
43
|
+
return this.read('critique', freshCritiqueSchema);
|
|
44
|
+
}
|
|
45
|
+
saveCritique(critique) {
|
|
46
|
+
this.write('critique', freshCritiqueSchema.parse(critique));
|
|
47
|
+
}
|
|
48
|
+
/** A studio that died left turns marked running: none runs now, so they failed. */
|
|
49
|
+
recover() {
|
|
50
|
+
for (const step of REVIEW_STEPS) {
|
|
51
|
+
const review = this.review(step);
|
|
52
|
+
if (review?.state === 'running')
|
|
53
|
+
this.saveReview(step, { ...review, state: 'failed' });
|
|
54
|
+
}
|
|
55
|
+
const critique = this.critique();
|
|
56
|
+
if (critique?.state === 'running')
|
|
57
|
+
this.saveCritique({ ...critique, state: 'failed' });
|
|
58
|
+
}
|
|
59
|
+
/** Every report already critiqued, as `<checkout>|<report>`: none runs twice. */
|
|
60
|
+
critiqued(key) {
|
|
61
|
+
return this.read('critiqued', critiquedSchema)?.includes(key) ?? false;
|
|
62
|
+
}
|
|
63
|
+
markCritiqued(key) {
|
|
64
|
+
const known = this.read('critiqued', critiquedSchema) ?? [];
|
|
65
|
+
this.write('critiqued', [...known.filter((item) => item !== key), key].slice(-500));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Chat, FreshReply, FreshStep, ReviewStep } from '@buffcore/contracts/workbench';
|
|
2
|
+
import { type Start, stopTree } from '../runner.ts';
|
|
3
|
+
import { type CritiqueSource } from './fresh-critique.ts';
|
|
4
|
+
import { FreshStore } from './fresh-store.ts';
|
|
5
|
+
export declare class FreshLooks {
|
|
6
|
+
readonly store: FreshStore;
|
|
7
|
+
private readonly root;
|
|
8
|
+
private readonly start;
|
|
9
|
+
private readonly stop;
|
|
10
|
+
private readonly runs;
|
|
11
|
+
/** A step whose files changed again while its review ran: read once more after it. */
|
|
12
|
+
private readonly again;
|
|
13
|
+
private readonly critiques;
|
|
14
|
+
private closed;
|
|
15
|
+
constructor(root: string, start: Start, stop?: typeof stopTree);
|
|
16
|
+
private settings;
|
|
17
|
+
/**
|
|
18
|
+
* A turn ended: a planning step that wrote its own files gets a review; a Prototype turn that
|
|
19
|
+
* took a passing full snapshot since `startedAt` gets the critique.
|
|
20
|
+
*/
|
|
21
|
+
afterTurn(chat: Chat, firstMessage: number, startedAt?: number): void;
|
|
22
|
+
private review;
|
|
23
|
+
/** A full studio snapshot passed: the critique runs once per report, as its own turn. */
|
|
24
|
+
afterSnapshot(source: CritiqueSource, report?: string): boolean;
|
|
25
|
+
read(step: FreshStep): FreshReply;
|
|
26
|
+
/** Take or Leave one finding; false when the step has no such finding. */
|
|
27
|
+
answer(step: ReviewStep, id: string, answer: 'take' | 'leave'): boolean;
|
|
28
|
+
running(): number;
|
|
29
|
+
/** The studio is closing: stop every fresh turn; nothing is recorded after. */
|
|
30
|
+
close(): void;
|
|
31
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const en = {
|
|
2
|
+
'fresh.review': 'You are a fresh reviewer, not the agent that wrote this step. Follow AGENTS.md. Read only: change no file and run no command. The step: {step}. Its files: {files}. The earlier steps’ files: {earlier}. Read them, then check the step against the brief, the earlier steps and the product’s rules in AGENTS.md: what is missing, what contradicts an earlier step, what breaks a rule. Reply with only one JSON object, nothing before or after it, in this shape:',
|
|
3
|
+
'fresh.reviewLimit': 'At most seven findings, each one plain sentence the person can act on; an empty list when the step holds up.',
|
|
4
|
+
'fresh.example': 'One sentence the person can act on.',
|
|
5
|
+
'fresh.none': 'none yet',
|
|
6
|
+
'fresh.critique': 'Follow AGENTS.md and the ape-critique skill: read .claude/skills/ape-critique/SKILL.md first, since this turn loads no skills by itself. You are the fresh agent it asks for: you did not draw these scenes, so read the repository and the passing full snapshot ({report}), not anyone’s account of them. Read only: change no file; you may run exactly `pnpm ape design check` and `pnpm ape i18n check`. In this fresh studio turn you do not write design/critique.md: reply with the report’s full Markdown in the skill’s shape (from “# Critique” through Scores, the seven dimensions, Keep, Fix and Quick wins) and nothing else, and the studio writes the file.',
|
|
7
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const es = {
|
|
2
|
+
'fresh.review': 'Eres un revisor nuevo, no el agente que escribió este paso. Sigue AGENTS.md. Solo lectura: no cambies ningún archivo ni ejecutes ningún comando. El paso: {step}. Sus archivos: {files}. Los archivos de los pasos anteriores: {earlier}. Léelos y revisa el paso frente al resumen, los pasos anteriores y las reglas del producto en AGENTS.md: qué falta, qué contradice un paso anterior, qué rompe una regla. Responde solo con un objeto JSON, sin nada antes ni después, con esta forma:',
|
|
3
|
+
'fresh.reviewLimit': 'Como mucho siete hallazgos, cada uno una frase sencilla sobre la que la persona pueda actuar; una lista vacía cuando el paso se sostiene.',
|
|
4
|
+
'fresh.example': 'Una frase sobre la que la persona pueda actuar.',
|
|
5
|
+
'fresh.none': 'ninguno aún',
|
|
6
|
+
'fresh.critique': 'Sigue AGENTS.md y la habilidad ape-critique: lee primero .claude/skills/ape-critique/SKILL.md, porque este turno no carga habilidades por sí solo. Eres el agente nuevo que pide: no dibujaste estas escenas, así que lee el repositorio y la captura completa que pasó ({report}), no el relato de nadie sobre ellas. Solo lectura: no cambies ningún archivo; puedes ejecutar exactamente `pnpm ape design check` y `pnpm ape i18n check`. En este turno nuevo del estudio no escribes design/critique.md: responde con el Markdown completo del informe con la forma de la habilidad (desde “# Critique” con Scores, las siete dimensiones, Keep, Fix y Quick wins) y nada más, y el estudio escribe el archivo.',
|
|
7
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Fresh agents' turns (0.8.43). After a planning step's turn writes the step's files, a fresh,
|
|
2
|
+
// read-only reviewer reads the step; after a passing full prototype snapshot, a fresh turn writes
|
|
3
|
+
// the critique (fresh-critique.ts). Neither is a chat: neither holds the step's tree, its session
|
|
4
|
+
// or its Save.
|
|
5
|
+
import { randomUUID } from 'node:crypto';
|
|
6
|
+
import { readFileSync } from 'node:fs';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { parseAgentsFile } from '../../agents-file.js';
|
|
9
|
+
import { stopTree } from '../runner.js';
|
|
10
|
+
import { CritiqueTurns, keep } from './fresh-critique.js';
|
|
11
|
+
import { runFresh, stopFresh } from './fresh-launch.js';
|
|
12
|
+
import { parseFindings, reviewPrompt, reviewStepOf, stepChoice } from './fresh-prompts.js';
|
|
13
|
+
import { prototypeTurn } from './fresh-report.js';
|
|
14
|
+
import { FreshStore } from './fresh-store.js';
|
|
15
|
+
export class FreshLooks {
|
|
16
|
+
store;
|
|
17
|
+
root;
|
|
18
|
+
start;
|
|
19
|
+
stop;
|
|
20
|
+
runs = new Map();
|
|
21
|
+
/** A step whose files changed again while its review ran: read once more after it. */
|
|
22
|
+
again = new Map();
|
|
23
|
+
critiques;
|
|
24
|
+
closed = false;
|
|
25
|
+
constructor(root, start, stop = stopTree) {
|
|
26
|
+
this.root = root;
|
|
27
|
+
this.store = new FreshStore(root);
|
|
28
|
+
keep(() => this.store.recover());
|
|
29
|
+
this.start = start;
|
|
30
|
+
this.stop = stop;
|
|
31
|
+
this.critiques = new CritiqueTurns(root, start, stop, this.store, () => this.settings());
|
|
32
|
+
}
|
|
33
|
+
settings() {
|
|
34
|
+
try {
|
|
35
|
+
return parseAgentsFile(readFileSync(join(this.root, 'plan', 'agents.md'), 'utf8'));
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A turn ended: a planning step that wrote its own files gets a review; a Prototype turn that
|
|
43
|
+
* took a passing full snapshot since `startedAt` gets the critique.
|
|
44
|
+
*/
|
|
45
|
+
afterTurn(chat, firstMessage, startedAt) {
|
|
46
|
+
if (this.closed)
|
|
47
|
+
return;
|
|
48
|
+
if (prototypeTurn(chat) && startedAt !== undefined)
|
|
49
|
+
void this.critiques.afterTurn(startedAt);
|
|
50
|
+
const step = reviewStepOf(chat, firstMessage);
|
|
51
|
+
if (!step || chat.agent !== 'claude')
|
|
52
|
+
return;
|
|
53
|
+
if (this.settings()?.review === false)
|
|
54
|
+
return;
|
|
55
|
+
const choice = stepChoice(chat);
|
|
56
|
+
if (this.runs.has(step))
|
|
57
|
+
this.again.set(step, choice);
|
|
58
|
+
else
|
|
59
|
+
this.review(step, choice);
|
|
60
|
+
}
|
|
61
|
+
review(step, choice) {
|
|
62
|
+
const record = { agent: 'claude', at: new Date().toISOString(), findings: [] };
|
|
63
|
+
keep(() => this.store.saveReview(step, { ...record, state: 'running' }));
|
|
64
|
+
const run = runFresh(this.start, { folder: this.root, prompt: reviewPrompt(step), ...choice });
|
|
65
|
+
this.runs.set(step, run);
|
|
66
|
+
void run.result.then(({ text, seconds }) => {
|
|
67
|
+
this.runs.delete(step);
|
|
68
|
+
if (this.closed)
|
|
69
|
+
return;
|
|
70
|
+
const found = text === undefined ? undefined : parseFindings(text);
|
|
71
|
+
const findings = (found ?? []).map((finding) => ({ id: randomUUID(), text: finding }));
|
|
72
|
+
const state = found ? 'done' : 'failed';
|
|
73
|
+
keep(() => this.store.saveReview(step, { ...record, state, seconds, findings }));
|
|
74
|
+
const next = this.again.get(step);
|
|
75
|
+
this.again.delete(step);
|
|
76
|
+
if (next)
|
|
77
|
+
this.review(step, next);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/** A full studio snapshot passed: the critique runs once per report, as its own turn. */
|
|
81
|
+
afterSnapshot(source, report) {
|
|
82
|
+
return this.critiques.after(source, report);
|
|
83
|
+
}
|
|
84
|
+
read(step) {
|
|
85
|
+
if (step === 'prototype') {
|
|
86
|
+
const critique = this.store.critique();
|
|
87
|
+
return critique ? { critique } : {};
|
|
88
|
+
}
|
|
89
|
+
const review = this.store.review(step);
|
|
90
|
+
return review ? { review } : {};
|
|
91
|
+
}
|
|
92
|
+
/** Take or Leave one finding; false when the step has no such finding. */
|
|
93
|
+
answer(step, id, answer) {
|
|
94
|
+
const review = this.store.review(step);
|
|
95
|
+
const finding = review?.findings.find((item) => item.id === id);
|
|
96
|
+
if (!review || !finding)
|
|
97
|
+
return false;
|
|
98
|
+
finding.answer = answer === 'take' ? 'taken' : 'left';
|
|
99
|
+
this.store.saveReview(step, review);
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
running() {
|
|
103
|
+
return this.runs.size + (this.critiques.running() ? 1 : 0);
|
|
104
|
+
}
|
|
105
|
+
/** The studio is closing: stop every fresh turn; nothing is recorded after. */
|
|
106
|
+
close() {
|
|
107
|
+
this.closed = true;
|
|
108
|
+
for (const run of this.runs.values())
|
|
109
|
+
stopFresh(run, this.stop);
|
|
110
|
+
this.critiques.close();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -2,17 +2,19 @@ import type { Chat } from '@buffcore/contracts/workbench';
|
|
|
2
2
|
import type { AgentTurn, Start } from '../runner.ts';
|
|
3
3
|
import { copyCodexExamples } from './codex-examples.ts';
|
|
4
4
|
import type { TurnMigrations } from './migration-turn.ts';
|
|
5
|
+
import { type TurnGuard } from './turn-guard.ts';
|
|
5
6
|
import { type Active } from './turn-state.ts';
|
|
6
7
|
export declare function startAgentTurn(start: Start, spec: Parameters<Start>[0], folder: string, turn: AgentTurn, work: Chat['work']): ReturnType<Start>;
|
|
7
|
-
export declare function startCodingTurn(start: Start, spec: Parameters<Start>[0], run: Active, migrations?: TurnMigrations, examples?: ReturnType<typeof copyCodexExamples
|
|
8
|
+
export declare function startCodingTurn(start: Start, spec: Parameters<Start>[0], run: Active, migrations?: TurnMigrations, examples?: ReturnType<typeof copyCodexExamples>, guard?: TurnGuard): import("child_process").ChildProcess;
|
|
8
9
|
/** Resolve flags, the start record and stdin from the same per-launch settings. */
|
|
9
|
-
export declare function launchInput(run: Active, root: string, context: string): {
|
|
10
|
+
export declare function launchInput(run: Active, root: string, context: string, save: () => void): {
|
|
10
11
|
adapter: import("./prompt.ts").ChatAdapter;
|
|
11
12
|
input: string;
|
|
12
13
|
examples: {
|
|
13
14
|
folder: string;
|
|
14
15
|
close: () => void;
|
|
15
16
|
} | undefined;
|
|
17
|
+
guard: TurnGuard | undefined;
|
|
16
18
|
spec: {
|
|
17
19
|
program: 'pnpm';
|
|
18
20
|
args: string[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { effectiveLevel } from '../../agents-file.js';
|
|
1
2
|
import { migrationTurnEnv } from '../../migrate-create-protocol.js';
|
|
2
3
|
import { stdinInput } from './attachments.js';
|
|
3
4
|
import { startWithClaudeTaskOutput } from './claude-task-output.js';
|
|
@@ -7,6 +8,7 @@ import { scrubLaunchIds } from './launch-ids.js';
|
|
|
7
8
|
import { inTree } from './permissions.js';
|
|
8
9
|
import { buildEnv, chatError, composePrompt, t } from './prompt.js';
|
|
9
10
|
import { message } from './store.js';
|
|
11
|
+
import { openTurnGuard } from './turn-guard.js';
|
|
10
12
|
import { adapterFor, turnArgs } from './turn-input.js';
|
|
11
13
|
import { turnContext } from './turn-state.js';
|
|
12
14
|
import { writesInChange } from './worktree.js';
|
|
@@ -15,7 +17,7 @@ export function startAgentTurn(start, spec, folder, turn, work) {
|
|
|
15
17
|
? startWithClaudeTaskOutput(start, spec, folder, turn)
|
|
16
18
|
: start(spec, folder, turn);
|
|
17
19
|
}
|
|
18
|
-
export function startCodingTurn(start, spec, run, migrations, examples) {
|
|
20
|
+
export function startCodingTurn(start, spec, run, migrations, examples, guard) {
|
|
19
21
|
let grant;
|
|
20
22
|
try {
|
|
21
23
|
grant = writesInChange(run.chat)
|
|
@@ -29,16 +31,20 @@ export function startCodingTurn(start, spec, run, migrations, examples) {
|
|
|
29
31
|
child.once(event, grant.close);
|
|
30
32
|
if (examples)
|
|
31
33
|
child.once('close', examples.close);
|
|
34
|
+
if (guard)
|
|
35
|
+
for (const event of ['error', 'close'])
|
|
36
|
+
child.once(event, guard.close);
|
|
32
37
|
return child;
|
|
33
38
|
}
|
|
34
39
|
catch (error) {
|
|
35
40
|
grant?.close();
|
|
36
41
|
examples?.close();
|
|
42
|
+
guard?.close();
|
|
37
43
|
throw error;
|
|
38
44
|
}
|
|
39
45
|
}
|
|
40
46
|
/** Resolve flags, the start record and stdin from the same per-launch settings. */
|
|
41
|
-
export function launchInput(run, root, context) {
|
|
47
|
+
export function launchInput(run, root, context, save) {
|
|
42
48
|
const adapter = adapterFor(run.chat.agent);
|
|
43
49
|
if (!adapter)
|
|
44
50
|
throw chatError('chat.unavailable', { agent: run.chat.agent });
|
|
@@ -46,8 +52,12 @@ export function launchInput(run, root, context) {
|
|
|
46
52
|
if (run.images.length && !def?.turn?.images)
|
|
47
53
|
message(run.chat, 'system', t('chat.imagesUnavailable', { agent: adapter.id }));
|
|
48
54
|
const examples = adapter.id === 'codex' && inTree(run.chat.work) ? copyCodexExamples(root) : undefined;
|
|
55
|
+
let guard;
|
|
49
56
|
try {
|
|
50
|
-
|
|
57
|
+
guard = adapter.id === 'claude' ? openTurnGuard(run, root, save) : undefined;
|
|
58
|
+
// One read of the level serves the arguments and the settings alike.
|
|
59
|
+
const level = guard?.level ?? effectiveLevel(root);
|
|
60
|
+
const args = turnArgs(run, root, adapter, examples?.folder, guard, level);
|
|
51
61
|
const input = stdinInput(adapter.id, scrubLaunchIds(context) +
|
|
52
62
|
(run.selection?.instructions ?? '') +
|
|
53
63
|
composePrompt(run.chat, root, run.retryNotice ? run.accepted : undefined), run.images);
|
|
@@ -58,6 +68,7 @@ export function launchInput(run, root, context) {
|
|
|
58
68
|
root,
|
|
59
69
|
folder: run.tree,
|
|
60
70
|
contained: run.contained,
|
|
71
|
+
level,
|
|
61
72
|
});
|
|
62
73
|
if (examples)
|
|
63
74
|
env = { ...env, ...codexExampleEnv(run.tree, examples.folder) };
|
|
@@ -65,6 +76,7 @@ export function launchInput(run, root, context) {
|
|
|
65
76
|
adapter,
|
|
66
77
|
input,
|
|
67
78
|
examples,
|
|
79
|
+
guard,
|
|
68
80
|
spec: {
|
|
69
81
|
program: 'pnpm',
|
|
70
82
|
args: ['exec', def?.bin, ...args],
|
|
@@ -75,6 +87,7 @@ export function launchInput(run, root, context) {
|
|
|
75
87
|
}
|
|
76
88
|
catch (error) {
|
|
77
89
|
examples?.close();
|
|
90
|
+
guard?.close();
|
|
78
91
|
throw error;
|
|
79
92
|
}
|
|
80
93
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The limit a command's text mentions, as the card names it (`git push`, `ape deploy`,
|
|
3
|
+
* `npm publish`, `gh release`, `.ssh`, `.env.production`, `curl`); nothing when it mentions none.
|
|
4
|
+
*/
|
|
5
|
+
export declare function mentionedLimit(command: string, cwd: string): string | undefined;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The limits' fail-safe: a command's whole text, read for every limit's words whatever the shape
|
|
3
|
+
* around them. When the parse (limits.ts) refused nothing but the text still mentions a limit,
|
|
4
|
+
* the call goes to the person's card for Allow once, so a shape the parse misses costs one click,
|
|
5
|
+
* not a hole. Case does not count; line continuations are joined first, and the text is also read
|
|
6
|
+
* with its quotes and escapes taken out (`'gi't pu\sh`). Plain Node only: the hook runs it.
|
|
7
|
+
*/
|
|
8
|
+
import { VALUED_OPTIONS } from './publish-limits.js';
|
|
9
|
+
import { SECRET_FOLDERS } from './secret-folders.js';
|
|
10
|
+
const escaped = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
11
|
+
/** A word on its own, not inside a longer word or file name. */
|
|
12
|
+
const word = (pattern, after = '(?![\\w-])') => new RegExp(`(?<![\\w.-])(?:${pattern})${after}`, 'gi');
|
|
13
|
+
const GIT = /(?<![\w.])git(?!\w)/i;
|
|
14
|
+
const PUSH = /(?<![\w.])(?:push|send-pack)(?!\w)/i;
|
|
15
|
+
const APE = word('ape');
|
|
16
|
+
const DEPLOY = word('deploy');
|
|
17
|
+
const PRODUCTION = /(?<![\w-])\.env\.(?:production|prod|staging)(?![\w-])[\w.-]*/i;
|
|
18
|
+
const SECRETS = word([...SECRET_FOLDERS].map(escaped).join('|'), '(?![\\w.-])');
|
|
19
|
+
const DOWNLOAD_NAMES = [
|
|
20
|
+
'curl',
|
|
21
|
+
'wget2?',
|
|
22
|
+
'aria2c',
|
|
23
|
+
'iwr',
|
|
24
|
+
'irm',
|
|
25
|
+
'invoke-webrequest',
|
|
26
|
+
'invoke-restmethod',
|
|
27
|
+
'start-bitstransfer',
|
|
28
|
+
'bitsadmin',
|
|
29
|
+
'net\\.webclient',
|
|
30
|
+
'downloadstring',
|
|
31
|
+
'downloadfile',
|
|
32
|
+
];
|
|
33
|
+
const DOWNLOADS = word(`(?:${DOWNLOAD_NAMES.join('|')})(?:\\.exe)?`, '(?![\\w.-])');
|
|
34
|
+
// Publishing: a package manager and `publish` (or npm's shortened names, down to `pu`), or `gh`,
|
|
35
|
+
// `release` and a verb that changes one. A path or a longer word (`src/publish.ts`,
|
|
36
|
+
// `publish-docs`) is not the subcommand; nor is one asked only for its help (`publish --help`,
|
|
37
|
+
// `npm help publish`), which is taken out of the text first.
|
|
38
|
+
const MANAGER = /(?<![\w.-])(npm|pnpm|yarn)(?![\w-])/i;
|
|
39
|
+
const PUBLISH = /(?<![\w./\\-])pu(?:b(?:l(?:i(?:sh?)?)?)?)?(?![\w./\\-])/i;
|
|
40
|
+
const GH = /(?<![\w.-])gh(?![\w-])/i;
|
|
41
|
+
const RELEASE = /(?<![\w./\\-])release(?![\w./\\-])/i;
|
|
42
|
+
const VERBS = 'create|new|upload|edit|delete(?:-asset)?';
|
|
43
|
+
const RELEASE_CHANGE = new RegExp(`(?<![\\w./\\\\-])(?:${VERBS})(?![\\w./\\\\-])`, 'i');
|
|
44
|
+
const HELP = new RegExp(`(?<![\\w./\\\\-])(?:(?:pu\\w*|${VERBS})\\s+(?:--help|-h)|help\\s+pu\\w*)(?=\\s*(?:$|[;&|)'"\\r\\n]))`, 'gi');
|
|
45
|
+
/** A value-taking option and its value (`--filter publish`): case counts, as `-C` is not `-c`. */
|
|
46
|
+
const VALUES = new RegExp(`(?<!\\S)(?:${VALUED_OPTIONS.join('|')})(?:\\s+|=)\\S+`, 'g');
|
|
47
|
+
const CERTUTIL = /(?<![\w.-])certutil(?:\.exe)?(?![\w-])/i;
|
|
48
|
+
const URLCACHE = /[-/]urlcache(?![\w-])/i;
|
|
49
|
+
const first = (pattern, text) => {
|
|
50
|
+
pattern.lastIndex = 0;
|
|
51
|
+
return pattern.exec(text)?.[0];
|
|
52
|
+
};
|
|
53
|
+
/** The text with the turn's own folder taken out, so a product kept under `secrets/` still works. */
|
|
54
|
+
function withoutFolder(text, cwd) {
|
|
55
|
+
const parts = cwd
|
|
56
|
+
.split(/[\\/]+/)
|
|
57
|
+
.filter(Boolean)
|
|
58
|
+
.map(escaped);
|
|
59
|
+
if (!parts.length)
|
|
60
|
+
return text;
|
|
61
|
+
return text.replace(new RegExp(parts.join('[\\\\/]+'), 'gi'), '.');
|
|
62
|
+
}
|
|
63
|
+
function mentionIn(text, cwd) {
|
|
64
|
+
// `git stash push` keeps work locally; any other `push` in the text still counts.
|
|
65
|
+
if (GIT.test(text) && PUSH.test(text.replace(/\bstash\s+push\b/gi, '')))
|
|
66
|
+
return 'git push';
|
|
67
|
+
if (first(APE, text) && first(DEPLOY, text))
|
|
68
|
+
return 'ape deploy';
|
|
69
|
+
const asked = text.replace(HELP, '').replace(VALUES, ' ');
|
|
70
|
+
const manager = MANAGER.exec(asked)?.[1];
|
|
71
|
+
if (manager && PUBLISH.test(asked))
|
|
72
|
+
return `${manager.toLowerCase()} publish`;
|
|
73
|
+
if (GH.test(asked) && RELEASE.test(asked) && RELEASE_CHANGE.test(asked))
|
|
74
|
+
return 'gh release';
|
|
75
|
+
const settings = PRODUCTION.exec(text)?.[0];
|
|
76
|
+
if (settings)
|
|
77
|
+
return settings;
|
|
78
|
+
const secret = first(SECRETS, withoutFolder(text, cwd))?.toLowerCase();
|
|
79
|
+
if (secret)
|
|
80
|
+
return secret;
|
|
81
|
+
// `certutil -urlcache` fetches a URL; its other uses read local files.
|
|
82
|
+
if (CERTUTIL.test(text) && URLCACHE.test(text))
|
|
83
|
+
return 'certutil';
|
|
84
|
+
return first(DOWNLOADS, text)?.toLowerCase();
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The limit a command's text mentions, as the card names it (`git push`, `ape deploy`,
|
|
88
|
+
* `npm publish`, `gh release`, `.ssh`, `.env.production`, `curl`); nothing when it mentions none.
|
|
89
|
+
*/
|
|
90
|
+
export function mentionedLimit(command, cwd) {
|
|
91
|
+
const joined = command.replace(/[\\`^]\r?\n/g, '');
|
|
92
|
+
const plain = joined.replace(/['"`^]/g, '').replace(/\\(?=[\w.])/g, '');
|
|
93
|
+
return (mentionIn(joined, cwd) ?? mentionIn(plain, cwd))?.slice(0, 80);
|
|
94
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The limits' read of shell patterns: a word with `*`, `?`, `[…]` or `{a,b}` names whatever files
|
|
3
|
+
* the shell finds, so `cat .env.*` or `cat ~/.ss?/id_rsa` reaches a limit no word spells out. Each
|
|
4
|
+
* such word's braces are expanded (bounded), each path segment becomes a pattern, and the pattern
|
|
5
|
+
* is tried against every secret folder's name and production settings file's name; a match sends
|
|
6
|
+
* the call to the card (limits.ts). A segment of wildcards only (`*`, `**`, `[a-z]?`) names every
|
|
7
|
+
* file and tells nothing, so `dist/*` and `src/**` stay free. Plain Node only: the hook runs it.
|
|
8
|
+
*/
|
|
9
|
+
import type { Reading } from './command-parts.ts';
|
|
10
|
+
/**
|
|
11
|
+
* The secret folder or settings file a pattern in the command could reach (`.ssh`,
|
|
12
|
+
* `.env.production`); nothing when none does. Its work counts in the reading's steps; past the
|
|
13
|
+
* cap, or a word whose braces expand too far, it marks the reading `budget` and names nothing.
|
|
14
|
+
*/
|
|
15
|
+
export declare function patternReach(command: string, reading: Reading, cap: number): string | undefined;
|