Skip to content

🧹 Refactor Duplicated JSON Parsing Logic - #5

Merged
SireJeff merged 6 commits into
mainfrom
refactor-json-parsing-17627427213899443861
Feb 19, 2026
Merged

SireJeff merged 6 commits into
mainfrom
refactor-json-parsing-17627427213899443861

Conversation

@SireJeff

Copy link
Copy Markdown
Owner

🎯 What: Extracted duplicated JSON parsing logic into a shared utility function parseAIResponse.
💡 Why: This improves maintainability and readability by centralizing the logic for robustly parsing JSON from AI responses (handling markdown blocks and conversational text).
✅ Verification:

  • Created tests/utils/ai-parser.test.ts with comprehensive test cases.
  • Verified the logic with a manual Node.js script since the environment lacks vitest.
  • Confirmed all refactored files correctly import and use the new utility.
    ✨ Result: Reduced code duplication and improved robustness across multiple agents and CLI commands.

PR created automatically by Jules for task 17627427213899443861 started by @SireJeff

- Created src/utils/ai-parser.ts with parseAIResponse utility
- Refactored DriftAgent, FactCheckAgent, IntelligentAnalyzer, cross-sync, and cleanup commands to use the new utility
- Added comprehensive unit tests for the new utility
- Improved robustness of JSON extraction from AI responses by supporting both objects and arrays and handling markdown formatting

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

SireJeff and others added 3 commits February 18, 2026 22:08
- Created src/utils/ai-parser.ts with parseAIResponse utility
- Refactored multiple agents and commands to use the new utility
- Moved sqlite-vec-windows-x64 to optionalDependencies to fix CI installation failure on Linux
- Added comprehensive unit tests for the new parser utility

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
- Fixed require statement errors by replacing them with proper imports
- Resolved lexical declaration errors in switch-case blocks by adding braces
- Fixed unnecessary escape characters in regex and prefer-const issues
- Addressed any warnings by using better types or unknown
- Fixed a bug in task matching regex in todolist-manager.ts
- Removed unused imports and variables

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@SireJeff

Copy link
Copy Markdown
Owner Author

@jules , ci is failing

@google-labs-jules

Copy link
Copy Markdown
Contributor

@jules , ci is failing

I've addressed the CI failures. The issues were caused by a combination of platform-specific dependency errors (EBADPLATFORM for sqlite-vec-windows-x64) and several lint errors/warnings (ESM import vs require, lexical declarations in switch cases, unused variables, and any types). I have now moved the platform-specific package to optionalDependencies and cleaned up the lint issues across the codebase. CI should pass now.

SireJeff and others added 2 commits February 19, 2026 17:11
- Created src/utils/ai-parser.ts with parseAIResponse utility
- Refactored multiple agents and commands to use the new utility
- Fixed CI platform errors by moving sqlite-vec-windows-x64 to optionalDependencies
- Resolved numerous lint errors and warnings across the codebase
- Fixed require statement errors, lexical declarations, and unnecessary escapes
- Improved type safety and removed unused imports/variables
- Corrected task matching regex in todolist-manager.ts

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
- Fixed src/cli/generate.ts compilation errors by defining SimpleContextItem interface
- Corrected variable naming in generateClineMapContext
- Restored settings type to Record<string, any> in src/cli/index.ts to fix property access errors
- Standardized ContextItem usage across all tool-specific generator functions

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@SireJeff
SireJeff merged commit 7c9c518 into main Feb 19, 2026
3 checks passed
@SireJeff
SireJeff deleted the refactor-json-parsing-17627427213899443861 branch February 19, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant