Skip to content

feat: copy loaded plugins into the config dir with the stdlib - #222

Merged
matheuswhite merged 3 commits into
mainfrom
feat/206-copy-plugin-to-config
Jul 17, 2026
Merged

feat: copy loaded plugins into the config dir with the stdlib#222
matheuswhite merged 3 commits into
mainfrom
feat/206-copy-plugin-to-config

Conversation

@matheuswhite

Copy link
Copy Markdown
Owner

Implements #206.

Loading a plugin used to require its scope.lua / shell.lua standard libraries to sit in the same folder, so the user had to copy them next to every plugin for require("scope") / require("shell") to resolve.

Now, on load, Scope:

  1. creates <config_dir>/scope/plugins/ (e.g. ~/.config/scope/plugins/);
  2. writes the embedded standard libraries (scope.lua, shell.lua) there;
  3. copies the plugin into that directory and loads it from there,

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 — the edit-and-reload workflow is unchanged. scope and shell are reserved plugin names.

Verified end-to-end (isolated HOME): plugins doing require("scope") and require("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

matheuswhite and others added 3 commits July 17, 2026 17:27
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]>
@matheuswhite
matheuswhite merged commit dcfa015 into main Jul 17, 2026
8 checks passed
@matheuswhite
matheuswhite deleted the feat/206-copy-plugin-to-config branch July 17, 2026 21:11
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.

Copy loaded plugin to $USR_CFG/scope/plugins

1 participant