@kurvball/rehearse 1.14.0 → 1.16.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 (63) hide show
  1. package/dist/commands/announce.js +2 -2
  2. package/dist/commands/clean.js +6 -3
  3. package/dist/commands/compare.js +6 -1
  4. package/dist/commands/drive.js +49 -13
  5. package/dist/commands/init.js +1 -1
  6. package/dist/commands/run.js +8 -4
  7. package/dist/commands/services.d.ts +2 -0
  8. package/dist/commands/services.js +9 -1
  9. package/dist/commands/stage.js +18 -2
  10. package/dist/commands/up.js +15 -5
  11. package/dist/compare/compare.d.ts +2 -0
  12. package/dist/compare/compare.js +19 -10
  13. package/dist/detect/detect.js +4 -0
  14. package/dist/detect/index.d.ts +1 -0
  15. package/dist/detect/index.js +1 -0
  16. package/dist/detect/keys.d.ts +16 -0
  17. package/dist/detect/keys.js +141 -0
  18. package/dist/detect/write.d.ts +2 -0
  19. package/dist/detect/write.js +20 -1
  20. package/dist/drive/open.js +20 -9
  21. package/dist/drive/state.d.ts +1 -0
  22. package/dist/git/checkout.d.ts +6 -0
  23. package/dist/git/checkout.js +28 -19
  24. package/dist/git/index.d.ts +3 -2
  25. package/dist/git/index.js +3 -2
  26. package/dist/kinds/flow/kind.js +2 -2
  27. package/dist/manifest/index.d.ts +2 -1
  28. package/dist/manifest/index.js +1 -0
  29. package/dist/manifest/load.js +21 -0
  30. package/dist/manifest/order.d.ts +8 -0
  31. package/dist/manifest/order.js +53 -0
  32. package/dist/manifest/types.d.ts +15 -0
  33. package/dist/repositories/copies.d.ts +16 -0
  34. package/dist/repositories/copies.js +132 -0
  35. package/dist/repositories/index.d.ts +1 -0
  36. package/dist/repositories/index.js +1 -0
  37. package/dist/run/cache.d.ts +2 -1
  38. package/dist/run/cache.js +6 -3
  39. package/dist/run/index.d.ts +1 -1
  40. package/dist/run/index.js +1 -0
  41. package/dist/run/observation.d.ts +4 -0
  42. package/dist/run/observation.js +5 -1
  43. package/dist/run/session.d.ts +3 -1
  44. package/dist/run/session.js +32 -20
  45. package/dist/services/index.d.ts +2 -2
  46. package/dist/services/index.js +2 -2
  47. package/dist/services/registry.d.ts +1 -0
  48. package/dist/services/service.d.ts +4 -0
  49. package/dist/services/service.js +24 -8
  50. package/dist/stage/api.d.ts +2 -0
  51. package/dist/stage/api.js +4 -0
  52. package/dist/stage/sending.d.ts +2 -1
  53. package/dist/stage/sending.js +12 -5
  54. package/dist/stage/server.d.ts +2 -0
  55. package/dist/stage/server.js +14 -1
  56. package/llms.txt +5 -5
  57. package/package.json +2 -2
  58. package/schema/v1/common.schema.json +22 -0
  59. package/schema/v1/init.schema.json +2 -1
  60. package/schema/v1/manifest.schema.json +30 -0
  61. package/schema/v1/samples/manifest.yaml +8 -0
  62. package/schema/v1/services.schema.json +8 -0
  63. package/skill/rehearse/SKILL.md +4 -0
@@ -4,6 +4,7 @@ import path from 'node:path';
4
4
  import { readAnnouncement } from '../compare/index.js';
5
5
  import { RehearseError, errorText } from '../errors.js';
6
6
  import { checkoutFor } from '../git/index.js';
7
+ import { copiesFor } from '../repositories/index.js';
7
8
  import { parseHurl, Refusal, sendFile, startPieceServer, } from '../kinds/index.js';
8
9
  import { scrubDeep } from '../people/index.js';
9
10
  import { readScenarios } from '../scenarios/index.js';
