ductor icon indicating copy to clipboard operation
ductor copied to clipboard

[Feature]: Allow sub-process cwd to be different from Ductor's working_dir

Open Aut0-Mat opened this issue 6 months ago • 1 comments

Problem or motivation

I'd like to run Ductor alongside another agent (Claude Code in interactive mode) that shares the same knowledge directory — an Obsidian vault hosting CLAUDE.md, .claude/skills/, .claude/rules/. For the CLI sub-process spawned by Ductor to natively discover those project-scoped instructions, it needs to be launched with cwd pointing into the vault.

The problem is that CLIConfig.working_dir today controls both the sub-process cwd and the ductor_home derivation (used for .env resolution, SHAREDMEMORY.md path, DUCTOR_HOME env var, Docker mount mapping). Setting working_dir to the vault path collapses ductor_home onto the vault too, breaking .env lookup and other internals.

Current workaround: a monkey-patch trampoline wrapper around ~/.local/bin/ductor that intercepts cwd at spawn time. It breaks on every pipx upgrade (the symlink gets rewritten to the original entrypoint).

This use case overlaps with #127 (topic→workdir mapping) but is more fundamental: even a single-topic setup needs this decoupling. Project pikiclaw (mentioned in #127 comments) uses a similar workspace-vs-repo isolation pattern.

Proposed solution

Conceptually: an optional second field on CLIConfig (e.g., cli_cwd) that, when set, controls only the sub-process cwd, while working_dir keeps controlling ductor_home derivation. When cli_cwd is None (default), behavior unchanged.

I'm not familiar enough with the codebase internals to propose a precise patch shape — would this kind of decoupling fit your architecture, and would you have a preferred way to expose it (CLI flag, config key, both)? Happy to contribute the PR with your guidance if the direction works for you.

Alternatives considered

  • Monkey-patch the entrypoint (current workaround): re-applied on every pipx upgrade, fragile.
  • Symlink the vault under working_dir: doesn't help because working_dir is still passed verbatim to the sub-process.
  • Fork Ductor: heavy maintenance cost, drifts from upstream.

Why this matters beyond my use case

Anyone running Ductor alongside another agent (Claude Code, Codex CLI standalone, IDE plugins) sharing a project root benefits from this. It also lays the groundwork for cleaner multi-tenant setups (one Ductor home, multiple project cwds reachable by symlink under the home) and removes the need for downstream monkey-patches that brick on pipx upgrade.

Before submitting

  • [x] I have searched existing issues and feature requests for duplicates.

Aut0-Mat avatar May 18 '26 16:05 Aut0-Mat

For visibility: this decoupling is also a likely prerequisite for #127 (per-topic workdir mapping). Today cli/base.py:177 ties ductor_home to working_dir, so any feature that varies working_dir (per-topic in #127's case, or globally to point into a vault in mine) will displace .env, SHAREDMEMORY.md, and DUCTOR_HOME derivation along with it. The cli_cwd field proposed here keeps that derivation stable while letting the sub-process cwd move independently — which seems like the building block #127 would want underneath.

No claim it's the only path, just flagging the overlap so you can scope both together if useful.

Aut0-Mat avatar May 18 '26 17:05 Aut0-Mat