Skip to content

feat: allow tool white-listing in plan mode via settings - #7

Open
mystilleef wants to merge 3 commits into
qmx:masterfrom
mystilleef:master
Open

mystilleef wants to merge 3 commits into
qmx:masterfrom
mystilleef:master

Conversation

@mystilleef

Copy link
Copy Markdown

This pull request enhances the configurability and test coverage of plan mode's tool whitelisting logic. It introduces support for a customizable tool whitelist (excluding inherently unsafe tools like write and edit), updates the agent's available tool list and prompt accordingly, and adds comprehensive tests for these behaviors.

Plan mode tool whitelist improvements:

  • Added a getActiveTools function in plan-mode.ts to compute the active tool list based on a planMode.toolWhitelist setting, always including safe defaults (read, bash) and filtering out write and edit even if whitelisted.
  • Updated the agent startup logic to use the computed active tool list, ensuring only allowed tools are available during plan mode.
  • Modified the plan mode prompt to dynamically list the currently active tools, reflecting the whitelist configuration.
  • Enhanced the tool_call hook to permit only whitelisted tools (except for write/edit, which are always blocked), and to apply additional safety checks for bash.

Test coverage:

  • Added new test cases in plan-mode.test.ts to verify correct filtering of whitelisted tools, proper blocking of write/edit, and the behavior of the tool_call hook when plan mode is active.
  • Included the vi mock utility from vitest to support the new tests.

Copilot AI review requested due to automatic review settings April 17, 2026 01:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds settings-driven tool whitelisting for plan mode, updates how the agent’s active tool set and plan-mode prompt are derived, and extends the test suite to cover these behaviors.

Changes:

  • Introduces getActiveTools() to compute plan-mode tools from planMode.toolWhitelist plus safe defaults, while excluding write/edit.
  • Uses the computed active tool list during agent startup and renders the plan-mode prompt’s “Available tools” section dynamically.
  • Adds Vitest-based tests for whitelist filtering and plan-mode tool blocking behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
plan-mode.ts Adds settings-based active tool computation and applies it to agent startup, prompt content, and tool-call enforcement.
plan-mode.test.ts Adds tests for tool whitelist filtering and tool-call behavior in plan mode (with room to extend coverage for non-whitelisted tools).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plan-mode.ts Outdated
Comment thread plan-mode.test.ts
Comment thread plan-mode.ts Outdated
- Read planMode.toolWhitelist from ~/.pi/agent/settings.json
  instead of non-existent ctx.settingsManager API
- Validate whitelist with Array.isArray before filtering
- Block non-whitelisted tools explicitly in tool_call hook
- Remove getAllTools filtering that excluded extension tools
- Add test for blocking non-whitelisted tools
- Mock node:fs in tests instead of settingsManager

Refs: qmx#6
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.

2 participants