Skip to content

fix: route slash commands through cli.sh so uv is on PATH#11

Merged
yyiilluu merged 3 commits intomainfrom
fix/slash-cmd-uv-bootstrap
May 3, 2026
Merged

fix: route slash commands through cli.sh so uv is on PATH#11
yyiilluu merged 3 commits intomainfrom
fix/slash-cmd-uv-bootstrap

Conversation

@yyiilluu
Copy link
Copy Markdown
Contributor

@yyiilluu yyiilluu commented May 3, 2026

Summary

  • Slash commands (/learn, /show, /restart, /clear-all) failed on fresh installs because Claude Code's ! bash directives run in a non-interactive, non-login shell that doesn't source ~/.zshrc, leaving the freshly-installed uv at ~/.local/bin invisible until the user manually re-sources their rc.
  • Route the four commands through a new plugin/scripts/cli.sh wrapper that bootstraps PATH the same way hook_entry.sh does, and short-circuits with the recorded reason when ~/.claude-smart/install-failed is present so a broken Setup hook surfaces a useful message instead of "uv not found".
  • Adapter rename: switch the two internal calls from client.search_profiles to client.search_user_profiles to match the canonical method on ReflexioClient (the old name is deprecated upstream).
  • Bump the reflexio submodule pointer to 0c1eced (single-loop agentic extraction/search v2), which is where the search_user_profiles rename landed.
  • Also picks up 18db3e4 (release Makefile gate on npm whoami), which had been sitting unpushed on local main.

Changes

Slash command wrapper

  • plugin/scripts/cli.sh (new) — bash wrapper that sources _lib.sh, calls claude_smart_source_login_path + claude_smart_prepend_astral_bins, honors the install-failed marker, then execs uv run --project "$PLUGIN_ROOT" --quiet python -m claude_smart.cli "$@".
  • plugin/commands/{clear-all,learn,restart,show}.mdallowed-tools switched from Bash(uv run:*) to Bash(bash:*); the ! directive now invokes bash "$HOME/.reflexio/plugin-root/scripts/cli.sh" <subcommand> ....

Adapter

  • plugin/src/claude_smart/reflexio_adapter.py — rename two client.search_profiles(...) call sites and their debug log strings to search_user_profiles. Adapter's own public method Adapter.search_profiles is unchanged — only the underlying client call.

Submodule

  • reflexio — pointer moved from 9143d1b0c1eced (agentic extraction + search v2).

Release tooling (carried in from local main)

  • Makefilecheck-npm-auth target gates release so an unauthenticated npm publish fails fast, before any version bump / commit / tag.

Test Plan

  • Fresh install in a new shell where ~/.local/bin is not on the inherited PATH: confirm /learn, /show, /restart, /clear-all all run successfully.
  • With ~/.claude-smart/install-failed present, confirm a slash command prints the recorded message (not "uv not found") and exits 1.
  • Run a session that triggers Adapter.fetch_project_profiles / Adapter.search_profiles against a reflexio backend at 0c1eced+: confirm no AttributeError and profiles come back.
  • make release against a logged-out npm: confirm it stops at check-npm-auth before bumping.

Notes for reviewer

  • The PR includes one prior chore commit (18db3e4) that was sitting unpushed on local main. Squash-merging this PR will collapse both into one commit on main.
  • The reflexio working tree is locally -dirty (a deprecated search_profiles alias added on top of 0c1eced for backward compat experimentation), but the gitlink recorded here is the clean 0c1eced SHA.

Summary by CodeRabbit

  • Chores

    • Added npm authentication verification to the release flow to ensure valid publish credentials before releasing.
    • Added a Bash CLI wrapper and updated plugin command execution to use it for more reliable local invocations.
    • Updated an internal subproject reference.
  • Documentation

    • Updated command docs to reflect the new Bash wrapper and adjusted allowed-tool patterns.

Add check-npm-auth target that runs npm whoami and falls back to
interactive npm login if needed. Wire it into release between
check-clean and bump so an unauthenticated release fails fast,
before any version files are edited or commits/tags are created.
Claude Code runs the `!` bash directives in slash command .md files in a
non-interactive, non-login shell that does not source ~/.zshrc, so a
freshly-installed `uv` at ~/.local/bin is invisible until the user
re-sources their shell rc. The four slash commands now go through a new
plugin/scripts/cli.sh wrapper that bootstraps PATH the same way
hook_entry.sh does, and surfaces ~/.claude-smart/install-failed when the
Setup hook recorded a broken install.

Also rename the adapter's two internal client calls from
search_profiles to search_user_profiles to match the canonical method
on ReflexioClient (the old name is deprecated upstream), and bump the
reflexio submodule pointer to 0c1eced where that rename landed.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a7fcff5e-8971-4da2-8d0f-7e45f5d066db

📥 Commits

Reviewing files that changed from the base of the PR and between cea0608 and 688df8c.

📒 Files selected for processing (1)
  • Makefile

📝 Walkthrough

Walkthrough

Adds an npm auth check to the Makefile release flow, introduces a Bash CLI wrapper (plugin/scripts/cli.sh) that delegates to uv run ... python -m claude_smart.cli, updates command docs to call that wrapper, updates Adapter calls to search_user_profiles, and advances the reflexio submodule pointer.

Changes

CLI Wrapper & Command Integration

Layer / File(s) Summary
Wrapper Script Foundation
plugin/scripts/cli.sh
New Bash wrapper that sources _lib.sh, runs claude_smart_source_login_path and claude_smart_prepend_astral_bins, checks for install-failure marker, validates uv on PATH, and execs uv run --project "$PLUGIN_ROOT" --quiet python -m claude_smart.cli "$@".
Command Documentation Updates
plugin/commands/clear-all.md, plugin/commands/learn.md, plugin/commands/restart.md, plugin/commands/show.md
Docs/frontmatter updated to invoke bash "$HOME/.reflexio/plugin-root/scripts/cli.sh" <cmd> instead of direct uv run ... python -m claude_smart.cli, and allowed-tools changed from Bash(uv run:*) to Bash(bash:*).

