@kurvball/rehearse 1.13.3 → 1.15.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 (82) hide show
  1. package/dist/cli.js +5 -0
  2. package/dist/commands/announce.js +2 -2
  3. package/dist/commands/clean.js +6 -3
  4. package/dist/commands/compare.js +6 -1
  5. package/dist/commands/drive.js +12 -3
  6. package/dist/commands/index.js +2 -0
  7. package/dist/commands/init.js +1 -1
  8. package/dist/commands/keys.d.ts +2 -0
  9. package/dist/commands/keys.js +67 -0
  10. package/dist/commands/run.js +8 -4
  11. package/dist/commands/services.d.ts +3 -0
  12. package/dist/commands/services.js +10 -1
  13. package/dist/commands/stage.js +18 -2
  14. package/dist/commands/up.js +11 -3
  15. package/dist/compare/compare.d.ts +2 -0
  16. package/dist/compare/compare.js +19 -10
  17. package/dist/detect/detect.js +4 -0
  18. package/dist/detect/index.d.ts +1 -0
  19. package/dist/detect/index.js +1 -0
  20. package/dist/detect/keys.d.ts +16 -0
  21. package/dist/detect/keys.js +141 -0
  22. package/dist/detect/write.d.ts +2 -0
  23. package/dist/detect/write.js +20 -1
  24. package/dist/drive/daemon.js +2 -1
  25. package/dist/drive/open.js +6 -1
  26. package/dist/errors.js +2 -1
  27. package/dist/git/checkout.d.ts +6 -0
  28. package/dist/git/checkout.js +28 -19
  29. package/dist/git/index.d.ts +3 -2
  30. package/dist/git/index.js +3 -2
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.js +1 -0
  33. package/dist/keys/index.d.ts +3 -0
  34. package/dist/keys/index.js +3 -0
  35. package/dist/keys/keys.d.ts +16 -0
  36. package/dist/keys/keys.js +139 -0
  37. package/dist/keys/report.d.ts +23 -0
  38. package/dist/keys/report.js +31 -0
  39. package/dist/keys/store.d.ts +7 -0
  40. package/dist/keys/store.js +133 -0
  41. package/dist/keys/tool.d.ts +11 -0
  42. package/dist/keys/tool.js +27 -0
  43. package/dist/kinds/flow/kind.js +2 -2
  44. package/dist/manifest/index.d.ts +1 -1
  45. package/dist/manifest/load.js +33 -0
  46. package/dist/manifest/types.d.ts +28 -0
  47. package/dist/repositories/copies.d.ts +16 -0
  48. package/dist/repositories/copies.js +132 -0
  49. package/dist/repositories/index.d.ts +1 -0
  50. package/dist/repositories/index.js +1 -0
  51. package/dist/run/cache.d.ts +2 -1
  52. package/dist/run/cache.js +3 -1
  53. package/dist/run/index.d.ts +1 -1
  54. package/dist/run/index.js +1 -0
  55. package/dist/run/observation.d.ts +4 -0
  56. package/dist/run/observation.js +5 -1
  57. package/dist/run/session.d.ts +3 -1
  58. package/dist/run/session.js +27 -13
  59. package/dist/schema.d.ts +1 -1
  60. package/dist/schema.js +1 -0
  61. package/dist/services/index.d.ts +2 -2
  62. package/dist/services/index.js +2 -2
  63. package/dist/services/registry.d.ts +1 -0
  64. package/dist/services/service.d.ts +4 -0
  65. package/dist/services/service.js +46 -14
  66. package/dist/stage/api.d.ts +2 -0
  67. package/dist/stage/api.js +4 -0
  68. package/dist/stage/http.js +2 -1
  69. package/dist/stage/sending.d.ts +2 -1
  70. package/dist/stage/sending.js +8 -2
  71. package/dist/stage/server.d.ts +2 -0
  72. package/dist/stage/server.js +14 -1
  73. package/llms.txt +7 -6
  74. package/package.json +2 -2
  75. package/schema/v1/common.schema.json +22 -0
  76. package/schema/v1/init.schema.json +2 -1
  77. package/schema/v1/keys.schema.json +51 -0
  78. package/schema/v1/manifest.schema.json +66 -0
  79. package/schema/v1/samples/keys.json +22 -0
  80. package/schema/v1/samples/manifest.yaml +12 -0
  81. package/schema/v1/services.schema.json +13 -0
  82. package/skill/rehearse/SKILL.md +8 -0
