@kurvball/rehearse 1.9.0 → 1.11.0

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.
Files changed (50) hide show
  1. package/README.md +3 -2
  2. package/dist/affected/affected.d.ts +1 -0
  3. package/dist/affected/affected.js +16 -6
  4. package/dist/commands/init.js +52 -7
  5. package/dist/commands/list.js +1 -0
  6. package/dist/compare/compare.js +2 -0
  7. package/dist/detect/detect.d.ts +6 -0
  8. package/dist/detect/detect.js +48 -0
  9. package/dist/detect/finding.d.ts +18 -0
  10. package/dist/detect/finding.js +4 -0
  11. package/dist/detect/globs.d.ts +10 -0
  12. package/dist/detect/globs.js +43 -0
  13. package/dist/detect/index.d.ts +2 -0
  14. package/dist/detect/index.js +2 -0
  15. package/dist/detect/lockfiles.d.ts +15 -0
  16. package/dist/detect/lockfiles.js +64 -0
  17. package/dist/detect/paths.d.ts +5 -0
  18. package/dist/detect/paths.js +39 -0
  19. package/dist/detect/pieces.d.ts +14 -0
  20. package/dist/detect/pieces.js +119 -0
  21. package/dist/detect/prepare.d.ts +14 -0
  22. package/dist/detect/prepare.js +78 -0
  23. package/dist/detect/repository.d.ts +33 -0
  24. package/dist/detect/repository.js +166 -0
  25. package/dist/detect/scenarios.d.ts +26 -0
  26. package/dist/detect/scenarios.js +170 -0
  27. package/dist/detect/scripts.d.ts +46 -0
  28. package/dist/detect/scripts.js +233 -0
  29. package/dist/detect/services.d.ts +16 -0
  30. package/dist/detect/services.js +171 -0
  31. package/dist/detect/write.d.ts +18 -0
  32. package/dist/detect/write.js +115 -0
  33. package/dist/manifest/index.d.ts +2 -2
  34. package/dist/manifest/index.js +2 -2
  35. package/dist/manifest/init.d.ts +47 -1
  36. package/dist/manifest/init.js +19 -16
  37. package/dist/manifest/load.d.ts +1 -0
  38. package/dist/manifest/load.js +14 -1
  39. package/dist/manifest/types.d.ts +2 -0
  40. package/dist/scenarios/glob.d.ts +1 -0
  41. package/dist/scenarios/glob.js +10 -3
  42. package/dist/scenarios/index.d.ts +1 -1
  43. package/dist/scenarios/index.js +1 -1
  44. package/llms.txt +1 -1
  45. package/package.json +1 -1
  46. package/schema/v1/init.schema.json +69 -1
  47. package/schema/v1/list.schema.json +7 -0
  48. package/schema/v1/manifest.schema.json +5 -0
  49. package/schema/v1/samples/init.json +46 -1
  50. package/skill/rehearse/SKILL.md +5 -0
@@ -0,0 +1,78 @@
1
+ import path from 'node:path';
2
+ import { dependenciesOf, isFile, joined, packageAt } from './repository.js';
3
+ import { quoted } from './scripts.js';
4
+ function entryOf(json) {
5
+ const pick = (value) => {
6
+ if (typeof value === 'string')
7
+ return value;
8
+ if (!value || typeof value !== 'object' || Array.isArray(value))
9
+ return null;
10
+ const v = value;
11
+ return pick(v['.'] ?? v.import ?? v.default ?? v.require ?? v.node);
12
+ };
13
+ return (pick(json.exports) ??
14
+ (typeof json.module === 'string' ? json.module : null) ??
15
+ (typeof json.main === 'string' ? json.main : null));
16
+ }
17
+ export function buildsOf(repo, services, pieceDirs) {
18
+ const byName = new Map(repo.packages.filter((p) => p.name).map((p) => [p.name, p]));
19
+ const users = [
20
+ ...services.map((s) => ({ pkg: s.pkg, by: s.name })),
21
+ ...pieceDirs.flatMap((dir) => {
22
+ const pkg = packageAt(repo.root, dir);
23
+ return pkg ? [{ pkg, by: `the pieces in ${dir || 'the root package'}` }] : [];
24
+ }),
25
+ ];
26
+ const walked = new Set(users.map((u) => u.pkg.dir));
27
+ const checked = new Set();
28
+ const used = [];
29
+ for (let i = 0; i < users.length; i += 1) {
30
+ const { pkg, by } = users[i];
31
+ for (const name of dependenciesOf(pkg.json)) {
32
+ const dep = byName.get(name);
33
+ if (!dep || dep.dir === pkg.dir || checked.has(dep.dir))
34
+ continue;
35
+ checked.add(dep.dir);
36
+ if (!walked.has(dep.dir))
37
+ users.push({ pkg: dep, by });
38
+ walked.add(dep.dir);
39
+ const entry = entryOf(dep.json);
40
+ const file = entry ? joined(dep.dir, entry) : null;
41
+ if (file && dep.scripts.build && (!isFile(path.join(repo.root, file)) || repo.ignored(file)))
42
+ used.push({ pkg: dep, why: `${by} uses ${name}, whose ${entry} its build writes` });
43
+ }
44
+ }
45
+ const own = services
46
+ .filter((s) => s.built !== null && s.pkg.scripts.build)
47
+ .map((s) => ({ pkg: s.pkg, why: `${s.name} runs ${s.built}, which its build writes` }));
48
+ return [...used.toReversed(), ...own];
49
+ }
50
+ const inside = (dir, command) => dir ? `(cd ${quoted(dir)} && ${command})` : command;
51
+ export function prepareOf(repo, builds) {
52
+ const steps = [];
53
+ const findings = [];
54
+ for (const lock of repo.lockfiles) {
55
+ steps.push(inside(joined(repo.prefix, lock.dir), lock.install));
56
+ findings.push({ kind: 'prepare', from: lock.file, written: true, why: lock.install });
57
+ }
58
+ findings.push(...repo.locking);
59
+ const installs = repo.lockfiles.length > 0 || repo.locking.length === 0;
60
+ for (const build of builds) {
61
+ const run = `${repo.managerOf(build.pkg.dir)} run build`;
62
+ if (installs)
63
+ steps.push(inside(joined(repo.prefix, build.pkg.dir), run));
64
+ findings.push({
65
+ kind: 'build',
66
+ from: build.pkg.file,
67
+ written: installs,
68
+ why: installs
69
+ ? `${run}: ${build.why}`
70
+ : `${build.why}, but it waits for an install prepare can't write.`,
71
+ });
72
+ }
73
+ return {
74
+ command: steps.length ? steps.join(' && ') : null,
75
+ from: findings.filter((f) => f.written).map((f) => f.from),
76
+ findings,
77
+ };
78
+ }
@@ -0,0 +1,33 @@
1
+ import type { Finding } from './finding.ts';
2
+ import { type Lockfile, type Manager } from './lockfiles.ts';
3
+ export { isFile, joined, readText, within } from './paths.ts';
4
+ export type { Lockfile, Manager } from './lockfiles.ts';
5
+ export type PackageJson = Record<string, unknown>;
6
+ export interface Package {
7
+ dir: string;
8
+ file: string;
9
+ name: string | null;
10
+ json: PackageJson;
11
+ scripts: Record<string, string>;
12
+ }
13
+ export interface Repository {
14
+ root: string;
15
+ prefix: string;
16
+ git: boolean;
17
+ files: readonly string[];
18
+ packages: Package[];
19
+ workspaces: boolean;
20
+ lockfiles: Lockfile[];
21
+ locking: Finding[];
22
+ managerOf(dir: string): Manager;
23
+ ignored(file: string): boolean;
24
+ }
25
+ export declare const dependenciesOf: (json: PackageJson) => string[];
26
+ export declare function packageAt(root: string, dir: string): Package | null;
27
+ export declare function readRepository(root: string): Repository;
28
+ export declare function declares(repo: Repository, dir: string, name: string): boolean;
29
+ export declare function defaultBranch(root: string): {
30
+ branch: string;
31
+ from: string;
32
+ local: boolean;
33
+ } | null;
@@ -0,0 +1,166 @@
1
+ import { createRequire } from 'node:module';
2
+ import path from 'node:path';
3
+ import { parse } from 'yaml';
4
+ import { gitOr, topOf } from '../git/index.js';
5
+ import { findFiles, globToRegExp, NEVER_WALKED, toPosix } from '../scenarios/index.js';
6
+ import { lockIn, managerNamed } from './lockfiles.js';
7
+ import { joined, readText, within } from './paths.js';
8
+ export { isFile, joined, readText, within } from './paths.js';
9
+ const NOT_AN_APP = new Set(['test', 'tests', '__tests__', 'fixtures', 'examples', 'e2e']);
10
+ const FILE_LIMIT = 100_000;
11
+ const DEPENDENCY_FIELDS = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'];
12
+ function readJson(file) {
13
+ const text = readText(file);
14
+ if (text === null)
15
+ return null;
16
+ try {
17
+ const value = JSON.parse(text.replace(/^\uFEFF/, ''));
18
+ return value && typeof value === 'object' && !Array.isArray(value) ? value : null;
19
+ }
20
+ catch {
21
+ return null;
22
+ }
23
+ }
24
+ const stringsOf = (value) => value && typeof value === 'object' && !Array.isArray(value)
25
+ ? Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === 'string'))
26
+ : {};
27
+ export const dependenciesOf = (json) => DEPENDENCY_FIELDS.flatMap((field) => Object.keys(stringsOf(json[field])));
28
+ function listFiles(root, git) {
29
+ const listed = git ? gitOr(root, ['ls-files', '-z', '--cached', '--others', '--exclude-standard']) : null;
30
+ const files = listed === null ? findFiles(root, ['**/*'], FILE_LIMIT) : listed.split('\0');
31
+ return [...new Set(files.filter(Boolean))]
32
+ .filter((file) => !file.split('/').some((part) => NEVER_WALKED.has(part)))
33
+ .sort();
34
+ }
35
+ function workspaceGlobs(root, json) {
36
+ const declared = json?.workspaces;
37
+ const listed = Array.isArray(declared)
38
+ ? declared
39
+ : declared && typeof declared === 'object'
40
+ ? declared.packages
41
+ : undefined;
42
+ const fromYaml = () => {
43
+ const text = readText(path.join(root, 'pnpm-workspace.yaml'));
44
+ if (text === null)
45
+ return undefined;
46
+ try {
47
+ return parse(text)?.packages;
48
+ }
49
+ catch {
50
+ return undefined;
51
+ }
52
+ };
53
+ const globs = Array.isArray(listed) ? listed : fromYaml();
54
+ if (!Array.isArray(globs))
55
+ return null;
56
+ const strings = globs.filter((g) => typeof g === 'string');
57
+ return strings.length ? strings : null;
58
+ }
59
+ export function packageAt(root, dir) {
60
+ const file = joined(dir, 'package.json');
61
+ const json = readJson(path.join(root, file));
62
+ if (!json)
63
+ return null;
64
+ return {
65
+ dir,
66
+ file,
67
+ name: typeof json.name === 'string' && json.name ? json.name : null,
68
+ json,
69
+ scripts: stringsOf(json.scripts),
70
+ };
71
+ }
72
+ function packagesOf(root, files, globs) {
73
+ const manifests = files.filter((f) => f === 'package.json' || f.endsWith('/package.json'));
74
+ const chosen = globs
75
+ ? manifests.filter((f) => {
76
+ const matches = (g) => globToRegExp(joined(g.replace(/^!/, ''), 'package.json')).test(f);
77
+ return (f === 'package.json' ||
78
+ (globs.some((g) => !g.startsWith('!') && matches(g)) &&
79
+ !globs.some((g) => g.startsWith('!') && matches(g))));
80
+ })
81
+ : manifests.filter((f) => {
82
+ const parts = f.split('/');
83
+ return parts.length === 1 || (parts.length === 2 && !NOT_AN_APP.has(parts[0]));
84
+ });
85
+ return [...new Set(chosen.map((f) => joined(path.posix.dirname(f))))]
86
+ .map((dir) => packageAt(root, dir))
87
+ .filter((p) => p !== null);
88
+ }
89
+ function lockingOf(root, prefix, packages, workspaces) {
90
+ const declaredAt = (dir) => managerNamed(packageAt(root, dir)?.json.packageManager);
91
+ const rootDeclared = declaredAt('');
92
+ const above = prefix
93
+ ? prefix.split('/').map((_, i) => Array.from({ length: i + 1 }, () => '..').join('/'))
94
+ : [];
95
+ const nearest = ['', ...above]
96
+ .map((dir) => ({ dir, locked: lockIn(root, dir, rootDeclared) }))
97
+ .find((l) => l.locked.manager !== null);
98
+ const own = workspaces
99
+ ? []
100
+ : packages
101
+ .filter((p) => p.dir)
102
+ .map((p) => ({ dir: p.dir, locked: lockIn(root, p.dir, declaredAt(p.dir) ?? rootDeclared) }))
103
+ .filter((l) => l.locked.manager !== null);
104
+ const all = [...(nearest ? [nearest] : []), ...own];
105
+ return {
106
+ lockfiles: all.flatMap((l) => (l.locked.lockfile ? [l.locked.lockfile] : [])),
107
+ managers: all.map((l) => ({ dir: l.dir, manager: l.locked.manager })),
108
+ findings: all.flatMap((l) => (l.locked.finding ? [l.locked.finding] : [])),
109
+ };
110
+ }
111
+ export function readRepository(root) {
112
+ const top = topOf(root);
113
+ const git = top !== null;
114
+ const prefix = git ? toPosix(path.relative(top, root)) : '';
115
+ const files = listFiles(root, git);
116
+ const rootJson = readJson(path.join(root, 'package.json'));
117
+ const globs = workspaceGlobs(root, rootJson);
118
+ const packages = packagesOf(root, files, globs);
119
+ const workspaces = globs !== null;
120
+ const locking = lockingOf(root, prefix, packages, workspaces);
121
+ const fallback = managerNamed(rootJson?.packageManager) ?? 'npm';
122
+ return {
123
+ root,
124
+ prefix,
125
+ git,
126
+ files,
127
+ packages,
128
+ workspaces,
129
+ lockfiles: locking.lockfiles,
130
+ locking: locking.findings,
131
+ managerOf: (dir) => locking.managers.filter((l) => l.dir.startsWith('..') || within(l.dir, joined(dir, 'x'))).at(-1)
132
+ ?.manager ?? fallback,
133
+ ignored: (file) => git && gitOr(root, ['check-ignore', '-q', file]) !== null,
134
+ };
135
+ }
136
+ export function declares(repo, dir, name) {
137
+ for (let at = dir;; at = joined(at, '..')) {
138
+ const json = readJson(path.join(repo.root, at, 'package.json'));
139
+ if (json && dependenciesOf(json).includes(name))
140
+ return true;
141
+ if (at === '' || at.startsWith('..'))
142
+ break;
143
+ }
144
+ try {
145
+ createRequire(path.join(repo.root, dir, 'package.json')).resolve(`${name}/package.json`);
146
+ return true;
147
+ }
148
+ catch {
149
+ return false;
150
+ }
151
+ }
152
+ export function defaultBranch(root) {
153
+ const head = gitOr(root, ['symbolic-ref', '--quiet', '--short', 'refs/remotes/origin/HEAD']);
154
+ const local = (branch) => gitOr(root, ['rev-parse', '--verify', '--quiet', `refs/heads/${branch}`]) !== null;
155
+ if (head?.startsWith('origin/')) {
156
+ const branch = head.slice('origin/'.length);
157
+ return { branch, from: 'origin/HEAD', local: local(branch) };
158
+ }
159
+ for (const branch of ['main', 'master']) {
160
+ if (local(branch))
161
+ return { branch, from: `refs/heads/${branch}`, local: true };
162
+ if (gitOr(root, ['rev-parse', '--verify', '--quiet', `refs/remotes/origin/${branch}`]) !== null)
163
+ return { branch, from: `refs/remotes/origin/${branch}`, local: false };
164
+ }
165
+ return null;
166
+ }
@@ -0,0 +1,26 @@
1
+ import { type Finding } from './finding.ts';
2
+ import { type PiecesBlock } from './pieces.ts';
3
+ import { type Repository } from './repository.ts';
4
+ import type { Service } from './services.ts';
5
+ export interface Blocks {
6
+ pieces: PiecesBlock | null;
7
+ flows: {
8
+ paths: string[];
9
+ service: string | null;
10
+ count: number;
11
+ } | null;
12
+ calls: {
13
+ paths: string[];
14
+ service: string | null;
15
+ count: number;
16
+ } | null;
17
+ files: {
18
+ paths: string[];
19
+ count: number;
20
+ } | null;
21
+ }
22
+ export declare function scenariosOf(repo: Repository, services: readonly Service[]): {
23
+ blocks: Blocks;
24
+ findings: Finding[];
25
+ pieceDirs: string[];
26
+ };
@@ -0,0 +1,170 @@
1
+ import path from 'node:path';
2
+ import { counted, GUIDE } from './finding.js';
3
+ import { either, extensionsOf, globOf, unreadable } from './globs.js';
4
+ import { PIECE, piecesOf } from './pieces.js';
5
+ import { readText, within } from './repository.js';
6
+ const CALL = /\.hurl$/;
7
+ const FILE_SCENARIO = /\.rehearse\.yaml$/;
8
+ const FLOW = /\.flow\.(ya?ml)$/;
9
+ const REACH = /(?:^|\/)(?:reach|[^/]+\.reach)\.(ts|mts|js|mjs)$/;
10
+ const OPENAPI = /(?:^|\/)(?:openapi|swagger)\.(?:ya?ml|json)$/;
11
+ const PLAYWRIGHT = /(?:^|\/)playwright\.config\.[cm]?[jt]s$/;
12
+ const SENT_AS = /^[ \t]*Authorization[ \t]*:[^\n]*?\{\{\s*([A-Za-z_][\w-]*)\s*\}\}/gim;
13
+ function servedBy(services, files, node) {
14
+ const ranked = services
15
+ .map((s) => ({ s, holds: files.filter((f) => within(s.pkg.dir, f)).length }))
16
+ .filter((r) => r.holds > 0)
17
+ .sort((a, b) => b.holds - a.holds || b.s.pkg.dir.length - a.s.pkg.dir.length);
18
+ return (ranked[0]?.s ?? services.find((s) => (s.server === 'node') === node) ?? services[0])?.name ?? null;
19
+ }
20
+ function sentAs(texts) {
21
+ const people = new Set();
22
+ for (const text of texts)
23
+ for (const m of text.matchAll(SENT_AS))
24
+ people.add(m[1]);
25
+ return [...people].sort();
26
+ }
27
+ const shortList = (items) => `${items.slice(0, 3).join(', ')}${items.length > 3 ? ` and ${items.length - 3} more` : ''}`;
28
+ function calls(repo, files, services, fallback) {
29
+ const texts = files.map((f) => readText(path.join(repo.root, f)) ?? '');
30
+ const glob = globOf(files, '*.hurl');
31
+ const askApi = texts.some((t) => /\{\{\s*api\s*\}\}/.test(t));
32
+ const many = counted(files.length, '.hurl file', '.hurl files');
33
+ const one = files.length === 1;
34
+ if (askApi && services.length === 0)
35
+ return {
36
+ block: null,
37
+ finding: {
38
+ kind: 'calls',
39
+ from: glob,
40
+ count: files.length,
41
+ written: false,
42
+ why: `${many} ${one ? 'sends' : 'send'} to {{api}}, and no service was found to answer ${one ? 'it' : 'them'}.`,
43
+ next: `Write the service that answers them under services, then add calls: ['${glob}'].`,
44
+ },
45
+ };
46
+ const chosen = askApi ? servedBy(services, files, true) : null;
47
+ const people = sentAs(texts);
48
+ return {
49
+ block: { paths: [glob], service: chosen !== fallback ? chosen : null, count: files.length },
50
+ finding: {
51
+ kind: 'calls',
52
+ from: glob,
53
+ count: files.length,
54
+ written: true,
55
+ why: `${many}${chosen ? `, sent to ${chosen}` : ''}`,
56
+ ...(people.length > 0 && {
57
+ next: `They use ${shortList(people.map((p) => `{{${p}}}`))}: say who signs in under people and signIn: ${GUIDE}/concepts/blocks/#people`,
58
+ }),
59
+ },
60
+ };
61
+ }
62
+ function flows(repo, files, services, fallback) {
63
+ const findings = [];
64
+ const yaml = files.filter((f) => FLOW.test(f));
65
+ const broken = yaml.length ? unreadable(repo, yaml, 'flow') : null;
66
+ const yamlGlob = yaml.length ? globOf(yaml, `*.flow.${either(extensionsOf(yaml, FLOW))}`) : null;
67
+ if (broken && yamlGlob)
68
+ findings.push({
69
+ kind: 'flows',
70
+ from: broken.file,
71
+ written: false,
72
+ why: `${broken.says} It doesn't read as a flow, so ${yamlGlob} would fail rehearse check.`,
73
+ next: `Fix it to the flow format (${GUIDE}/reference/scenario-files/), then add flows: ['${yamlGlob}'].`,
74
+ });
75
+ const reach = files.filter((f) => {
76
+ if (!REACH.test(f))
77
+ return false;
78
+ const text = readText(path.join(repo.root, f)) ?? '';
79
+ return /\bexport\s+default\b/.test(text) && /\bsteps\s*:/.test(text);
80
+ });
81
+ const plain = reach.some((f) => path.posix.basename(f).startsWith('reach.'));
82
+ const named = reach.some((f) => !path.posix.basename(f).startsWith('reach.'));
83
+ const stem = plain && named ? '{reach,*.reach}' : plain ? 'reach' : '*.reach';
84
+ const read = [...(broken ? [] : yaml), ...reach];
85
+ const paths = [
86
+ ...(yamlGlob && !broken ? [yamlGlob] : []),
87
+ ...(reach.length ? [globOf(reach, `${stem}.${either(extensionsOf(reach, REACH))}`)] : []),
88
+ ];
89
+ if (paths.length === 0)
90
+ return { block: null, findings };
91
+ const chosen = servedBy(services, read, false);
92
+ findings.unshift({
93
+ kind: 'flows',
94
+ from: paths.join(', '),
95
+ count: read.length,
96
+ written: true,
97
+ why: `${counted(read.length, 'flow file', 'flow files')}${chosen ? `, opening ${chosen}` : ''}`,
98
+ });
99
+ return {
100
+ block: { paths, service: chosen !== fallback ? chosen : null, count: read.length },
101
+ findings,
102
+ };
103
+ }
104
+ function fileScenarios(repo, files) {
105
+ const glob = globOf(files, '*.rehearse.yaml');
106
+ const broken = unreadable(repo, files, 'file-scenario');
107
+ if (broken)
108
+ return {
109
+ block: null,
110
+ finding: {
111
+ kind: 'files',
112
+ from: broken.file,
113
+ written: false,
114
+ why: `${broken.says} It doesn't read as a file scenario, so ${glob} would fail rehearse check.`,
115
+ next: `Fix it to the file scenario format (${GUIDE}/reference/scenario-files/), then add files: ['${glob}'].`,
116
+ },
117
+ };
118
+ return {
119
+ block: { paths: [glob], count: files.length },
120
+ finding: {
121
+ kind: 'files',
122
+ from: glob,
123
+ count: files.length,
124
+ written: true,
125
+ why: counted(files.length, 'file scenario', 'file scenarios'),
126
+ },
127
+ };
128
+ }
129
+ export function scenariosOf(repo, services) {
130
+ const of = (re) => repo.files.filter((f) => re.test(f));
131
+ const fallback = services.some((s) => s.name === 'api') ? 'api' : (services[0]?.name ?? null);
132
+ const pieces = piecesOf(repo, of(PIECE));
133
+ const flow = flows(repo, of(FLOW).concat(of(REACH)), services, fallback);
134
+ const hurl = of(CALL);
135
+ const call = hurl.length ? calls(repo, hurl, services, fallback) : null;
136
+ const scenarioFiles = of(FILE_SCENARIO);
137
+ const file = scenarioFiles.length ? fileScenarios(repo, scenarioFiles) : null;
138
+ const findings = [
139
+ ...pieces.findings,
140
+ ...flow.findings,
141
+ ...(call ? [call.finding] : []),
142
+ ...(file ? [file.finding] : []),
143
+ ];
144
+ for (const from of of(OPENAPI))
145
+ findings.push({
146
+ kind: 'openapi',
147
+ from,
148
+ written: false,
149
+ why: "Rehearse compares calls written in Hurl, and doesn't read an OpenAPI description.",
150
+ next: `Write a .hurl file beside the handlers, one call for each answer that matters: ${GUIDE}/guides/calls/`,
151
+ });
152
+ for (const from of of(PLAYWRIGHT))
153
+ findings.push({
154
+ kind: 'playwright',
155
+ from,
156
+ written: false,
157
+ why: "Rehearse doesn't run Playwright tests: it compares flows, the steps a person takes, by accessible name.",
158
+ next: `Write a *.flow.yaml for each path that matters: ${GUIDE}/guides/flows/. A future rehearse record will write one from a session you drive.`,
159
+ });
160
+ return {
161
+ blocks: {
162
+ pieces: pieces.block,
163
+ flows: flow.block,
164
+ calls: call?.block ?? null,
165
+ files: file?.block ?? null,
166
+ },
167
+ findings,
168
+ pieceDirs: pieces.dirs,
169
+ };
170
+ }
@@ -0,0 +1,46 @@
1
+ export type Framework = 'vite' | 'next' | 'astro';
2
+ export type Read = {
3
+ as: 'framework';
4
+ framework: Framework;
5
+ script: string;
6
+ words: string[];
7
+ } | {
8
+ as: 'node';
9
+ script: string;
10
+ entry: string | null;
11
+ tool: string;
12
+ } | {
13
+ as: 'tool';
14
+ } | {
15
+ as: 'others';
16
+ script: string;
17
+ tool: string;
18
+ } | {
19
+ as: 'unknown';
20
+ script: string;
21
+ tool: string;
22
+ } | {
23
+ as: 'fixed';
24
+ script: string;
25
+ port: string;
26
+ } | {
27
+ as: 'together';
28
+ script: string;
29
+ how: '&' | '|';
30
+ } | {
31
+ as: 'handover';
32
+ script: string;
33
+ via: string;
34
+ };
35
+ export declare const FILE_LIKE: RegExp;
36
+ export declare function wordsOf(segment: string): string[];
37
+ export declare function unwrap(words: readonly string[]): {
38
+ words: string[];
39
+ env: string[];
40
+ };
41
+ export declare function segmentsOf(text: string): {
42
+ segments: string[];
43
+ together: '&' | '|' | null;
44
+ };
45
+ export declare const readScript: (scripts: Readonly<Record<string, string>>, script: string) => Read;
46
+ export declare const quoted: (word: string) => string;