nukadoko 0.1.0 → 0.2.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 (147) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +291 -0
  3. data/README.ja.md +58 -5
  4. data/README.md +15 -3
  5. data/exe/nuka +8 -0
  6. data/lib/nukadoko/aria_snapshot.rb +1008 -0
  7. data/lib/nukadoko/aria_tree.rb +150 -0
  8. data/lib/nukadoko/base.rb +274 -0
  9. data/lib/nukadoko/check.rb +669 -22
  10. data/lib/nukadoko/claim_check.rb +177 -0
  11. data/lib/nukadoko/claim_check_run.rb +293 -0
  12. data/lib/nukadoko/claim_line.rb +381 -0
  13. data/lib/nukadoko/claim_rules.rb +519 -0
  14. data/lib/nukadoko/claims.rb +407 -30
  15. data/lib/nukadoko/cli.rb +802 -19
  16. data/lib/nukadoko/codes.json +942 -0
  17. data/lib/nukadoko/codes.rb +19 -0
  18. data/lib/nukadoko/command.rb +214 -12
  19. data/lib/nukadoko/criteria.rb +172 -0
  20. data/lib/nukadoko/definition.rb +33 -41
  21. data/lib/nukadoko/env_check.rb +90 -0
  22. data/lib/nukadoko/features.rb +80 -10
  23. data/lib/nukadoko/fixtures.rb +296 -10
  24. data/lib/nukadoko/http_recording.rb +68 -0
  25. data/lib/nukadoko/init.rb +130 -0
  26. data/lib/nukadoko/judge.rb +221 -0
  27. data/lib/nukadoko/judgment_file.rb +78 -0
  28. data/lib/nukadoko/judgments.rb +256 -0
  29. data/lib/nukadoko/literal.rb +129 -0
  30. data/lib/nukadoko/measured.rb +105 -0
  31. data/lib/nukadoko/order.rb +84 -0
  32. data/lib/nukadoko/parts.rb +42 -21
  33. data/lib/nukadoko/pattern.rb +11 -1
  34. data/lib/nukadoko/poll.rb +17 -6
  35. data/lib/nukadoko/program.rb +105 -17
  36. data/lib/nukadoko/project_fixtures.rb +17 -2
  37. data/lib/nukadoko/report_allure.rb +751 -0
  38. data/lib/nukadoko/report_messages.rb +167 -0
  39. data/lib/nukadoko/report_run.rb +169 -0
  40. data/lib/nukadoko/run.rb +865 -88
  41. data/lib/nukadoko/run_record.rb +532 -0
  42. data/lib/nukadoko/scaffold.rb +1015 -0
  43. data/lib/nukadoko/schema.rb +61 -4
  44. data/lib/nukadoko/secrets.rb +359 -0
  45. data/lib/nukadoko/selection.rb +163 -0
  46. data/lib/nukadoko/signature.rb +4 -1
  47. data/lib/nukadoko/skill.rb +36 -0
  48. data/lib/nukadoko/step.rb +62 -21
  49. data/lib/nukadoko/summary.rb +662 -0
  50. data/lib/nukadoko/table.rb +34 -2
  51. data/lib/nukadoko/text_fit.rb +179 -0
  52. data/lib/nukadoko/trace.rb +244 -0
  53. data/lib/nukadoko/trace_actions.rb +116 -0
  54. data/lib/nukadoko/tree_passes.rb +119 -0
  55. data/lib/nukadoko/verdict.rb +128 -0
  56. data/lib/nukadoko/version.rb +2 -1
  57. data/lib/nukadoko/vocabulary.rb +6 -0
  58. data/lib/nukadoko/walk.rb +305 -0
  59. data/lib/nukadoko/walk_files.rb +473 -0
  60. data/lib/nukadoko/walk_step.rb +149 -0
  61. data/lib/nukadoko.rb +36 -0
  62. data/llms.txt +296 -0
  63. data/sig/generated/nukadoko/aria_snapshot.rbs +331 -0
  64. data/sig/generated/nukadoko/aria_tree.rbs +142 -0
  65. data/sig/generated/nukadoko/base.rbs +136 -0
  66. data/sig/generated/nukadoko/check.rbs +255 -0
  67. data/sig/generated/nukadoko/claim_check.rbs +118 -0
  68. data/sig/generated/nukadoko/claim_check_run.rbs +88 -0
  69. data/sig/generated/nukadoko/claim_line.rbs +158 -0
  70. data/sig/generated/nukadoko/claim_rules.rbs +172 -0
  71. data/sig/generated/nukadoko/claims.rbs +165 -0
  72. data/sig/generated/nukadoko/cli.rbs +182 -0
  73. data/sig/generated/nukadoko/codes.rbs +16 -0
  74. data/sig/generated/nukadoko/command.rbs +109 -0
  75. data/sig/generated/nukadoko/criteria.rbs +83 -0
  76. data/sig/generated/nukadoko/definition.rbs +30 -0
  77. data/sig/generated/nukadoko/env_check.rbs +38 -0
  78. data/sig/generated/nukadoko/features.rbs +101 -0
  79. data/sig/generated/nukadoko/fixtures.rbs +152 -0
  80. data/sig/generated/nukadoko/http_recording.rbs +29 -0
  81. data/sig/generated/nukadoko/init.rbs +66 -0
  82. data/sig/generated/nukadoko/judge.rbs +64 -0
  83. data/sig/generated/nukadoko/judgment_file.rbs +39 -0
  84. data/sig/generated/nukadoko/judgments.rbs +120 -0
  85. data/sig/generated/nukadoko/literal.rbs +71 -0
  86. data/sig/generated/nukadoko/measured.rbs +42 -0
  87. data/sig/generated/nukadoko/order.rbs +54 -0
  88. data/sig/generated/nukadoko/parts.rbs +35 -0
  89. data/sig/generated/nukadoko/pattern.rbs +28 -0
  90. data/sig/generated/nukadoko/poll.rbs +40 -0
  91. data/sig/generated/nukadoko/program.rbs +101 -0
  92. data/sig/generated/nukadoko/project_fixtures.rbs +57 -0
  93. data/sig/generated/nukadoko/report_allure.rbs +268 -0
  94. data/sig/generated/nukadoko/report_messages.rbs +68 -0
  95. data/sig/generated/nukadoko/report_run.rbs +102 -0
  96. data/sig/generated/nukadoko/run.rbs +257 -0
  97. data/sig/generated/nukadoko/run_record.rbs +174 -0
  98. data/sig/generated/nukadoko/scaffold.rbs +328 -0
  99. data/sig/generated/nukadoko/schema.rbs +137 -0
  100. data/sig/generated/nukadoko/secrets.rbs +157 -0
  101. data/sig/generated/nukadoko/selection.rbs +73 -0
  102. data/sig/generated/nukadoko/signature.rbs +17 -0
  103. data/sig/generated/nukadoko/skill.rbs +20 -0
  104. data/sig/generated/nukadoko/step.rbs +115 -0
  105. data/sig/generated/nukadoko/summary.rbs +204 -0
  106. data/sig/generated/nukadoko/table.rbs +43 -0
  107. data/sig/generated/nukadoko/text_fit.rbs +70 -0
  108. data/sig/generated/nukadoko/trace.rbs +127 -0
  109. data/sig/generated/nukadoko/trace_actions.rbs +40 -0
  110. data/sig/generated/nukadoko/tree_passes.rbs +48 -0
  111. data/sig/generated/nukadoko/verdict.rbs +56 -0
  112. data/sig/generated/nukadoko/version.rbs +5 -0
  113. data/sig/generated/nukadoko/vocabulary.rbs +25 -0
  114. data/sig/generated/nukadoko/walk.rbs +139 -0
  115. data/sig/generated/nukadoko/walk_files.rbs +189 -0
  116. data/sig/generated/nukadoko/walk_step.rbs +50 -0
  117. data/sig/generated/nukadoko.rbs +15 -0
  118. data/sig/nukadoko.rbs +5 -48
  119. data/skills/nukadoko/SKILL.md +120 -0
  120. data/skills/nukadoko/references/checking-steps.md +200 -0
  121. data/skills/nukadoko/references/diagnosing.md +200 -0
  122. data/skills/nukadoko/references/done.md +99 -0
  123. data/skills/nukadoko/references/evidence.md +124 -0
  124. data/skills/nukadoko/references/examples/cli.md +230 -0
  125. data/skills/nukadoko/references/examples/http-api.md +339 -0
  126. data/skills/nukadoko/references/examples/workflow.md +173 -0
  127. data/skills/nukadoko/references/exploring.md +184 -0
  128. data/skills/nukadoko/references/fixtures.md +198 -0
  129. data/skills/nukadoko/references/from-prose.md +51 -0
  130. data/skills/nukadoko/references/judgments.md +95 -0
  131. data/skills/nukadoko/references/maintenance.md +97 -0
  132. data/skills/nukadoko/references/merge-risk.md +74 -0
  133. data/skills/nukadoko/references/parts.md +152 -0
  134. data/skills/nukadoko/references/perturbed-worlds.md +107 -0
  135. data/skills/nukadoko/references/program.md +200 -0
  136. data/skills/nukadoko/references/reviewing.md +200 -0
  137. data/skills/nukadoko/references/running.md +200 -0
  138. data/skills/nukadoko/references/scenario-rules.md +188 -0
  139. data/skills/nukadoko/references/states.md +66 -0
  140. data/skills/nukadoko/references/step-files.md +200 -0
  141. data/skills/nukadoko/references/verdicts.md +200 -0
  142. data/skills/nukadoko/references/writing-steps.md +200 -0
  143. data/skills/nukadoko/references/writing-the-feature.md +165 -0
  144. data/skills/nukadoko/scripts/claude-code-verdict-hook.mjs +99 -0
  145. data/skills/nukadoko/scripts/merge-risk.jq +56 -0
  146. data/skills/nukadoko-verification/SKILL.md +263 -0
  147. metadata +121 -1
