Skip to content

refactor(cli): simplify command composition - #2606

Open
codyhartsook wants to merge 6 commits into
kagent-dev:mainfrom
codyhartsook:api-v2-cli-pr3
Open

refactor(cli): simplify command composition#2606
codyhartsook wants to merge 6 commits into
kagent-dev:mainfrom
codyhartsook:api-v2-cli-pr3

Conversation

@codyhartsook

@codyhartsook codyhartsook commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Reduces cmd/kagent/main.go to a small entrypoint backed by a reusable root command
  • Flattens and colocates command constructors under a consistent internal command structure
  • Keeps root.go focused on composition while each command owns its Cobra wiring and flags
  • Centralizes connection flags, session setup, and output handling
  • Aligns CLI command composition with the agentregistry layout

The resulting boundary is intentionally small: Root() creates a fresh command tree, command packages own command-specific setup, and the shared connection package owns gRPC, TLS, and temporary port-forward setup. This removes package-level CLI flag state and keeps command behavior out of main.go.

tui-recording-pr.mp4

This is the third of three related CLI PRs and builds on #2559 and #2605. When reviewed as a stack, the changes unique to this PR are structural; the API v2 workflows and AgentInstance TUI behavior live in the first two PRs.

Related to #2366 and the K13 CLI cutover in docs/plans/api-v2-execution-plan.md.

Test plan

  • make -C go test
  • go test ./core/cli/...
  • make -C go lint
  • make -C go build
  • API v2 E2E suite against a refreshed local Kind cluster
  • CLI and AgentInstance TUI smoke tests against a local installation

@codyhartsook
codyhartsook requested a review from a team as a code owner August 27, 2026 20:45
@codyhartsook codyhartsook changed the title refactor(cli): align command composition with agentregistry refactor(cli): simplify command composition Aug 27, 2026
EItanya added a commit that referenced this pull request Aug 29, 2026
## Summary

- Adds API v2 CLI commands for AgentTemplate discovery and AgentInstance
lifecycle and invocation
- Adds typed AgentInstance and upstream A2A clients over the shared gRPC
connection
- Connects through configured gRPC or a temporary controller
port-forward, with optional TLS
- Removes the legacy client-side agent project workflow while retaining
`mcp`

Note that of the 64 files changed, 35 were removals from the legacy CLI
project workflow ; no server-side APIs or controllers are removed.

This is the first of three related CLI PRs:

1. [#2559](#2559) : API v2 CLI
foundation: template/instance discovery, create/delete,
invoke/streaming, JSON output, and quarantining legacy commands.
2. [#2605](#2605) : TUI: browse
AgentInstances, load history, and chat through the same A2A path as
invoke.
3. [#2606](#2606) : Cleanup:
simplify `main.go` and align the command structure with agentregistry.

Suspend and resume are deliberately not exposed by this CLI work.

Related to #2366 and the K13 CLI cutover in
`docs/plans/api-v2-execution-plan.md`.

## Test plan

- [x] `make -C go test`
- [x] `go test ./core/cli/...`
- [x] `make -C go lint`
- [x] `make -C go build`
- [x] AgentTemplate and AgentInstance CLI smoke test against a local
installation

---------

Signed-off-by: Cody Hartsook <cody.hartsook@solo.io>
Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Co-authored-by: Eitan Yarmush <eitan.yarmush@solo.io>
Signed-off-by: Cody Hartsook <cody.hartsook@solo.io>
Signed-off-by: Cody Hartsook <cody.hartsook@solo.io>
Signed-off-by: Cody Hartsook <cody.hartsook@solo.io>
Signed-off-by: Cody Hartsook <cody.hartsook@solo.io>
Signed-off-by: Cody Hartsook <cody.hartsook@solo.io>
Signed-off-by: Cody Hartsook <cody.hartsook@solo.io>

@EItanya EItanya left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package boundary seems inconsistent: some one-command areas (agenttemplate, envdoc) have subpackages, while root commands such as version, install, bug-report, and dashboard remain in commands. Can we use a clear convention here—e.g. subpackages only for actual command families—and flatten the one-off command packages?

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.

2 participants