Skip to content

fix(sleep): expand ~ in the configured Claude and Codex homes - #395

Open
Muhammad Abdullah Butt (1AbdullahButt) wants to merge 1 commit into
microsoft:mainfrom
1AbdullahButt:fix/sleep-home-tilde
Open

Muhammad Abdullah Butt (1AbdullahButt) wants to merge 1 commit into
microsoft:mainfrom
1AbdullahButt:fix/sleep-home-tilde

Conversation

@1AbdullahButt

Copy link
Copy Markdown
Contributor

Fixes #394

SleepConfig joined claude_home and codex_home into paths as given. Config files are not shell-expanded, so "claude_home": "~/.claude-work" was a relative path named ~:

  • transcripts_dir / history_path pointed at a directory that does not exist, so nothing was harvested.
  • skills_dir / managed_skill_path() put the adopted skill under ./~/..., where Claude Code never loads it.
  • state_dir moved to ./~/.skillopt-sleep, even for "~/.claude" (the default home).
  • codex_archived_sessions_dir had the same problem for codex_home.

--claude-home and --codex-home also called os.path.abspath without expanduser.

The fix adds a small _home_dir() helper that expands and absolutizes the home, and uses it in those properties. That is what pi_sessions_dir and cursor_projects_dir already do. The two CLI flags now call expanduser like --pi-home and --cursor-home. Absolute homes behave the same as before.

Tests

  • New tests/test_sleep_home_tilde.py covers ~ homes from a config.json, "~/.claude" keeping the default state dir, and the two CLI flags. All 3 tests fail on main and pass with this change.
  • python -m pytest -q tests -k "sleep or harvest or config or pi_ or cursor or codex" on Windows: 801 passed here and 798 on main. The same 18 tests fail on both; they are Windows-only failures that already occur on main.

This change was written with Claude Code.

🤖 Generated with Claude Code

Config files are not shell-expanded, so "claude_home": "~/.claude-work"
reached SleepConfig as a relative path named "~". transcripts_dir,
history_path and skills_dir then pointed under ./~ (nothing harvested,
the adopted skill written where Claude Code never loads it), and
state_dir moved to ./~/.skillopt-sleep even for "~/.claude".
codex_archived_sessions_dir had the same problem, and --claude-home /
--codex-home skipped expanduser.

Expand both homes the way pi_home and cursor_home already are.

Fixes microsoft#394

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

sleep: a claude_home or codex_home starting with ~ is not expanded, so nothing is harvested and the skill and state land under ./~

1 participant