Skip to content

fix: support python fallback in continuous-learning observe hook#350

Open
tsubasakong wants to merge 3 commits intoaffaan-m:mainfrom
tsubasakong:fix/349-python-fallback-observe-hook
Open

fix: support python fallback in continuous-learning observe hook#350
tsubasakong wants to merge 3 commits intoaffaan-m:mainfrom
tsubasakong:fix/349-python-fallback-observe-hook

Conversation

@tsubasakong
Copy link
Contributor

@tsubasakong tsubasakong commented Mar 7, 2026

Summary

  • resolve Python command dynamically in skills/continuous-learning-v2/hooks/observe.sh (python3 preferred, python fallback)
  • replace hardcoded python3 invocations with the resolved command to support Windows Git Bash environments
  • add a CLAUDE_PLUGIN_ROOT fallback in scripts/hooks/run-with-flags-shell.sh based on script location when the env var is unset

Validation

  • bash -n skills/continuous-learning-v2/hooks/observe.sh
  • bash -n scripts/hooks/run-with-flags-shell.sh

Closes #349


Summary by cubic

Make the continuous-learning observe hook portable by resolving the Python executable at runtime and defaulting CLAUDE_PLUGIN_ROOT from the script location. Fixes failures on Windows (Git Bash) and when the env var is unset, addressing #349.

  • Bug Fixes
    • Detect python3 first, fallback to python, and use it for all inline JSON parsing.
    • Exit cleanly and skip observation if no Python is found.
    • Set a default CLAUDE_PLUGIN_ROOT in scripts/hooks/run-with-flags-shell.sh based on the script path.

Written for commit 30abf36. Summary will update on new commits.

Summary by CodeRabbit

  • Chores
    • Improved plugin path initialization for more reliable discovery and consistent startup across environments.
    • Enhanced Python interpreter detection with a graceful fallback and clear warning when none is available, improving compatibility and robustness of runtime hooks.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 7, 2026

📝 Walkthrough

Walkthrough

Adds a SCRIPT_DIR-based fallback for plugin root resolution and makes observe.sh detect and use an available Python binary (python3 or python), with a graceful skip when none is found. No existing behavior removed; INPUT handling unchanged.

Changes

Cohort / File(s) Summary
Plugin Path Initialization
scripts/hooks/run-with-flags-shell.sh
Adds SCRIPT_DIR (script directory), DEFAULT_PLUGIN_ROOT (two levels up), and a fallback so CLAUDE_PLUGIN_ROOT defaults to DEFAULT_PLUGIN_ROOT when unset.
Python Executable Resolution
skills/continuous-learning-v2/hooks/observe.sh
Introduces PYTHON_CMD detection (prefer python3, fallback to python), replaces hardcoded python3 calls with "$PYTHON_CMD", and exits early with a warning if no Python is found.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 I hopped along the script-lined trail,
Found paths that once would sometimes fail.
Now python pair and plugin root align,
Hooks hum softly, everything’s fine —
A carrot-cheer for robust design! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding Python fallback support to the observe hook, which is the primary objective of this PR.
Linked Issues check ✅ Passed The PR fully addresses issue #349 objectives: implements runtime Python detection with fallback, replaces all hardcoded python3 calls, adds graceful exit when Python unavailable, and adds CLAUDE_PLUGIN_ROOT fallback in run-with-flags-shell.sh.
Out of Scope Changes check ✅ Passed All changes directly align with the stated objectives: Python fallback in observe.sh and CLAUDE_PLUGIN_ROOT fallback in run-with-flags-shell.sh. No extraneous modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files


Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@skills/continuous-learning-v2/hooks/observe.sh`:
- Around line 15-23: The early-exit branch that runs when no Python is found
should first drain stdin to avoid leaving the upstream printf writer hanging; in
the no-Python else branch (the block that echoes "[observe] No python found,
skipping observation" and exits), consume/redirect stdin (e.g. by piping/reading
to /dev/null or using cat >/dev/null) before calling exit so the caller's writer
doesn't receive SIGPIPE and fail the pipeline.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f93907fe-e5e4-409a-8446-bb7ec5d98697

📥 Commits

Reviewing files that changed from the base of the PR and between 03b3e0d and ffc1688.

📒 Files selected for processing (2)
  • scripts/hooks/run-with-flags-shell.sh
  • skills/continuous-learning-v2/hooks/observe.sh

Copy link
Owner

@affaan-m affaan-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: this PR has merge conflicts. Please rebase or resolve.

Copy link
Owner

@affaan-m affaan-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: this PR has merge conflicts. Please rebase or resolve.

Copy link
Owner

@affaan-m affaan-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: this PR has merge conflicts. Please rebase or resolve.

Copy link
Owner

@affaan-m affaan-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: this PR has merge conflicts. Please rebase or resolve.

Copy link
Owner

@affaan-m affaan-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: this PR has merge conflicts. Please rebase or resolve.

Copy link
Owner

@affaan-m affaan-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: this PR has merge conflicts. Please rebase or resolve.

Copy link
Owner

@affaan-m affaan-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: checks are failing. Please fix failures before review.

Copy link
Owner

@affaan-m affaan-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: checks are failing. Please fix failures before review.

Copy link
Owner

@affaan-m affaan-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: checks are failing. Please fix failures before review.

Copy link
Owner

@affaan-m affaan-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: checks are failing. Please fix failures before review.

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.

bug: observe.sh hardcodes python3 which doesn't exist on Windows

2 participants