feat(tools): SwiftAgentKitTools product (filesystem, shell, PDF) - #17
Merged
Conversation
A new opt-in library product of ready-made native AgentTools, mirroring the SwiftAgentKitMCP pattern. Apps import it, register what they want, and supply the confirmation UI/policy via AgentCallbacks.onToolConfirmation. - Filesystem (Foundation-only, cross-platform): read_file (paged), write_file (append/overwrite, requiresConfirmation), list_dir, search_files (name/content substring, bounded traversal). - Shell (run_shell, requiresConfirmation, macOS-only): zsh -lc, reads to EOF, bounded output, configurable default working directory. Promoted from Naseem. - PDF (#if canImport(PDFKit)): pdf_info, pdf_extract_text (page range), pdf_merge / pdf_split (requiresConfirmation). Read tools are unconfirmed; disk-mutating tools require confirmation. New SwiftAgentKitToolsTests target (11 tests): filesystem round-trips, search, shell exit/cwd, PDF merge->split. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
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.
Summary
Adds
SwiftAgentKitTools, a new opt-in library product of ready-made nativeAgentTools — the same pattern asSwiftAgentKitMCP. Appsimport SwiftAgentKitTools, register the ones they want, and supply the confirmation UI/policy viaAgentCallbacks.onToolConfirmation.Layering: generic capability lives in the framework; app-specific UI/policy stays in the app; security-sensitive tools split (execution here, decision/UI in the app).
Tools
read_file(paged),write_file(append/overwrite,requiresConfirmation),list_dir,search_files(name and/or content substring, bounded traversal).run_shell,requiresConfirmation, macOS-only via#if os(macOS)):zsh -lc, reads to EOF (no pipe deadlock), bounded output, configurable default working directory. Promoted from the Naseem app so every consumer gets it.#if canImport(PDFKit)):pdf_info,pdf_extract_text(page range, bounded),pdf_merge/pdf_split(requiresConfirmation).Read tools are unconfirmed; disk-mutating tools are
requiresConfirmation(fail-closed via the existing dispatcher gate).Tests
New
SwiftAgentKitToolsTests(11): filesystem write→read→append, list-dir, search by name/content, shell exit/cwd, PDF merge→split round-trip, confirmation flags. All 108 tests pass.🤖 Generated with Claude Code