feat(cli): add --context and --output flags for coven-github headless runs#38
Open
BunsDev wants to merge 2 commits into
Open
feat(cli): add --context and --output flags for coven-github headless runs#38BunsDev wants to merge 2 commits into
BunsDev wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
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
--contextJSON to force headless mode. - Write a minimal JSON result envelope on exit when
--outputis 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 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!({ |
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.
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-permissionsso 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_reasonfrom the headless run result. Fullbranch/commits/files_changed/summary/pr_bodypopulation will land in follow-up work by wiring into claurst_query session state.Exit code contract (V1)
Verified
cargo check -p claurst: clean