Skip to content

fix(hooks, uninstall, lifecycle): resolve fallback syntax, MCP cleanup, launchd XML escaping, and agent tool definitions - #476

Open
seb4ez wants to merge 4 commits into
monk-io:mainfrom
seb4ez:fix/hooks-uninstall-telemetry-comprehensive-fixes
Open

seb4ez wants to merge 4 commits into
monk-io:mainfrom
seb4ez:fix/hooks-uninstall-telemetry-comprehensive-fixes

Conversation

@seb4ez

@seb4ez seb4ez commented Aug 31, 2026

Copy link
Copy Markdown

Bounty eligibility

  • I signed up for the Monk.io bug bounty at https://monk.io/bug-bounty with this GitHub account
  • I used the installed Monk product end-to-end for this reproduction
  • I starred monk-io/monk-plugin

Summary

Resolves critical cross-platform synchronization, uninstaller cleanup, telemetry formatting, macOS launchd XML escaping, and agent MCP tool whitelist defects:

  1. hooks/block-monk.ps1: Fixed a fatal PowerShell syntax error in the fallback hash table (missing opening @{).
  2. hooks/block-monk.sh: Restored newline (\n) unescaping prior to normalization to prevent multiline shell command bypasses.
  3. .antigravity-plugin/hooks.json: Corrected the PreInvocation hook path to point to hooks/ensure-monk-agent.* rather than scripts/ensure-monk-agent.*, ensuring valid JSON stdout contracts.
  4. scripts/uninstall-monk-agent.ps1: Implemented Remove-AntigravityMcp to prevent orphaned MCP registrations in ~/.gemini/config/mcp_config.json after uninstallation on Windows, and sanitized UTF-16 null bytes in Test-MonkOwnsDistro.
  5. scripts/monk-launcher-telemetry.ps1: Standardized last-launch-emit timestamp storage to integer Unix epoch seconds, restoring deduplication compatibility with the POSIX .sh sibling.
  6. scripts/start-monk-agent.sh: Added xml_escape for plist interpolation, removed stale pid_file on Launchd starts to prevent premature loop aborts, and tracked plugin_version in Linux state files.
  7. agents/*.md: Added mcp__plugin_monk_monk__* to subagent tool whitelists and replaced raw CLI prompt invocations with MCP tooling directives.

Changes

  • Repaired fallback response syntax in hooks/block-monk.ps1.
  • Restored awk newline unescape in hooks/block-monk.sh.
  • Synchronized shell delimiter regexes across .antigravity-plugin/ and plugins/monk/.
  • Updated PreInvocation and diagnostics hooks in .antigravity-plugin/.
  • Added Remove-AntigravityMcp and WSL UTF-16 null-byte sanitization in uninstall-monk-agent.ps1.
  • Standardized epoch timestamp formatting in monk-launcher-telemetry.ps1.
  • Added XML entity escaping and state tracking in start-monk-agent.sh.
  • Whitelisted MCP tools and removed CLI leaks in agents/*.md.

Test Coverage

  • Automated test suite added in tests/monk-comprehensive-audit.test.mjs (26/26 tests passing via pnpm test):
    • hooks/block-monk.ps1 must not have missing @{ in fallback hashtable
    • hooks/block-monk.sh must unescape JSON newlines (\n) before normalization
    • All block-monk hooks across plugins must have synchronized delimiter regexes
    • .antigravity-plugin/hooks.json PreInvocation hook must point to hooks/ directory
    • .antigravity-plugin/hooks/ensure-monk-agent.ps1 must not self-silence via $BashUsable on Windows
    • .antigravity-plugin/hooks/monk-diagnostics.ps1 must guarantee {} on stdout
    • scripts/uninstall-monk-agent.ps1 must implement Remove-AntigravityMcp
    • scripts/monk-launcher-telemetry.ps1 must write epoch seconds to last-launch-emit
    • scripts/start-monk-agent.sh must define xml_escape and sanitize plist interpolations
    • scripts/start-monk-agent.sh must track agent_local and plugin_version in Linux state file
    • Agent definitions must include mcp__* tools in frontmatter
    • Agent prompts must not instruct execution of forbidden CLI commands

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.

1 participant