- Created isInsideToolParameter() helper method to eliminate code duplication
- Method handles both open and close tag scenarios with optional tagName parameter
- Maintains existing functionality while improving code maintainability
- All tests continue to pass
- Extract isInsideCodeBlock() method from DirectiveStreamingParser
- Replace duplicate code in onopentag and onclosetag handlers
- Add comprehensive test coverage for the extracted logic
- Improve code maintainability and follow DRY principle
- Modified DirectiveStreamingParser to check if currently inside a tool parameter context
- Added logic to treat nested XML tags as plain text when inside tool directive parameters
- Made currentContext and currentParamName properties public in ToolDirectiveHandler for access
- Updated both onopentag and onclosetag handlers to respect tool parameter boundaries
- Fixes issue where <log_message> tags inside <attempt_completion><result> were being processed as separate directives
- All existing tests continue to pass, new test case now passes
- Enhanced DirectiveStreamingParser to track code block state within tool parameters
- Fixed FallbackParser to respect code blocks and properly parse nested XML structures
- Added comprehensive tests for both streaming and fallback scenarios
- Prevents log messages inside code blocks from being processed as actual directives
Fixes issue where <log_message> tags inside code blocks within tool parameters
were being parsed as separate log directives instead of plain text content.
- Add specific test case for `xml code blocks containing log_message directives
- Test passes, confirming the implementation handles this scenario correctly in tests
- However, runtime behavior still differs from test behavior
- Add CodeBlockState enum and extend ParseContext with code block tracking
- Create CodeBlockStateMachine to detect ` boundaries and manage state
- Update TextDirectiveHandler to integrate with state machine
- Modify DirectiveStreamingParser to suppress XML parsing inside code blocks
- Add comprehensive tests for code block handling
NOTE: Tests pass but implementation does NOT work in runtime.
The log messages still appear in Output window instead of being treated
as plain text within code blocks. The real parsing flow differs from
test scenarios and needs further investigation.
- Add missing log_message case handler in presentAssistantMessage.ts
- Fix syntax error by adding missing opening brace for tool_use case
- Make LogManager public in Task class to allow access from presentAssistantMessage
- All tests passing (11/11) and TypeScript compilation clean
- Log messages now properly displayed in Roo-Code Output window
- Replace character-by-character XML parsing with robust SAX parser library
- Add sax and @types/sax dependencies for reliable XML parsing
- Implement event-driven parsing with onopentag, onclosetag, ontext handlers
- Add XML wrapping to handle multiple root elements in streaming scenarios
- Create hasIncompleteXml() method for proper partial XML detection
- Maintain backward compatibility with existing partial detection logic
- Add comprehensive test suite with 6 new test cases
- Preserve fallback to manual parsing when SAX parser fails
- Improve error handling and maintain all existing functionality
Benefits:
- More robust XML parsing with better edge case handling
- Improved performance with event-driven parsing
- Cleaner, more maintainable code
- Standards-compliant XML parsing
- Full backward compatibility
- Moved StreamingParser to DirectiveStreamingParser in assistant-message/
- Renamed directives/ to parsers/
- Created new parser classes with updated names: TextContentParser, ToolUseParser, ParameterParser
- Simplified method names to parse() and finalize()
- Updated documentation in README.md
- Extract TextContentHandler into TextContentHandler.ts
- Extract ParameterHandler into ParameterHandler.ts
- Extract ToolUseHandler into ToolUseHandler.ts
- Create types.ts for shared type definitions
- Update StreamingParser to import from separate files
- Update index.ts exports to reference correct files
- Update README.md to reflect new file structure
- Maintain backward compatibility and streaming behavior
- All tests pass, multi-contributor friendly structure
- Add TextDirective alias for TextContent
- Add ToolDirective alias for ToolUse
- Add Directive union type for TextDirective | ToolDirective
- Maintain backward compatibility with AssistantMessageContent alias
- Update internal usage to use new type names