Skip to content

Add approval-gated workspace file editing - #14

Merged
Chillsbro merged 1 commit into
mainfrom
feat/workspace-file-editing
Aug 13, 2026
Merged

Chillsbro merged 1 commit into
mainfrom
feat/workspace-file-editing

Conversation

@Chillsbro

Copy link
Copy Markdown
Owner

Summary

  • add a provider-independent write_workspace_file tool for creating and replacing ordinary workspace files
  • route every mutation through the existing approval gate and record successful writes as clickable session links
  • teach the runtime prompt and docs to use the controlled write path instead of leaving code only in chat

Safety

  • restrict writes to relative regular-file paths inside the selected workspace
  • reject .git, absolute paths, traversal, symlinks, non-files, content over 1 MiB, and concurrent file changes
  • use atomic create/replace behavior and preserve intervening user edits
  • treat Escape during approval as denial without touching disk

Verification

  • bun test --max-concurrency 1: 219 passed, 0 failed
  • bun run typecheck
  • bun run lint
  • bun run build

Copilot AI lite review requested due to automatic review settings August 13, 2026 03:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an approval-gated, provider-independent way for agents to create or fully replace ordinary files inside the selected workspace, ensuring all workspace mutations flow through the existing approval gate and are recorded as session events with clickable file links.

Changes:

  • Introduces a new src/workspace/ editor module (createWorkspaceEditor) with strict path containment, .git/symlink refusal, size limits, concurrent-change detection, and atomic create/replace semantics.
  • Adds the write_workspace_file runtime tool wired into the approval gate and transcript timeline (workspace_file_finished events rendered as file:// links).
  • Updates the runtime system prompt + docs and adds unit/integration/TUI tests covering approvals, safety checks, and timeline output.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/unit/workspace/workspaceEditor.test.ts Unit coverage for approval gating, unsafe path rejection, and concurrent-change fail-closed behavior.
tests/unit/transcript/buildTimelineItems.test.ts Verifies timeline items link to written workspace files.
tests/unit/runtime/createCodexAgent.test.ts Ensures tool server startup receives the new tool definition.
tests/tui/app.test.tsx Confirms workspace write approvals appear in the existing approval dialog UX.
tests/integration/workspace/workspaceFileEditing.test.ts End-to-end verification of runtime approvals + disk writes + timeline events.
src/workspace/types.ts Adds workspace editor types + maxWorkspaceFileBytes.
src/workspace/index.ts Exposes workspace editor public API surface.
src/workspace/createWorkspaceEditor.ts Implements validated, approval-gated, atomic create/replace for workspace files.
src/transcript/buildTimelineItems.ts Adds rendering for workspace_file_finished events with file links.
src/sessions/types/Session.ts Adds workspace_file_finished event + generalizes approval request typing.
src/runtime/tools/index.ts Exports the new createWriteWorkspaceFileTool.
src/runtime/tools/createWriteWorkspaceFileTool.ts Implements the write_workspace_file tool and publishes session events.
src/runtime/creating/systemPromptAppend.ts Instructs the agent to use write_workspace_file for workspace edits.
src/runtime/creating/startRuntimeAgent.ts Registers the new tool in the runtime agent tool list.
src/runtime/approvals/createApprovalGate.ts Updates approval gate types to use the generalized request type.
src/components/Approval/ApprovalDialog.tsx Updates dialog prop typing for generalized approval requests.
src/app/state/AppState.ts Updates app state typing for generalized approval requests.
README.md Documents approval-gated workspace file editing and safety constraints.
CONTEXT.md Documents the “Workspace editor” seam and how it’s surfaced via the tool.

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

Comment on lines +168 to +171
if (!stats) {
await mkdir(current);
stats = await lstat(current);
}
Comment on lines +35 to +38
content: z
.string()
.max(maxWorkspaceFileBytes)
.describe("Complete UTF-8 contents to write")
@Chillsbro
Chillsbro merged commit 1fee260 into main Aug 13, 2026
8 checks passed
@Chillsbro
Chillsbro deleted the feat/workspace-file-editing branch August 13, 2026 03:43
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