Add approval-gated workspace file editing - #14
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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_fileruntime tool wired into the approval gate and transcript timeline (workspace_file_finishedevents 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") |
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.
Summary
Safety
Verification