Skip to content

refactor(core): thin the CLI — move parsing/resolution into ant-core, route all daemon calls through the client#155

Closed
Nic-dorman wants to merge 7 commits into
mainfrom
refactor/v2-189-cli-thinning
Closed

refactor(core): thin the CLI — move parsing/resolution into ant-core, route all daemon calls through the client#155
Nic-dorman wants to merge 7 commits into
mainfrom
refactor/v2-189-cli-thinning

Conversation

@Nic-dorman

@Nic-dorman Nic-dorman commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Five mechanical fixes from the CLI-architecture audit (the "CLI should be a thin adapter" contract in CLAUDE.md), one commit per finding:

Behavior notes

  • Parse/lookup error texts are preserved (No node found with service name '…', Expected KEY=VALUE, port-range messages near-identical).
  • Daemon-error surfacing for add/reset changes from Daemon returned error: {body} to HTTP request error: {body} (the shared daemon-client convention).
  • node add download progress moves stdout → stderr, consistent with the rest of the progress UI.

Testing

  • cargo test --workspace: 443 passed (new unit tests for PortRange::from_str, parse_env_vars, resolve_bootstrap_peers priority).
  • clippy -D warnings clean, fmt clean.
  • Live smoke against a running daemon (empty registry): name-miss and name-hit resolution for start/stop, reset --force --json no-op, add --json full round-trip with a stub binary (then dismissed), client-side parse failures for inverted port range and malformed --env — all outputs byte-compatible with the old CLI.

🤖 Generated with Claude Code

Nic and others added 7 commits July 23, 2026 09:19
… (V2-744)

Port-range parsing ("12000" / "12000-12004") lived in ant-cli while the
PortRange type lives in ant-core, so every frontend had to reimplement
it. Parse via the standard FromStr trait next to the type instead; the
CLI now just calls .parse().

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Every frontend passing env vars to AddNodeOpts needs the same KEY=VALUE
parsing the CLI hand-rolled; expose it as AddNodeOpts::parse_env_vars.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…(V2-742)

The explicit-peers > devnet-manifest > bootstrap_peers.toml priority
logic (with manifest-peer socket-addr filtering) lived in ant-cli, but
it's business logic every frontend needs. Move it to
config::resolve_bootstrap_peers; the no-source case is now a typed
Error::NoBootstrapPeers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ant node add / ant node reset hand-rolled reqwest POSTs against the
daemon while every other endpoint goes through
ant_core::node::daemon::client. Add client::add_node and client::reset
and use them from the CLI.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ant node start/stop --service-name read node_registry.json directly to
translate name -> ID even while the daemon (the registry's owner) is
running, so the daemon could mutate the registry between the CLI's read
and the API call. Add client::resolve_node_id_by_name, which resolves
through GET /nodes/status, and drop the CLI's direct registry read.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
CliProgress (node add, unicode bar to stdout) and CliUpdateProgress
(self-update, plain percent to stderr) were near-identical impls of the
same trait. Keep one CliProgress in ant-cli/src/progress.rs, writing to
stderr like the rest of the progress UI.

Also fixes: ant node add --json no longer interleaves download-progress
output with the JSON result (NoopProgress in JSON mode, matching
ant update).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Nic-dorman Nic-dorman changed the title CLI audit: thin the CLI per V2-189 findings #2/#3/#4/#7/#8/#9 refactor(core): thin the CLI — move parsing/resolution into ant-core, route all daemon calls through the client Jul 23, 2026
@Nic-dorman Nic-dorman closed this Jul 23, 2026
@Nic-dorman Nic-dorman reopened this Jul 23, 2026
@Nic-dorman Nic-dorman closed this Jul 23, 2026
@Nic-dorman
Nic-dorman deleted the refactor/v2-189-cli-thinning branch July 23, 2026 08:39
@Nic-dorman

Copy link
Copy Markdown
Contributor Author

Superseded by #157 — the head branch was renamed and GitHub detached this PR's head ref, closing it. All commits and discussion context live on in #157.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant