Skip to content

feat(cli): p export claude takes --cwd behind the resume-remote feature - #247

Open
ecalifornica wants to merge 6 commits into
mainfrom
ecalifornica/export-claude-cwd
Open

feat(cli): p export claude takes --cwd behind the resume-remote feature#247
ecalifornica wants to merge 6 commits into
mainfrom
ecalifornica/export-claude-cwd

Conversation

@ecalifornica

@ecalifornica ecalifornica commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

scripts/resume-remote.sh ships a session to another host, and the session it ships must record the remote project directory as its cwd, so p export claude takes --cwd <dir>. The flag is behind a new cargo feature, resume-remote, off by default.

The rewrite is Conversation::reroot(dir), a new toolpath-claude method that sets project_path and every cwd the format carries, while message content, tool results, and session IDs are not touched.

clap validates the value (an absolute normalized POSIX path, which need not exist locally) at parse time, and --cwd conflicts with --project. The script builds with the feature, exports with --cwd <remote-dir>, and rewrites only the sessionId keys with sed.

Three commits: the library method, the flag, the script.

toolpath-claude 0.13.1, path-cli 0.19.0, toolpath-cli 0.19.0. Stacked on #246.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@ecalifornica ecalifornica self-assigned this Aug 27, 2026
@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown

🔍 Preview deployed: https://cc3904e0.toolpath.pages.dev

Comment thread crates/path-cli/src/cmd_export.rs Outdated
}

/// `run_claude` with no remote-session flag set.
fn run_claude_without_remote_session(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we should migrate to some form of config with builder or something so we don't have to have this telescoping wrapper and forcing all callers to think about remote-ness?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added the ClaudeArgs struct for the config, feels much better.

.stdout(predicate::str::contains("pathbase"));
}

#[cfg(feature = "resume-remote")]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can nest these tests under a module that you apply the flag to once.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

neat!

@akesling akesling assigned ecalifornica and unassigned akesling Aug 28, 2026
Base automatically changed from ecalifornica/script-no-overwrite to main August 28, 2026 19:10
.stdout(predicate::str::contains("pathbase"));
}

#[cfg(feature = "resume-remote")]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

neat!

Comment thread crates/path-cli/src/cmd_export.rs Outdated
}

/// `run_claude` with no remote-session flag set.
fn run_claude_without_remote_session(

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added the ClaudeArgs struct for the config, feels much better.

Comment thread crates/path-cli/src/cmd_export.rs Outdated
use std::collections::HashMap;
use toolpath::v1::{ArtifactChange, PathIdentity, Step, StepIdentity, StructuralChange};

pub(super) fn make_path_doc() -> toolpath::v1::Graph {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

dropped this visibility

`reroot(dir)` sets the directory everywhere the format carries it:
`project_path`, every entry's `cwd` that is present, and a top-level
`cwd` on a preamble line. Message content and tool results are not
touched.

toolpath-claude 0.13.1.
`--cwd <dir>` roots the session: the directory becomes the `cwd` of
every line that carries one, through `Conversation::reroot`. It must be
an absolute POSIX path in normalized form (no `.`, `..`, or empty
component; one trailing `/` is dropped) and does not have to exist on
this machine. It conflicts with `--project`. Message content and tool
results are not touched. The rewrite runs only when the flag is given;
clap validates the value at parse time.

The flag and its tests live in `cmd_export/remote_session.rs` and
compile only with the `resume-remote` cargo feature, off by default.
The feature keeps the flag out of the default binary: it serves
`scripts/resume-remote.sh`, which builds with the feature, and is not
a supported `path` surface. Without the feature, `p export claude
--help` shows no trace of the flag. The gate is `all(feature =
"resume-remote", not(target_os = "emscripten"))`: `p export claude`
bails on emscripten, so the feature has no effect on the wasm build
and the module carries no emscripten cfgs. Both states pass `cargo
test -p path-cli` and clippy with `-D warnings`.

path-cli 0.19.0; toolpath-cli 0.19.0 (lockstep bump of the shim).
The script builds path-cli with the `resume-remote` feature. Step 5
exports with `--cwd <remote-dir>`, checks the output carries the remote
project directory as its cwd, and rewrites only the sessionId keys to
the minted ID.
@ecalifornica
ecalifornica force-pushed the ecalifornica/export-claude-cwd branch from 2eb3f4c to 080f155 Compare August 28, 2026 22:58
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