Implement Sourcegraph Toolbox PowerShell port into PSAI#111
Closed
Copilot wants to merge 5 commits intospike-toolkit-and-skillsfrom
Closed
Implement Sourcegraph Toolbox PowerShell port into PSAI#111Copilot wants to merge 5 commits intospike-toolkit-and-skillsfrom
Copilot wants to merge 5 commits intospike-toolkit-and-skillsfrom
Conversation
…e tools Co-authored-by: dfinke <67258+dfinke@users.noreply.github.com>
…e registrations Co-authored-by: dfinke <67258+dfinke@users.noreply.github.com>
Co-authored-by: dfinke <67258+dfinke@users.noreply.github.com>
Co-authored-by: dfinke <67258+dfinke@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement Sourcegraph Toolbox PowerShell port into PSAI
Implement Sourcegraph Toolbox PowerShell port into PSAI
Oct 23, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR implements a Sourcegraph Toolbox-style toolbox system for PSAI, enabling dynamic discovery and loading of tool collections for AI agents. The implementation is provided as a spike in
/spikes/PSToolboxAIand demonstrates the pattern described in issue #108.Overview
The Sourcegraph Toolbox pattern provides a way to organize and dynamically load collections of related tools that AI agents can use. This implementation follows the environment-based discovery approach described in the Sourcegraph Toolbox documentation, adapted for PowerShell and integrated with PSAI's existing agent infrastructure.
Key Features
Environment-Based Discovery
$env:PSAI_TOOLBOX_PATHenvironment variable (supports multiple paths)Dynamic Tool Registration
Global:scope for accessibilityRegister-Toolto create OpenAI-compatible tool specificationsSeamless Integration
New-Agent -ToolsparameterGet-AgentResponseandInvoke-InteractiveCLICalculatorToolandTavilyToolImplementation
The module provides three main functions:
Get-PSAIToolboxPath- Discovers toolbox directories from environment or returns default pathGet-PSAIToolbox- Loads tool scripts, calls registration functions, and returns tool specificationsNew-PSAIToolboxAgent- Convenience function combining tool discovery and agent creationIncluded Toolboxes
Three sample toolboxes demonstrate the pattern:
FileSystem Toolbox (
tmp/tools/filesystem/)Get-DirectoryListing- List files and directories with filteringRead-FileContent- Read file contents with encoding supportTest-FileExists- Check file/directory existenceDateTime Toolbox (
tmp/tools/datetime/)Get-CurrentDateTime- Get current time in multiple formats (ISO8601, Unix, etc.)Format-DateTime- Convert date/time strings between formatsGet-DateDifference- Calculate time differences in various unitsText Toolbox (
tmp/tools/text/)Get-TextStatistics- Analyze text (word count, character count, sentence count, etc.)Convert-TextCase- Convert case (upper, lower, title, sentence)Search-TextPattern- Search text using regex patternsUsage Example
Creating Custom Toolboxes
Tool scripts follow a simple pattern:
Testing
A comprehensive test suite validates:
Run tests with:
pwsh -File spikes/PSToolboxAI/test-toolbox.ps1Documentation
Technical Notes
Function Scope: Tool functions use
Global:scope (following the pattern inTavilyTool.psm1) to ensure they're accessible toRegister-Tool.JSON Output: All tool functions return JSON strings as required by OpenAI's function calling API.
No Breaking Changes: This is a new spike module that doesn't modify existing PSAI code.
Future Enhancements
The spike establishes patterns that enable:
Files Added
PSToolboxAI.psd1- Module manifestPSToolboxAI.psm1- Module loaderPublic/PSToolboxAI.ps1- Core functions (240 lines)tmp/tools/*/- Three toolboxes with 9 tools (525 lines)Examples/- Usage examples (2 scripts)test-toolbox.ps1- Test suite (196 lines)README.md- User documentation (280 lines)IMPLEMENTATION_NOTES.md- Technical documentation (275 lines)Closes #108
Original prompt
Fixes #108
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.