Skip to content

Use tree sitter for parsing terminal auto approve sub-commands - #272281

Merged
Daniel Imms (Tyriar) merged 22 commits into
mainfrom
tyriar/tree_sitter_subcommand
Oct 22, 2025
Merged

Daniel Imms (Tyriar) merged 22 commits into
mainfrom
tyriar/tree_sitter_subcommand

Conversation

@Tyriar

@Tyriar Daniel Imms (Tyriar) commented Oct 20, 2025 •

Copy link
Copy Markdown
Contributor

Fixes #261794

@Tyriar Daniel Imms (Tyriar) added this to the October 2025 milestone Oct 20, 2025
@Tyriar Daniel Imms (Tyriar) self-assigned this Oct 20, 2025
@Tyriar
Daniel Imms (Tyriar) force-pushed the tyriar/tree_sitter_subcommand branch from e1b411e to e5f4295 Compare October 22, 2025 12:38
Copilot AI review requested due to automatic review settings October 22, 2025 13:02

Copilot AI left a comment

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.

Pull Request Overview

This PR migrates from a string-based regex parser to Tree-sitter for parsing terminal commands into sub-commands to improve accuracy and support for shell syntax edge cases.

Key Changes:

  • Adds TreeSitterCommandParser class to parse commands using Tree-sitter grammars for Bash and PowerShell
  • Extends ITreeSitterLibraryService with async getLanguage() and createQuery() methods
  • Updates @vscode/tree-sitter-wasm dependency from 0.1.4 to 0.2.0
  • Removes string-based sub-command splitting logic and associated test file

Reviewed Changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/vs/workbench/services/treeSitter/browser/treeSitterLibraryService.ts Adds async getLanguage() and createQuery() methods, renames sync methods with Sync suffix
src/vs/workbench/contrib/terminalContrib/chatAgentTools/test/browser/subCommands.test.ts Removes entire test file for deprecated string-based parser
src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalChatAgentToolsConfiguration.ts Removes dangerous pattern rules that blocked parentheses, braces, and backticks
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/treeSitterCommandParser.ts New class implementing Tree-sitter-based command parsing
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts Integrates Tree-sitter parser, updates auto-approve flow with async parsing
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/subCommands.ts Removes entire file containing deprecated string-based parser
src/vs/editor/test/common/services/testTreeSitterLibraryService.ts Updates test service to implement new interface methods
src/vs/editor/standalone/browser/standaloneTreeSitterLibraryService.ts Updates standalone service to implement new interface methods
src/vs/editor/common/services/treeSitter/treeSitterLibraryService.ts Adds documentation and new async methods to interface
src/vs/editor/common/model/tokens/treeSitter/treeSitterSyntaxTokenBackend.ts Updates to use renamed Sync suffix methods
package.json Updates tree-sitter dependency version
eslint.config.js Adds type import allowance for tree-sitter-wasm

@Tyriar
Daniel Imms (Tyriar) marked this pull request as ready for review October 22, 2025 21:12
@Tyriar
Daniel Imms (Tyriar) merged commit cc5c66b into main Oct 22, 2025
@Tyriar
Daniel Imms (Tyriar) deleted the tyriar/tree_sitter_subcommand branch October 22, 2025 21:34
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Dec 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use tree sitter for terminal auto approve command parsing

3 participants