Skip to content

feat(cli): configure policy engine from existing settings#8348

Merged
allenhutchison merged 15 commits intomainfrom
adh/feature/policy-engine-integration
Sep 18, 2025
Merged

feat(cli): configure policy engine from existing settings#8348
allenhutchison merged 15 commits intomainfrom
adh/feature/policy-engine-integration

Conversation

@allenhutchison
Copy link
Copy Markdown
Contributor

@allenhutchison allenhutchison commented Sep 12, 2025

This commit introduces the logic to generate a default configuration for the Policy Engine based on existing user settings. This ensures backwards compatibility and a seamless transition to the new permissions model.

The new createPolicyEngineConfig function translates settings from config.yaml into the structured rules required by the Policy Engine. This includes:

  • Mapping tools.allowed and tools.exclude to allow/deny rules.
  • Translating mcp.allowed and mcp.excluded for MCP tool sources.
  • Preserving the behavior of tools.autoAccept for read-only tools.
  • Handling approval modes such as YOLO and AUTO_EDIT.

This change ensures that users' existing configurations continue to work as expected with the introduction of the underlying Policy Engine.

Comprehensive unit tests have been added to verify that the translation from legacy settings to policy rules is correct.

Part of the work for #7231

This commit introduces the logic to generate a default configuration for the Policy Engine based on existing user settings. This ensures backwards compatibility and a seamless transition to the new permissions model.

The new `createPolicyEngineConfig` function translates settings from `config.yaml` into the structured rules required by the Policy Engine. This includes:
- Mapping `tools.allowed` and `tools.exclude` to allow/deny rules.
- Translating `mcp.allowed` and `mcp.excluded` for MCP tool sources.
- Preserving the behavior of `tools.autoAccept` for read-only tools.
- Handling approval modes such as `YOLO` and `AUTO_EDIT`.

This change ensures that users' existing configurations continue to work as expected with the introduction of the underlying Policy Engine.

Comprehensive unit tests have been added to verify that the translation from legacy settings to policy rules is correct.
@allenhutchison allenhutchison requested a review from a team as a code owner September 12, 2025 16:05
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @allenhutchison, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a robust mechanism to bridge existing user configurations with a new Policy Engine, ensuring backward compatibility and a smooth transition to an updated permissions model. By translating current config.yaml settings into structured policy rules, the system can maintain expected behavior for tool allowances, exclusions, and approval workflows without requiring users to reconfigure their environments. This change is foundational for enhancing the flexibility and security of tool execution within the CLI.

Highlights

  • Policy Engine Configuration Generation: A new createPolicyEngineConfig function has been introduced to dynamically generate policy engine configurations based on existing user settings.
  • Backward Compatibility: This function translates legacy config.yaml settings, such as tools.allowed, tools.exclude, mcp.allowed, mcp.excluded, tools.autoAccept, and useSmartEdit, into structured policy rules to ensure seamless transition to the new permissions model.
  • Approval Mode Handling: The new configuration logic properly accounts for different approval modes like YOLO and AUTO_EDIT, preserving their intended behavior within the new policy framework.
  • Integration with CLI Configuration: The generated policy engine configuration is now integrated into the loadCliConfig function, ensuring the new permissions model is applied during the CLI's configuration loading process.
  • Comprehensive Unit Testing: Extensive unit tests have been added to thoroughly validate the correct translation of various legacy settings into the new policy rules, covering different scenarios and edge cases.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a policy engine configuration layer to maintain backward compatibility with existing settings. The implementation correctly translates most legacy settings into policy rules. However, I've found a critical issue in the implementation of YOLO approval mode, where it fails to auto-approve tools that perform write actions due to incorrect rule priorities. I've provided a suggestion to fix this logic and an update to the corresponding unit test. The rest of the changes, including the new tests and wiring in config.ts, look good.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 12, 2025

Size Change: +3.26 kB (+0.02%)

Total Size: 17.3 MB

Filename Size Change
./bundle/gemini.js 17.3 MB +3.26 kB (+0.02%)
ℹ️ View Unchanged
Filename Size
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB
./bundle/sandbox-macos-permissive-open.sb 830 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB

compressed-size-action

@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 12, 2025

Code Coverage Summary

