-
Notifications
You must be signed in to change notification settings - Fork 3.2k
refactor(gists): migrate gists.go to NewTool pattern #1591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(gists): migrate gists.go to NewTool pattern #1591
Conversation
Convert GetMe, GetTeams, and GetTeamMembers to use the new typed dependency injection pattern: - Functions now take only translations helper, return toolsets.ServerTool - Handler is generated lazily via deps.GetClient/deps.GetGQLClient - Tests updated to use serverTool.Handler(deps) pattern - Fixed error return pattern to return nil for Go error (via result.IsError) Co-authored-by: Adam Holt <oholt@github.com>
There was a problem hiding this comment.
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 gist-related tools to the new NewTool pattern with dependency injection, removing the getClient parameter from function signatures and using ToolDependencies instead. This is part of a stacked PR series refactoring the ServerTool architecture.
- Removes
getClientparameter from all gist tool functions - Adopts
NewToolpattern withToolDependenciesfor dependency injection - Standardizes error handling using
utils.NewToolResultErrorFromErr - Updates all tests to use the new
serverTool.Handler(deps)pattern withresult.IsErrorchecks
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/github/gists.go | Refactored all four gist tools (ListGists, GetGist, CreateGist, UpdateGist) to use NewTool pattern with ToolDependencies, standardized error handling, and removed getClient parameter |
| pkg/github/tools.go | Updated gist toolset registration to remove NewServerToolLegacy wrapper and call tool functions without getClient parameter |
| pkg/github/gists_test.go | Updated all test cases to use new pattern with serverTool.Handler(deps), replaced error checking with result.IsError assertions, and added getErrorResult helper usage |
Convert all gist tools (ListGists, GetGist, CreateGist, UpdateGist) to use the new NewTool helper with ToolDependencies injection. - Remove getClient parameter from function signatures - Use deps.GetClient(ctx) inside handlers - Standardize error handling with utils.NewToolResultErrorFromErr() - Update all tests to use serverTool.Handler(deps) pattern Co-authored-by: Adam Holt <omgitsads@users.noreply.github.com>
af97440 to
820ce1e
Compare
07249a0 to
b863da9
Compare
bac6db2
into
SamMorrowDrums/server-tool-refactor-context-tools
* refactor(search): migrate search tools to new ServerTool pattern Migrate search.go tools (SearchRepositories, SearchCode, SearchUsers, SearchOrgs) to use the new NewTool helper and ToolDependencies pattern. - Functions now take only TranslationHelperFunc and return ServerTool - Handler generation uses ToolDependencies for typed access to clients - Update tools.go call sites to remove getClient parameter - Update tests to use new Handler(deps) pattern This demonstrates the migration pattern for additional tool files. Co-authored-by: Adam Holt <oholt@github.com> * Migrate context_tools to new ServerTool pattern Convert GetMe, GetTeams, and GetTeamMembers to use the new typed dependency injection pattern: - Functions now take only translations helper, return toolsets.ServerTool - Handler is generated lazily via deps.GetClient/deps.GetGQLClient - Tests updated to use serverTool.Handler(deps) pattern - Fixed error return pattern to return nil for Go error (via result.IsError) Co-authored-by: Adam Holt <omgitsads@users.noreply.github.com> * refactor(gists): migrate gists.go to NewTool pattern (#1591) * Migrate context_tools to new ServerTool pattern Convert GetMe, GetTeams, and GetTeamMembers to use the new typed dependency injection pattern: - Functions now take only translations helper, return toolsets.ServerTool - Handler is generated lazily via deps.GetClient/deps.GetGQLClient - Tests updated to use serverTool.Handler(deps) pattern - Fixed error return pattern to return nil for Go error (via result.IsError) Co-authored-by: Adam Holt <oholt@github.com> * refactor(gists): migrate gists.go to NewTool pattern Convert all gist tools (ListGists, GetGist, CreateGist, UpdateGist) to use the new NewTool helper with ToolDependencies injection. - Remove getClient parameter from function signatures - Use deps.GetClient(ctx) inside handlers - Standardize error handling with utils.NewToolResultErrorFromErr() - Update all tests to use serverTool.Handler(deps) pattern Co-authored-by: Adam Holt <omgitsads@users.noreply.github.com> --------- Co-authored-by: Adam Holt <oholt@github.com> Co-authored-by: Adam Holt <omgitsads@users.noreply.github.com> --------- Co-authored-by: Adam Holt <oholt@github.com> Co-authored-by: Adam Holt <omgitsads@users.noreply.github.com>
Summary
Migrates all gist tools (
ListGists,GetGist,CreateGist,UpdateGist) to the newNewToolpattern withToolDependenciesinjection.Part of stacked PRs for ServerTool refactoring:
Changes
getClientparameter from all gist function signaturest translations.TranslationHelperFuncand returntoolsets.ServerTooldeps.GetClient(ctx)inside handlers to get the GitHub clientutils.NewToolResultErrorFromErr()instead offmt.ErrorfserverTool.Handler(deps)pattern withresult.IsErrorchecksTesting
script/lintpassesscript/testpassesCo-authored-by: Adam Holt oholt@github.com