Skip to content

feat(cli): complete agentflare work command (tasks 6-9) - #260

Merged
getappz merged 4 commits into
masterfrom
task/207
Jul 19, 2026
Merged

getappz merged 4 commits into
masterfrom
task/207

Conversation

@getappz

@getappz getappz commented Jul 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Implements item fix(mcp): server-derive artifact sender; default item(list) filter to identity (#75) #207 (Tasks 6-9 of the agentflare work plan, following on from Tasks 1-5 on feat/agentflare-work): extracts work.rs into pure, unit-tested helpers (build_prompt, parse_claude_reply, format_success_comment, failure_message, build_extra_args), wires Claude Code's --output-format json structured-output parsing (session id / cost capture), adds a --notify handoff hook, and adds two real integration tests against an isolated AgentflareMcp::for_test instance (new constructor).
  • Clears pre-existing cargo clippy --workspace --all-features -- -D warnings debt in agent-registry, flare-output, and flare-code (missing # Errors/# Panics docs, implicit_hasher, match_same_arms, needless_pass_by_value, cast_possible_truncation, doc_markdown, redundant_closure_for_method_calls) — unrelated to the work-command change but blocking the full workspace lint gate.

Test plan

  • cargo build --workspace --all-features
  • cargo clippy --workspace --all-features -- -D warnings (clean)
  • cargo fmt --all -- --check (clean)
  • cargo test --workspace (all green, incl. 12 new cli::work tests)

Summary by CodeRabbit

  • New Features
    • Added the work command to claim work items, run agents in dedicated worktrees, and report completion or failure.
    • Added support for agent-specific autonomous permissions, extra arguments, timeouts, turn limits, cost limits, and optional notifications.
    • Completion reports can include pull request, session, and cost details when available.
  • Bug Fixes
    • Agent failures now preserve and report captured error output, improving troubleshooting.
  • Documentation
    • Expanded documentation for configuration, state, detection, compression, validation, and API error behavior.

@coderabbitai

coderabbitai Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds the work CLI workflow for claiming, executing, and reporting backend work items. Agent execution now accepts autonomous arguments and captures stderr. The patch also updates compression ownership, MCP visibility, registry exports, documentation, lint allowances, and tests.

Changes

Agent execution and registry

Layer / File(s) Summary
Agent invocation and autonomous arguments
crates/agent-registry/..., src/agent_launch.rs, src/agents.rs
Agent-specific autonomous flags are exported, headless execution accepts extra arguments, and child stderr is captured alongside stdout.
MCP work-item access and isolated testing
src/mcp_server.rs, src/mcp_server/item.rs
Work-item handlers and backend/worktree helpers become crate-visible, with isolated test-server construction.
Work command orchestration and reporting
src/cli/work.rs, src/cli/mod.rs, src/cli/handoff.rs
The new command claims items, runs agents in worktrees, posts success or failure comments, releases failed claims, and optionally publishes handoffs.
Compression API ownership and size conversion
crates/flare-output/src/compress.rs, src/cli/optimize.rs
Compression borrows prompts, updates callers and tests, and uses checked compressed-size conversion.
Documentation and minor cleanup
crates/flare-code/..., crates/flare-output/...
Rustdoc error sections, fenced-block documentation, lint allowances, and a process-parent lookup simplification are added.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Operator
  participant WorkCommand
  participant MCPBackend
  participant AgentProcess
  Operator->>WorkCommand: invoke work target
  WorkCommand->>MCPBackend: claim item and obtain worktree
  WorkCommand->>AgentProcess: run headless agent with autonomous args
  AgentProcess-->>WorkCommand: result, stdout, stderr
  WorkCommand->>MCPBackend: mark done or release and comment
Loading

Possibly related PRs

Suggested labels: enhancement, rust

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: completing the agentflare work command tasks.
Description check ✅ Passed The summary and test plan are complete; only the reviewer notes section is missing, which is non-critical.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch task/207

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
crates/agent-registry/src/registry.rs (2)

319-329: 🧹 Nitpick | 🔵 Trivial

Operational note: bypass/YOLO flags run unattended, outside a container sandbox.

agentflare work launches these agents with permission-bypass flags (--dangerously-skip-permissions, --yolo) inside a plain git worktree, not a network/filesystem sandbox. Vendor guidance for all three agents explicitly recommends running bypass modes only inside containers/VMs with restricted network and no credentials loaded, given documented incidents of destructive rm -rf / credential-exfiltration outcomes. Worth considering container isolation (or at minimum a locked-down --allowedTools/--disallowedTools-style scope) for agentflare work's execution environment given it's unattended and autonomous by design.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/agent-registry/src/registry.rs` around lines 319 - 329, Update the
unattended agent execution flow that consumes autonomous_args so bypass modes
are not launched in an unrestricted plain worktree. Add container/VM isolation
with restricted network and credentials, or enforce an equivalent
allowed/disallowed tool scope for ClaudeCode, Codex, and GeminiCli before
launching autonomous work; preserve normal execution for agents without bypass
flags.

309-329: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Switch Codex to the current non-interactive permission flags

--full-auto is now a deprecated compatibility path in codex exec and emits a warning. Replace it with Codex’s explicit sandbox/approval flags or a saved profile so this registry entry doesn’t depend on a legacy switch that may disappear.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/agent-registry/src/registry.rs` around lines 309 - 329, Update the
Codex branch in autonomous_args to replace the deprecated --full-auto switch
with Codex’s current explicit non-interactive sandbox and approval flags, or the
established saved-profile option. Keep the existing behavior for ClaudeCode,
GeminiCli, and agents without known bypass flags unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@crates/agent-registry/src/registry.rs`:
- Around line 319-329: Update the unattended agent execution flow that consumes
autonomous_args so bypass modes are not launched in an unrestricted plain
worktree. Add container/VM isolation with restricted network and credentials, or
enforce an equivalent allowed/disallowed tool scope for ClaudeCode, Codex, and
GeminiCli before launching autonomous work; preserve normal execution for agents
without bypass flags.
- Around line 309-329: Update the Codex branch in autonomous_args to replace the
deprecated --full-auto switch with Codex’s current explicit non-interactive
sandbox and approval flags, or the established saved-profile option. Keep the
existing behavior for ClaudeCode, GeminiCli, and agents without known bypass
flags unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 84f2ca2f-fb54-48fa-a037-e1e6447c02ee

📥 Commits

Reviewing files that changed from the base of the PR and between 3e2c400 and bc39b16.

📒 Files selected for processing (17)
  • crates/agent-registry/src/detect.rs
  • crates/agent-registry/src/lib.rs
  • crates/agent-registry/src/registry.rs
  • crates/flare-code/src/config.rs
  • crates/flare-code/src/detect.rs
  • crates/flare-code/src/state.rs
  • crates/flare-output/src/compress.rs
  • crates/flare-output/src/llm.rs
  • crates/flare-output/src/validate.rs
  • src/agent_launch.rs
  • src/agents.rs
  • src/cli/handoff.rs
  • src/cli/mod.rs
  • src/cli/optimize.rs
  • src/cli/work.rs
  • src/mcp_server.rs
  • src/mcp_server/item.rs

@getappz
getappz merged commit 3a1f3aa into master Jul 19, 2026
18 checks passed
@getappz
getappz deleted the task/207 branch July 19, 2026 10:24
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