Package Lines Statements Functions Branches
CLI 76.43% 76.43% 77.03% 80.53%
Core 80.03% 80.03% 79.43% 85.18%
CLI Package - Full Text Report
-------------------|---------|----------|---------|---------|-------------------
File               | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
-------------------|---------|----------|---------|---------|-------------------
All files          |   76.43 |    80.53 |   77.03 |   76.43 |                   
 src               |   64.67 |    68.75 |   56.25 |   64.67 |                   
  gemini.tsx       |   50.79 |    45.45 |   54.54 |   50.79 | ...53,464-472,486 
  ...ractiveCli.ts |    91.3 |       80 |   33.33 |    91.3 | ...7-70,96-97,127 
  ...ActiveAuth.ts |     100 |     90.9 |     100 |     100 | 65-70             
 src/commands      |   70.45 |      100 |      25 |   70.45 |                   
  extensions.tsx   |   55.55 |      100 |       0 |   55.55 | 21-31,35          
  mcp.ts           |   94.11 |      100 |      50 |   94.11 | 26                
 ...nds/extensions |   49.75 |    96.42 |   32.14 |   49.75 |                   
  disable.ts       |   30.76 |      100 |       0 |   30.76 | 18-27,33-44,46-50 
  enable.ts        |   26.66 |      100 |       0 |   26.66 | 18-33,39-50,52-56 
  install.ts       |      90 |    93.33 |   66.66 |      90 | 80,83-88          
  link.ts          |   28.57 |      100 |       0 |   28.57 | 17-31,38-43,45-48 
  list.ts          |   32.14 |      100 |       0 |   32.14 | 11-27,34-35       
  new.ts           |     100 |      100 |     100 |     100 |                   
  uninstall.ts     |   45.71 |      100 |   33.33 |   45.71 | 15-23,35-40,43-46 
  update.ts        |   13.25 |      100 |       0 |   13.25 | ...,84-99,101-105 
 ...les/mcp-server |       0 |        0 |       0 |       0 |                   
  example.ts       |       0 |        0 |       0 |       0 | 1-60              
 src/commands/mcp  |   95.62 |       80 |    90.9 |   95.62 |                   
  add.ts           |    97.4 |    83.33 |     100 |    97.4 | 109-112,119       
  list.ts          |   90.56 |    80.76 |      80 |   90.56 | ...07-109,134-135 
  remove.ts        |     100 |    66.66 |     100 |     100 | 19-23             
 src/config        |   92.24 |    86.25 |   87.34 |   92.24 |                   
  auth.ts          |     100 |      100 |     100 |     100 |                   
  config.ts        |    97.3 |     90.9 |      80 |    97.3 | ...14,566,692-696 
  extension.ts     |   79.06 |    86.23 |      80 |   79.06 | ...38-761,777-779 
  keyBindings.ts   |     100 |      100 |     100 |     100 |                   
  policy.ts        |     100 |      100 |     100 |     100 |                   
  sandboxConfig.ts |   54.16 |    23.07 |   66.66 |   54.16 | ...44,54-68,73-89 
  settings.ts      |   90.97 |    80.46 |   95.65 |   90.97 | ...44-645,746-749 
  ...ingsSchema.ts |     100 |      100 |     100 |     100 |                   
  ...tedFolders.ts |   93.07 |     92.1 |     100 |   93.07 | ...59-160,173-178 
 ...fig/extensions |   69.67 |    82.24 |    90.9 |   69.67 |                   
  ...Enablement.ts |   94.39 |    94.28 |     100 |   94.39 | 80-82,154-156     
  github.ts        |   55.55 |    74.54 |      80 |   55.55 | ...99-304,310-346 
  ...ableSchema.ts |     100 |      100 |     100 |     100 |                   
  variables.ts     |   90.69 |    82.35 |     100 |   90.69 | 30-31,64-65       
 src/core          |   75.92 |     37.5 |     100 |   75.92 |                   
  auth.ts          |   56.25 |       50 |     100 |   56.25 | 27-36             
  initializer.ts   |   85.71 |    33.33 |     100 |   85.71 | 46-49             
  theme.ts         |      80 |    33.33 |     100 |      80 | 18-19             
 src/generated     |     100 |      100 |     100 |     100 |                   
  git-commit.ts    |     100 |      100 |     100 |     100 |                   
 src/patches       |       0 |        0 |       0 |       0 |                   
  is-in-ci.ts      |       0 |        0 |       0 |       0 | 1-17              
 src/services      |   85.33 |    86.55 |   94.11 |   85.33 |                   
  ...mandLoader.ts |     100 |      100 |     100 |     100 |                   
  ...andService.ts |     100 |      100 |     100 |     100 |                   
  ...mandLoader.ts |   89.44 |    91.11 |     100 |   89.44 | ...85-190,273-280 
  ...omptLoader.ts |   74.88 |       80 |   83.33 |   74.88 | ...97-198,264-265 
  types.ts         |     100 |      100 |     100 |     100 |                   
 ...mpt-processors |   97.12 |     93.5 |     100 |   97.12 |                   
  ...tProcessor.ts |     100 |      100 |     100 |     100 |                   
  ...eProcessor.ts |   94.44 |    84.21 |     100 |   94.44 | 43-44,90-91       
  ...tionParser.ts |     100 |      100 |     100 |     100 |                   
  ...lProcessor.ts |   97.14 |    94.87 |     100 |   97.14 | 94-97             
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/test-utils    |   91.22 |    83.33 |      80 |   91.22 |                   
  ...omMatchers.ts |   69.69 |       50 |      50 |   69.69 | 32-35,37-39,45-47 
  ...andContext.ts |     100 |      100 |     100 |     100 |                   
  render.tsx       |     100 |      100 |     100 |     100 |                   
 src/ui            |   71.07 |    70.14 |   48.71 |   71.07 |                   
  App.tsx          |     100 |      100 |     100 |     100 |                   
  AppContainer.tsx |   72.11 |    57.14 |   30.76 |   72.11 | ...60-917,951-954 
  ...tionNudge.tsx |    9.58 |      100 |       0 |    9.58 | 26-98             
  colors.ts        |   59.18 |      100 |   33.33 |   59.18 | ...46,48-49,54-55 
  constants.ts     |     100 |      100 |     100 |     100 |                   
  keyMatchers.ts   |   95.65 |    95.65 |     100 |   95.65 | 25-26             
  ...tic-colors.ts |     100 |      100 |     100 |     100 |                   
  textConstants.ts |     100 |      100 |     100 |     100 |                   
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/ui/auth       |   60.37 |      100 |      50 |   60.37 |                   
  AuthDialog.tsx   |     100 |      100 |     100 |     100 |                   
  ...nProgress.tsx |   16.66 |      100 |       0 |   16.66 | 19-63             
  useAuth.ts       |      10 |      100 |       0 |      10 | 15-26,29-96       
 src/ui/commands   |   85.83 |    82.05 |   87.69 |   85.83 |                   
  aboutCommand.ts  |   95.65 |    58.33 |     100 |   95.65 | 52-53             
  authCommand.ts   |     100 |      100 |     100 |     100 |                   
  bugCommand.ts    |   79.48 |       40 |     100 |   79.48 | 33-36,78-87,93-94 
  chatCommand.ts   |   93.73 |    85.71 |     100 |   93.73 | ...15-216,314-319 
  clearCommand.ts  |     100 |      100 |     100 |     100 |                   
  ...essCommand.ts |     100 |    88.88 |     100 |     100 | 73                
  copyCommand.ts   |     100 |      100 |     100 |     100 |                   
  corgiCommand.ts  |     100 |      100 |     100 |     100 |                   
  ...ryCommand.tsx |   69.27 |    73.07 |     100 |   69.27 | ...25-126,161-169 
  docsCommand.ts   |     100 |      100 |     100 |     100 |                   
  editorCommand.ts |     100 |      100 |     100 |     100 |                   
  ...onsCommand.ts |   96.11 |      100 |     100 |   96.11 | 65-68             
  helpCommand.ts   |     100 |      100 |     100 |     100 |                   
  ideCommand.ts    |   62.25 |       60 |   54.54 |   62.25 | ...52-266,274-288 
  initCommand.ts   |     100 |      100 |     100 |     100 |                   
  mcpCommand.ts    |      82 |    82.22 |   71.42 |      82 | ...92-393,449-456 
  memoryCommand.ts |   99.11 |    81.25 |     100 |   99.11 | 90                
  ...acyCommand.ts |     100 |      100 |     100 |     100 |                   
  quitCommand.ts   |     100 |      100 |     100 |     100 |                   
  ...oreCommand.ts |      92 |    87.09 |     100 |      92 | ...,82-87,128-129 
  ...ngsCommand.ts |     100 |      100 |     100 |     100 |                   
  ...hubCommand.ts |   83.66 |    66.66 |     100 |   83.66 | ...54-157,160-163 
  statsCommand.ts  |   84.48 |       75 |     100 |   84.48 | 25-33             
  ...tupCommand.ts |     100 |      100 |     100 |     100 |                   
  themeCommand.ts  |     100 |      100 |     100 |     100 |                   
  toolsCommand.ts  |     100 |      100 |     100 |     100 |                   
  types.ts         |     100 |      100 |     100 |     100 |                   
  vimCommand.ts    |   44.44 |      100 |       0 |   44.44 | 15-25             
 src/ui/components |    71.6 |    78.06 |   65.75 |    71.6 |                   
  AboutBox.tsx     |     100 |       50 |     100 |     100 | 104               
  AnsiOutput.tsx   |     100 |      100 |     100 |     100 |                   
  AppHeader.tsx    |   36.36 |      100 |       0 |   36.36 | 19-35             
  AsciiArt.ts      |     100 |      100 |     100 |     100 |                   
  ...Indicator.tsx |   15.15 |      100 |       0 |   15.15 | 17-47             
  Composer.tsx     |   98.82 |     67.5 |     100 |   98.82 | 124,133           
  ...itDisplay.tsx |   62.16 |      100 |      50 |   62.16 | 21-32,36-37       
  ...ryDisplay.tsx |   21.05 |      100 |       0 |   21.05 | 17-35             
  ...ryDisplay.tsx |   87.91 |    62.06 |     100 |   87.91 | ...48-49,79-84,89 
  ...geDisplay.tsx |     100 |      100 |     100 |     100 |                   
  ...gProfiler.tsx |      24 |      100 |       0 |      24 | 13-36             
  ...esDisplay.tsx |   10.34 |      100 |       0 |   10.34 | 24-83             
  ...ogManager.tsx |   13.49 |      100 |       0 |   13.49 | 30-192            
  ...ngsDialog.tsx |    6.94 |      100 |       0 |    6.94 | 30-183            
  ...ustDialog.tsx |     100 |      100 |     100 |     100 |                   
  Footer.tsx       |   83.59 |    84.78 |     100 |   83.59 | ...59-166,169-172 
  ...ngSpinner.tsx |   54.28 |       50 |      50 |   54.28 | 31-48,61          
  Header.tsx       |   87.23 |    57.14 |     100 |   87.23 | 36-39,55,64       
  Help.tsx         |   98.46 |       60 |     100 |   98.46 | 77,131            
  ...emDisplay.tsx |   71.42 |    38.88 |     100 |   71.42 | ...2-67,89-97,100 
  InputPrompt.tsx  |   80.86 |    81.65 |     100 |   80.86 | ...3-985,993-1004 
  ...Indicator.tsx |     100 |      100 |     100 |     100 |                   
  ...firmation.tsx |   90.62 |      100 |      50 |   90.62 | 26-31             
  MainContent.tsx  |   16.07 |      100 |       0 |   16.07 | 16-66             
  ...geDisplay.tsx |   22.58 |      100 |       0 |   22.58 | 15-41             
  ...tsDisplay.tsx |     100 |      100 |     100 |     100 |                   
  ...fications.tsx |   17.02 |      100 |       0 |   17.02 | 15-62             
  PrepareLabel.tsx |   91.66 |    76.19 |     100 |   91.66 | 73-75,77-79,110   
  ...otaDialog.tsx |     100 |      100 |     100 |     100 |                   
  ...ngDisplay.tsx |   23.07 |      100 |       0 |   23.07 | 13-37             
  ...ryDisplay.tsx |     100 |      100 |     100 |     100 |                   
  ...ngsDialog.tsx |   62.58 |    76.33 |      75 |   62.58 | ...98,805,811-812 
  ...ionDialog.tsx |   85.91 |      100 |   33.33 |   85.91 | 35-38,43-50       
  ...putPrompt.tsx |      15 |      100 |       0 |      15 | 19-57             
  ...Indicator.tsx |   44.44 |      100 |       0 |   44.44 | 12-17             
  ...MoreLines.tsx |      28 |      100 |       0 |      28 | 18-40             
  StatsDisplay.tsx |   98.59 |    93.33 |     100 |   98.59 | 195-197           
  ...nsDisplay.tsx |   87.35 |    68.18 |     100 |   87.35 | ...53,102,124-126 
  ThemeDialog.tsx  |   91.13 |    48.27 |      75 |   91.13 | ...13-114,156-158 
  Tips.tsx         |   19.23 |      100 |       0 |   19.23 | 17-45             
  ...tsDisplay.tsx |     100 |     87.5 |     100 |     100 | 30-31             
  ...ification.tsx |   36.36 |      100 |       0 |   36.36 | 15-22             
  ...ionDialog.tsx |    8.64 |      100 |       0 |    8.64 | 20-112            
 ...nents/messages |   80.43 |    81.67 |   58.33 |   80.43 |                   
  ...onMessage.tsx |   94.11 |    82.35 |     100 |   94.11 | 48,50,52          
  DiffRenderer.tsx |   93.03 |    85.55 |     100 |   93.03 | ...02,228-229,295 
  ErrorMessage.tsx |   22.22 |      100 |       0 |   22.22 | 16-31             
  ...niMessage.tsx |      20 |      100 |       0 |      20 | 21-46             
  ...geContent.tsx |   19.04 |      100 |       0 |   19.04 | 25-43             
  InfoMessage.tsx  |   26.31 |      100 |       0 |   26.31 | 17-32             
  ...onMessage.tsx |   81.63 |    77.27 |   33.33 |   81.63 | ...10-111,132-147 
  ...upMessage.tsx |   91.34 |    91.66 |     100 |   91.34 | 40-43,136-140     
  ToolMessage.tsx  |   82.28 |    63.63 |     100 |   82.28 | ...38-143,210-212 
  UserMessage.tsx  |     100 |      100 |     100 |     100 |                   
  ...llMessage.tsx |   36.36 |      100 |       0 |   36.36 | 17-25             
  ...ngMessage.tsx |   26.31 |      100 |       0 |   26.31 | 17-32             
 ...ponents/shared |   83.76 |    75.75 |   95.74 |   83.76 |                   
  EnumSelector.tsx |     100 |    96.42 |     100 |     100 | 58                
  MaxSizedBox.tsx  |   81.62 |    81.81 |   88.88 |   81.62 | ...07-508,613-614 
  ...tonSelect.tsx |   86.79 |    67.44 |     100 |   86.79 | ...52,155-156,234 
  ...eSelector.tsx |     100 |       50 |     100 |     100 | 35-40             
  text-buffer.ts   |   82.06 |    75.96 |   96.87 |   82.06 | ...1895,1922,1984 
  ...er-actions.ts |   86.71 |    67.79 |     100 |   86.71 | ...07-608,809-811 
 ...mponents/views |     100 |    93.75 |     100 |     100 |                   
  ...sionsList.tsx |     100 |    93.75 |     100 |     100 | 15                
 src/ui/contexts   |   76.45 |    77.54 |   80.76 |   76.45 |                   
  AppContext.tsx   |      40 |      100 |       0 |      40 | 17-22             
  ...igContext.tsx |   81.81 |       50 |     100 |   81.81 | 15-16             
  FocusContext.tsx |     100 |      100 |     100 |     100 |                   
  ...ssContext.tsx |   84.82 |    84.67 |     100 |   84.82 | ...87-592,688-690 
  ...owContext.tsx |   89.28 |       80 |   66.66 |   89.28 | 34,47-48,60-62    
  ...onContext.tsx |   46.59 |    59.09 |   66.66 |   46.59 | ...25-226,230-233 
  ...gsContext.tsx |   83.33 |       50 |     100 |   83.33 | 17-18             
  ...ngContext.tsx |   71.42 |       50 |     100 |   71.42 | 17-20             
  ...nsContext.tsx |   86.66 |       50 |     100 |   86.66 | 53-54             
  ...teContext.tsx |      80 |       50 |     100 |      80 | 121-122           
  ...deContext.tsx |   67.39 |    28.57 |      50 |   67.39 | 47-48,52-59,75-80 
 src/ui/editors    |   93.18 |    85.71 |   66.66 |   93.18 |                   
  ...ngsManager.ts |   93.18 |    85.71 |   66.66 |   93.18 | 48,62-63          
 src/ui/hooks      |   79.44 |    80.85 |   82.95 |   79.44 |                   
  ...dProcessor.ts |   78.76 |    80.19 |     100 |   78.76 | ...47-450,461-479 
  keyToAnsi.ts     |    3.92 |      100 |       0 |    3.92 | 19-77             
  ...dProcessor.ts |   94.94 |       72 |     100 |   94.94 | ...62-263,268-269 
  ...dProcessor.ts |   80.56 |    67.53 |   71.42 |   80.56 | ...72-376,437-465 
  ...Completion.ts |   92.77 |    89.28 |     100 |   92.77 | ...85-186,219-222 
  ...tIndicator.ts |     100 |      100 |     100 |     100 |                   
  ...ketedPaste.ts |    23.8 |      100 |       0 |    23.8 | 19-37             
  ...ompletion.tsx |    95.3 |       80 |     100 |    95.3 | ...24-225,227-228 
  useCompletion.ts |    92.4 |     87.5 |     100 |    92.4 | 68-69,93-94,98-99 
  ...leMessages.ts |   98.68 |       95 |     100 |   98.68 | 55                
  ...orSettings.ts |     100 |      100 |     100 |     100 |                   
  useFocus.ts      |     100 |      100 |     100 |     100 |                   
  ...olderTrust.ts |     100 |      100 |     100 |     100 |                   
  ...miniStream.ts |   74.79 |    74.85 |      75 |   74.79 | ...-998,1031-1132 
  ...BranchName.ts |   90.38 |    81.81 |     100 |   90.38 | 49-55             
  ...oryManager.ts |   98.41 |    93.33 |     100 |   98.41 | 43                
  ...stListener.ts |   83.87 |    58.33 |     100 |   83.87 | 19,24,40,42-43    
  ...putHistory.ts |    92.5 |    85.71 |     100 |    92.5 | 62-63,71,93-95    
  ...storyStore.ts |     100 |    94.11 |     100 |     100 | 66                
  useKeypress.ts   |     100 |      100 |     100 |     100 |                   
  ...rdProtocol.ts |   36.36 |      100 |       0 |   36.36 | 24-31             
  ...gIndicator.ts |     100 |      100 |     100 |     100 |                   
  useLogger.ts     |      25 |      100 |       0 |      25 | 15-33             
  ...oryMonitor.ts |     100 |      100 |     100 |     100 |                   
  ...ssageQueue.ts |     100 |      100 |     100 |     100 |                   
  ...raseCycler.ts |    95.6 |       80 |     100 |    95.6 | ...73-174,190-192 
  ...cySettings.ts |   86.48 |    78.94 |     100 |   86.48 | ...08-109,120-131 
  ...Completion.ts |   40.64 |    56.52 |     100 |   40.64 | ...23-224,226-227 
  ...ndFallback.ts |   98.27 |    96.42 |     100 |   98.27 | 69-71             
  ...lScheduler.ts |      85 |    94.73 |     100 |      85 | ...00-203,291-301 
  ...oryCommand.ts |       0 |        0 |       0 |       0 | 1-7               
  ...ompletion.tsx |   90.59 |    83.33 |     100 |   90.59 | ...01,104,137-140 
  ...ngsCommand.ts |   18.75 |      100 |       0 |   18.75 | 10-25             
  ...ellHistory.ts |   91.66 |    79.41 |     100 |   91.66 | ...69,117-118,128 
  ...oryCommand.ts |       0 |        0 |       0 |       0 | 1-76              
  ...Completion.ts |   77.86 |    78.88 |      90 |   77.86 | ...62-470,491-497 
  ...tateAndRef.ts |   13.63 |      100 |       0 |   13.63 | 16-36             
  ...rminalSize.ts |   18.18 |      100 |       0 |   18.18 | 12-32             
  ...emeCommand.ts |    7.89 |      100 |       0 |    7.89 | 24-101            
  useTimer.ts      |   88.09 |    85.71 |     100 |   88.09 | 44-45,51-53       
  ...eMigration.ts |   11.11 |      100 |       0 |   11.11 | 16-70             
  vim.ts           |   83.57 |     79.5 |     100 |   83.57 | ...38,742-750,759 
 src/ui/privacy    |   14.44 |      100 |       0 |   14.44 |                   
  ...acyNotice.tsx |   10.25 |      100 |       0 |   10.25 | 21-119            
  ...acyNotice.tsx |   14.28 |      100 |       0 |   14.28 | 16-59             
  ...acyNotice.tsx |   12.19 |      100 |       0 |   12.19 | 16-62             
  ...acyNotice.tsx |   30.76 |      100 |       0 |   30.76 | 19-36,39-41       
 src/ui/state      |     100 |      100 |     100 |     100 |                   
  extensions.ts    |     100 |      100 |     100 |     100 |                   
 src/ui/themes     |   98.99 |    60.43 |     100 |   98.99 |                   
  ansi-light.ts    |     100 |      100 |     100 |     100 |                   
  ansi.ts          |     100 |      100 |     100 |     100 |                   
  atom-one-dark.ts |     100 |      100 |     100 |     100 |                   
  ayu-light.ts     |     100 |      100 |     100 |     100 |                   
  ayu.ts           |     100 |      100 |     100 |     100 |                   
  color-utils.ts   |     100 |      100 |     100 |     100 |                   
  default-light.ts |     100 |      100 |     100 |     100 |                   
  default.ts       |     100 |      100 |     100 |     100 |                   
  dracula.ts       |     100 |      100 |     100 |     100 |                   
  github-dark.ts   |     100 |      100 |     100 |     100 |                   
  github-light.ts  |     100 |      100 |     100 |     100 |                   
  googlecode.ts    |     100 |      100 |     100 |     100 |                   
  no-color.ts      |     100 |      100 |     100 |     100 |                   
  ...tic-tokens.ts |     100 |      100 |     100 |     100 |                   
  ...-of-purple.ts |     100 |      100 |     100 |     100 |                   
  theme-manager.ts |    87.5 |    78.33 |     100 |    87.5 | ...86-292,297-298 
  theme.ts         |     100 |    32.25 |     100 |     100 | 255-437           
  xcode.ts         |     100 |      100 |     100 |     100 |                   
 src/ui/utils      |   67.19 |     81.3 |   78.78 |   67.19 |                   
  ...Colorizer.tsx |   79.45 |    81.81 |     100 |   79.45 | ...52-155,191-217 
  ...olePatcher.ts |      78 |    77.77 |     100 |      78 | 58-69             
  ...nRenderer.tsx |   52.85 |    27.27 |     100 |   52.85 | ...26-132,142-144 
  ...wnDisplay.tsx |   85.62 |    87.69 |     100 |   85.62 | ...73-281,314-339 
  ...eRenderer.tsx |   78.09 |    76.19 |     100 |   78.09 | 55-83             
  ...boardUtils.ts |   31.11 |     37.5 |     100 |   31.11 | ...51-110,125-141 
  commandUtils.ts  |   92.79 |    88.37 |     100 |   92.79 | ...12,116,118-119 
  computeStats.ts  |     100 |      100 |     100 |     100 |                   
  displayUtils.ts  |     100 |      100 |     100 |     100 |                   
  formatters.ts    |   90.47 |    95.83 |     100 |   90.47 | 57-60             
  highlight.ts     |   98.63 |       95 |     100 |   98.63 | 93                
  isNarrowWidth.ts |     100 |      100 |     100 |     100 |                   
  ...olDetector.ts |    7.89 |      100 |       0 |    7.89 | ...11-112,115-116 
  ...nUtilities.ts |   69.84 |    85.71 |     100 |   69.84 | 75-91,100-101     
  ...mConstants.ts |     100 |      100 |     100 |     100 |                   
  terminalSetup.ts |       4 |      100 |       0 |       4 | 40-342            
  textUtils.ts     |   94.44 |    90.32 |   85.71 |   94.44 | 18-19,147-148     
  updateCheck.ts   |     100 |    80.95 |     100 |     100 | 27-39             
 src/utils         |   54.69 |    92.89 |   90.78 |   54.69 |                   
  checks.ts        |   33.33 |      100 |       0 |   33.33 | 23-28             
  cleanup.ts       |   65.38 |      100 |   66.66 |   65.38 | 28-37             
  commands.ts      |     100 |      100 |     100 |     100 |                   
  commentJson.ts   |     100 |      100 |     100 |     100 |                   
  deepMerge.ts     |     100 |    89.65 |     100 |     100 | 41-43,49          
  ...ScopeUtils.ts |   97.67 |    88.88 |     100 |   97.67 | 63                
  ...arResolver.ts |   96.42 |       96 |     100 |   96.42 | 111-112           
  errors.ts        |     100 |    96.77 |     100 |     100 | 77                
  events.ts        |     100 |      100 |     100 |     100 |                   
  gitUtils.ts      |   94.66 |    82.35 |     100 |   94.66 | 75-78             
  ...AutoUpdate.ts |    51.2 |       95 |      50 |    51.2 | 84-149            
  ...lationInfo.ts |     100 |      100 |     100 |     100 |                   
  package.ts       |   88.88 |       80 |     100 |   88.88 | 33-34             
  processUtils.ts  |     100 |      100 |     100 |     100 |                   
  readStdin.ts     |   79.24 |       90 |      80 |   79.24 | 31-38,50-52       
  resolvePath.ts   |   66.66 |       25 |     100 |   66.66 | 12-13,16,18-19    
  sandbox.ts       |       0 |        0 |       0 |       0 | 1-959             
  settingsUtils.ts |   87.33 |    94.73 |   96.87 |   87.33 | ...91-418,462-463 
  spawnWrapper.ts  |     100 |      100 |     100 |     100 |                   
  ...upWarnings.ts |   53.84 |    33.33 |     100 |   53.84 | 17-26,38-39       
  ...entEmitter.ts |     100 |      100 |     100 |     100 |                   
  ...upWarnings.ts |     100 |      100 |     100 |     100 |                   
  version.ts       |     100 |       50 |     100 |     100 | 11                
 ...ed-integration |   25.05 |        0 |       0 |   25.05 |                   
  acp.ts           |    3.29 |        0 |       0 |    3.29 | ...53-289,292-339 
  ...temService.ts |   19.35 |      100 |       0 |   19.35 | 15-19,22-34,37-46 
  schema.ts        |     100 |      100 |     100 |     100 |                   
  ...ntegration.ts |    3.13 |        0 |       0 |    3.13 | ...18-869,884-934 
