Skip to content

feat(opencode): give delegated children a persistent working folder without widening permissions #779

Open

Description

@agenteinstinct1-max

Problem

At dev-vibecoded commit 897e85177c03b0dfb8618e1f3cf09250a9cbebe6, a delegated task cannot select its own working folder. Relative file-tool paths and the system prompt use the instance/project directory even when independent child tasks should work in different folders.

A folder selection must change path resolution, not authorization. It must not reroot the instance or approval store, change the process cwd, or weaken restrictions inherited from an ancestor.

Required behavior

  • Add optional task.directory; resolve relative requests from the calling session's folder and inherit that folder when omitted.
  • Require an existing directory. Expand only ~. Canonicalize the selected folder, including symlinks/junctions, before recording it.
  • Persist the folder on the child session. Foreground, background and resumed execution use that record. Reject an explicit different folder on resume; legacy sessions without a selection retain their creation directory.
  • Resolve relative read, grep, glob, edit, write and apply_patch paths, and default search roots, from the session folder. Report the selected folder and the unchanged project directory separately in the prompt.
  • Keep external_directory checks anchored to the instance. Selecting an external folder adds no allow rule. Preserve ancestor denies and existing allowed external grants; isolate parents and siblings, including nested and ancestor-relative selections.
  • Use platform path rules: Windows drive-absolute and UNC paths are absolute; drive-relative (C:folder) and drive-rooted (\folder) requests are rejected rather than resolved from ambient process state. Compare Windows case spellings consistently.

Shell integration is a separate, unfinished acceptance item

The shell tool still needs a coordinated change to use the session folder for both its default cwd and the base of a relative workdir. Today both use the instance directory. An explicit absolute shell workdir remains subject to existing external-directory checks.

Do not describe file-tool support as completion of shell cwd support. Shell and permission-policy changes must be coordinated with their current owner rather than edited concurrently.

Verification required

  1. Real task/session and tool regressions for inheritance, sibling isolation, fixed-on-resume behavior, legacy rows, canonical paths and prompt reporting.
  2. Permission controls proving no new grant from selection, retained external allows, and no escape from ancestor denies.
  3. Linux execution plus actual Windows CI execution of drive/case/junction behavior. Platform-spelling simulations or Linux-skipped Windows tests are not Windows execution evidence.
  4. Package typecheck and the unchanged full package test command. Any failure must be compared with the same command and test-list prefix on the exact base before attributing it to pre-existing behavior; no assertion, timeout, test-list or isolation waiver.
  5. Preserve unrelated accepted changes when integrating the implementation.

An implementation may publish the file-tool portion as a draft while explicitly leaving the shell acceptance item unfinished. Such a partial PR should reference this issue without closing it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions