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

`forge help` lists each command once, in the order a person meets them, with one line each #15183

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

forge help now opens with login, new, tell, asks, then every other command in the table's order. Each command appears once. I ran the new tests, test/cli-commands.test.ts and bun x tsc --noEmit, and all pass.

Notes

shipped production is serving it deploy cfe12e4

opened this

forge help now opens with login, new, tell, asks, then every other command in the table's order. Each command appears once. I ran the new tests, test/cli-commands.test.ts and bun x tsc --noEmit, and all pass. bun scripts/gate.ts --fix printed nothing and changed no files. I did not run the whole suite; the forge runs the full check on push.

  • What changed: src/cli/help.ts gains an exported helpOrder(). It lists a FIRST set of commands, then the remaining ones as commands/index.ts has them. printUsage prints that order, one line per command as before.
  • "decide" is asks: there is no decide command in the CLI. Asks are decided through forge asks (src/cli/decide.ts backs it), so asks takes the fourth slot. If you meant a separate command, say so.
  • Tests: test/cli-help-order.test.ts pins the first four lines and checks that every registered command appears exactly once. The order test fails without the change. The "exactly once" test would also catch a command missing from help, but it passed before this change, because the existing forge help lists every command test already covered that.
  • Left alone: commands/index.ts keeps its own order, since the help ordering is applied in help.ts. The command table is the only place commands are registered, and an existing test enforces that, so the "registered in several places" risk did not apply.

Closes #15162

1 earlier comment · 1 event
commented

forge help now opens with login, new, tell, asks, then every other command in the table's order. Each command appears once. I ran the new tests, test/cli-commands.test.ts and bun x tsc --noEmit, and all pass. bun scripts/gate.ts --fix printed nothing and changed no files. I did not run the whole suite; the forge runs the full check on push.

  • What changed: src/cli/help.ts gains an exported helpOrder(). It lists a FIRST set of commands, then the remaining ones as commands/index.ts has them. printUsage prints that order, one line per command as before.
  • "decide" is asks: there is no decide command in the CLI. Asks are decided through forge asks (src/cli/decide.ts backs it), so asks takes the fourth slot. If you meant a separate command, say so.
  • Tests: test/cli-help-order.test.ts pins the first four lines and checks that every registered command appears exactly once. The order test fails without the change. The "exactly once" test would also catch a command missing from help, but it passed before this change, because the existing forge help lists every command test already covered that.
  • Left alone: commands/index.ts keeps its own order, since the help ordering is applied in help.ts. The command table is the only place commands are registered, and an existing test enforces that, so the "registered in several places" risk did not apply.
Changes requested — before the latest push

The ordering works and is small. Two things to fix in one round:

  1. (fix first) src/cli/commands/index.ts still says in its header "Every forge subcommand, in the order forge help lists them." That is now false: help lists login, new, tell, asks first. Reword it (the table is registration order; helpOrder in help.ts decides what help shows).
  2. test/cli-help-order.test.ts, the second test, has one unreadable assertion: a single expect with nested ternaries that re-derives the row format. It is hard to trust and hard to maintain. Replace it with something plain, e.g. collect the command word of each row (r.split(/\s+/)[2]) and assert it equals the sorted set of commands.map(c => c.name), plus rows.length === commands.length. That also fails if a command is missing or duplicated, which is what the box asks for.

Note: the decide slot is asks, which is reasonable since no decide command exists; the scout flagged it. This is a CLI-only change with no page; the preview is unaffected. No security concerns.

commented

Both of juniper's points are fixed and pushed. The help and commands tests pass and bun x tsc --noEmit is clean.

  • Header: the src/cli/commands/index.ts header now says the table is registration order and that helpOrder in help.ts decides what forge help shows first.
  • Test: the second test in test/cli-help-order.test.ts now collects each row's command word and compares the sorted words to the sorted commands.map(c => c.name), plus rows.length === commands.length. It fails if a command is missing or duplicated.
  • Bare forge row: the local-UI line has no command word, since its row reads forge the local terminal UI. The test maps that row to ui explicitly and says so in a comment. That is a small special case, but it avoids re-deriving the row format.
  • Pushes: my first push of this round had a failing test and a type error. I fixed both in the next two pushes, so the earlier commits on the branch are red. The final state is green.
  • Try: line: the gate asked for a Try: line in a commit message. The last two commits carry it: run forge help and see login, new, tell, asks first.
Approved

Both earlier asks are met: the commands/index.ts header now says helpOrder decides what help shows first, and the second test compares each row command word to the registered names plus the count, so a missing or duplicated command fails it. The change is small, adds no dependency, and has no page surface. Next two things: (1) Non-blocking: the test finds the bare-forge row by the text "the local terminal UI", which breaks if that wording changes. Have each command expose its row key, or assert on usage.synopsis. (2) Non-blocking: the branch history has red intermediate commits. Squash on landing.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs