Skip to content

refactor: self-contained plugin (vendor engine into matilde_plugin) for HSM install#7

Merged
juniperbevensee merged 1 commit into
mainfrom
dev/juniperbevensee/selfcontained-plugin
Jun 17, 2026
Merged

refactor: self-contained plugin (vendor engine into matilde_plugin) for HSM install#7
juniperbevensee merged 1 commit into
mainfrom
dev/juniperbevensee/selfcontained-plugin

Conversation

@juniperbevensee

Copy link
Copy Markdown
Collaborator

Makes the Hermes plugin a self-contained, copyable artifact so HSM can install it by copying a single subdir (required for the use-case-template install flow).

  • hermes-plugin/matilde_plugin/ (import-safe package name; plugin.yaml name: matilde unchanged, so Hermes still loads it by manifest name).
  • engine/matilde_plugin/engine/ (git mv, history preserved, no duplication). citations.py/openneuro.py move with zero content change.
  • Imports switched to relative (from .engine.citations import ...); removed the sys.path hack. CLI is now python -m matilde_plugin.engine.cli (prog name still matilde).
  • Tests + docs + sanitize.config.json updated to the new paths.

Verified: 75 passed / 6 skipped (same as baseline; skips are the MATILDE_LIVE=1 network tests). Plugin confirmed loadable standalone when copied to /tmp (returns register, 6 tools, _check_available()); CLI --help smoke OK.

Packaging-only refactor — no behavior change. Enables git:NimbleCoAI/Matilde#<tag>:matilde_plugin as an installable HSM artifact.

🤖 Generated with Claude Code

Consolidate the engine INSIDE the plugin so copying only the plugin
directory imports cleanly. The engine is moved (not copied) — there is
exactly one copy of citations.py/openneuro.py/parsing.py/cli.py.

Naming decision: the plugin dir is renamed `hermes-plugin/` ->
`matilde_plugin/` because a hyphen is not import-safe and the CLI runs as
`python -m <pkg>.engine.cli`. `plugin.yaml` `name: "matilde"` is unchanged,
so Hermes still loads the plugin by its manifest name. The plugin loads
three ways, all verified: as a normal package import, loaded by file path
(Hermes-style), and when the directory is copied standalone elsewhere.

Changes:
- git mv hermes-plugin/ -> matilde_plugin/; git mv engine/ ->
  matilde_plugin/engine/ (history preserved as renames).
- tools.py: drop the sys.path hack; engine imports are now relative
  (`from .engine.citations import ...`). Lazy at-call-time imports and the
  `_check_available` gate behavior are unchanged.
- __init__.py: register the package in sys.modules with a search path so
  tools.py's relative imports resolve even when loaded by file path, then
  import tools as a real submodule (no more file-path exec of tools.py).
- engine internals (__init__, parsing, cli) use relative imports; CLI is
  now `python3 -m matilde_plugin.engine.cli` (prog name still "matilde").
- tests: updated imports to matilde_plugin.engine.* and the plugin loader
  path to matilde_plugin/. Coverage identical.
- references updated: README, CONTRIBUTING, docs/onboarding, plugin.yaml
  comment, sanitize.config.json + check_sanitization.py sensitive prefix.

Packaging refactor only — behavior identical. Suite: 75 passed, 6 skipped
(same as baseline; the 6 are live-network integration tests).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@juniperbevensee
juniperbevensee merged commit 62e890b into main Jun 17, 2026
1 check 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