Skip to content

Let headless claude runs write in their own Workspace - #1339

Open
eutialia wants to merge 1 commit into
TraderAlice:devfrom
eutialia:feat/headless-claude-accept-edits
Open

Let headless claude runs write in their own Workspace#1339
eutialia wants to merge 1 commit into
TraderAlice:devfrom
eutialia:feat/headless-claude-accept-edits

Conversation

@eutialia

@eutialia eutialia commented Sep 4, 2026

Copy link
Copy Markdown

Summary

  • Headless Claude runs (claude -p) pass --allowedTools covering only the Bash(alice*) prefixes, so every Write and Edit falls through to a permission prompt nobody can answer. Scheduled Issues that write a report, append to a watchlist, or update a map lose their output, and the session record shows each Write and Edit denied.
  • Add --permission-mode acceptEdits to the headless argv. File writes inside the Workspace are granted, Bash stays gated by the allowlist.
  • Alternatives rejected: --dangerously-skip-permissions also unlocks arbitrary Bash; auto and dontAsk still escalate to an unanswerable prompt in -p mode (checked on Claude Code 2.1.259); shipping a permissions block in the Workspace .claude/settings.local.json changes the settings contract Alice writes and would apply to interactive sessions.

Included increments

  • fix(workspaces): let headless claude runs write in their own Workspace (src/workspaces/adapters/claude.ts, ai-config.spec.ts)

Verification

  • npx tsc --noEmit (root, covers src/): clean
  • npx vitest run src/workspaces/adapters/ai-config.spec.ts: 105 passed
  • Real surface:
  • Problem evidence:
  • Not run: packaged Electron smoke. Residual risk: a headless run can write anywhere under its Workspace cwd without a prompt. It already could through the allowed Bash prefixes, so the boundary is unchanged.

Boundary touch

  • runtime (agent permissions for one adapter). No trading, auth, credentials, migrations, or packaging.

Non-goals

  • Write-class Bash stays denied, so git commit inside an Issue body still fails. Bash grants belong to the individual Workspace, not the adapter, so they are out of scope here.
  • No change to interactive Claude sessions or to other adapters.

--allowedTools covers Bash only, so Write/Edit fell through to the
permission prompt claude -p has nobody to answer. Headless Issues that
write a report, append to a watchlist, or update a map lost their
output and reported every Write/Edit call denied by the sandbox.

pi passes --approve and agy passes --dangerously-skip-permissions
under Docker; claude was the only adapter that could not persist.
acceptEdits grants file writes and leaves Bash gated, so the
allowlist keeps its meaning instead of being replaced by a blanket
bypass. Verified against Claude Code 2.1.237: auto and dontAsk are
both no-ops headless, they still escalate to an unanswerable prompt,
so acceptEdits is the only mode that works.

Write-class Bash stays denied, so git commit in an Issue body still
fails. Narrow Bash(git add:*) / Bash(git commit:*) prefixes are a
separate follow-up.
Copilot AI lite review requested due to automatic review settings September 4, 2026 07:10
@vercel

vercel Bot commented Sep 4, 2026

Copy link
Copy Markdown

@eutialia is attempting to deploy a commit to the luokerenx4's Team Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI 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.

🔵 Needs a closer look

It changes runtime permission behavior for a headless agent process and depends on external Claude Code flag semantics/compatibility that can’t be fully validated from the diff alone.

Pull request overview

Enables non-interactive Claude Code (claude -p) runs to successfully perform file Write/Edit operations within a Workspace by explicitly setting a headless-specific permission mode, preventing tool calls from falling through to an unanswerable prompt during scheduled/automated runs.

Changes:

  • Add a headless-only --permission-mode acceptEdits flag to the Claude adapter’s headless argv.
  • Update the headless argv composition test to assert the new flag is present in the expected position.
File summaries
File Description
src/workspaces/adapters/claude.ts Adds a dedicated headless permission mode constant and passes --permission-mode acceptEdits for claude -p runs.
src/workspaces/adapters/ai-config.spec.ts Updates the composeHeadlessCommand expectation for Claude to include the new permission-mode flag.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@luokerenx4

Copy link
Copy Markdown
Contributor

claude code usually has this kind of strange actions. Thanks for your PR . I will merge it after 0.91.0 launch.

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.

3 participants