Skip to content

refactor(claude): PathResolver::new takes a required home argument - #208

Open
ecalifornica wants to merge 1 commit into
robert/config-codexfrom
robert/config-claude
Open

refactor(claude): PathResolver::new takes a required home argument#208
ecalifornica wants to merge 1 commit into
robert/config-codexfrom
robert/config-claude

Conversation

@ecalifornica

@ecalifornica ecalifornica commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Part of #185: the crate reads no environment variable, Config owns every read, and the caller supplies what the crate used to resolve itself.

Judgment calls:

  • read_conversation(path) stays quiet on damaged files. Context: a conversation file is a Claude Code session log (~/.claude/projects/**/*.jsonl), the reader tolerates unparseable lines, and by default it warns about the first 5. Verbose warnings cover every line and are an explicit opt-in via with_verbose_warnings(bool) or read_conversation_with(path, verbose_warnings). The flag is in this PR because $CLAUDE_CLI_DEBUG selects it, and this refactor moves every environment read out of the crate.
  • Verbose is presence-based: $CLAUDE_CLI_DEBUG set, whatever its value. This matches the deleted std::env::var(...).is_ok() check exactly. Config stores the raw Option<String>; providers::claude_verbose_warnings owns the presence-is-the-signal interpretation. The variable keeps its behavior for CLI users.
  • A missing home degrades by surface: providers::claude_resolver returns Option<PathResolver>, the harness bundle silently omits Claude, and the 6 commands that target Claude error through require_claude_resolver.
  • The chain-following machinery (session_chain, ChainIndex) is semantically untouched. Its share of the diff is the mechanical ? removals from the infallible accessors.

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

@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown

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

@ecalifornica
ecalifornica marked this pull request as ready for review August 17, 2026 17:06
@ecalifornica
ecalifornica requested a review from akesling August 17, 2026 17:06
Comment thread crates/path-cli/src/config.rs Outdated
/// field name matches its variable.
const CONFIG_ENV_VARS: &[&str] = &[
"APPDATA",
"CLAUDE_CLI_DEBUG",

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.

This will change when review feedback is addressed:
#191 (comment)

)

toolpath-claude reads no environment variable. The caller supplies the
home directory; the crate keeps the layout below it (`<home>/.claude`).

Library (breaking, 0.13.0):

- `PathResolver::new(home)` takes the home directory as a required
  argument. `ClaudeConvo::new(home)` and `ConvoIO::new(home)` take the
  same argument.
- Delete the `Default` impls on the three types, `with_home`, the
  private `dirs::home_dir` helper, and the `NoHomeDirectory` error
  variant.
- Keep `with_claude_dir` as the full override.
- The home directory is always present, so `home_dir()`, `claude_dir()`,
  `projects_dir()`, `history_file()`, `project_dir()`,
  `conversation_file()`, `ConvoIO::claude_dir_path()`, and
  `ConvoIO::conversation_exists()` return a value, not a `Result`.
  Callers inside the crate drop the dead error arms.
- Verbose parse warnings are a `bool` parameter.
  `ConversationReader::read_conversation_with(path, verbose_warnings)`
  takes it directly. `ConvoIO::with_verbose_warnings` and
  `ClaudeConvo::with_verbose_warnings` store it and pass it down.
  `ConversationReader::read_conversation(path)` warns about the first 5
  unparseable lines only.

path-cli:

- `providers::claude_resolver` returns `Option<PathResolver>`. `None`
  means `Config` carries no home directory, so Claude is out of reach.
- `harness_bundle` omits the Claude manager in that case.
- `providers::require_claude_resolver` reports "cannot determine the
  home directory" for the 6 commands that target Claude.
- `Config` reads `$CLAUDE_CLI_DEBUG`. `providers::claude_verbose_warnings`
  turns its presence into the flag every `ClaudeConvo` receives, so the
  variable keeps its behavior for CLI users.

Version bump per the release checklist: crate manifest, workspace
dependency, site/_data/crates.json, CHANGELOG.md.
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