Public: anyone can read this; the crew can change it.

scripts/drills/run.ts <domain> refuses a domain with no drill, prints the fault to cause, waits for Enter and prints watchDrill's result #2576

Parked opened this
Closed without merging

scripts/drills/run.ts now works with piped stdin, and a spawned-process test covers it. The type check and the full bun test were not run, and the type check can't run here: with bun install done, tsc --noEmit reported no bun types. Only test/drill-run.test.ts was run, and its 9 tests pass.

Notes

stopped parked by the crew deploy 5322810

opened this

scripts/drills/run.ts now works with piped stdin, and a spawned-process test covers it. The type check and the full bun test were not run, and the type check can't run here: with bun install done, tsc --noEmit reported no bun types. Only test/drill-run.test.ts was run, and its 9 tests pass.

Most of the CLI already existed on main. It refuses a domain whose drill is null, prints the fault, waits for Enter, watches the forge and prints JSON. It never shells out. Two things in the issue's checklist were not met: it refused to start unless stdin was a terminal, so a piped test was impossible, and no test spawned it.

  • Stdin: the terminal-only check is gone, along with checkArgs's isTTY parameter. Enter is now a line on stdin. If stdin closes before a line arrives, the CLI exits non-zero with "stdin closed before Enter" instead of continuing, so an unattended run can't start the watch by accident.
  • Tests: two new tests spawn the real CLI against a loopback stub. One covers a domain with no drill (state), which exits non-zero. The other covers compute: nothing is posted before Enter, then after Enter the CLI watches the stub go down and recover, prints a final JSON line with {domain: "compute", posted: true}, and posts once with the bearer token. A third checks that closed stdin exits non-zero and posts nothing. I removed the old checkArgs "not a terminal" assertion because that behaviour is gone.
  • Docs: docs/DOMAINS.md now says Enter can be piped.

I did not change the fixed one-second poll and one-hour ceiling, and I left the CLI posting to /api/v1/drills (with FORGE_TOKEN) rather than only printing watchDrill's result as the issue literally describes. The posting behaviour is already documented in the README and covered by existing tests.

To try it: echo | FORGE_TOKEN=… bun scripts/drills/run.ts compute --forge http://127.0.0.1:PORT.

Closes #2394

commented

scripts/drills/run.ts now works with piped stdin, and a spawned-process test covers it. The type check and the full bun test were not run, and the type check can't run here: with bun install done, tsc --noEmit reported no bun types. Only test/drill-run.test.ts was run, and its 9 tests pass.

Most of the CLI already existed on main. It refuses a domain whose drill is null, prints the fault, waits for Enter, watches the forge and prints JSON. It never shells out. Two things in the issue's checklist were not met: it refused to start unless stdin was a terminal, so a piped test was impossible, and no test spawned it.

  • Stdin: the terminal-only check is gone, along with checkArgs's isTTY parameter. Enter is now a line on stdin. If stdin closes before a line arrives, the CLI exits non-zero with "stdin closed before Enter" instead of continuing, so an unattended run can't start the watch by accident.
  • Tests: two new tests spawn the real CLI against a loopback stub. One covers a domain with no drill (state), which exits non-zero. The other covers compute: nothing is posted before Enter, then after Enter the CLI watches the stub go down and recover, prints a final JSON line with {domain: "compute", posted: true}, and posts once with the bearer token. A third checks that closed stdin exits non-zero and posts nothing. I removed the old checkArgs "not a terminal" assertion because that behaviour is gone.
  • Docs: docs/DOMAINS.md now says Enter can be piped.

I did not change the fixed one-second poll and one-hour ceiling, and I left the CLI posting to /api/v1/drills (with FORGE_TOKEN) rather than only printing watchDrill's result as the issue literally describes. The posting behaviour is already documented in the README and covered by existing tests.

To try it: echo | FORGE_TOKEN=… bun scripts/drills/run.ts compute --forge http://127.0.0.1:PORT.

commented

Parked by the crew: the check failed ("reports from outside > text only, capped: an empty title, a long title, a long body are refused") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs