Skip to content

Add --add-dir / for edit tool in copilot engine (workaround for GitHub/copilot-cli#67)#1805

Merged
pelikhan merged 2 commits into
mainfrom
copilot/add-dir-arguments-for-edit-tool
Oct 16, 2025
Merged

Add --add-dir / for edit tool in copilot engine (workaround for GitHub/copilot-cli#67)#1805
pelikhan merged 2 commits into
mainfrom
copilot/add-dir-arguments-for-edit-tool

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 16, 2025

Problem

When using the edit tool with the copilot engine, write operations fail for files outside the /tmp/gh-aw/ directory due to a limitation in copilot-cli. The copilot-cli restricts write operations to directories explicitly specified via --add-dir arguments.

This is a known issue tracked in github/copilot-cli#67.

Solution

This PR adds --add-dir / to the copilot CLI arguments when the edit tool is enabled, allowing write access to all paths in the filesystem.

Implementation

The change is made in copilot_engine.go in the GetExecutionSteps method:

// Add --add-dir / when edit tool is enabled to allow write on all paths
// Workaround for GitHub/copilot-cli issue 67: https://github.com/GitHub/copilot-cli/issues/67
if _, hasEdit := workflowData.Tools["edit"]; hasEdit {
    copilotArgs = append(copilotArgs, "--add-dir", "/")
}

The edit tool can be present in a workflow through:

  1. Explicit declaration: tools: { edit: } in the workflow frontmatter
  2. Automatic addition: When create-pull-request is configured in safe-outputs, the compiler automatically adds the edit tool

Generated Command Example

Before (edit tool fails for files outside /tmp/gh-aw/):

copilot --add-dir /tmp/gh-aw/ --log-level all --allow-tool write --prompt "..."

After (edit tool works for all paths):

copilot --add-dir /tmp/gh-aw/ --log-level all --allow-tool write --add-dir / --prompt "..."

Testing

  • ✅ Added comprehensive test coverage with 4 test cases
  • ✅ All existing tests pass (338 tests)
  • ✅ Manual verification with compiled workflows
  • ✅ Linter passes with no issues

Test Cases

  1. Edit tool present → --add-dir / is added
  2. Edit tool with other tools → --add-dir / is added
  3. No edit tool → --add-dir / is NOT added
  4. Empty tools → --add-dir / is NOT added

Affected Workflows

The following workflows in this repository now include the --add-dir / workaround (they use the edit tool either explicitly or via create-pull-request):

  • poem-bot.md
  • q.md
  • repo-tree-map.md
  • tidy.md
  • cli-version-checker.md
  • security-fix-pr.md
  • technical-doc-writer.md
  • unbloat-docs.md

References

Original prompt

When edit tool is enabled, the copilot agentic engine should add --add-dir / arguments to allow write on all paths. Add note that this is a workaround for GitHub/copilot-cli issue 67


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add workaround for edit tool enabling write permissions Add --add-dir / for edit tool in copilot engine (workaround for GitHub/copilot-cli#67) Oct 16, 2025
Copilot AI requested a review from pelikhan October 16, 2025 15:08
@pelikhan pelikhan marked this pull request as ready for review October 16, 2025 17:08
@pelikhan pelikhan merged commit 85c2e09 into main Oct 16, 2025
5 checks passed
@pelikhan pelikhan deleted the copilot/add-dir-arguments-for-edit-tool branch October 16, 2025 17:08
@github-actions
Copy link
Copy Markdown
Contributor

Agentic Changeset Generator triggered by this pull request

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