Add extensible application hook system for dynamic AI reactions #15
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 a plugin architecture allowing MSAgent-AI to monitor applications/games and trigger AI responses based on process/window events.
Architecture
Core Components:
IAppHookinterface - Contract for custom hooksAppHookBase- Shared functionality (lifecycle, logging, disposal)AppHookManager- Registration, lifecycle, event forwardingEvent Flow:
Built-in Hooks
ProcessMonitorHook: Detects app start/stop via periodic process enumeration
WindowMonitorHook: Tracks active window title changes via Win32 API
Configuration
JSON-based hook definitions in
AppSettings:{ "EnableAppHooks": true, "AppHooks": [ { "HookType": "ProcessMonitor", "TargetApp": "notepad", "Enabled": true, "Parameters": { "StartPrompt": "User opened Notepad. Encourage their writing!", "StopPrompt": "User closed Notepad. Ask if they saved.", "PollInterval": "2000" } } ] }Event System
AppHookEventArgssupports:10 event types: ApplicationStarted, ApplicationStopped, WindowTitleChanged, Achievement, Error, Custom, etc.
Integration
MainForm changes:
InitializeAppHooks()- Parses config, instantiates hooksOnHookTriggered()- Routes events to AI/speech systemsThread-safe UI marshalling via
InvokeRequiredpattern.Extensibility
Developers create custom hooks by:
IAppHookor extendingAppHookBaseOnStart()/OnStop()for monitoring logicTriggerEvent()to send eventsExample template in
examples/TextFileMonitorHook.csdemonstrates file monitoring pattern.Documentation
APPHOOKS.md(843 lines) - API reference, best practices, examplesAPPHOOKS-QUICKSTART.md(360 lines) - User setup guide, common configsexamples/- Hook implementations and JSON configsFiles Modified
New:
src/AppHook/- Core infrastructure (5 files)Changed:
AppSettings.cs-AppHookConfigclassMainForm.cs- Hook integration (~150 lines)README.md- Feature documentationOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.