@@ -0,0 +1,51 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://rehearse.kurvball.ca/schema/v1/keys.schema.json",
4
+ "title": "Rehearse v1: rehearse keys --json",
5
+ "description": "The keys the manifest names: where each comes from, which services get it and as what, and with --check (or after keys add) whether it is there. Never a key's value. rehearse keys --check exits 1 when a key isn't there.",
6
+ "type": "object",
7
+ "required": ["v", "kept", "keys"],
8
+ "properties": {
9
+ "v": { "$ref": "common.schema.json#/$defs/v" },
10
+ "kept": {
11
+ "description": "This computer's key store, where a key with no from is kept: the Mac's keychain, the Secret Service or Credential Manager.",
12
+ "type": "string"
13
+ },
14
+ "keys": {
15
+ "type": "array",
16
+ "items": {
17
+ "type": "object",
18
+ "required": ["name", "from", "find", "services"],
19
+ "properties": {
20
+ "name": { "type": "string" },
21
+ "from": {
22
+ "description": "The password manager's reference it is read from, or null when it is kept on this computer.",
23
+ "type": ["string", "null"]
24
+ },
25
+ "find": {
26
+ "description": "Where a person finds the key to add it.",
27
+ "type": ["string", "null"]
28
+ },
29
+ "services": {
30
+ "description": "The services that get it, and the environment variable each gets it as.",
31
+ "type": "array",
32
+ "items": {
33
+ "type": "object",
34
+ "required": ["service", "env"],
35
+ "properties": { "service": { "type": "string" }, "env": { "type": "string" } }
36
+ }
37
+ },
38
+ "state": {
39
+ "description": "With --check: found; missing (not there, or empty); live (it, or its reference, says live or production); short (fewer than 8 characters); unreadable (the password manager or key store didn't answer).",
40
+ "type": "string",
41
+ "pattern": "^[a-z][a-z_]*$"
42
+ },
43
+ "says": {
44
+ "description": "With --check: what was found, and what to do, in plain words.",
45
+ "type": "string"
46
+ }
47
+ }
48
+ }
49
+ }
50
+ }
51
+ }
@@ -132,12 +132,68 @@
132
132
  }
133
133
  },
134
134
  "additionalProperties": false
135
+ },
136
+ "keys": {
137
+ "description": "The keys services need, by name: where each comes from, never its value. A key is given to a service's up as it starts, as the service's own keys say, and is never written or printed.",
138
+ "type": "object",
139
+ "propertyNames": { "$ref": "#/$defs/name" },
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
+ }
135
167
  }
136
168
  },
137
169
  "additionalProperties": false,