Profile Search API Migration

Layer / File(s) Summary
Adapter Method Calls
plugin/src/claude_smart/reflexio_adapter.py
fetch_project_profiles and search_profiles now call client.search_user_profiles(...) instead of client.search_profiles(...); log messages updated to reference search_user_profiles.
Submodule Pointer
reflexio
Submodule updated from commit 9143d1bf... to 0c1eced0... (pointer advance correlated with API rename).

Release Process Authentication

Layer / File(s) Summary
Makefile Auth Target & Wiring
Makefile
Added .PHONY entry and new check-npm-auth target that checks NPM_TOKEN or runs npm whoami and exits non-zero with guidance if unauthenticated; release prerequisites updated to require check-npm-auth before bump.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User as User
  participant CLI as Bash wrapper\n`cli.sh`
  participant UV as `uv` runner
  participant Python as `python -m claude_smart.cli`
  Note over CLI,UV: colors: rgba(135,206,250,0.5) for CLI, rgba(144,238,144,0.5) for UV
  User->>CLI: invoke `bash .../cli.sh <cmd>`
  CLI->>CLI: source `_lib.sh`, run preflight hooks
  CLI->>CLI: check install-failed marker
  CLI-->>User: error + exit (if failed)
  CLI->>CLI: verify `uv` on PATH
  CLI-->>User: error + exit (if missing)
  CLI->>UV: exec `uv run --project ... --quiet python -m claude_smart.cli "<cmd>"`
  UV->>Python: run CLI command
  Python-->>User: command output
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

I hop through scripts with careful paws,
A wrapper bridges CLI and cause,
Profiles call by their new names,
npm checks before release games,
🐇 small hops, steady paws.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and specifically describes the main change: adding cli.sh as a wrapper to ensure uv is on PATH for slash commands, which aligns with the primary objective of the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/slash-cmd-uv-bootstrap

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Review rate limit: 9/10 reviews remaining, refill in 6 minutes.

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

Copy link
Copy Markdown

@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: 2

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

Inline comments:
In `@Makefile`:
- Around line 39-45: Update the Makefile targets so they check for the NPM_TOKEN
env var before attempting any interactive login: in the check-npm-auth recipe
(and the release target that depends on it) first test if NPM_TOKEN is set and
accept that as authenticated, otherwise fall back to `npm whoami >/dev/null
2>&1`; if both checks fail, print a clear error like "error: not authenticated
via npm whoami and NPM_TOKEN is not set; set NPM_TOKEN for CI or run npm login
locally" and exit 1 (do not invoke interactive `npm login` in non-TTY/CI paths).

In `@plugin/src/claude_smart/reflexio_adapter.py`:
- Around line 195-201: The adapter's search_profiles method calls
client.search_user_profiles but the test mocks only implement search_profiles,
causing AttributeError swallowed by the exception handler; update the test mocks
used by tests that exercise search_profiles to expose a search_user_profiles
method (or add both search_user_profiles and search_profiles on the mock client)
so the adapter's call to client.search_user_profiles resolves correctly and the
integration is actually tested.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7a265ab6-8f3f-40dc-b938-fc185389afc7

📥 Commits

Reviewing files that changed from the base of the PR and between f889563 and cea0608.

📒 Files selected for processing (8)
  • Makefile
  • plugin/commands/clear-all.md
  • plugin/commands/learn.md
  • plugin/commands/restart.md
  • plugin/commands/show.md
  • plugin/scripts/cli.sh
  • plugin/src/claude_smart/reflexio_adapter.py
  • reflexio

Comment thread Makefile Outdated
Comment on lines +195 to +201
response = client.search_user_profiles(
user_id=project_id,
query="",
top_k=top_k,
)
except Exception as exc: # noqa: BLE001
_LOGGER.debug("search_profiles failed: %s", exc)
_LOGGER.debug("search_user_profiles failed: %s", exc)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify every in-repo client mock/call site has been migrated to search_user_profiles.
rg -nP '\bsearch_profiles\s*\(' tests plugin/src
rg -nP '\bsearch_user_profiles\s*\(' tests plugin/src

Repository: ReflexioAI/claude-smart

Length of output: 939


🏁 Script executed:

sed -n '235,260p' plugin/src/claude_smart/reflexio_adapter.py

Repository: ReflexioAI/claude-smart

Length of output: 957


Update test mocks to provide search_user_profiles() instead of search_profiles().

The adapter's search_profiles() method now calls client.search_user_profiles() internally, but test mocks in tests/test_adapter.py still only define search_profiles(). This causes an AttributeError when tests run, which the silent exception handler at lines 197–201 and 255–259 catches and converts to an empty list. Tests pass, but the integration with the actual client API is never validated. Update the mock definitions at lines 35, 128, 182, and 198 to expose search_user_profiles() instead, or add both methods for compatibility.

Also applies to: 253–259

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugin/src/claude_smart/reflexio_adapter.py` around lines 195 - 201, The
adapter's search_profiles method calls client.search_user_profiles but the test
mocks only implement search_profiles, causing AttributeError swallowed by the
exception handler; update the test mocks used by tests that exercise
search_profiles to expose a search_user_profiles method (or add both
search_user_profiles and search_profiles on the mock client) so the adapter's
call to client.search_user_profiles resolves correctly and the integration is
actually tested.

@yyiilluu yyiilluu merged commit 413fc1c into main May 3, 2026
5 checks passed
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