docs/plans/2026-10-10-file-splits.md
87 lines · 7126 bytes
13 symbols in this file
File Splits Implementation PlanGlobal constraintsReview focusTask 1: `Sources/Orgstar/ContentView.swift` (1,106 lines)Task 2: `Sources/OrgEditorAppKit/OrgEditor.swift` (1,566 lines)Task 3: `Sources/OrgstarMobile/MobileEditor.swift` (1,209 lines)Task 4: `Sources/OrgCore/Compute/Babel.swift` (2,017 lines)Task 5: `Sources/OrgCore/Keymap/Presets.swift` (1,357 lines)Task 6: `Sources/OrgCore/Keymap/Vim.swift` (1,353 lines)Task 7: `Sources/Orgstar/AgendaView.swift` (1,278 lines)Task 8: `Sources/OrgCore/Compute/TableFormulas.swift` (1,241 lines)Task 9: `Sources/OrgCore/Commands/OrgList.swift` (1,009 lines)Task 10: Keep it that way
File Splits Implementation Plan
For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: No hand-written Swift file over 1,000 lines, by moving code between files without changing it, so the next pieces of work (windows and panes first) land in files that fit in one read.
Architecture: Each split moves whole // MARK: sections or whole types into a new file in the same module as an extension of the same type. private members that the moved code reaches become internal (no modifier); nothing is renamed, reordered or reworded. One commit per source file, with swift build and swift test green before and after each.
Tech Stack: Swift 6.2, Swift Testing.
Spec: this file.
Global constraints
- Behaviour-preserving: the diff of each commit is moves plus access-level changes only.
git diff --statshows a drop in the source file matching the sum of the new files, give or take theextensionlines. - Generated files are exempt and untouched:
Sources/OrgCore/Keymap/CharFold.swift(fromscripts/update-char-fold.sh) andSources/OrgHighlight/Queries.swift(fromscripts/update-highlight-queries.sh). - Order:
ContentView.swiftandOrgEditor.swiftfirst, since2026-10-10-windows-and-panes.mdedits both; the rest in any order. - Each new file starts with the imports its code needs and nothing else.
Review focus
- A
privatemember made internal must not collide with another internal name in the module: build errors catch it, but checkOrgCorefor duplicate helper names such aslines,trimmedandoffsetbefore moving. @MainActoron the type carries to its extensions;nonisolatedand@objcmethods (textStorage(_:didProcessEditing:…), delegate conformances) must stay in an extension that declares the conformance, orNSObjectdispatch breaks at run time, not build time: run the app afterOrgEditorandMobileEditormove.- Swift Testing suites that use
@testable importand reachprivatehelpers throughfileprivatetest extensions lose access when the helper moves; build the test targets, not just the products. - Stored properties cannot live in extensions: every
varwith storage stays in the file that declares the type.
Task 1: Sources/Orgstar/ContentView.swift (1,106 lines)
- Move
SidebarandOutlineColumntoSidebar.swift(SidebarFiles.swiftalready exists and stays). - Move
SearchResultsandQuickOpenViewtoSearchViews.swift. - Move
BufferTabsandPaneDividertoBufferTabs.swift. - Move
PanelandBlockEditRequesttoPanels.swift. -
ContentViewitself is about 790 lines and stays. Build, test, run the app, commit "Split ContentView.swift".
Task 2: Sources/OrgEditorAppKit/OrgEditor.swift (1,566 lines)
- Move
ShadedFragment,ImageFragment,EntityFragment,FoldedHeadingFragment,InlineImageBoxand theNSAttributedString.Keyextension toFragments.swift. - Move
HiddenRangesandFoldedHeadingstoHiddenRanges.swift. - Move the
Folding,Sparse trees,STARTUP displayandNarrowingsections toOrgEditor+Folding.swift. - Move
Inline imagestoOrgEditor+Images.swift,Shrunk table columnstoOrgEditor+Shrink.swift,StylingtoOrgEditor+Styling.swift. -
OrgEditor.swiftkeeps the class with its stored properties,Initial styling,Saving,Commands,Disk,Editingand the delegate extensions (DocumentBuffer,NSTextStorageDelegate,NSTextContentStorageDelegate,NSTextLayoutManagerDelegate). Build, test, run the app and type in a folded file, commit "Split OrgEditor.swift".
Task 3: Sources/OrgstarMobile/MobileEditor.swift (1,209 lines)
- Move
LockedRanges,FragmentStyle,KeyedTextView,SelectionHighlightView,OrgLineFragment,InlineImageBoxand theNSAttributedString.Keyextension toMobileFragments.swift. - Move
StylingtoMobileEditor+Styling.swift;Shrunk table columns,Inline images,TruncationandFoldingtoMobileEditor+Display.swift. - Build with
scripts/build-ios-app.sh, run in the Simulator, fold a heading and shrink a column, commit "Split MobileEditor.swift".
Task 4: Sources/OrgCore/Compute/Babel.swift (2,017 lines)
- Keep
BabelJob,BabelOutput,enum BabelwithPlanning, andExecuteSrcBlockinBabel.swift. -
BabelNoweb.swift:Noweb(check first whetherBabelExpand.swiftalready holds the expansion it calls; if so, moveNowebthere). -
BabelHeaders.swift:Header argumentsandVariables;BabelVars.swift:Tables in variables. -
BabelCache.swift:Cache.BabelLanguages.swift:PythonandEmacs Lisp.BabelResults.swift:FinishingandInserting. -
swift test --filter Babel, then the whole suite, commit "Split Babel.swift".
Task 5: Sources/OrgCore/Keymap/Presets.swift (1,357 lines)
-
PresetEmacs.swift:emacsBindings;PresetMac.swift:macBindings;PresetDoom.swift:doomBindingsanddoomToml. The enum,common,speedCommandsandspeedBindings(mode:)stay. Static string constants move asextension KeymapPreset { static let emacsBindings = """…""" }. - Keymap tests, commit "Split Presets.swift".
Task 6: Sources/OrgCore/Keymap/Vim.swift (1,353 lines)
-
VimParser.swift:Parsing;VimMotions.swift:MotionsandText objects;VimApply.swift:ApplyingandText.Vim.swiftkeeps the struct, its state andFeeding keys.VimExtras.swiftis the precedent for extensions onVim. - Vim tests, commit "Split Vim.swift".
Task 7: Sources/Orgstar/AgendaView.swift (1,278 lines)
-
AgendaRowView.swift:AgendaRowViewandHabitGraph.AgendaView+Toolbar.swift:Toolbar,Span,Filters.AgendaView+Actions.swift:CommandsandClock, refile, archive, bulk.AgendaView.swiftkeepsAgendaSpan,CalendarAccess, the view,Lines,Days,Items. - Build, open the agenda, run a bulk action, commit "Split AgendaView.swift".
Task 8: Sources/OrgCore/Compute/TableFormulas.swift (1,241 lines)
-
TableFormulaCommands.swift:TableRecalculate,TableEvalFormula,TableEditField, the twoBlockEditextensions and theEmacsBufferextensions after line 977.TableFormulas.swiftkeepsRemoteTablesand the evaluator extension (lines 15–910). - Table formula tests and the oracle, commit "Split TableFormulas.swift".
Task 9: Sources/OrgCore/Commands/OrgList.swift (1,009 lines)
-
OrgListIndent.swift:Indentation changesandRepairs. The rest stays. - List tests and the sort-list oracle, commit "Split OrgList.swift".
Task 10: Keep it that way
-
scripts/check-file-sizes.sh: lists hand-written Swift files over 1,000 lines, exempting the two generated files, exit 1 when any. Note it indocs/design.mdunder Testing, besideswift test. - Commit "check-file-sizes.sh".