@@ -72,8 +73,19 @@ export async function startStage(o) {
72
73
  const baseRef = o.base ?? m.base;
73
74
  const baseCheckout = async () => (base ??= await checkoutFor(m, head.path, baseRef, o.progress, [head.path], o.cwd));
74
75
  const checkoutOf = async (side) => (side === 'head' ? head.path : (await baseCheckout()).path);
76
+ const copies = new Map();
77
+ const copiesOn = (side) => {
78
+ const known = copies.get(side);
79
+ if (known)
80
+ return known;
81
+ const given = (side === 'head' ? o.headRepositories : o.baseRepositories) ?? {};
82
+ const resolving = checkoutOf(side).then((dir) => copiesFor(m, given, dir, o.progress, o.cwd));
83
+ resolving.catch(() => copies.delete(side));
84
+ copies.set(side, resolving);
85
+ return resolving;
86
+ };
75
87
  const scenarioOn = async (side, id) => (await readScenarios(m, await checkoutOf(side))).scenarios.find((s) => s.id === id) ?? null;
76
- const sending = servicesForSending(m, checkoutOf, o.progress);
88
+ const sending = servicesForSending(m, checkoutOf, copiesOn, o.progress);
77
89
  const pieces = new Map();
78
90
  const api = {
79
91
  ...apiOf({
@@ -82,6 +94,7 @@ export async function startStage(o) {
82
94
  head,
83
95
  baseRef,
84
96
  checkoutOf,
97
+ copiesOn,
85
98
  scenarioOn,
86
99
  runs: new Map(),
87
100
  compared: lastCompared(path.join(stateDir(m.dir), 'compare'), head.path, baseAsked(head.path, baseRef, o.cwd)),
package/llms.txt CHANGED
@@ -9,13 +9,13 @@
9
9
  - `rehearse services | people | worlds [--json]`: what can come up; who you can sign in as (people: the sign-in shape {name: {token, …}}, everyone described in about; tokens only with --json); the named starting states.
10
10
  - `rehearse keys [--check] [--json]` and `rehearse keys add <key>`: the keys services need (manifest `keys`: an op:// reference, or this computer's key store), where each comes from and who gets it as which variable; --check looks each up (found, missing, live, short, unreadable; exit 1 when one isn't there); add keeps one on this computer from stdin. Never prints a key (schema keys).
11
11
  - `rehearse list [--affected <file>… | --since <ref>] [--json]`: the scenarios, or those a change reaches, each with reachedBy (schema list).
12
- - `rehearse up [<service>…] [--world] [--real <stand-in>]` and `rehearse down [--all]`: services left running with a world built on them (schema up).
13
- - `rehearse run <scenario> [--on <checkout|ref>] [--world] [--as <person>] [--real <stand-in>] [--keep] [--parallel <n>] --json`: one observation (schema observation).
14
- - `rehearse compare [<id or glob>…] [--affected] [--base <ref|./folder>] [--head <ref|./folder>] [--announce <file>] [--announce-from changesets] [--said <id>]… [--world] [--as] [--real] [--fresh] [--parallel <n>] [--gate [--preview <url>]] --json`: a verdict per scenario (schema comparison). --gate prints a gate answer instead ({v, ok, summary, details, annotations, links, tool}; exit 0 ok, 1 not, 2 can't compare). --announce-from changesets also reads the `announce` blocks of the changesets the change adds. Exit 0 when both sides came up and nothing fails on the head or changed without saying so. --parallel runs groups that share no service at once, and the base beside the head when budget.services allows two; the result is the same as one at a time.
12
+ - `rehearse up [<service>…] [--on <checkout>] [--repository <name=ref|folder>]… [--world] [--real <stand-in>]` and `rehearse down [--all]`: services left running with a world built on them (schema up).
13
+ - `rehearse run <scenario> [--on <checkout|ref>] [--repository <name=ref|folder>]… [--world] [--as <person>] [--real <stand-in>] [--keep] [--parallel <n>] --json`: one observation (schema observation). A service whose manifest entry names a `repository` (top-level `repositories: {name: {from, base?, prepare?}}`) runs in a fresh, prepared copy of that repository at its base, or at what --repository names; checkout.repositories gives each copy's {path, ref, commit, dirty}.
14
+ - `rehearse compare [<id or glob>…] [--affected] [--base <ref|./folder>] [--head <ref|./folder>] [--base-repository <name=ref|folder>]… [--head-repository <name=ref|folder>]… [--announce <file>] [--announce-from changesets] [--said <id>]… [--world] [--as] [--real] [--fresh] [--parallel <n>] [--gate [--preview <url>]] --json`: a verdict per scenario (schema comparison). --gate prints a gate answer instead ({v, ok, summary, details, annotations, links, tool}; exit 0 ok, 1 not, 2 can't compare). --announce-from changesets also reads the `announce` blocks of the changesets the change adds. Exit 0 when both sides came up and nothing fails on the head or changed without saying so. --parallel runs groups that share no service at once, and the base beside the head when budget.services allows two; the result is the same as one at a time.
15
15
  - `rehearse announce [<id or glob>…] [--draft] [--base] [--head] [--announce <file>] [--announce-from changesets] [--said <id>]… [--format yaml|changeset] --json`: what a comparison would read as announced (schema announce); with --draft (and compare's own options) it compares and proposes {scenario, why} for each scenario whose verdict is unsaid, its why the first difference, for you to rewrite as the reason. --format changeset prints an `announce` block for a changeset. It writes no file; refuses with code not_compared when the base or head doesn't come up.
16
16
  - `rehearse drive start [--service <name> | --piece <id>] [--world] [--as <person>] [--scheme light|dark]` (or DRIVE_SCHEME), then `rehearse drive click --name <name> [--role <role>] | fill --name <name> --with <text> | type <text> | key <key> | snapshot [--name <name> [--role <role>]] | screenshot <file.png> | stop`, each with --json: the drive result shape {ok, command, ms, file, tree} plus v and driver (schema drive). Exit 0 done, 1 failed, 2 usage.
17
17
  - `rehearse record <file.flow.yaml> --from-drive [--name <words>] [--force] --json`: writes the steps the current or latest drive took as a flow, every step by accessible name, then `rehearse run <file>` runs it (schema record: {file, from, replaced, steps, warnings}, each warning with the line it points to). It keeps each click, fill, type and key that worked, and each `snapshot --name` as a check the element is there; it leaves out failed steps and looks. The drive's steps are kept in .rehearse/drive-steps.jsonl until the next drive start. Without --from-drive, `rehearse record <file> [--service] [--world] [--as] [--start]` opens a Chromium window and records what a person clicks, fills, chooses and presses until the window closes or Ctrl-C. Rehearse keeps typed text only for plain fields it can see (native text, email, search, url, tel and number inputs and textareas, not secret, checked again when the step is written): a secret field (ever a password, a secret autocomplete, -webkit-text-security, or a name, label, placeholder or title saying pass, secret, token, key, pin, otp…) is written as `<password>`, anything else (custom elements, role=textbox, contenteditable, closed shadow roots, a service's own driver) as `<not recorded>`, each with a warning at its line that never quotes the text; text holding `{{` gets `literal: true`, the person's own token is written as `{{token}}`, and any other form of a token is kept out. A role and name more than one element has keeps its step with a warning. Refuses with code exists when the file is there (--force replaces it), and no_steps when there is nothing to write.
18
- - `rehearse stage [--base] [--head] [--port] [--announce <file>] [--announce-from changesets] [--said <id>]…`: the stage on 127.0.0.1 (default port 4400): every scenario in Base, Head and Diff, with Works, Doesn't and a note (kept in .rehearse/tries.jsonl, schema try).
18
+ - `rehearse stage [--base] [--head] [--base-repository]… [--head-repository]… [--port] [--announce <file>] [--announce-from changesets] [--said <id>]…`: the stage on 127.0.0.1 (default port 4400): every scenario in Base, Head and Diff, with Works, Doesn't and a note (kept in .rehearse/tries.jsonl, schema try).
19
19
  - `rehearse stage --static <dir> [--base <ref>] [--json]`: writes the stage of the latest comparison of this checkout with the base (the newer of .rehearse/compare/latest.json and latest-partial.json; --base as compare was given it) into <dir> as plain files with relative addresses, for any static host, such as a pull request's preview, then exits (schema static). It runs nothing; Run, Compare, Send, Works and a piece's live canvas aren't there. For a public preview it turns local paths (the checkouts, the home folder, and any /home/<name>, /Users/<name>, /root or C:\Users\<name>, also JSON-escaped or percent-encoded) into {{checkout}} and ~, copies an input only when git tracks it unchanged, copies from .rehearse only what runs made, and copies anything but a PNG, JPEG, WebP or GIF as scrubbed plain text; a home with a space in its name can slip through, so read a copy made on your own machine before publishing it. --base matches a ref by name and a folder by path; the newer comparison is the one written later. Refuses with code no_comparison when there is no comparison of this checkout with the base it can read, and exists when <dir> holds files an earlier copy didn't write.
20
20
  - `rehearse open <scenario> [--json]`: the stage's address for a scenario (schema open), starting the stage if none runs.
21
21
  - `rehearse clean [--all]`: removes old base checkouts, runs and comparisons (schema clean).
@@ -34,7 +34,7 @@
34
34
  - same: as on the base. said: changed and said so (announced, or its own definition edited, unless it is a file scenario with contract: true; announced wins). unsaid: changed without saying so. new: not on the base. fails: fails on the head (failsOnBase: it fails on the base too, so not this change's doing).
35
35
  - Ids, times and opaque tokens are set aside before comparing; arrays keep their order unless a scenario says unordered; a comparison counts what it set aside.
36
36
  - A change announces what it expects to change in .rehearse/announce.yaml beside rehearse.yaml (schema announce): changes: [{scenario: <id or glob>, why: <one line>}].
37
- - The base's observations are cached by commit under .rehearse/cache, so each base commit runs once; scenarios that share services in a world are cached and run as a group; --fresh runs again.
37
+ - The base's observations are cached by commit (and by the commit of each other repository's copy) under .rehearse/cache, so each base commit runs once; scenarios that share services in a world are cached and run as a group; --fresh runs again.
38
38
 
39
39
  ## Schemas (schema/v1/)
40
40
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kurvball/rehearse",
3
- "version": "1.14.0",
3
+ "version": "1.16.0",
4
4
  "description": "Rehearse a change before it ships: bring the product up, sign in as named people, start from named worlds, and compare any scenario on the base and on the head.",
5
5
  "homepage": "https://rehearse.kurvball.ca/",
6
6
  "repository": {
@@ -83,7 +83,7 @@
83
83
  "docs:dev": "pnpm --filter rehearse-docs dev",
84
84
  "rehearse": "node dist/cli.js",
85
85
  "changeset": "changeset",
86
- "release:version": "changeset version && node scripts/changelog.ts && node docs/scripts/since.ts && prettier --write CHANGELOG.md package.json",
86
+ "release:version": "changeset version && node scripts/changelog.ts && node docs/scripts/since.ts && prettier --write CHANGELOG.md package.json docs/reference docs/src/content/docs",
87
87
  "release:publish": "node scripts/release.ts"
88
88
  }
89
89
  }
@@ -61,6 +61,23 @@
61
61
  }
62
62
  }
63
63
  },
64
+ "copy": {
65
+ "description": "A copy of one of the manifest's other repositories.",
66
+ "type": "object",
67
+ "required": ["path"],
68
+ "properties": {
69
+ "path": { "description": "The copy's folder, or the folder given as it is.", "type": "string" },
70
+ "ref": {
71
+ "description": "The ref it was asked for, or null for a folder given.",
72
+ "type": ["string", "null"]
73
+ },
74
+ "commit": { "description": "The commit it holds.", "type": ["string", "null"] },
75
+ "dirty": {
76
+ "description": "Whether it holds uncommitted changes to tracked files. A run with one is never cached.",
77
+ "type": "boolean"
78
+ }
79
+ }
80
+ },
64
81
  "checkout": {
65
82
  "type": "object",
66
83
  "required": ["path"],
@@ -80,6 +97,11 @@
80
97
  "dirty": {
81
98
  "description": "Whether it holds uncommitted changes. A dirty checkout is never cached.",
82
99
  "type": "boolean"
100
+ },
101
+ "repositories": {
102
+ "description": "The copy of each of the manifest's other repositories that its services ran in, by name: its folder, the ref asked for, its commit and whether it holds changes.",
103
+ "type": "object",
104
+ "additionalProperties": { "$ref": "#/$defs/copy" }
83
105
  }
84
106
  }
85
107
  },
@@ -40,6 +40,7 @@
40
40
  "prepare",
41
41
  "build",
42
42
  "service",
43
+ "key",
43
44
  "pieces",
44
45
  "flows",
45
46
  "calls",
@@ -50,7 +51,7 @@
50
51
  ]
51
52
  },
52
53
  "name": {
53
- "description": "The service's name in the manifest, for a service it wrote.",
54
+ "description": "The name it wrote in the manifest, for a service or a key.",
54
55
  "type": "string"
55
56
  },
56
57
  "from": {
@@ -138,6 +138,32 @@
138
138
  "type": "object",
139
139
  "propertyNames": { "$ref": "#/$defs/name" },
140
140
  "additionalProperties": { "$ref": "#/$defs/key" }
141
+ },
142
+ "repositories": {
143
+ "description": "Other repositories services run from, by name. Rehearse keeps a clone of each and runs a service in a fresh copy of the commit each side needs: its base, unless the change names another.",
144
+ "type": "object",
145
+ "propertyNames": { "$ref": "#/$defs/name" },
146
+ "additionalProperties": {
147
+ "type": "object",
148
+ "required": ["from"],
149
+ "properties": {
150
+ "from": {
151
+ "description": "Where to clone it from: a git address (https://, ssh://, git@host:path, file://) or a folder, relative to the manifest's folder.",
152
+ "type": "string",
153
+ "minLength": 1
154
+ },
155
+ "base": {
156
+ "description": "The branch, tag or commit a comparison's base runs, and what runs when nothing names another. Default: the branch the repository's HEAD named when Rehearse cloned it.",
157
+ "type": "string",
158
+ "minLength": 1
159
+ },
160
+ "prepare": {
161
+ "description": "Run once in each fresh copy, before a service comes up in it, as the manifest's prepare is in its own.",
162
+ "$ref": "#/$defs/command"
163
+ }
164
+ },
165
+ "additionalProperties": false
166
+ }
141
167
  }
142
168
  },
