refactor: logging helper + tool boilerplate extractor#55
Merged
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Centralize stderr writes behind src/util/log.ts so we stop having to remember to add \n, drop the awkward template + "\\n" concatenation pattern, and remove the bug class where missing newlines made log lines run together. script.ts is left on console.* since it's a standalone CLI, not the MCP server. index.ts's fatal-error console.error is kept since it carries the Error object for stack output.
Every trading tool repeated the same try/catch: - serialise the result as pretty JSON - if ApprovalRequiredError, serialise that as JSON instead - otherwise rethrow Centralizing it in one helper drops ~48 lines and makes each tool's execute body focus on its zod schema + service call.
MarvelNwachukwu
force-pushed
the
chore/logging-and-tool-helpers
branch
from
May 15, 2026 11:06
6a67a52 to
92e0287
Compare
2 tasks
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
Two small refactors that cut ~75 lines and remove a bug class:
src/util/log.ts— centralises stderr writes behind onelog()helper, so we stop having to remember to append\n(the bug from chore: quick-win cleanup batch (6 atomic fixes) #54 commitbe9f75a) or use the awkwardtemplate + "\n"concatenation pattern.src/util/with-approval-guard.ts— every trading tool repeated the sametry { ... ApprovalRequiredError ... }boilerplate. Now one helper covers that, and each tool'sexecutebody focuses on schema + service call.script.tskeepsconsole.*(standalone CLI, not the MCP server).index.ts's fatal-error path keepsconsole.errorbecause it carries theErrorobject for stack output.Test plan