🧹 refactor parseStableLocation with declarative rule matcher - #65
🧹 refactor parseStableLocation with declarative rule matcher#65MarsLuay wants to merge 1 commit into
Conversation
Refactors parseStableLocation in src/ai/docxStableIds.ts to use declarative PART_RULES and SUFFIX_RULES, decoupling part prefix matching from element suffix matching. This reduces over 200 lines of repetitive if blocks down to a clean, maintainable rule-driven loop while preserving exact location parsing behavior. Includes unit test suite in tests/docx-stable-ids.test.mjs.
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
🎯 What: Refactored
parseStableLocationinsrc/ai/docxStableIds.tsusing declarativePART_RULESandSUFFIX_RULES, and added comprehensive unit tests intests/docx-stable-ids.test.mjs.💡 Why:
parseStableLocationwas over 200 lines long and contained 20 repetitiveifblocks for matching combinations of document parts (body,header,footer,footnotes,endnotes) and block kinds (paragraph,run,table,cell). Decoupling prefix parsing from suffix parsing reduces code duplication, improves maintainability, and enhances readability.✅ Verification:
tests/docx-stable-ids.test.mjstestingparseStableLocationand ID builders across all document parts, block kinds, and invalid formats.node --test tests/docx-stable-ids.test.mjs.npm run smoke:ai-agent.npm run typecheckandnpm run lint.✨ Result: Reduced codebase duplication by ~200 lines with zero behavioral changes and verified test coverage.
PR created automatically by Jules for task 13232248385739136359 started by @MarsLuay