Skip to content

refactor: simplify and harden code since v2.1.0 release#377

Merged
itdove merged 1 commit into
mainfrom
devaiflow_review
May 30, 2026
Merged

refactor: simplify and harden code since v2.1.0 release#377
itdove merged 1 commit into
mainfrom
devaiflow_review

Conversation

@itdove
Copy link
Copy Markdown
Owner

@itdove itdove commented May 30, 2026

Jira Issue:

Description

Simplification and hardening of code changes since the v2.1.0 release, based on automated /simplify and /code-review analysis.

Simplification (7 items):

  • Extract strip_code_fences() utility, replacing 6 duplicate instances across complete_command.py and pr_template.py
  • Deduplicate temp directory cleanup in open_command.py by delegating to canonical cleanup_temp_directory() from temp_directory.py
  • Deduplicate PR template AI prompt (built once, passed to API fallback) and pass pre-loaded config to _fill_template_fallback
  • Cache package_file_name property in ReleaseManager, replacing 2 inline expressions that re-read pyproject.toml
  • Extract _clone_repo_to_temp() shared core from clone_to_temp_directory and prompt_and_clone_to_temp
  • Fix duplicate git ls-remote call in open_command.py (wasted network round-trip)

Code review fixes (6 items):

  • Fix _cleanup_temp_directory in complete_command.py not handling nested daf-session-* directories (orphaned temp dirs)
  • Fix unbound prompt variable in pr_template.py FileNotFoundError handler
  • Sanitize issue_key in investigate_command.py session name to prevent path separators
  • Use lambda in re.sub for session.goal to prevent regex backreference interpretation
  • Tighten JIRA placeholder regex from \w+ to \d+ to avoid matching words like ISSUE-HANDLING
  • Add Path.resolve() to temp directory cleanup for macOS symlink compatibility

Assisted-by: Claude

Testing

Steps to test

  1. Pull down the PR and run python -m pytest tests/ -x -q
  2. Verify 3609+ tests pass (1 pre-existing flaky test in test_workspace.py is unrelated)
  3. Run daf investigate #123 or daf investigate owner/repo#123 and verify session name is sanitized
  4. Run daf complete on a ticket_creation session and verify temp directory cleanup removes the parent daf-session-* directory

Scenarios tested

  • Full test suite: 3609 passed, 65 skipped, 1 pre-existing flaky
  • PR template tests: 23 passed (updated for new function signatures)
  • Temp directory tests: 57 passed
  • Investigate command tests: 22 passed
  • Release manager tests: 49 passed

Deployment considerations

  • This code change is ready for deployment on its own

🤖 Generated with Claude Code

Simplification (from /simplify review):
- Extract strip_code_fences() utility, replacing 6 duplicate instances
  across complete_command.py and pr_template.py
- Deduplicate temp directory cleanup in open_command.py by delegating
  to canonical cleanup_temp_directory() from temp_directory.py
- Deduplicate PR template AI prompt (built once, passed to API fallback)
- Pass pre-loaded config to _fill_template_fallback to avoid re-reading
- Cache package_file_name property in ReleaseManager, replacing 2 inline
  expressions that each re-read pyproject.toml
- Extract _clone_repo_to_temp() shared core from clone_to_temp_directory
  and prompt_and_clone_to_temp, eliminating ~30 duplicate lines
- Fix duplicate git ls-remote call in open_command.py (wasted network
  round-trip)

Code review fixes (from /code-review):
- Fix _cleanup_temp_directory in complete_command.py not handling nested
  daf-session-* directories (orphaned temp dirs in /tmp/)
- Fix unbound 'prompt' variable in pr_template.py FileNotFoundError
  handler by moving context/prompt building outside the try block
- Sanitize issue_key in investigate_command.py session name generation
  to prevent path separators in names (e.g., owner/repo#123)
- Use lambda in re.sub for session.goal to prevent regex backreference
  interpretation of user-provided text
- Tighten JIRA placeholder regex from \w+ to \d+ to avoid matching
  natural English words like ISSUE-HANDLING
- Add Path.resolve() to temp directory cleanup symlink comparison
  for macOS compatibility (/tmp -> /private/tmp)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@itdove itdove merged commit 6a2c379 into main May 30, 2026
7 checks passed
@itdove itdove deleted the devaiflow_review branch May 30, 2026 14:36
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