@@ -0,0 +1,124 @@
1
+ # Adding your own evidence
2
+
3
+ The automatic evidence (screenshot, trace, `http.jsonl`, `page_events`,
4
+ and `observed`) never covers something application-specific: a DB row, a
5
+ file a child process wrote outside a scratch directory, or the whole of a
6
+ response body past the 16 KiB `http.jsonl` keeps. Reach for the `evidence` fixture instead
7
+ of `console.log`-ing it away or writing it to disk with no place on the
8
+ step record to point back at:
9
+
10
+ ```ts
11
+ async run({ evidence, request }, args) {
12
+ const res = await request.get("/orders");
13
+ await evidence.attach("orders.json", await res.body());
14
+ }
15
+ ```
16
+
17
+ A call through `page.request` or `context.request` is already part of the
18
+ automatic evidence above. It lands on `http.jsonl` with `via: "request"`,
19
+ the same way the `request` fixture does. In-page `fetch` and navigation
20
+ stay `via: "page"`.
21
+
22
+ A request the step's own code sends through Node's `fetch`, `node:http`,
23
+ or `node:https` is a line too, with `via` naming that API. Every line
24
+ but a page's keeps the request body and the response body as text, up to
25
+ 16 KiB each and redacted, and no line keeps headers. A body nukadoko
26
+ stopped reading (a `fetch` body past 32 KiB, or one still arriving when
27
+ the step ended, marked `incomplete`) has `bytes_read` instead of `bytes`: not the whole size.
28
+ A body that failed on its own (the server aborted it, the step destroyed
29
+ it) has `bytes_read` and an `error`, and a `node:http` response the step
30
+ never read is `{ "unread": "the step did not read the body" }`. A stream or
31
+ FormData body the step passes to `fetch` in its `init` is unread too: nukadoko
32
+ sends `fetch` exactly what the step passed. A request with no
33
+ response when the step ended has `status: 0` and an `error` that says so
34
+ and how long it had.
35
+ A `fetch` that an interceptor installed after nukadoko (msw, nock)
36
+ answers itself never reaches nukadoko, so it has no line; a mocked
37
+ `node:http` request still has one.
38
+
39
+ A step that calls a program's MCP server uses the SDK's own `Client`,
40
+ connected in a fixture, with its transport passed through `measureMcp`
41
+ (from `nukadoko`); nukadoko adds no client:
42
+
43
+ ```ts
44
+ await client.connect(measureMcp(new StreamableHTTPClientTransport(new URL("/mcp", baseURL))));
45
+ ```
46
+
47
+ Each request and notification a step sends through it is a line of the
48
+ step's `mcp.jsonl` (`evidence.mcp`, counted by `observed.mcp`): the
49
+ method, the tool, prompt, or resource, `params` and `result` kept like
50
+ a body, `is_error` (the tool reported an error), `error` (a JSON-RPC
51
+ error), `duration_ms`, or `unanswered`. The call carries the step's
52
+ trace context in `params._meta.traceparent`, and over HTTP to the world
53
+ in its header too, so the server's events for it are the step's
54
+ (`references/program.md`). An error answer is a result the step reads,
55
+ never a failure nukadoko decides. `nuka check` notes
56
+ `mcp-transport-unmeasured` for a transport written inside `connect(...)`,
57
+ which nothing can wrap: build it first.
58
+
59
+ A step that talks to the program over a WebSocket uses Node's global
60
+ `WebSocket`, usually kept in a scenario fixture; nukadoko adds no
61
+ client. Each socket's open and close, and each frame sent or received,
62
+ is a line of the step's `websocket.jsonl` (`evidence.websocket`, counted
63
+ by `observed.websocket`): `event`, `socket` (a number per socket, so two
64
+ people's sockets to one URL stay apart), `url`, `at`, and a text frame's
65
+ `data` kept like a body. A frame sent belongs to the step that sent it;
66
+ a frame received belongs to the step running when it arrived, so a Then
67
+ that waits for a broadcast holds the frames it waited for. When such a
68
+ step fails, read this file before putting the last message in the
69
+ error text. A socket from the `ws` package goes over `node:http` and is
70
+ not seen this way: what it carries is an `unmeasured` socket.
71
+
72
+ A request, a `runCommand` process, or an MCP call the step's code starts after its
73
+ record was written (a timer it left behind) is written beside that
74
+ record, marked `after_step_end`, never in the next step's files, and the
75
+ run summary names it on the step's `after-record` entry, with the file that holds the
76
+ requests (`http.jsonl`, which the record may not name). A request still
77
+ open when the run ends gets its line then. The record does not count it.
78
+
79
+ What nukadoko saw but cannot measure is in `observed.unmeasured`: a
80
+ process started through `node:child_process` instead of `runCommand`
81
+ (named by its program and argument count only, never its arguments or a
82
+ `NAME=value` word, however it ended), a
83
+ `Worker`, a connection the step opened or wrote to that carries no
84
+ recorded request (a database client, a pool opened before the step),
85
+ what a WebSocket from a library over `node:http` (the `ws` package) or a
86
+ CONNECT tunnel carried after its handshake, a UDP
87
+ datagram sent through `node:dgram`, a Chromium page's request to the world that went without a `traceparent` because the page's DevTools session failed, or a path the step wrote whose identity nukadoko could not read. Such an
88
+ entry says the record holds no evidence of what that action did. Start
89
+ the program with `runCommand`, or attach the evidence the action
90
+ produced. An empty list means nukadoko saw nothing it could not measure,
91
+ not that nothing happened: a Worker's own traffic, a native addon, and a
92
+ child process's own traffic are never seen.
93
+
94
+ `evidence.attach(name, body)` writes and lists the attachment on the step
95
+ record's `evidence.attachments` in one call. `evidence.path(name)` only
96
+ allocates a path, Playwright's own `outputPath()`, for a step that writes
97
+ with its own tool instead of handing `attach` a buffer directly; only a
98
+ path a step actually wrote to lands on the step record, so calling `path()`
99
+ without following through leaves nothing behind, on purpose. Calling
100
+ either twice with the same `name` keeps both files: it never overwrites
101
+ the first. A name that differs only by case counts as the same name, so
102
+ the second call is suffixed the same way (`Report.txt`, then
103
+ `report-2.txt`) and the two do not share one path. A harness file name is
104
+ refused with `ReservedEvidenceNameError`: `record.json`, `final.png`,
105
+ `trace.zip`, `http.jsonl`, `program-log.txt`, `program-log-late.txt`,
106
+ `events.jsonl`, `events-late.jsonl`, `events-read.jsonl`, `mcp.jsonl`, `judged` (a
107
+ claim step's `judged_view`), `world` under `nuka do`, and `process-<n>.stdout.txt`,
108
+ `process-<n>.stderr.txt`, `process-<n>.stdin.txt`, and
109
+ `process-<n>.json` (what a `runCommand` process printed and was given,
110
+ and the entry of one that started after the step ended), in any case.
111
+ Pick another name.
112
+
113
+ Compat glue uses `this.attach` instead, in cucumber-js's forms (a
114
+ `base64:` media type, `{ mediaType, fileName }`, a stream the step
115
+ awaits), and `this.link` takes URLs rather than a display name. Those land
116
+ on the step record's `declared` field, not on `evidence.attachments`.
117
+
118
+ Keep secrets out of whatever you hand `attach`. Record text loses a
119
+ loaded secret in the raw form, the percent-encoded form, and the
120
+ JSON-escaped form. A JSON number equal to a numeric secret stays a
121
+ number. The step record's own `name`/`file` strings are redacted like
122
+ every other field, but a file's own contents are not, since redacting
123
+ arbitrary bytes would corrupt them about as often as it would protect
124
+ them.
@@ -0,0 +1,230 @@
1
+ # Worked example: a command-line program
2
+
3
+ A finished project for a program run from the command line, built with
4
+ nukadoko 0.16.1 and rescaffolded with the releases after it (which added
5
+ `nuka scaffold --cwd` and then `--argv`, and moved its Thens to claims) on Node 24.22.0. Every output block below is copied
6
+ from a real run of that project, which is `examples/acceptance/cli/` in
7
+ the nukadoko repository; CI runs it. The rules it follows are in
8
+ `../scenario-rules.md`.
9
+
10
+ ## The ticket
11
+
12
+ `tally <file.csv> [--json]` sums amounts per category. The output is one
13
+ `category: total` line per category, sorted by name. `--json` prints the
14
+ same totals as one object. A file that cannot be read exits 2 with `tally:
15
+ cannot read <file>`. A line that is not `category,amount` exits 3 with
16
+ `tally: bad line: <line>`.
17
+
18
+ ## The feature
19
+
20
+ `features/tally.feature`, written before the first `nuka run`. Every
21
+ expected value comes from the ticket.
22
+
23
+ ```gherkin
24
+ Feature: tally sums amounts per category
25
+
26
+ Acceptance criteria (from the request):
27
+ - Given a CSV of category,amount lines, tally prints one "category: total" line per category, sorted by name
28
+ - --json prints the same totals as one JSON object
29
+ - A file that cannot be read is an error with exit code 2
30
+ - A line that is not category,amount is an error with exit code 3
31
+
32
+ Scenario: totals per category, sorted by name
33
+ Given a file "input.csv" with these lines
34
+ """
35
+ rent,100
36
+ food,3
37
+ food,2.5
38
+ """
39
+ When I run tally with "input.csv"
40
+ Then it exits with 0
41
+ And the output is
42
+ """
43
+ food: 5.5
44
+ rent: 100
45
+ """
46
+
47
+ Scenario: --json prints one object
48
+ Given a file "input.csv" with these lines
49
+ """
50
+ rent,100
51
+ food,3
52
+ """
53
+ When I run tally with "input.csv --json"
54
+ Then it exits with 0
55
+ And the output is
56
+ """
57
+ {"food":3,"rent":100}
58
+ """
59
+
60
+ Scenario: a file that cannot be read
61
+ Given an empty directory
62
+ When I run tally with "missing.csv"
63
+ Then it exits with 2
64
+ And the error says "tally: cannot read missing.csv"
65
+
66
+ Scenario: a malformed line
67
+ Given a file "input.csv" with these lines
68
+ """
69
+ rent,100
70
+ oops
71
+ """
72
+ When I run tally with "input.csv"
73
+ Then it exits with 3
74
+ And the error says "tally: bad line: oops"
75
+ ```
76
+
77
+ ## The steps
78
+
79
+ - `a-csv-file-with` (Given): writes the docstring to `{name}` in a new
80
+ `scratch.dir()` and returns `dir` and `bytes`.
81
+ - `an-empty-directory` (Given): returns a new `scratch.dir()` as `dir`.
82
+ - `run-tally` (When): `I run tally with {argv:string}`; reads `dir` from
83
+ either Given through `from` and runs `src/cli.ts` there with
84
+ `runCommand`. The scaffold wrote both `from` candidates, `cwd: dir`,
85
+ and the split of `argv` on whitespace (`--argv argv`).
86
+ - `exits-with`, `output-is`, `error-says` (Then): each reads one key of
87
+ `run-tally` through `from` and declares one claim on it, with no `run`.
88
+ `error-says` claims the first line of stderr (`view: "lines"`,
89
+ `at: "0"`).
90
+
91
+ Every step that runs is `mutates: false`: the Givens write only inside the
92
+ scenario's scratch directory, and `tally` writes nothing. A Then runs
93
+ nothing, so it has no `mutates` to declare.
94
+
95
+ `features/steps/run-tally.ts`. The scaffold wrote the imports, the `from`
96
+ entry, `cwd: dir`, the split of `argv`, and `returns`; the descriptions
97
+ and `mutates: false` are by hand (see "Decisions"):
98
+
99
+ ```ts
100
+ import { defineStep, runCommand, z } from "nukadoko";
101
+ import { resolve } from "node:path";
102
+ import aCsvFileWith from "./a-csv-file-with.ts";
103
+ import anEmptyDirectory from "./an-empty-directory.ts";
104
+
105
+ const cli = resolve("src/cli.ts");
106
+
107
+ export default defineStep({
108
+ description: "Run tally with these arguments in the directory an earlier step prepared",
109
+ pattern: "I run tally with {argv:string}",
110
+ args: z.object({
111
+ argv: z.string().describe("Arguments after `tally`, separated by spaces"),
112
+ dir: aCsvFileWith.returns.shape.dir,
113
+ }),
114
+ from: {
115
+ dir: [[aCsvFileWith, "dir"], [anEmptyDirectory, "dir"]],
116
+ },
117
+ returns: z.object({
118
+ exitCode: z.number().nullable().describe("The process exit code"),
119
+ stdout: z.string().describe("Everything the process wrote to stdout"),
120
+ stderr: z.string().describe("Everything the process wrote to stderr"),
121
+ }),
122
+ // Runs the program under test in a scratch directory a Given step made.
123
+ mutates: false,
124
+ async run({}, { argv, dir }) {
125
+ return await runCommand(process.execPath, [cli, ...argv.split(/\s+/).filter((part) => part !== "")], { cwd: dir });
126
+ },
127
+ });
128
+ ```
129
+
130
+ `features/steps/output-is.ts`. The scaffold wrote the import, the `from`
131
+ entry, the key for the docstring, and the claim with `view: "text"` and
132
+ its comment; the key's name `expected` and the descriptions are by hand:
133
+
134
+ ```ts
135
+ import { defineStep, z } from "nukadoko";
136
+ import runTally from "./run-tally.ts";
137
+
138
+ export default defineStep({
139
+ description: "stdout is exactly the docstring, ignoring a trailing newline",
140
+ pattern: "the output is",
141
+ args: z.object({
142
+ expected: z.string().describe("The expected stdout, verbatim"),
143
+ stdout: runTally.returns.shape.stdout,
144
+ }),
145
+ from: {
146
+ stdout: [runTally, "stdout"],
147
+ },
148
+ // The program ends its output with a newline that the feature line does not show.
149
+ claims: [{ actual: "stdout", view: "text", compare: "equal", expected: "expected" }],
150
+ });
151
+ ```
152
+
153
+ ## The commands, in order
154
+
155
+ A producer has to declare its key in `returns` before a consumer is
156
+ scaffolded `--from` it. Scaffolding `run-tally` while `a-csv-file-with`
157
+ was still a stub:
158
+
159
+ ```
160
+ $ npx nuka scaffold run-tally --pattern 'I run tally with {argv:string}' --command src/cli.ts --from a-csv-file-with.dir --argv argv
161
+ refused step-inputs-invalid - Refusing to scaffold: a-csv-file-with declares no returns, so it has no key to chain; declare returns with "dir" in features/steps/a-csv-file-with.ts
162
+ fix: Add returns: z.object({ dir: <its schema> }) to features/steps/a-csv-file-with.ts and return dir from its run().
163
+ do: nuka scaffold run-tally --pattern 'I run tally with {argv:string}' --command src/cli.ts --from a-csv-file-with.dir --argv argv
164
+ ```
165
+
166
+ Once both Givens returned `dir`, one command wrote the When step: each
167
+ `--from` for `dir` is one candidate producer, `--cwd dir` runs the
168
+ program in that directory instead of a new, empty one, and `--argv argv`
169
+ splits the capture on whitespace, so `"input.csv --json"` reaches the
170
+ program as two arguments:
171
+
172
+ ```
173
+ $ npx nuka scaffold run-tally --pattern 'I run tally with {argv:string}' --command src/cli.ts --from a-csv-file-with.dir --from an-empty-directory.dir --cwd dir --argv argv
174
+ features/steps/run-tally.ts
175
+ ```
176
+
177
+ Every `the output is` line in the feature carries a docstring, so the
178
+ Then step got a `docstring` key beside the chained `stdout`, and its claim
179
+ compares the two:
180
+
181
+ ```
182
+ $ npx nuka scaffold output-is --pattern 'the output is' --then --from run-tally.stdout
183
+ features/steps/output-is.ts
184
+ ```
185
+
186
+ A red run, with `rent: 101` in the docstring for the first scenario. The
187
+ first line of the message carries both values and where each came from:
188
+
189
+ ```
190
+ step 4/4 failed 0.0s the output is
191
+ claim broken: "food: 5.5\nrent: 100" (from:run-tally@16.stdout as text) equal "food: 5.5\nrent: 101" (sentence:expected); first difference at line 2: actual "rent: 100", expected "rent: 101"
192
+ record .nukadoko/runs/run-20261024-091044-63n9/steps/step-20261024-091044-kjjx
193
+ ```
194
+
195
+ The run that passed:
196
+
197
+ ```
198
+ $ npx nuka check
199
+ ok: no issues found
200
+ $ npx nuka run
201
+ ...
202
+ 4 scenarios: 4 passed, 0 failed (2s)
203
+ ```
204
+
205
+ Two probes, outside the feature, for the rules `nuka check` enforces. A
206
+ scenario with no Then (S2):
207
+
208
+ ```
209
+ warning scenario-without-then probe/no-then.feature:3 Scenario "a run with no claim" has no Then step, so it passes whenever its steps run without an error, and no step checks an outcome.
210
+ fix: Add a Then line that binds a claim step (defineStep with claims) and checks the outcome the scenario is for.
211
+ ```
212
+
213
+ The action under test written as a Given, with no Given before it (S10):
214
+
215
+ ```
216
+ error from-order-violation probe/given-run.feature:4 Step "run-tally"'s from.dir needs exactly one of its candidate producers ("a-csv-file-with", "an-empty-directory") to have already run earlier in this scenario, but none has: "a-csv-file-with" is never bound anywhere in this scenario; "an-empty-directory" is never bound anywhere in this scenario. This line would fail args validation with certainty
217
+ fix: Put a line that runs exactly one of steps "a-csv-file-with", "an-empty-directory" earlier in the scenario.
218
+ ```
219
+
220
+ ## Decisions
221
+
222
+ | Date | Decision | Chosen | Why | Became |
223
+ | --- | --- | --- | --- | --- |
224
+ | 2026-10-16 | How the input file reaches the program's working directory | the Given returns `dir`, the When reads it through `from` and runs there (`--cwd dir`) | each `scratch.dir()` call is a new directory, so the program has to run in the one the Given wrote to | Shapes: a program's input file |
225
+ | 2026-10-16 | One capture per argument, or one for all | `{argv:string}`, split on whitespace (`--argv argv` since 2026-10-18) | one When step serves every flag and the missing-file path | Shapes: arguments |
226
+ | 2026-10-16 | `mutates` on the `--command` step | `false`, with a comment | the scaffold writes the default `true`; `tally` writes nothing and runs in a scratch directory | SKILL.md "Before the first command" |
227
+ | 2026-10-24 | How a Then compares | one claim per Then, with no `run` | the claim record carries both values and where each came from, so no message has to be written by hand | S11 |
228
+ | 2026-10-16 | Does `--json` also claim the exit code | yes, `Then it exits with 0` | a program that crashed after printing would pass without it | S1 |
229
+ | 2026-10-16 | Does the output compare the trailing newline | no: `view: "text"` trims the end of stdout, and the description says so | the program ends its output with a newline that the docstring does not show | none |
230
+ | 2026-10-17 | Order of scaffolding | Givens first, then the When, then the Thens | `--from` refuses a producer that does not return the key yet | SKILL.md "The loop" |