Skip to content

Add agent edit and apply commands#35

Merged
Furisto merged 1 commit into
mainfrom
CON-128
Jun 16, 2025
Merged

Add agent edit and apply commands#35
Furisto merged 1 commit into
mainfrom
CON-128

Conversation

@Furisto
Copy link
Copy Markdown
Owner

@Furisto Furisto commented Jun 16, 2025

  • Add agent edit command for interactive YAML-based agent configuration editing using $EDITOR
  • Add agent apply command for declarative agent management from YAML files
  • Improve model name resolution and error handling in agent get/list commands
  • Support both create and update operations in apply command based on ID presence
  • Follow kubectl-style workflow for better DevOps integration and automation

Summary by CodeRabbit

  • New Features

    • Added CLI command: agent apply — reads an agent spec from YAML to create or update agents with validation and clear feedback.
    • Added CLI command: agent edit — opens your editor for interactive YAML-based editing with change detection and selective updates.
  • Improvements

    • Agent display now shows the model name directly and defaults to “none” when no model is set.
    • More robust agent get/list behavior by only fetching model details when available, reducing unnecessary errors.

- Add `agent edit` command for interactive YAML-based agent configuration editing using $EDITOR
- Add `agent apply` command for declarative agent management from YAML files
- Improve model name resolution and error handling in agent get/list commands
- Support both create and update operations in apply command based on ID presence
- Follow kubectl-style workflow for better DevOps integration and automation
@linear
Copy link
Copy Markdown

linear Bot commented Jun 16, 2025

@Furisto Furisto merged commit 2a805cd into main Jun 16, 2025
@Furisto
Copy link
Copy Markdown
Owner Author

Furisto commented Sep 20, 2025

@coderabbitai Review this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Sep 20, 2025

@Furisto I'll review this PR for you. Let me examine the changes and provide comprehensive feedback on the implementation of the agent edit and apply commands.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Sep 20, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds two new CLI subcommands: agent edit (interactive YAML edit) and agent apply (apply YAML spec). Updates ConvertAgentToDisplay to accept a model name string. Adjusts agent get/list to resolve and pass model names conditionally based on ModelId. Wires new commands into the agent root command.

Changes

Cohort / File(s) Summary of Changes
CLI wiring and display conversion
frontend/cli/cmd/agent.go
Added NewAgentEditCmd and NewAgentApplyCmd to root agent command. Updated ConvertAgentToDisplay(agent, modelName string) signature and defaulted empty modelName to "none".
Apply from YAML spec
frontend/cli/cmd/agent_apply.go
New agent apply command. Added AgentSpec type. Reads YAML, validates fields, resolves model by name, creates agent when ID absent, selectively updates when ID present. Error and success output paths added.
Interactive edit
frontend/cli/cmd/agent_edit.go
New agent edit command. Added AgentEditSpec type. Fetches agent and model, opens temp YAML in editor, parses and validates, computes field diffs, resolves model by name, performs selective update.
Get flow model resolution
frontend/cli/cmd/agent_get.go
Conditionally fetches model only when ModelId present. Extracts modelName and passes it to ConvertAgentToDisplay. Adjusted error handling for conditional fetch.
List flow display input
frontend/cli/cmd/agent_list.go
Passes only model name string to ConvertAgentToDisplay instead of full model object.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant C as CLI (agent apply)
  participant API as API Server

  U->>C: agent apply --file spec.yaml
  C->>C: Parse YAML -> AgentSpec
  alt ID missing (create)
    C->>API: Resolve Model by name (optional)
    API-->>C: ModelId
    C->>API: CreateAgent(Name, Desc, Instructions, ModelId)
    API-->>C: Agent(ID, ...)
    C-->>U: Created agent with ID
  else ID present (update)
    C->>API: GetAgent(ID)
    API-->>C: Agent(current fields)
    C->>API: Resolve Model by name (optional)
    API-->>C: ModelId
    C->>C: Compute changed fields
    C->>API: UpdateAgent(ID, changed fields)
    API-->>C: Updated agent
    C-->>U: Updated agent
  end
Loading
sequenceDiagram
  autonumber
  actor U as User
  participant C as CLI (agent edit)
  participant API as API Server
  participant E as Editor

  U->>C: agent edit <id|name>
  C->>API: Resolve Agent (+Model name if ModelId)
  API-->>C: Agent + ModelName?
  C->>E: Open temp YAML spec
  U->>E: Edit and save
  E-->>C: Edited YAML
  C->>C: Parse, validate, diff vs current
  alt No changes
    C-->>U: No changes detected
  else Changes present
    C->>API: Resolve Model by name (if changed)
    API-->>C: ModelId
    C->>API: UpdateAgent(ID, changed fields)
    API-->>C: Updated agent
    C-->>U: Edit applied
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch CON-128

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 043b993 and 8470631.

📒 Files selected for processing (5)
  • frontend/cli/cmd/agent.go (2 hunks)
  • frontend/cli/cmd/agent_apply.go (1 hunks)
  • frontend/cli/cmd/agent_edit.go (1 hunks)
  • frontend/cli/cmd/agent_get.go (1 hunks)
  • frontend/cli/cmd/agent_list.go (1 hunks)

Comment @coderabbitai help to get the list of available commands and usage tips.

@Furisto Furisto deleted the CON-128 branch December 1, 2025 10:52
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