Skip to content

feat(cli): add --context and --output flags for coven-github headless runs#38

Merged
BunsDev merged 2 commits into
mainfrom
feat/headless-context-output
Jun 6, 2026
Merged

feat(cli): add --context and --output flags for coven-github headless runs#38
BunsDev merged 2 commits into
mainfrom
feat/headless-context-output

Conversation

@BunsDev
Copy link
Copy Markdown
Member

@BunsDev BunsDev commented Jun 3, 2026

Why

Part of the coven-github integration: enables coven-code to act as the execution backend for a GitHub App coding agent without requiring any interactive input.

What

--context <session-brief.json>

Loads a coven-github session brief at startup. The brief carries the GitHub task context (repo, issue body, familiar config, workspace root, installation token). Implies headless mode and --dangerously-skip-permissions so the familiar can edit files and run tests autonomously.

Brief schema (written by coven-github worker):

{
  "trigger": "issue_assigned",
  "repo": { "owner": "...", "name": "...", "clone_url": "...", "default_branch": "main" },
  "task": { "kind": "fix_issue", "issue_number": 42, "issue_title": "...", "issue_body": "..." },
  "familiar": { "id": "cody", "model": "anthropic/claude-sonnet-4-6", "skills": [...] },
  "workspace": { "root": "/tmp/task-abc123" },
  "auth": { "token": "<installation_access_token>" }
}

--output <result.json>

Writes a structured result envelope on exit. coven-github workers read this to decide whether to open a PR, post a clarifying comment, or retry.

Current implementation: writes status + exit_reason from the headless run result. Full branch/commits/files_changed/summary/pr_body population will land in follow-up work by wiring into claurst_query session state.

Exit code contract (V1)

0  — success
1  — agent failure (result.json written with exit_reason)
2  — infra error (retry-safe, per coven-github worker retry logic)
3  — needs clarification (agent posts comment, exits cleanly)

Verified

  • cargo check -p claurst: clean

Copilot AI review requested due to automatic review settings June 3, 2026 14:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds initial CLI surface area for coven-github headless execution by introducing --context (session brief JSON) and --output (result envelope JSON) so coven-code can be used as an execution backend without interactive input.

Changes:

  • Add --context <BRIEF_JSON> and --output <RESULT_JSON> flags to the CLI.
  • Parse the --context JSON to force headless mode.
  • Write a minimal JSON result envelope on exit when --output is provided.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 579 to +590
// Determine mode early (needed for auth error handling and permission handler selection).
let is_headless = cli.print || cli.prompt.is_some();
// --context implies full headless + skip-permissions + model/cwd override from brief.
let github_context = if let Some(ctx_path) = &cli.context {
let raw = std::fs::read_to_string(ctx_path)
.context("Failed to read --context brief JSON")?;
let brief: serde_json::Value = serde_json::from_str(&raw)
.context("Failed to parse --context brief JSON")?;
Some(brief)
} else {
None
};
let is_headless = cli.print || cli.prompt.is_some() || github_context.is_some();
Comment on lines +881 to +883
if let Err(e) = std::fs::write(output_path, serde_json::to_string_pretty(&envelope).unwrap_or_default()) {
eprintln!("[coven-github] warning: failed to write --output result: {e}");
}
Comment thread src-rust/crates/cli/src/main.rs Outdated
Comment on lines +870 to +872
let status = if headless_result.is_ok() { "success" } else { "failure" };
let exit_reason = if headless_result.is_err() { Some("infra_error") } else { None };
let envelope = serde_json::json!({
@BunsDev BunsDev merged commit 74ec78b into main Jun 6, 2026
BunsDev added a commit that referenced this pull request Jun 6, 2026
…nflicts

- TUI files: took main's trusted_command_path helpers over HEAD's hardcoded cmds
- app.rs: kept HistorySearch::default impl, took main's clipboard delegation
- cli/main.rs: took main (already has #27 + #38 fixes); fixed EffortLevel::from_str → ::parse
- All other Rust files: took main (formatting/reformatting only)

cargo check clean.
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