Skip to content

Conversation

@were
Copy link
Contributor

@were were commented Jan 23, 2026

Summary

Consolidated duplicate AGENTIZE_HOME path resolution logic by moving the _get_agentize_home() function from workflow.py into session_utils.py as a public get_agentize_home() function. This eliminates code duplication while maintaining workflow.py's self-contained design principle (since session_utils.py is part of the plugin lib).

The new implementation also handles symlink resolution correctly using os.path.realpath(), which fixes path derivation when imported via the .cursor/hooks/lib symlink.

Changes

  • Added get_agentize_home() to .claude-plugin/lib/session_utils.py:12-35 with symlink-aware path resolution
  • Updated session_dir() in .claude-plugin/lib/session_utils.py:89 to use get_agentize_home() instead of direct os.getenv()
  • Removed _get_agentize_home() from .claude-plugin/lib/workflow.py:145-168
  • Updated .claude-plugin/lib/workflow.py:29 to import get_agentize_home from session_utils
  • Updated .claude-plugin/lib/logger.py:4,9 to use get_agentize_home() in _tmp_dir()
  • Updated .claude-plugin/lib/session_utils.md to document get_agentize_home() interface
  • Updated .claude-plugin/lib/README.md:51 to reflect workflow.py's dependency on session_utils

Testing

  • Updated tests/cli/test-workflow-module.sh:295-323 (Tests 40-42) to import from session_utils
  • Updated tests/cli/test-handsoff-session-path.sh:47-62 (Test 2) for new path derivation behavior
  • Updated tests/cli/test-cursor-hook-before-prompt-submit.sh:56-71 (Test 3) for new behavior
  • All 45 bash tests pass (make test-fast)
  • All 99 Python tests pass

Related Issue

Closes #592

.claude-plugin/lib/session_utils.py: Add get_agentize_home() as public function with
symlink-aware path resolution using os.path.realpath(). Update session_dir() to use it.

.claude-plugin/lib/workflow.py: Remove _get_agentize_home(), import from session_utils.
Update module docstring to reflect the dependency on session_utils.

.claude-plugin/lib/logger.py: Update _tmp_dir() to use get_agentize_home() instead of
direct os.getenv() call.

.claude-plugin/lib/session_utils.md: Document get_agentize_home() interface and behavior.
.claude-plugin/lib/README.md: Update workflow.py description.

tests/cli/test-workflow-module.sh: Update tests 40-42 to import from session_utils.
tests/cli/test-handsoff-session-path.sh: Update test 2 for new path derivation behavior.
tests/cli/test-cursor-hook-before-prompt-submit.sh: Update test 3 for new behavior.

This eliminates AGENTIZE_HOME path resolution duplication across workflow.py,
session_utils.py, and logger.py by centralizing the robust derivation logic.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@were were added the agentize:pr PR created by agentize label Jan 23, 2026
@were were merged commit b267eab into main Jan 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agentize:pr PR created by agentize

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[plan][refactor] Fuse _get_agentize_home() with session_utils.py

2 participants