Add DEBUG=tweakcc env var support and replace raw console.log/warn (#471)#512
Add DEBUG=tweakcc env var support and replace raw console.log/warn (#471)#512astrosteveo wants to merge 5 commits intoPiebald-AI:mainfrom
Conversation
📝 WalkthroughWalkthroughReplaces ad-hoc console.log/console.warn calls with centralized Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
e0d848a to
c9a8e2d
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/patches/systemPrompts.ts`:
- Around line 130-136: The backtick validation currently logs the formatted
error with debug(formatBacktickError(...)) then silently continues (continue)
leaving no trace in results; change these debug() calls to warn() so users see
the actionable message (i.e., call warn(formatBacktickError(...)) and warn('')
instead of debug), and before the continue push a concise failure entry into
results (e.g., mark this prompt as skipped with the formatted error message) so
callers can programmatically observe which prompts were skipped.
🧹 Nitpick comments (2)
src/tests/logger.test.ts (2)
40-54: Spy and env cleanup can leak if an assertion throws.In the
debugtest,spy.mockRestore()anddelete process.env.DEBUGare after the assertions. If an assertion fails, the spy stays attached andDEBUGremains set, potentially affecting later tests. Consider usingafterEachor atry/finallyblock, consistent with the pattern already used in theisDebugsuite.Suggested structure
describe('debug', () => { + afterEach(() => { + delete process.env.DEBUG; + }); + it('only outputs when debug is enabled', () => { const spy = vi.spyOn(console, 'log').mockImplementation(() => {}); - delete process.env.DEBUG; - - debug('should not appear'); - expect(spy).not.toHaveBeenCalled(); - - process.env.DEBUG = 'tweakcc'; - debug('should appear'); - expect(spy).toHaveBeenCalledWith('should appear'); - - spy.mockRestore(); - delete process.env.DEBUG; + try { + delete process.env.DEBUG; + debug('should not appear'); + expect(spy).not.toHaveBeenCalled(); + + process.env.DEBUG = 'tweakcc'; + debug('should appear'); + expect(spy).toHaveBeenCalledWith('should appear'); + } finally { + spy.mockRestore(); + } }); });
57-65: Same cleanup concern forwarnspy.Minor nit — same pattern applies: wrap in
try/finallyor useafterEachforspy.mockRestore().
b2dcaf6 to
7c55623
Compare
Backtick errors in user prompt files are actionable user feedback, not internal diagnostics. Using debug() would silently skip broken prompts.
7c55623 to
ae94546
Compare
Summary
isDebug()to checkprocess.env.DEBUGfortweakccor*, enabling debug output viaDEBUG=tweakccwithout the--debugCLI flagwarn()helper tosrc/utils.tsfor consistent warning outputconsole.log(diagnostic) withdebug()andconsole.warnwithwarn()across 8 filesChanges
src/utils.ts:isDebug()now checksDEBUGenv var; addedwarn()helpersrc/patches/helpers.ts: 10 diagnosticconsole.log→debug()src/patches/conversationTitle.ts: 1console.log→debug()src/patches/systemPrompts.ts: 3console.log→debug()src/config.ts: 6console.warn→warn()src/nativeInstallation.ts: 1console.warn→warn()src/systemPromptDownload.ts: 1console.warn→warn()src/patches/fixLspSupport.ts: 3console.warn→warn()src/patches/suppressNativeInstallerWarning.ts: 1console.warn→warn()src/tests/logger.test.ts: 6 new tests forisDebug(),debug(), andwarn()User-facing CLI output in
index.tsx,commands.ts, andsystemPromptSync.tsis intentionally unchanged. Allconsole.errorcalls are unchanged per requirements.Testing
Manually verified against CC 2.1.39:
DEBUG=tweakcc pnpm start --applyshows diagnostic outputpnpm start --applyis clean (no debug noise)--debugflag still works as beforeRelated Issues
Closes #471
Summary by CodeRabbit
Refactor
Tests