-------------------|---------|----------|---------|---------|-------------------
Core Package - Full Text Report
-------------------|---------|----------|---------|---------|-------------------
File               | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
-------------------|---------|----------|---------|---------|-------------------
All files          |   80.03 |    85.18 |   79.43 |   80.03 |                   
 src               |     100 |      100 |     100 |     100 |                   
  index.ts         |     100 |      100 |     100 |     100 |                   
 src/__mocks__/fs  |     100 |      100 |     100 |     100 |                   
  promises.ts      |     100 |      100 |     100 |     100 |                   
 src/code_assist   |   78.65 |    83.68 |   81.25 |   78.65 |                   
  codeAssist.ts    |    17.5 |      100 |       0 |    17.5 | 16-38,41-54       
  converter.ts     |   96.22 |    95.55 |     100 |   96.22 | 181-185,199       
  ...al-storage.ts |     100 |    74.07 |     100 |     100 | 37-39,70-73       
  oauth2.ts        |   81.77 |    82.71 |    92.3 |   81.77 | ...13-514,537-538 
  server.ts        |   54.21 |    73.33 |   57.14 |   54.21 | ...30-233,252-253 
  setup.ts         |   86.66 |    78.94 |     100 |   86.66 | ...,92-94,118-124 
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/config        |    79.4 |    86.92 |    53.9 |    79.4 |                   
  config.ts        |   78.19 |    85.27 |   48.54 |   78.19 | ...-977,1041-1042 
  models.ts        |     100 |      100 |     100 |     100 |                   
  storage.ts       |   84.44 |    94.73 |      75 |   84.44 | ...14-115,118-119 
 ...nfirmation-bus |    95.5 |    90.47 |   85.71 |    95.5 |                   
  index.ts         |       0 |        0 |       0 |       0 | 1-8               
  message-bus.ts   |   98.71 |    94.73 |     100 |   98.71 | 74                
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/core          |   81.36 |    85.62 |   76.92 |   81.36 |                   
  baseLlmClient.ts |     100 |      100 |     100 |     100 |                   
  client.ts        |   85.89 |    85.81 |      68 |   85.89 | ...73-681,759-767 
  ...tGenerator.ts |   92.47 |     82.6 |     100 |   92.47 | 77-78,129,149-152 
  ...lScheduler.ts |   79.13 |    80.37 |   85.18 |   79.13 | ...1088,1168-1172 
  geminiChat.ts    |    82.9 |    88.69 |   71.42 |    82.9 | ...87-688,691-692 
  geminiRequest.ts |     100 |      100 |     100 |     100 |                   
  logger.ts        |   82.94 |    81.81 |     100 |   82.94 | ...44-348,388-399 
  ...tGenerator.ts |   12.98 |      100 |      10 |   12.98 | ...93-194,197-200 
  ...olExecutor.ts |     100 |      100 |      50 |     100 |                   
  prompts.ts       |   97.77 |      100 |   66.66 |   97.77 | 347-404           
  subagent.ts      |   86.84 |    81.31 |     100 |   86.84 | ...55-663,706-707 
  tokenLimits.ts   |   14.28 |      100 |       0 |   14.28 | 15-32             
  turn.ts          |      88 |    88.46 |     100 |      88 | ...23,336-337,384 
 src/fallback      |     100 |      100 |     100 |     100 |                   
  handler.ts       |     100 |      100 |     100 |     100 |                   
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/generated     |     100 |      100 |     100 |     100 |                   
  git-commit.ts    |     100 |      100 |     100 |     100 |                   
 src/ide           |   72.27 |     83.9 |   75.47 |   72.27 |                   
  constants.ts     |     100 |      100 |     100 |     100 |                   
  detect-ide.ts    |   96.96 |    97.29 |     100 |   96.96 | 63-65             
  ide-client.ts    |   57.07 |    78.65 |    60.6 |   57.07 | ...92-800,826-834 
  ide-installer.ts |   89.14 |    81.48 |     100 |   89.14 | ...37,144-148,161 
  ideContext.ts    |     100 |      100 |     100 |     100 |                   
  process-utils.ts |   87.09 |    74.19 |     100 |   87.09 | ...25,156,166-167 
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/mcp           |   76.73 |    71.11 |   83.72 |   76.73 |                   
  ...h-provider.ts |   86.36 |      100 |   33.33 |   86.36 | ...85,89,93,97-98 
  ...h-provider.ts |   73.43 |    52.12 |     100 |   73.43 | ...98-805,812-814 
  ...en-storage.ts |    98.6 |    97.67 |     100 |    98.6 | 84-85             
  oauth-utils.ts   |   67.78 |    78.57 |    90.9 |   67.78 | ...61-282,307-330 
 .../token-storage |   88.39 |    86.46 |      95 |   88.39 |                   
  ...en-storage.ts |     100 |      100 |     100 |     100 |                   
  ...en-storage.ts |   82.75 |    82.35 |   92.85 |   82.75 | ...62-172,180-181 
  ...en-storage.ts |     100 |      100 |     100 |     100 |                   
  index.ts         |     100 |      100 |     100 |     100 |                   
  ...en-storage.ts |   85.71 |    81.81 |      90 |   85.71 | ...25-227,249-250 
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/mocks         |     100 |      100 |     100 |     100 |                   
  msw.ts           |     100 |      100 |     100 |     100 |                   
 src/output        |     100 |      100 |     100 |     100 |                   
  ...-formatter.ts |     100 |      100 |     100 |     100 |                   
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/policy        |   93.33 |    94.02 |    90.9 |   93.33 |                   
  index.ts         |       0 |        0 |       0 |       0 | 1-8               
  policy-engine.ts |     100 |      100 |     100 |     100 |                   
  ...-stringify.ts |   89.09 |    88.88 |     100 |   89.09 | 63-64,69-70,90-91 
  types.ts         |     100 |      100 |     100 |     100 |                   
 src/prompts       |   26.41 |      100 |      25 |   26.41 |                   
  mcp-prompts.ts   |   18.18 |      100 |       0 |   18.18 | 11-19             
  ...t-registry.ts |   28.57 |      100 |   28.57 |   28.57 | ...42,48-55,68-73 
 src/routing       |   98.59 |       75 |      80 |   98.59 |                   
  ...terService.ts |     100 |    85.71 |     100 |     100 | 78                
  ...ngStrategy.ts |       0 |        0 |       0 |       0 | 1                 
 ...ing/strategies |     100 |      100 |     100 |     100 |                   
  ...erStrategy.ts |     100 |      100 |     100 |     100 |                   
  ...teStrategy.ts |     100 |      100 |     100 |     100 |                   
  ...ltStrategy.ts |     100 |      100 |     100 |     100 |                   
  ...ckStrategy.ts |     100 |      100 |     100 |     100 |                   
  ...deStrategy.ts |     100 |      100 |     100 |     100 |                   
 src/services      |   89.64 |    83.21 |   92.75 |   89.64 |                   
  ...ingService.ts |   85.27 |    57.14 |     100 |   85.27 | ...14-416,443-445 
  ...eryService.ts |   96.73 |    96.96 |    87.5 |   96.73 | 115,140-141       
  ...temService.ts |     100 |      100 |     100 |     100 |                   
  gitService.ts    |   69.07 |     92.3 |      60 |   69.07 | ...12-122,125-129 
  ...ionService.ts |   97.67 |     92.5 |     100 |   97.67 | ...79-380,386-387 
  ...ionService.ts |   89.54 |    82.35 |     100 |   89.54 | ...85-590,608-613 
 src/telemetry     |   72.75 |    86.17 |   76.97 |   72.75 |                   
  ...y-detector.ts |     100 |      100 |     100 |     100 |                   
  ...vity-types.ts |     100 |      100 |     100 |     100 |                   
  constants.ts     |     100 |      100 |     100 |     100 |                   
  ...-exporters.ts |   26.47 |      100 |       0 |   26.47 | ...84,87-88,91-92 
  gcp-exporters.ts |     100 |      100 |     100 |     100 |                   
  ...rk-tracker.ts |     100 |      100 |     100 |     100 |                   
  index.ts         |     100 |      100 |     100 |     100 |                   
  ...t.circular.ts |       0 |        0 |       0 |       0 | 1-63              
  ...t.circular.ts |       0 |        0 |       0 |       0 | 1-128             
  loggers.ts       |   65.04 |    72.22 |      60 |   65.04 | ...30-649,652-671 
  metrics.ts       |   69.56 |    94.44 |   53.84 |   69.56 | ...78-280,286-288 
  rate-limiter.ts  |     100 |      100 |     100 |     100 |                   
  sdk.ts           |   86.58 |    65.38 |     100 |   86.58 | ...06,211-212,214 
  ...etry-utils.ts |     100 |      100 |     100 |     100 |                   
  ...l-decision.ts |     100 |      100 |     100 |     100 |                   
  types.ts         |   76.59 |    77.94 |   81.39 |   76.59 | ...85-605,639-650 
  uiTelemetry.ts   |    99.3 |    96.15 |     100 |    99.3 | 130               
 ...learcut-logger |   72.79 |    76.62 |   61.53 |   72.79 |                   
  ...cut-logger.ts |    69.6 |    76.31 |   61.53 |    69.6 | ...1078,1081-1084 
  ...tadata-key.ts |     100 |      100 |     100 |     100 |                   
 src/test-utils    |   76.01 |     92.3 |   66.66 |   76.01 |                   
  config.ts        |     100 |      100 |     100 |     100 |                   
  index.ts         |     100 |      100 |     100 |     100 |                   
  mock-tool.ts     |   18.64 |        0 |       0 |   18.64 | ...8,61-62,72-115 
  ...aceContext.ts |     100 |      100 |     100 |     100 |                   
  tools.ts         |   95.86 |    95.23 |      80 |   95.86 | 60-61,129,133-134 
 src/tools         |   74.07 |    82.28 |   81.92 |   74.07 |                   
  diffOptions.ts   |     100 |      100 |     100 |     100 |                   
  edit.ts          |   83.06 |    88.37 |   85.71 |   83.06 | ...49-450,540-580 
  glob.ts          |   91.11 |    81.96 |    87.5 |   91.11 | ...29-230,332-333 
  grep.ts          |   59.25 |    82.14 |      80 |   59.25 | ...04-608,618-619 
  ls.ts            |   96.29 |    88.52 |     100 |   96.29 | 140-145,176,180   
  ...nt-manager.ts |   80.89 |    66.66 |      80 |   80.89 | ...12-119,127-128 
  mcp-client.ts    |    31.6 |    78.02 |      50 |    31.6 | ...1367,1371-1374 
  mcp-tool.ts      |    94.9 |    93.05 |   94.11 |    94.9 | 200-210,272-273   
  memoryTool.ts    |   83.15 |    82.97 |   88.88 |   83.15 | ...31-246,357-375 
  ...iable-tool.ts |     100 |    84.61 |     100 |     100 | 99,106            
  read-file.ts     |    98.7 |    97.14 |    87.5 |    98.7 | 63-64             
  ...many-files.ts |   78.78 |    79.41 |   85.71 |   78.78 | ...37-438,445-446 
  ripGrep.ts       |   90.13 |    87.61 |   93.75 |   90.13 | ...63-464,485-486 
  shell.ts         |   83.22 |    77.02 |    90.9 |   83.22 | ...76-383,388-389 
  smart-edit.ts    |   79.06 |    76.34 |      85 |   79.06 | ...70-772,784-827 
  tool-error.ts    |     100 |      100 |     100 |     100 |                   
  tool-registry.ts |    72.8 |    66.07 |   77.77 |    72.8 | ...09-411,438-439 
  tools.ts         |   86.32 |    89.13 |      75 |   86.32 | ...73-374,390-396 
  web-fetch.ts     |    60.3 |    54.05 |    90.9 |    60.3 | ...45-346,353-354 
  web-search.ts    |     100 |     93.1 |     100 |     100 | 106-107           
  write-file.ts    |   83.95 |    83.87 |      75 |   83.95 | ...49-452,464-500 
 src/utils         |   87.73 |    88.31 |    89.3 |   87.73 |                   
  LruCache.ts      |   80.64 |       75 |     100 |   80.64 | 28,30-34          
  bfsFileSearch.ts |   89.77 |     92.3 |     100 |   89.77 | 86-94             
  browser.ts       |    7.69 |      100 |       0 |    7.69 | 17-56             
  editCorrector.ts |   77.94 |    61.64 |    92.3 |   77.94 | ...89-701,735,749 
  editor.ts        |   96.83 |    93.75 |     100 |   96.83 | ...84-185,187-188 
  ...entContext.ts |     100 |      100 |     100 |     100 |                   
  errorParsing.ts  |     100 |     92.3 |     100 |     100 | 76,80,86          
  ...rReporting.ts |   83.72 |    84.61 |     100 |   83.72 | 82-86,107-115     
  errors.ts        |   55.95 |    71.42 |   41.66 |   55.95 | ...86-102,106-112 
  fetch.ts         |   34.04 |      100 |       0 |   34.04 | 22-27,31-57       
  fileUtils.ts     |   95.32 |    90.37 |     100 |   95.32 | ...36-240,450-456 
  formatters.ts    |   54.54 |       50 |     100 |   54.54 | 12-16             
  ...noreParser.ts |   85.45 |    81.48 |     100 |   85.45 | ...59,65-66,72-73 
  ...eUtilities.ts |    95.4 |    94.87 |     100 |    95.4 | 16-17,45-46       
  ...rStructure.ts |   95.96 |    94.93 |     100 |   95.96 | ...14-117,345-347 
  getPty.ts        |    12.5 |      100 |       0 |    12.5 | 21-34             
  ...noreParser.ts |    92.3 |    89.13 |     100 |    92.3 | ...15-116,186-187 
  gitUtils.ts      |   51.21 |       90 |      50 |   51.21 | 40-41,50-73       
  ...rePatterns.ts |     100 |      100 |     100 |     100 |                   
  ...ionManager.ts |     100 |       90 |     100 |     100 | 23                
  ...-detection.ts |     100 |      100 |     100 |     100 |                   
  ...edit-fixer.ts |     100 |      100 |     100 |     100 |                   
  ...yDiscovery.ts |   85.75 |    75.43 |   77.77 |   85.75 | ...87-388,391-392 
  ...tProcessor.ts |   91.51 |    88.46 |   84.61 |   91.51 | ...02-308,385-386 
  ...Inspectors.ts |     100 |      100 |     100 |     100 |                   
  ...kerChecker.ts |   83.69 |    83.33 |     100 |   83.69 | 65-66,76-81,89-95 
  partUtils.ts     |     100 |      100 |     100 |     100 |                   
  pathReader.ts    |     100 |      100 |     100 |     100 |                   
  paths.ts         |   86.13 |    87.87 |     100 |   86.13 | ...,89-90,101-102 
  ...tIdContext.ts |     100 |      100 |     100 |     100 |                   
  ...rDetection.ts |    64.4 |    76.19 |     100 |    64.4 | ...4,88-89,99-100 
  retry.ts         |   62.55 |    73.21 |     100 |   62.55 | ...58-278,323-338 
  ...nStringify.ts |     100 |      100 |     100 |     100 |                   
  ...aValidator.ts |    82.6 |       50 |     100 |    82.6 | 27-28,30-31       
  ...r-launcher.ts |   76.52 |     87.5 |   66.66 |   76.52 | ...33,135,153-191 
  session.ts       |     100 |      100 |     100 |     100 |                   
  shell-utils.ts   |   88.59 |    93.91 |   91.66 |   88.59 | ...43-245,463-491 
  summarizer.ts    |     100 |    88.88 |     100 |     100 | 91                
  ...emEncoding.ts |      98 |    94.11 |     100 |      98 | 106-107           
  ...Serializer.ts |   99.07 |    91.22 |     100 |   99.07 | 90,150-152        
  testUtils.ts     |   84.44 |    72.72 |   83.33 |   84.44 | 27-28,34-35,70-72 
  textUtils.ts     |   53.33 |      100 |      50 |   53.33 | 36-55             
  tool-utils.ts    |   91.48 |    89.47 |     100 |   91.48 | 53-54,57-58       
  ...untManager.ts |   97.14 |    94.59 |     100 |   97.14 | 36-38             
  ...aceContext.ts |   96.82 |    95.12 |    92.3 |   96.82 | 94-95,109-110     
 ...ils/filesearch |   96.17 |     91.4 |     100 |   96.17 |                   
  crawlCache.ts    |     100 |      100 |     100 |     100 |                   
  crawler.ts       |   96.22 |     92.3 |     100 |   96.22 | 66-67             
  fileSearch.ts    |   93.22 |    87.14 |     100 |   93.22 | ...28-229,231-232 
  ignore.ts        |     100 |      100 |     100 |     100 |                   
  result-cache.ts  |     100 |     92.3 |     100 |     100 | 46                
