Two core files exceed the 300-line guideline significantly:
cli/src/osf.ts: 1,130 lines (377% over limit)parser/src/parser.ts: 904 lines (301% over limit)
- Harder to review and maintain
- Violates AGENTS.md coding standards
- Increases cognitive load for contributors
cli/src/
βββ osf.ts (main, <200 lines)
βββ types.ts (shared types)
βββ utils/
β βββ html-escape.ts (XSS prevention)
β βββ text-renderer.ts (TextRun rendering)
β βββ formula-evaluator.ts (spreadsheet formulas)
βββ render/
β βββ html.ts (renderHtml)
β βββ markdown.ts (exportMarkdown)
β βββ json.ts (exportJson)
β βββ converters.ts (PDF/DOCX/PPTX/XLSX)
βββ commands/
βββ parse.ts
βββ lint.ts
βββ render.ts
βββ export.ts
parser/src/
βββ parser.ts (main parse/serialize, <200 lines)
βββ types.ts (already exists)
βββ lexer.ts
β βββ findBlocks()
β βββ skipWS()
β βββ removeComments()
βββ string-parser.ts
β βββ parseString()
β βββ escapeString()
βββ block-parsers/
β βββ meta.ts (parseMetaBlock)
β βββ doc.ts (parseDocBlock)
β βββ slide.ts (parseSlideBlock)
β βββ sheet.ts (parseSheetBlock)
β βββ chart.ts (parseChartBlock)
β βββ diagram.ts (parseDiagramBlock)
β βββ code.ts (parseCodeBlock)
βββ serializers/
βββ meta.ts (serializeMetaBlock)
βββ doc.ts (serializeDocBlock)
βββ content.ts (serializeContentBlock)
- Create a dedicated refactoring PR
- Extract modules one at a time
- Run full test suite after each extraction
- Maintain 100% test coverage throughout
- No new features during refactoring
- 6-8 hours of careful extraction
- 2-3 hours of testing and validation
- Total: 1-2 days for clean, tested refactor
- All files <300 lines
- 88/88 tests still passing
- No breaking changes to public API
- Documentation updated
- Lint warnings eliminated
Lines: 618, 625
Context: Parsing arbitrary JSON-like structures from OSF
Mitigation: Using type assertions with as unknown as Type
Risk: Low - validated by tests
Lines: 244
Issue: Unnecessary escape characters in template strings
Fix: Use single quotes or remove escapes
- Add runtime validation for chart/diagram data structures
- Create branded types for better type safety
- Add Zod schemas for OSF block validation
Add documentation to:
- All public API functions (
parse,serialize) - Complex internal functions
- Type definitions
Add tests for:
- Unicode edge cases (partial escapes, boundary conditions)
- XSS edge cases (formula results, nested content)
- Error position tracking at EOF
- Large file parsing performance
- Memoize
getLineColumn()for large files - Consider streaming parser for >1MB files
- Add benchmarks for regression testing
This technical debt is acceptable for v1.1.0 release because:
- β All 88/88 tests passing
- β No security vulnerabilities
- β No functional bugs
- β API is stable and backward compatible
- β Production deployments successful
The debt should be addressed in v1.2.0 or earlier to maintain code quality standards.
Created: 2025-01-16
Last Updated: 2025-01-16
Target Resolution: v1.2.0 (Q1 2025)