feat: hooks-plugin migration — replace HookRegistry with typed plugin system#6
Merged
feat: hooks-plugin migration — replace HookRegistry with typed plugin system#6
Conversation
- Add hooks-plugin dependency, define 14 typed hook contexts - Implement ShoggothPluginSystem wrapping PluginSystem, freezeConfig utility - Add MessagingPlatformPlugin interface + defineMessagingPlatformPlugin validator - Replace HookRegistry with ShoggothPluginSystem throughout - Rewrite plugin loader to read package.json shoggothPlugin bag (not shoggoth.json) - Add fireDaemonHooks helper for boot sequence hook orchestration - Create Discord plugin (createDiscordPlugin factory) with 4 required hooks - Update daemon bootstrap to use new plugin system - Add plugin system documentation - Delete hook-registry.ts, add 27 new tests (2169 total, all passing)
Extract Discord-specific wiring from daemon/index.ts into the platform-discord plugin. The plugin implements MessagingPlatformPlugin and receives all dependencies through PlatformStartCtx. - plugin.ts: Fill in platform.start with Discord gateway startup, interaction handler, HITL reaction wiring, reaction passthrough, subagent extension, message tool context, and platform adapter - hook-types.ts: Expand PlatformDeps with daemon-provided callbacks - daemon-hooks.ts: Pass expanded context when firing platform.start - daemon/index.ts: Refactor to use ShoggothPluginSystem + fireDaemonHooks
…d plugin self-containment - Remove plan references and rename internal functions - Init procman before fireDaemonHooks so MCP stdio uses procman env merge - Harden direct spawn fallback to merge process.env - Move TurnQueue and ModelResilienceGate init before fireDaemonHooks - Remove placeholder messageToolContext so Discord plugin builds real context - Plugin owns its own HitlDiscordNoticeRegistry, remove from daemon/PlatformDeps
…iveryRegistry - Remove all @shoggoth/platform-discord imports from daemon/src/index.ts - Discord plugin loaded via config.plugins + loadAllPluginsFromConfig (same as 3rd party) - Add PlatformDeliveryRegistry: plugins register resolvers for their platform segment - Daemon uses deliveryRegistry.resolveOperatorDelivery() instead of Discord-specific config reads - Plugin owns bot token resolution, session-for-channel resolution, owner user ID - Remove resolveSessionForChannel/getBotToken from PlatformDeps - Add deliveryRegistry to PlatformStartCtx - Default config.plugins includes @shoggoth/platform-discord
…shared and @shoggoth/messaging - Add plugin-interfaces.ts to @shoggoth/shared with proper interfaces - hook-types.ts imports ShoggothConfig, Logger from @shoggoth/shared - hook-types.ts imports PlatformRegistration, PlatformRuntime, InternalMessage from @shoggoth/messaging - HitlPendingStack, HitlAutoApproveGate, PolicyEngine, etc. defined in @shoggoth/shared - Add @shoggoth/messaging as dependency of @shoggoth/plugins - Zero placeholder `type X = any` remaining
…age.json entrypoint
…m-discord packages
haliphax
added a commit
that referenced
this pull request
Apr 22, 2026
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.
Replace the hand-rolled
HookRegistry(2 untyped hooks) with a typedShoggothPluginSystembuilt onhooks-plugin. Extract Discord platform wiring fromdaemon/src/index.tsinto a fully self-contained plugin loaded via standard plugin discovery.What changed
Plugin system (
@shoggoth/plugins)ShoggothPluginSystemclass wrappinghooks-pluginprimitives (sync, async, waterfall)MessagingPlatformPlugininterface +defineMessagingPlatformPluginvalidatorPlatformDeliveryRegistry— platform-agnostic operator delivery resolution; plugins register resolvers for their URN segmentpackage.jsonshoggothPluginproperty bagfreezeConfigutility for post-waterfall config immutabilityHookRegistry@shoggoth/sharedand@shoggoth/messaging(no placeholderanytypes)Shared plugin interfaces (
@shoggoth/shared)plugin-interfaces.tsdefinesHitlPendingStack,HitlAutoApproveGate,PolicyEngine,SubagentRuntimeExtension,MessageToolContext,PlatformAdapter, etc.Daemon hook orchestration
fireDaemonHookshelper fires hooks in boot sequence order: configure → register → health → start → startup → lock → readyplatform.stopanddaemon.shutdownfireDaemonHooks()@shoggoth/platform-discordin daemon — no platform-specific code leaksdeliveryRegistry.resolveOperatorDelivery()for workflow notificationsDiscord plugin (
@shoggoth/platform-discord)loadAllPluginsFromConfig(same path as 3rd-party plugins)config.pluginsincludes{ package: "@shoggoth/platform-discord" }PlatformDeliveryResolverfor the"discord"URN segmentplatform.starthandles gateway connection, interaction handler, HITL reactions, reaction passthrough, subagent extension, message tool context, platform adapterMCP transport hardening
mcp-jsonrpc-transport.tsdirect spawn fallback now mergesprocess.envwith config env (preventsPATHloss)Tests: 2169 passing, 220 test files, no regressions