-------------------|---------|----------|---------|---------|-------------------

For detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run.

@gemini-cli gemini-cli bot added kind/enhancement priority/p2 Important but can be addressed in a future release. area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality labels Sep 12, 2025
Copy link
Copy Markdown
Contributor

@abhipatel12 abhipatel12 left a comment

Choose a reason for hiding this comment

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

Looks great! Have a couple of questions!

if (approvalMode === ApprovalMode.YOLO) {
rules.push({
decision: PolicyDecision.ALLOW,
priority: 0, // Lowest priority
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is YOLO supposed to have the lowest priority?

In general, how are we assigning the priority number here? Will we want some central map or set that tells us the various numbers in use at any given point?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added updated comments.

}
}

for (const tool of WRITE_TOOLS) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are we adding this loop for readability? We have a default decision below as well for ASK_USER

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes I wanted it to be explicit while we transition over to the new system.

if (settings.mcp?.excluded) {
for (const server of settings.mcp.excluded) {
rules.push({
toolName: `^mcp://${server}/.*`,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does the PolicyEngine in core support pattern matching like we have here? I thought the matching was exact string matching?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Add comprehensive support for MCP server trust configurations in the policy
engine, enabling centralized tool permission management. This change:

- Adds policy rules for MCP servers with trust=true flag (priority 90)
- Adds policy rules for allowed MCP servers from settings.mcp.allowed (priority 85)
- Adds policy rules for excluded MCP servers from settings.mcp.excluded (priority 195)
- Uses the serverName__* pattern to match MCP tool naming convention
- Documents the complete priority hierarchy for policy rules
- Updates tests to cover all MCP server configuration scenarios including
  trust flags, allowed/excluded lists, and priority conflicts
- Ensures proper priority ordering: excludes > allows > trust > general rules

This centralizes all tool confirmation logic into the policy engine, making
it easier to understand and maintain the security model for both built-in
tools and MCP server tools.
…vers

Enhance the policy engine to support wildcard patterns in tool names using
the "serverName__*" syntax. This enables MCP server-wide policy rules that
match all tools from a specific server.

Changes:
- Modified ruleMatches() to detect and handle "__*" wildcard patterns
- Pattern "serverName__*" now matches any tool like "serverName__toolName"
- Added comprehensive tests for wildcard pattern matching
- Ensures specific tool rules can override server-wide wildcards via priority

This change is essential for the MCP server trust integration, allowing
policies to efficiently manage permissions for all tools from a server
without needing to enumerate each tool individually.
Fix policy engine integration issues and add comprehensive integration tests
to ensure the policy configuration works correctly with the PolicyEngine.

Changes:
- Fixed TypeScript error in wildcard pattern matching for undefined tool names
- Fixed YOLO mode to not add write tool rules that would override the
  wildcard ALLOW rule (priority issue)
- Added comprehensive integration test suite that verifies:
  - Basic tool allow/deny configurations
  - MCP server wildcard patterns work correctly
  - Priority ordering is applied properly
  - YOLO and AUTO_EDIT modes function as expected
  - Edge cases like conflicting configurations
  - Non-interactive mode transformations

The integration tests ensure that the policy configuration generated by
createPolicyEngineConfig() produces valid PolicyEngine configurations that
behave correctly in all scenarios.
@allenhutchison
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a policy engine configuration layer to maintain backward compatibility with existing settings. The implementation correctly translates various settings like tools.allowed, mcp.allowed, etc., into policy rules. The changes are well-tested with new unit and integration tests.

My review focuses on a critical correctness issue in the policy priority logic and a high-severity maintainability issue related to deep package imports. The current priority assignment leads to counterintuitive permission behavior where general rules override specific ones. Additionally, deep imports into the dist folder of a dependency create a fragile coupling between packages. I've provided suggestions to address these points.

Comment on lines +46 to +59
// Priority system for policy rules:
// - Higher priority numbers win over lower priority numbers
// - When multiple rules match, the highest priority rule is applied
// - Rules are evaluated in order of priority (highest first)
//
// Priority levels used in this configuration:
// 0: Default allow-all (YOLO mode only)
// 10: Write tools default to ASK_USER
// 50: Auto-accept read-only tools
// 85: MCP servers allowed list
// 90: MCP servers with trust=true
// 100: Explicitly allowed individual tools
// 195: Explicitly excluded MCP servers
// 200: Explicitly excluded individual tools (highest priority)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

The current priority system for policy rules can lead to counterintuitive behavior. Specifically, a general server exclusion (mcp.excluded with priority 195) overrides a specific tool permission (tools.allowed with priority 100). A user would reasonably expect a more specific rule to take precedence over a general one.

For example, if a user excludes mcp-server but wants to allow mcp-server__safe-tool, the current logic will deny the tool. This is confirmed by tests in policy-engine.integration.test.ts.

To fix this, the priorities should be adjusted to give specific rules higher precedence. Here is a suggested new priority scheme:

  • 210: tools.exclude (Specific Deny)
  • 200: tools.allowed (Specific Allow)
  • 195: mcp.excluded (Wildcard Deny)
  • 90: mcp.trust (Wildcard Allow)
  • 85: mcp.allowed (Wildcard Allow)

This would make the behavior more predictable and align with user expectations. The existing tests will need to be updated to reflect this corrected logic.

- Export PolicyEngine from @google/gemini-cli-core to avoid deep imports
- Update integration test to use proper import path
- Fix misleading comment about priority precedence
- Add comprehensive test coverage for all settings combinations

This addresses maintainability concerns about brittle deep imports
into the dist folder and clarifies the intentional priority system
where denies always override allows for security.
Copy link
Copy Markdown
Contributor

@abhipatel12 abhipatel12 left a comment

Choose a reason for hiding this comment

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

Looks good! Had a couple of questions!


// READ_ONLY_TOOLS is a list of built-in tools that do not modify the user's
// files or system state.
const READ_ONLY_TOOLS = new Set([
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: should we consider using the actual tool names (by importing the tool) in the off chance these change during some hill climbing exercise where we change tool names.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same comment for the write tools below!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. Done

// 85: MCP servers allowed list
// 90: MCP servers with trust=true
// 100: Explicitly allowed individual tools
// 195: Explicitly excluded MCP servers
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This may be the intended behavior, but is there a way for a user to exclude a MCP server in general but then specifically allow a single tool?

Is there any reason we'd want to give higher priority to explicitly allowed or disallowed tools than server wide inclusions/exclusions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Includes and excludes for MCP work on a per-tool basis. There is a trust setting that covers the entire MCP server config.

Comment on lines +128 to +134
if (settings.useSmartEdit) {
rules.push({
toolName: 'replace',
decision: PolicyDecision.DENY,
priority: 200,
});
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the smart edit tool uses the same name as the regular edit (replace).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I thought it was actually called SmartEdit from the file name. Thanks.


// If auto-accept is enabled, allow all read-only tools.
// Priority: 50
if (settings.tools?.autoAccept) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Did not know we even had this haha!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right, we have so many settings for permissions. At least this will bring them all together in one place.

@allenhutchison allenhutchison linked an issue Sep 17, 2025 that may be closed by this pull request
3 tasks
Copy link
Copy Markdown
Contributor

@abhipatel12 abhipatel12 left a comment

Choose a reason for hiding this comment

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

Awesome, really excited to build on this! LGTM

Comment on lines +51 to +52
WebFetchTool.Name,
WebSearchTool.Name,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Did you mean to move web search from read only to write?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed. Good catch. That's what I get for manual coding :-/

@allenhutchison allenhutchison added this pull request to the merge queue Sep 18, 2025
@mattKorwel mattKorwel removed this pull request from the merge queue due to the queue being cleared Sep 18, 2025
@allenhutchison allenhutchison added this pull request to the merge queue Sep 18, 2025
Merged via the queue into main with commit afba59a Sep 18, 2025
24 checks passed
@allenhutchison allenhutchison deleted the adh/feature/policy-engine-integration branch September 18, 2025 20:58
nagendrareddy10 pushed a commit to nagendrareddy10/gemini-cli that referenced this pull request Sep 22, 2025
yashv6655 added a commit to yashv6655/gemini-cli that referenced this pull request Sep 22, 2025
giraffe-tree pushed a commit to giraffe-tree/gemini-cli that referenced this pull request Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality priority/p2 Important but can be addressed in a future release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Epic: Tool Confirmation Message Bus

2 participants