@@ -37,7 +37,7 @@ This document outlines a prioritized refactoring plan for the 51 issues identifi
3737| 2.5a | Extract multiline keyboard navigation | ✅ Complete | Codebuff |
3838| 2.5b | Extract multiline editing handlers | ✅ Complete | Codebuff |
3939| 2.6 | Simplify use-activity-query.ts | ✅ Complete | Codebuff |
40- | 2.7 | Consolidate XML parsing | ⬜ Not Started | - |
40+ | 2.7 | Consolidate XML parsing | ✅ Complete | Codebuff |
4141| 2.8 | Consolidate analytics | ⬜ Not Started | - |
4242| 2.9 | Refactor doStream | ⬜ Not Started | - |
4343| 2.10 | DRY up OpenRouter stream handling | ⬜ Not Started | - |
@@ -637,22 +637,79 @@ After initial commit, 4 CLI agents reviewed and identified warnings. All were fi
637637
638638---
639639
640- ### Commit 2.7: Consolidate XML Parsing
640+ ### Commit 2.7: Consolidate XML Parsing ✅ COMPLETE
641641** Files:** ` common/src/util/saxy.ts ` + 3 related files
642642** Est. Time:** 2-3 hours
643- ** Est. LOC Changed:** ~ 400-500
643+ ** Actual Time:** ~ 2 hours (including multi-agent review and fixes)
644+ ** Est. LOC Changed:** ~ 400-500
645+ ** Actual LOC Changed:** 808 lines total (741 saxy + 20 tool-call-parser + 7 tag-utils + 17 index + 23 package.json export)
644646
645- | Task | Description |
646- | ------| -------------|
647- | Audit all XML parsing usages | Map current implementations |
648- | Create unified ` xml-parser.ts ` | Single parsing module |
649- | Create typed interfaces | ` XmlNode ` , ` XmlParser ` |
650- | Migrate all usages | Update imports |
651- | Remove duplicate implementations | Clean up |
647+ | Task | Description | Status |
648+ | ------| -------------| --------|
649+ | Audit all XML parsing usages | Mapped 4 files: saxy.ts, xml.ts, xml-parser.ts, stream-xml-parser.ts | ✅ |
650+ | Create unified ` common/src/util/xml/ ` directory | New directory with organized modules | ✅ |
651+ | Move ` saxy.ts ` to ` xml/saxy.ts ` | Core streaming XML parser | ✅ |
652+ | Move ` xml-parser.ts ` to ` xml/tool-call-parser.ts ` | Tool call XML parsing utility | ✅ |
653+ | Move ` xml.ts ` to ` xml/tag-utils.ts ` | XML tag utilities (closeXml, getStopSequences) | ✅ |
654+ | Create ` xml/index.ts ` | Unified re-exports for all XML utilities | ✅ |
655+ | Update all 7 consumers | Direct imports from ` @codebuff/common/util/xml ` | ✅ |
656+ | Add package.json export | Explicit ` ./util/xml ` → ` ./src/util/xml/index.ts ` | ✅ |
657+ | Multi-agent review | 4 CLI agents (Codex, Codebuff, Claude Code, Gemini) | ✅ |
658+ | Apply review fixes | Deleted shims, cleaned AI slop | ✅ |
659+
660+ ** New Directory Structure:**
661+ ```
662+ common/src/util/xml/
663+ ├── index.ts (17 lines) - Unified exports (cleaned)
664+ ├── saxy.ts (741 lines) - Streaming XML parser
665+ ├── tag-utils.ts (7 lines) - closeXml, getStopSequences (cleaned)
666+ └── tool-call-parser.ts (20 lines) - parseToolCallXml (cleaned)
667+ ```
668+
669+ ** Multi-Agent Review (Codex, Codebuff, Claude Code, Gemini):**
670+
671+ All 4 CLI agents reviewed the initial implementation and reached consensus on improvements:
652672
653- ** Dependencies:** None (can run in parallel with 2.6)
673+ | Finding | Agents | Severity | Resolution |
674+ | ---------| --------| ----------| ------------|
675+ | ** Shims add unnecessary complexity** | All 4 | ⚠️ Warning | Deleted all 3 shim files |
676+ | ** Only 6-7 consumers need updating** | All 4 | Info | Updated all consumers directly |
677+ | ** AI slop comments** | 3/4 | Suggestion | Removed verbose JSDoc |
678+ | ** Duplicate parseToolCallXml export** | Claude | ⚠️ Warning | Fixed by removing shims |
679+ | ** Package export needed** | - | Critical | Added explicit export in package.json |
680+
681+ ** Review Fixes Applied:**
682+
683+ | Fix | Description |
684+ | -----| -------------|
685+ | Delete shim files | Removed ` saxy.ts ` , ` xml.ts ` , ` xml-parser.ts ` shims (24 lines) |
686+ | Update 7 consumers | Direct imports from ` @codebuff/common/util/xml ` |
687+ | Add package.json export | ` "./util/xml" ` → ` "./src/util/xml/index.ts" ` for module resolution |
688+ | Clean AI slop | Removed ~ 30 lines of verbose JSDoc comments |
689+ | Update test import | ` saxy.test.ts ` now imports from ` ../xml ` |
690+
691+ ** Files Updated:**
692+ - ` common/package.json ` - Added explicit xml export
693+ - ` common/src/util/__tests__/saxy.test.ts ` - Import from ` ../xml `
694+ - ` packages/internal/src/utils/xml-parser.ts ` - Import from ` @codebuff/common/util/xml `
695+ - ` agents-graveyard/base/ask.ts ` - Already using correct import
696+ - ` agents-graveyard/base/base-lite-grok-4-fast.ts ` - Already using correct import
697+ - ` agents-graveyard/base/base-prompts.ts ` - Already using correct import
698+ - ` packages/agent-runtime/src/system-prompt/prompts.ts ` - Already using correct import
699+ - ` packages/agent-runtime/src/util/messages.ts ` - Already using correct import
700+ - ` web/src/app/admin/traces/utils/trace-processing.ts ` - Already using correct import
701+ - ` web/src/app/api/admin/relabel-for-user/route.ts ` - Already using correct import
702+
703+ ** Test Results:**
704+ - 259 common package tests pass
705+ - All 13 package typechecks pass
706+ - 2,892+ tests pass across CLI, agent-runtime, billing, SDK packages
707+ - 29 Saxy XML parser tests pass
708+
709+ ** Dependencies:** None
654710** Risk:** Low
655- ** Rollback:** Revert single commit
711+ ** Rollback:** Revert single commit
712+ ** Commit:** ` 417c0b5ff `
656713
657714---
658715
0 commit comments