feat(tools): add TestRunner, GitAnalysis, DependencyAnalyzer, CodeAnalysis tools#1475
feat(tools): add TestRunner, GitAnalysis, DependencyAnalyzer, CodeAnalysis tools#1475skyhighbg22-jpg wants to merge 1 commit into
Conversation
…lysis tools New tools for the agent: TestRunnerTool (TestRunner): - Structured test execution with auto-detection (jest, vitest, pytest, go test, cargo test) - Parses results into pass/fail counts, failure details, durations - checkPermissions returns 'ask' (routes through permission system) - isReadOnly: false, isConcurrencySafe: false GitAnalysisTool (GitAnalysis): - blame: who wrote each line (with line range support) - log: search commit messages with author/date/file filters - diff-range: compare arbitrary refs - show-commit: full commit analysis - isReadOnly: true (no bisect — removed as it mutates .git) DependencyTool (DependencyAnalyzer): - audit, outdated, graph, license, info operations - Auto-detects package manager (npm/cargo/pip/go) - checkPermissions returns 'ask' (routes through permission system) - isReadOnly: false, isConcurrencySafe: false CodeAnalysisTool (CodeAnalysis): - complexity, dead-code, imports, duplicates, size operations - Python-aware indentation-based scope tracking - Go import block parsing (not overbroad regex) - isReadOnly: true All tools registered in tool pool. TestRunner and DependencyAnalyzer removed from ASYNC_AGENT_ALLOWED_TOOLS (require permission prompt). Includes focused permission tests (6 tests).
jatmn
left a comment
There was a problem hiding this comment.
I found issues that need to be addressed before this is ready.
Findings
-
[P1] Keep CodeAnalysis inside approved project roots
src/tools/CodeAnalysisTool/CodeAnalysisTool.ts:232
CodeAnalysisis registered as read-only, auto-allowed, and available to async agents, but it resolves any supplied path withpath.resolve(cwd, inputPath)and then reads it without checking that the target stays inside the current workspace or an explicitly allowed directory. A model can therefore callCodeAnalysison an absolute path or..path outside the project and get file-derived content back without a permission prompt. For example, theimportsoperation reads a target file and returns matchingexportlines, so a source-like file outside the repo can be disclosed through the tool result. Please route this through the same project/file permission boundary used by existing file-reading tools, or reject paths outside approved roots before anystatSync/readFileSync/directory walk occurs. -
[P2] Show the real dependency commands before running them
src/tools/DependencyTool/DependencyTool.ts:121
The dependency tool asks for permission using only the high-level operation name, but the implementation may execute materially different commands, including package-manager installs andnpxexecution. For instance,operation: "license"on npm runsnpx license-checker --json, Go audit first runsgo install github.com/securego/gosec/v2/cmd/gosec@latest, and Cargo license/outdated operations install helper crates before running the analysis. A user approving “Run dependency command: license” or “audit” is not being shown the network/install/executable command they are actually approving. Please compute and display the exact command sequence incheckPermissions, or split install/bootstrap steps into explicit prompts.
Summary
Adds 4 new analysis tools to the agent's tool pool. Each tool is self-contained with its own schema, UI, prompt, and constants. Includes focused permission tests.
New Tools
TestRunnerTool (
TestRunner)Structured test execution with framework auto-detection. Accepts
command(optional — auto-detects from project files),args, andpattern(test name filter).isReadOnly: false,isConcurrencySafe: falsecheckPermissionsreturns{ behavior: 'ask' }— goes through the permission system like BashToolGitAnalysisTool (
GitAnalysis)Read-only git history analysis. Operations:
blame— line-by-line authorship with optional line rangelog— search commits by message, author, date range, filediff-range— compare two refs with stat + full diffshow-commit— full commit details (author, date, diff, stats)isReadOnly: true(nobisect— it mutates.gitstate)DependencyTool (
DependencyAnalyzer)Dependency analysis with auto-detected package manager (npm/cargo/pip/go). Operations:
audit— security vulnerability scanningoutdated— check for outdated packagesgraph— dependency tree visualizationlicense— license info for all dependenciesinfo— details for a specific packageisReadOnly: false,checkPermissionsreturns{ behavior: 'ask' }CodeAnalysisTool (
CodeAnalysis)Static code analysis for refactoring decisions. Operations:
complexity— cyclomatic complexity metrics (Python-aware with indentation-based scope tracking)dead-code— detect potentially unused exports/modulesimports— import/dependency graph analysis (Go import block parsing, not overbroad regex)duplicates— detect duplicate code blocks across filessize— file sizes and line countsisReadOnly: trueTool Registration
getAllBaseTools()insrc/tools.tsTestRunnerToolandDependencyToolexcluded fromASYNC_AGENT_ALLOWED_TOOLS(require permission prompt for subprocess execution)GitAnalysisToolandCodeAnalysisToolincluded inASYNC_AGENT_ALLOWED_TOOLS(read-only)Tests
src/tools/TestRunnerTool/permissions.test.ts— 6 tests:isReadOnly() === false,isConcurrencySafe() === false,checkPermissions → askisReadOnly() === false,isConcurrencySafe() === false,checkPermissions → ask