Skip to content

Keep Claude Code's paths in the adapter package (review item 6) - #77

Open
ExJtac wants to merge 1 commit into
mainfrom
fix-claude-paths-in-adapter
Open

ExJtac wants to merge 1 commit into
mainfrom
fix-claude-paths-in-adapter

Conversation

@ExJtac

@ExJtac ExJtac commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Review item 6: Claude Code paths were spelled in connectors.py, nudge.py, auto.py, outputs.py, startup_plugins.py and trim_skills.py.

What changed

  • New tokenstretch/adapters/claude_paths.py holds every Claude Code path: config folder, settings files, ~/.claude.json, .mcp.json, session logs, skills, plugins, handoff notes.
  • The six modules and adapters/claude_code.py all read paths from it. No path literal is left in the six modules.
  • adapters/__init__.py now builds the registry on first use. The old body moved unchanged to adapters/_registry.py.
  • No change in behaviour.

One deviation from the review wording

The review said to move the paths into adapters/claude_code.py. They are in a leaf file beside it instead. Reason: auto and nudge run as hooks on every prompt, and importing the full adapter there took a hook run from about 45 ms to about 134 ms. With the leaf file, hook start time is unchanged. If you want them literally inside claude_code.py, say so and I will move them and accept the slower hooks.

Tests

  • New tests/test_claude_paths.py, 12 tests: no Claude path piece in the six modules (reads the syntax tree), the layout values, adapter and hooks share the same note paths, the paths file imports nothing from the package, a hook command does not load the adapters, the lazy registry is the same list.
  • Full suite: 558 passed, 1 skipped.
  • Network denied (sandbox-exec, deny network*): 552 passed, 6 skipped, 1 deselected.

Notes

🤖 Generated with Claude Code

connectors.py, nudge.py, auto.py, outputs.py, startup_plugins.py and
trim_skills.py each spelled ~/.claude, ~/.claude.json, .mcp.json or the
handoff note paths themselves. They now ask adapters/claude_paths.py,
which the Claude Code adapter also uses. No change in behaviour.

The paths sit in a leaf file beside claude_code.py rather than inside it:
the hook commands run on every prompt, and importing the full adapter
there took a hook from about 45 ms to about 134 ms. For the same reason
the adapter registry is now built on first use (adapters/_registry.py).

A test fails if one of the six modules spells such a path again, and if
a hook command loads the adapters to find a path.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.

1 participant