refactor: self-contained plugin (vendor engine into matilde_plugin) for HSM install#7
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.yamlname: matildeunchanged, so Hermes still loads it by manifest name).engine/→matilde_plugin/engine/(git mv, history preserved, no duplication).citations.py/openneuro.pymove with zero content change.from .engine.citations import ...); removed thesys.pathhack. CLI is nowpython -m matilde_plugin.engine.cli(prog name stillmatilde).sanitize.config.jsonupdated to the new paths.Verified: 75 passed / 6 skipped (same as baseline; skips are the
MATILDE_LIVE=1network tests). Plugin confirmed loadable standalone when copied to /tmp (returnsregister, 6 tools,_check_available()); CLI--helpsmoke OK.Packaging-only refactor — no behavior change. Enables
git:NimbleCoAI/Matilde#<tag>:matilde_pluginas an installable HSM artifact.🤖 Generated with Claude Code