138
170
  "$defs": {
139
171
  "name": { "type": "string", "pattern": "^[A-Za-z_][A-Za-z0-9_-]*$" },
140
172
  "command": { "type": "string", "minLength": 1 },
173
+ "key": {
174
+ "description": "Where a key comes from: a password manager's reference such as op://Shop/Payments/test key, read through 1Password's op; or, with no from, this computer's own key store (the keychain on a Mac, the Secret Service on Linux, Credential Manager on Windows), under the key's name. A string is its from.",
175
+ "oneOf": [
176
+ { "type": "null" },
177
+ { "$ref": "#/$defs/keyFrom" },
178
+ {
179
+ "type": "object",
180
+ "properties": {
181
+ "from": { "$ref": "#/$defs/keyFrom" },
182
+ "find": {
183
+ "description": "Where a person finds the key to add it, such as the provider's page for test keys.",
184
+ "type": "string",
185
+ "minLength": 1
186
+ }
187
+ },
188
+ "additionalProperties": false
189
+ }
190
+ ]
191
+ },
192
+ "keyFrom": {
193
+ "description": "A password manager's reference to the key: op://<vault>/<item>/<field>.",
194
+ "type": "string",
195
+ "pattern": "^op://[^/]+/[^/]+/.+$"
196
+ },
141
197
  "env": {
142
198
  "type": "object",
143
199
  "propertyNames": { "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" },
@@ -201,6 +257,16 @@
201
257
  "drive": {
202
258
  "description": "The service's own driver for flows and rehearse drive, such as 'pnpm drive'. It takes the drive steps and answers in the drive result JSON (drive.schema.json).",
203
259
  "$ref": "#/$defs/command"
260
+ },
261
+ "keys": {
262
+ "description": "The keys its up is given as it starts: an environment variable's name, then the name of a key in the manifest's keys.",
263
+ "type": "object",
264
+ "propertyNames": { "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" },
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"
204
270
  }
205
271
  },
206
272
  "additionalProperties": false
@@ -0,0 +1,22 @@
1
+ {
2
+ "v": 1,
3
+ "kept": "the Secret Service",
4
+ "keys": [
5
+ {
6
+ "name": "payments",
7
+ "from": "op://Shop/Payments/test secret key",
8
+ "find": null,
9
+ "services": [{ "service": "api", "env": "PAYMENTS_KEY" }],
10
+ "state": "found",
11
+ "says": "It's there."
12
+ },
13
+ {
14
+ "name": "carrier",
15
+ "from": null,
16
+ "find": "The carrier's developer page, under Sandbox keys",
17
+ "services": [{ "service": "api", "env": "CARRIER_KEY" }],
18
+ "state": "missing",
19
+ "says": "It isn't kept on this computer: add it with `rehearse keys add carrier`. Where to find it: The carrier's developer page, under Sandbox keys"
20
+ }
21
+ ]
22
+ }
@@ -10,11 +10,16 @@ services:
10
10
  ready: http://127.0.0.1:{{port}}/health
11
11
  env: { NODE_ENV: test }
12
12
  isolate: { env: ACME_STATE_DIR }
13
+ keys: { PAYMENTS_KEY: payments, CARRIER_KEY: carrier }
13
14
  app:
14
15
  up: pnpm drive start --scenario {{world}}
15
16
  ready: { command: pnpm drive snapshot --json }
16
17
  down: pnpm drive stop
17
18
  drive: pnpm drive
19
+ billing:
20
+ repository: billing
21
+ up: pnpm serve --port {{port}}
22
+ port: auto
18
23
  signIn:
19
24
  command: node scripts/people.mjs --api {{api_url}}
20
25
  service: api
@@ -53,3 +58,10 @@ setAside:
53
58
  keys: ['^requestId$']
54
59
  keep: ['$.expiresAt']
55
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
65
+ keys:
66
+ payments: op://Acme/Payments/test secret key
67
+ carrier: { find: "The carrier's developer page, under Sandbox keys" }
@@ -45,6 +45,15 @@
45
45
  "description": "The service's own driver for flows and rehearse drive, when it has one.",
46
46
  "type": ["string", "null"]
47
47
  },
48
+ "keys": {
49
+ "description": "The keys its up is given as it starts: an environment variable's name, then the key's name in rehearse keys.",
50
+ "type": "object",
51
+ "additionalProperties": { "type": "string" }
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
+ },
48
57
  "standins": {
49
58
  "description": "The stand-ins that apply to it.",
50
59
  "type": "array",
@@ -58,6 +67,10 @@
58
67
  "required": ["checkout", "pid"],
59
68
  "properties": {
60
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
+ },
61
74
  "url": { "type": ["string", "null"] },
62
75
  "port": { "type": ["integer", "null"] },
63
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:
@@ -217,5 +221,9 @@ rehearse stage --static <dir> --json # the latest comparison's stage as plain
217
221
  ## Rules
218
222
 
219
223
  - Never print, log or commit a token from `rehearse people --json`. Rehearse scrubs them from what it keeps.
224
+ - Never ask for a key's value, and never pass one on a command line. When a service needs a key that isn't there
225
+ (`no_key`), `rehearse keys --check --json` says which; a person adds it with `rehearse keys add <key>`, or in the
226
+ password manager its `from` names. Rehearse refuses live-looking keys (`live_key`) and shows a key it gave as
227
+ `{{key:<name>}}`.
220
228
  - Run one comparison at a time: services, browsers and builds are heavy.
221
229
  - `rehearse down --all` and `rehearse drive stop` stop what you started.