feat(plugin): integrate plugin loader into validate_and_load startup#208
Closed
snipcodeit wants to merge 3 commits intomainfrom
Closed
feat(plugin): integrate plugin loader into validate_and_load startup#208snipcodeit wants to merge 3 commits intomainfrom
snipcodeit wants to merge 3 commits intomainfrom
Conversation
Add templates/mgw-plugin-schema.json defining the JSON Schema (draft-07) for mgw-plugin.json manifests. Schema covers plugin metadata (name, version, author), plugin type (agent-template, hook, validator), entry point, supported pipeline stages, hook definitions, and optional config schema. Add lib/plugin-loader.cjs with validateManifest(), loadPlugin(), and discoverPlugins() functions. Uses Ajv for schema validation with graceful degradation to structural checks when Ajv is unavailable. Closes #191 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ader Add buildRegistry(plugins) that takes the discoverPlugins() output and returns a Map<'name:type', pluginEntry> for O(1) lookup by extension point. Last-found wins on duplicate keys so project-local plugins (discovered last when dirs are ordered project-first) override user-global plugins. Add getDefaultPluginDirs(repoRoot) that returns the standard two-path discovery array: <repoRoot>/.mgw/plugins (project-local, priority) and ~/.mgw/plugins (user-global). Neither path must exist — discoverPlugins silently skips missing directories. Also add os module import and expand the module docblock to document the registry and standard discovery directory pattern. All smoke tests pass. No breaking changes to existing exports. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…load) Call discoverPlugins(getDefaultPluginDirs(repoRoot)) and buildRegistry() at bin/mgw.cjs startup via a non-fatal IIFE that runs before program.parseAsync(). The resulting registry is stored on global._mgwPluginRegistry and exposed through getPluginRegistry() in lib/plugin-loader.cjs for clean consumer access. - bin/mgw.cjs: import plugin-loader; add loadPlugins() IIFE before parseAsync; show "[N plugins loaded]" in mgw:run startup banner when plugins are present - lib/plugin-loader.cjs: add getPluginRegistry() accessor for global registry; export it in module.exports - lib/index.cjs: add plugin-loader.cjs to barrel export - commands/workflows/state.md: document plugin loading step in validate_and_load pattern; add Plugin Loading section with implementation details, registry access pattern, directory table, and startup banner example; update Consumers table Non-fatal: broken plugins log a warning and are skipped; startup failures set an empty Map so commands always receive a usable registry. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 task
Owner
Author
|
Resetting milestone for rerun |
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.
Summary
discoverPlugins(getDefaultPluginDirs(repoRoot))andbuildRegistry()atbin/mgw.cjsstartup (non-fatal IIFE beforeprogram.parseAsync()), so every MGW command automatically sees registered pluginsglobal._mgwPluginRegistry; exposes it viagetPluginRegistry()fromlib/plugin-loader.cjsfor clean consumer access without global coupling[N plugins loaded]suffix to themgw:runstartup banner when plugins are presentcommands/workflows/state.md(new Plugin Loading section + validate_and_load step 5 + Consumers table update)Closes #193
Milestone Context
Changes
bin/mgw.cjs— ImportdiscoverPlugins,buildRegistry,getDefaultPluginDirs; addloadPlugins()IIFE beforeparseAsync; add plugin count suffix tomgw:runbannerlib/plugin-loader.cjs— AddgetPluginRegistry()accessor that returnsglobal._mgwPluginRegistryor a new emptyMap; export itlib/index.cjs— Add...require('./plugin-loader.cjs')to barrel exportcommands/workflows/state.md— New "Plugin Loading" section; plugin step documented invalidate_and_load; Consumers table updatedNote: commits
efd29c8andeddfb2fare cherry-picks fromissue/192-implement-plugin-discovery-and-loader-in-lib-plugin-loader-cjs(PR #207). They will fast-forward cleanly when #207 merges.Test Plan
node --check bin/mgw.cjsexits 0node --check lib/plugin-loader.cjsexits 0npm testreports 387 pass, 0 failnode -e "const {getPluginRegistry} = require('./lib/plugin-loader.cjs'); console.log(getPluginRegistry() instanceof Map)"printstruenode -e "const {getPluginRegistry} = require('./lib/index.cjs'); console.log(typeof getPluginRegistry)"printsfunctionmgw run 1startup banner format — no crash; if plugins installed, shows[N plugins loaded]Cross-References
🤖 Generated with Claude Code