feat: copy loaded plugins into the config dir with the stdlib - #222
Merged
Conversation
A plugin's require("scope") / require("shell") only resolved when the
scope.lua / shell.lua standard libraries sat in the plugin's own folder,
forcing the user to stage them next to every plugin.
On load, copy the plugin into <config_dir>/scope/plugins/ and write the
embedded standard libraries (scope.lua, shell.lua) there, then load the
plugin from that directory so require(...) resolves with no manual staging.
The original path is kept as the plugin's identity, so !plugin reload
re-copies the (possibly edited) source. "scope" and "shell" are reserved
plugin names.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Writing scope.lua / shell.lua on every plugin load rewrote them each time and clobbered a user's local copy. Provision each only when it isn't already in the plugins directory; the plugin itself is still copied on every load so reload keeps picking up edits. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Extract the filesystem staging (create dir, provision the bundled stdlib only when missing, copy the plugin) out of the async load_plugin into a pure stage_plugin helper, and unit-test it: the stdlib is provisioned and the plugin copied; an existing stdlib is not overwritten; re-staging re-copies an edited source (reload); and a source already at the destination is a no-op. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.
Implements #206.
Loading a plugin used to require its
scope.lua/shell.luastandard libraries to sit in the same folder, so the user had to copy them next to every plugin forrequire("scope")/require("shell")to resolve.Now, on load,
Scope:<config_dir>/scope/plugins/(e.g.~/.config/scope/plugins/);scope.lua,shell.lua) there;so
require(...)resolves with no manual staging. The original path is kept as the plugin's identity, so!plugin reloadre-copies the (possibly edited) source — the edit-and-reload workflow is unchanged.scopeandshellare reserved plugin names.Verified end-to-end (isolated
HOME): plugins doingrequire("scope")andrequire("shell")from a bare directory load successfully; reload picks up edits to the original; 175 unit tests pass; fmt/clippy clean.Closes #206
🤖 Generated with Claude Code