GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor(core): file tools use the environment of the path they resolved by kitlangton · Pull Request #64774 · anomalyco/opencode

Conversation

@kitlangton

@kitlangton kitlangton commented Nov 19, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

The file tools now ask the path they resolved where it lives, instead of assuming the session's one environment.
An environment is where files are read and commands run: the local disk, or a remote workspace. Today a session has exactly one, and every tool captures it when the tool is set up. This is groundwork for letting a single tool call reach a different machine than the session's own. Nothing can do that yet.

❌ Before

  1. A tool turns a path into a target: an absolute path plus what to ask permission for.
  2. It then reads and writes that path through the session's environment, which it captured at setup.
  3. So "which machine does this path live on" has no place to be answered. It is always "the session's".

✅ After

  1. A tool turns a path into a target, and the target carries its environment.
  2. read, edit, write and patch, and the services they write through, use the target's environment.
  3. Path resolution still hands every target the session's environment, so the answer is the same as before. It is now answered in one place.

🟰 Behavior change: none.

- environment = session's environment            (captured when the tool is set up)
- target      = resolve(path)
- environment.files.read(target.absolute)
+ target      = resolve(path)                    (target.environment = session's environment)
+ target.environment.files.read(target.absolute)

The live object on the target is a step, not the end shape. A target should stay a plain value that names where a file lives, and one filesystem should take that name and route to the right place, so call sites read files.read(place). That needs a list of environments to look the name up in, which does not exist yet. This PR does the part that is needed either way: no file tool assumes the session’s environment any more.

Not yet through the target. These still use the session's environment or the host directly. They are identical today and each needs the same treatment before a target can point anywhere else:

Still on the session or the host Where
Running the command the shell tool; only its working-directory check moved
Search grep, glob
Formatting after a write edit, write, patch
Finding nested AGENTS.md after a read read
A move between two environments patch assumes both ends share one
Code Mode's file reads its writes already go through the target
Image and video tools, MCP untouched

📊 Proof

The new test points every target at an in-memory environment, while a file with the same name sits on disk, then runs the real write, read, edit and patch tools.

Check Result
The in-memory file ends with the last edit ✅
The file on disk is untouched ✅
The diffs the tools report, and the permission preview, show the in-memory content ✅

The test fails without the change: pointing any one of three reads back at the session (the preview read in write, and the read after the write in edit and in patch) fails it, each on its own assertion.

👀 Read: packages/core/src/tool/plugin/patch.ts. Each pending update now keeps its target beside its content, so the write, the move and the formatting pass each use the right file’s environment. The formatting pass walks the same files in the same order as before. FileMutation and the read tool's filesystem service no longer depend on the environment, so their layers build from nothing. The rest is routine.

🔍 First step of the multi-machine plan · no user reports · no flag, because nothing behaves differently

Checks run

From packages/core:

  • bun typecheck: no type errors
  • bun test test/tool-target-environment.test.ts (new): 1 pass, 0 fail
  • tool-read 40 pass · tool-read-filesystem 42 pass · tool-edit 21 pass · tool-write 10 pass · tool-patch 43 pass
  • file-mutation 9 pass · file-access 7 pass · file-access-path 22 pass · session-instructions 8 pass · tool-execute 37 pass
  • tool-shell: 96 pass, 2 fail. The two (conditional substitutions respect once and respect always) fail the same way on dev without this change on the Mac they ran on, with wait: pid … is not a child of this shell.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
kitlangton added 2 commits November 18, 2026 16:53
@kitlangton
refactor(core): tools take files from the resolved target
0e19fce
@kitlangton
test(core): assert tool diffs come from the target's environment
426398e
@github-actions github-actions Bot added the contributor label Nov 19, 2026
@github-actions github-actions Bot mentioned this pull request Nov 19, 2026
📊 AI CLI 工具社区动态日报 2026-11-19 litang9/big_model_radar#726
Open
@kitlangton
kitlangton marked this pull request as ready for review November 19, 2026 04:05
opencodejr[bot]
opencodejr Bot reviewed Nov 19, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Looks sound. packages/core type-checks cleanly with tsc (the bun typecheck script needs a newer Bun than this machine has), and the read, write, edit, patch, file-mutation, file-access, session-instructions, tool-execute and shell tests all pass. The new target-environment test passes here and fails on dev, so it covers the change.

I checked the patch.ts formatting pass: de-duplicating the targets by path keeps the same files in the same order as walking the keys of updates, including moves and case-only renames.

Public API: unchanged. FileAccess.Target.environment and the new files argument on the ReadToolFileSystem methods are internal to packages/core.

No blocking concerns.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kitlangton
refactor(core): keep each pending patch update with its target
0968bf6
opencodejr[bot]
opencodejr Bot reviewed Nov 19, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The new commit looks sound. Formatting in patch.ts now loops over updates, which keeps the same files in the same order as dev, and each file goes through its own target's environment. I re-ran the patch tests and the target-environment test (44 pass, 0 fail), and packages/core type-checks cleanly with tsc. Public API: unchanged. No new concerns.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kitlangton
kitlangton merged commit 47fcf73 into dev Nov 19, 2026
14 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@kitlangton
kitlangton deleted the resolve-environment branch November 19, 2026 04:27
This was referenced Nov 19, 2026
refactor(core): read tool calls its filesystem functions directly #64795
Merged
refactor(core): Code Mode files use the environment of the path they resolved #64807
Merged
refactor(core): image and video tools use the environment of the path they resolved #64813
Merged
refactor(core): search runs in the environment of the path it resolved #64814
Merged
refactor(core): shell commands run in the environment of their working directory #64815
Merged
@github-actions github-actions Bot mentioned this pull request Nov 19, 2026
📊 AI CLI 工具社区动态日报 2026-11-19 96loveslife/big_model_radar#808
Open
@Edo771977 Edo771977 mentioned this pull request Nov 19, 2026
chore: merge upstream/dev into the fork Edo771977/opencode#93
Merged
@lidongze1002 lidongze1002 mentioned this pull request Nov 23, 2026
test(app): use browser conditions #64701
Open
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

contributor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@kitlangton
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.