Skip to content

fix(plugin): add user/project plugin dirs to sys.path so factories import#92

Open
libinzhang1119-beep wants to merge 1 commit into
mainfrom
fix/plugin_user_dir_syspath
Open

fix(plugin): add user/project plugin dirs to sys.path so factories import#92
libinzhang1119-beep wants to merge 1 commit into
mainfrom
fix/plugin_user_dir_syspath

Conversation

@libinzhang1119-beep

@libinzhang1119-beep libinzhang1119-beep commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

File-based USER/PROJECT plugins ship their factory module inside the plugin directory (~/.raven/plugins//), which nothing put on sys.path. Discovery found the manifest but _resolve_factory's bare importlib.import_module always failed — a self-contained plugin dropped into the user dir could never load.

activate() now threads each DiscoveredPlugin's source and location into _activate_one, which calls _ensure_importable before resolving factories: for USER/PROJECT plugins it appends (not prepends, so installed packages keep priority) the plugin directory to sys.path, guarded for idempotency. BUNDLED (in-package) and ENTRY_POINTS (installed) are untouched.

Add regression tests that write real on-disk factory packages (not pre-seeded into sys.modules) under user/project dirs and assert the backend/tool build end to end.

Summary

Type

  • Fix
  • Feature
  • Docs
  • CI / tooling
  • Refactor
  • Other

Verification

  • Relevant tests pass locally
  • Relevant lint / type checks pass locally
  • User-facing docs or screenshots are updated when needed

Risk

  • Security impact considered
  • Backward compatibility considered
  • Rollback path is clear for risky changes

Related Issues

…port

File-based USER/PROJECT plugins ship their factory module inside the
plugin directory (~/.raven/plugins/<id>/), which nothing put on
sys.path. Discovery found the manifest but _resolve_factory's bare
importlib.import_module always failed - a self-contained plugin dropped
into the user dir could never load.

activate() now threads each DiscoveredPlugin's source and location into
_activate_one, which calls _ensure_importable before resolving factories:
for USER/PROJECT plugins it appends (not prepends, so installed packages
keep priority) the plugin directory to sys.path, guarded for idempotency.
BUNDLED (in-package) and ENTRY_POINTS (installed) are untouched.

Add regression tests that write real on-disk factory packages (not
pre-seeded into sys.modules) under user/project dirs and assert the
backend/tool build end to end.

Co-authored-by: Claude (claude-opus-4-8) <noreply@anthropic.com>
@libinzhang1119-beep libinzhang1119-beep force-pushed the fix/plugin_user_dir_syspath branch from 2ca0bfc to 582a62a Compare July 3, 2026 10:16
@libinzhang1119-beep libinzhang1119-beep changed the title fix(plugin): add user/project plugin dirs to sys.path so factories im… fix(plugin): add user/project plugin dirs to sys.path so factories import Jul 3, 2026
@libinzhang1119-beep libinzhang1119-beep requested a review from 0xKT July 3, 2026 10:28
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