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
Closed
refactor(core): thin the CLI — move parsing/resolution into ant-core, route all daemon calls through the client#155Nic-dorman wants to merge 7 commits into
Nic-dorman wants to merge 7 commits into
Conversation
… (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>
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Five mechanical fixes from the CLI-architecture audit (the "CLI should be a thin adapter" contract in CLAUDE.md), one commit per finding:
PortRangeparsing (audit docs: comprehensive API documentation for data, wallet, devnet, and library usage #7):impl FromStr for PortRangein ant-core next to the type; CLI uses.parse()instead of its ownparse_port_range.AddNodeOpts::parse_env_varsownsKEY=VALUEparsing; CLI helper removed.bootstrap_peers.tomlpriority (with manifest-peer filtering) moved toant_core::config::resolve_bootstrap_peers; no-source case is now typedError::NoBootstrapPeers.node add/node resetno longer hand-roll reqwest against the daemon — newdaemon::client::add_node/client::resetmatching every other endpoint.node start/stop --service-nameresolved the node ID by readingnode_registry.jsondirectly while the daemon (the registry owner) was running. Newclient::resolve_node_id_by_namegoes throughGET /nodes/status; the CLI no longer touches the registry file at all.ProgressReporterimpls (CliProgressin add.rs,CliUpdateProgressin update.rs) collapsed into oneprogress::CliProgresson stderr. Side fix:ant node add --jsonno longer interleaves download progress with the JSON result (NoopProgress in JSON mode, matchingant update).Behavior notes
No node found with service name '…',Expected KEY=VALUE, port-range messages near-identical).Daemon returned error: {body}toHTTP request error: {body}(the shared daemon-client convention).node adddownload progress moves stdout → stderr, consistent with the rest of the progress UI.Testing
cargo test --workspace: 443 passed (new unit tests forPortRange::from_str,parse_env_vars,resolve_bootstrap_peerspriority).-D warningsclean, fmt clean.reset --force --jsonno-op,add --jsonfull 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