refactor(working-directory): move the workspace only through Host operations
Remove the model-facing working_directory tool and the cwd parameter of the
subagent tools, so only Host operations move a Session's directory. Every
change the service records carries `workspace: true`, and the workspace root
is the directory of the last marked change, or the original project. The
anchor field, the anchor list, relocate, inherit, and anchorsOf are gone;
get, ensure, set, and rootOf remain.
A change without the marker, recorded while the model could move the
directory, moves only the current directory, so stored Sessions keep the
root they had.
- worktree: create enters the checkout through set; exit returns the Session
to the source checkout of the recorded worktree that contains its directory,
and exit_worktree exposes it to the model.
- subagent: a child starts in the parent's workspace root or a Host-chosen
directory through set.
- SDK: the working-directory methods return { cwd } again and
getWorkspaceRoot / get_workspace_root are removed.
- Recorded sessions: the worktree scenario leaves through exit_worktree and
covers recovery from a removed worktree; the two scenarios that only drove
the removed tool are deleted; three compaction scenarios lower their tuned
context window by the removed tool-schema tokens.
This commit is contained in:
1 parent
5db7347a83
commit
ed30d274f1
308 files changed
+1062
-4371
No files matched your search
@@ -206,11 +206,6 @@ class Session:
|
||||
self.harness.start()
|
||||
return self.harness.client.get_working_directory(self.id)
|
||||
|
||||
def get_workspace_root(self) -> str:
|
||||
"""Read the workspace root the effective directory is in, recovering a missing directory first."""
|
||||
self.harness.start()
|
||||
return self.harness.client.get_workspace_root(self.id)
|
||||
|
||||
def set_working_directory(self, path: str) -> str:
|
||||
"""Change the effective directory while existing processes retain their own directories."""
|
||||
self.harness.start()
|
||||
|
||||
@@ -249,15 +249,6 @@ class HarnessClient:
|
||||
)
|
||||
return response.cwd
|
||||
|
||||
def get_workspace_root(self, session_id: str) -> str:
|
||||
"""Read the workspace root the effective directory is in, recovering a missing directory first."""
|
||||
response = self.request(
|
||||
"session/working-directory/get",
|
||||
{"sessionId": session_id},
|
||||
response_model=_WorkingDirectoryResponse,
|
||||
)
|
||||
return response.root
|
||||
|
||||
def set_working_directory(self, session_id: str, path: str) -> str:
|
||||
"""Enter an absolute or Session-relative directory without changing origin or permissions."""
|
||||
response = self.request(
|
||||
@@ -726,7 +717,6 @@ class _SessionPromptResponse(BaseModel):
|
||||
|
||||
class _WorkingDirectoryResponse(BaseModel):
|
||||
cwd: str
|
||||
root: str
|
||||
|
||||
|
||||
class _EmptyResponse(BaseModel):
|
||||
|
||||
Reference in new issue
Block a user