fix(cli): correct top-level help contracts - #784
Conversation
独立窄审 · PR #784 (Draft)Verdict: CLEAN — no BLOCKER, no MAJOR, no MINOR. Reviewer: 通信IM马 (independent, read-only). Extracted PR tree via Context: PR #776 was merged on an unfixed head, so current main correctly advertised a non-existent Provenance
Item-by-item① 2-file denominator + no product expansion — CONFIRMEDFiles changed:
No function bodies changed. No new command added. No dispatcher changed. Pure documentation-of-existing-implementation. ② 3 new help lines match the actual command parsers on main — CONFIRMEDI read each real implementation on
function configShowCommand() {
...
const sub = args[1];
if (sub === "path") {
console.log(`\n ${configPath}`);
} else if (sub === "json") {
console.log(`\n${JSON.stringify(gc, null, 2)}`);
} else {
console.log(`\n Subcommands:`);
console.log(` anet config Show config summary`);
console.log(` anet config path Print config file path`);
console.log(` anet config json Print raw JSON`);
}
}Dispatcher
async function batchCommand() {
const sub = args[1];
if (!sub || sub === "-h" || sub === "--help" || sub.startsWith("-")) {
console.log(`
anet batch <verb> <prefix> # batch lifecycle ops (issue #55)
Verbs:
start <prefix> stop <prefix> restart <prefix> cleanup <prefix> ... list
...`);
}
const validVerbs = ["start", "stop", "restart", "cleanup", "list"] as const;
...
}Verb-based command (start/stop/restart/cleanup/list). No
async function opencodeAuthLoginCommand(rawNode: string | undefined): Promise<void> {
const usage = "anet opencode auth-login <node> --provider <anthropic|openai>";
if (!rawNode) {
console.error(`[anet] usage: ${usage}`);
process.exit(1);
}
const commandOpts = parseOpts();
const provider = commandOpts.provider;
const preset = findOpencodePreset(provider);
if (!provider || provider === "true" || !preset) {
console.error(`[anet] auth-login requires --provider anthropic or --provider openai`);
process.exit(1);
}
...
}
③ new test is REAL subprocess (not source-string grep) — CONFIRMEDimport { spawnSync } from "child_process";
...
const CLI = join(import.meta.dir, "..", "bin", "cli.ts");
function realHelp(...args: string[]) {
const home = mkdtempSync(join(tmpdir(), "anet-top-help-home-"));
const cwd = mkdtempSync(join(tmpdir(), "anet-top-help-cwd-"));
try {
return spawnSync("bun", [CLI, ...args], {
cwd, env: { PATH: process.env.PATH ?? "", HOME: home },
encoding: "utf8", timeout: 15_000,
});
} finally {
rmSync(home, { recursive: true, force: true });
rmSync(cwd, { recursive: true, force: true });
}
}
This is behavior-verified: if the help text in ④ baseline 2/0/9 + named witnessed-red on config-text revert — CONFIRMEDBaseline test count: 2 tests inside
Expect count across both:
Baseline claim 2 tests / 0 failures / 9 expects matches ✓ Named witnessed-red on config revert:
Both positive and negative assertions in the same test → both directions covered (drift back to old vocab OR drop new vocab both red on named lines). Test 2 (provider required): If someone removes ⑤ test temp HOME/CWD cleanup, no side effect, no secret — CONFIRMED
Secret sweep across 2 changed files ( ⑥ current-main merge-tree — CLEAN
Additional observations (informational, not blocking)
Reviewer discipline (self)Applied Independent verifications:
No approve, no merge, no deploy. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 76e96df72e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| } | ||
|
|
||
| describe("top-level help matches the implemented command parsers", () => { |
There was a problem hiding this comment.
Check in a Docker harness and report for this suite
This new regression suite has no corresponding checked-in tests/testN-.../Dockerfile and run.sh, and the commit adds no docs/tests/report-testN.txt; therefore its claimed verification cannot be reproduced or audited through the repository's required isolated test workflow. Add the independent Docker suite and saved result alongside the test.
AGENTS.md reference: AGENTS.md:L7-L9
Useful? React with 👍 / 👎.
|
|
||
| Config & tokens: | ||
| anet config get|set <k> [v] Read/write node or global config | ||
| anet config [path|json] Show config summary, path, or raw JSON |
There was a problem hiding this comment.
Stop describing mixed config output as raw JSON
When a user follows this entry with anet config json, configShowCommand() first prints the human-readable heading, fields, and node count at lines 12593–12604 and only then appends JSON at line 12610. The resulting stream is not raw JSON and fails consumers such as anet config json | jq; either describe it as a summary with appended JSON or bypass the summary for the json form.
Useful? React with 👍 / 👎.
Why
PR #776 merged three top-level help entries that do not match the implemented parsers. The current main therefore advertises config get/set and batch , neither of which exists, and omits the required provider option for opencode auth-login.
Prior review finding: #776 (comment)
Fix
No new product command is introduced to make the old wording true.
Scope
Docker verification
oven/bun:1.3.14, isolated copy with dependencies installed:
The first container attempt stopped before tests because the minimal image lacked Python for node-pty; after adding python3/make/g++ the same test ran green. This is recorded as an environment setup failure, not a product failure.