143
169
  "additionalProperties": false,
@@ -237,6 +263,10 @@
237
263
  "type": "object",
238
264
  "propertyNames": { "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" },
239
265
  "additionalProperties": { "$ref": "#/$defs/name" }
266
+ },
267
+ "repository": {
268
+ "description": "The repository, in the manifest's repositories, whose copy it runs in: up, cwd and {{checkout}} are that copy's. Default: the manifest's own.",
269
+ "$ref": "#/$defs/name"
240
270
  }
241
271
  },
242
272
  "additionalProperties": false
@@ -16,6 +16,10 @@ services:
16
16
  ready: { command: pnpm drive snapshot --json }
17
17
  down: pnpm drive stop
18
18
  drive: pnpm drive
19
+ billing:
20
+ repository: billing
21
+ up: pnpm serve --port {{port}}
22
+ port: auto
19
23
  signIn:
20
24
  command: node scripts/people.mjs --api {{api_url}}
21
25
  service: api
@@ -54,6 +58,10 @@ setAside:
54
58
  keys: ['^requestId$']
55
59
  keep: ['$.expiresAt']
56
60
  budget: { services: 1, checkouts: 3 }
61
+ repositories:
62
+ billing:
63
+ from: git@github.com:acme/billing-api.git
64
+ prepare: pnpm install --frozen-lockfile --offline
57
65
  keys:
58
66
  payments: op://Acme/Payments/test secret key
59
67
  carrier: { find: "The carrier's developer page, under Sandbox keys" }
@@ -50,6 +50,10 @@
50
50
  "type": "object",
51
51
  "additionalProperties": { "type": "string" }
52
52
  },
53
+ "repository": {
54
+ "description": "The repository, in the manifest's repositories, whose copy it runs in, or null for the manifest's own.",
55
+ "type": ["string", "null"]
56
+ },
53
57
  "standins": {
54
58
  "description": "The stand-ins that apply to it.",
55
59
  "type": "array",
@@ -63,6 +67,10 @@
63
67
  "required": ["checkout", "pid"],
64
68
  "properties": {
65
69
  "checkout": { "type": "string" },
70
+ "root": {
71
+ "description": "For a service with a repository, the copy of it it runs in.",
72
+ "type": "string"
73
+ },
66
74
  "url": { "type": ["string", "null"] },
67
75
  "port": { "type": ["integer", "null"] },
68
76
  "pid": { "type": "integer" },
@@ -130,6 +130,10 @@ Read `line`, then each entry of `scenarios`:
130
130
  `byChange` groups unannounced changes by what changed. `notRun` lists scenarios that couldn't run, and `base.ok: false`
131
131
  means the base didn't come up. The command exits 0 only when nothing fails on the head and nothing changed unsaid.
132
132
 
133
+ When the manifest has `repositories`, a service runs from a fresh copy of its own repository, at that repository's
134
+ `base`. If your change is in one of them, name it: `rehearse compare --head-repository api=<your branch or ./folder>`,
135
+ and `rehearse run '<id>' --repository api=<…>`. `checkout.repositories` says which commit of each ran.
136
+
133
137
  ## 5. Announce what you meant, before you push
134
138
 
135
139
  Announce every change you made on purpose, so a reviewer sees what you meant apart from what slipped. Before you push: