Reduce the codebase: comments, duplication, and single-use indirection - #36
Merged
Conversation
Drop the carve-outs for module/file-header doc blocks and section dividers, and spell out the never-write list so the project policy matches the global one instead of contradicting it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Remove module/file-header blocks, section dividers, restatement docstrings, ceremonial @param/@returns templates, and narration across all ten code workspaces. Trim the blocks whose buried rationale was worth keeping down to that rationale. Comments only: the sole non-comment changes are three trailing-comment strips and one `catch { /* ignore */ }` collapsed to `catch {}`. Typecheck clean and 746 tests pass, unchanged from before. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Package-local reductions across seven workspaces: - Store's ship and repo halves collapse onto one JsonCollection; the shared SerialQueue keeps both serialized against each other, and load() still commits both maps or neither. - One SerialQueue, one isStrictDescendant, one armory record reader/writer, one GitHub header builder, one sha256 schema, one provider list. - ReposRoute and ShipsRoute share a RegistryPage shell; five copies of the async-submit modal body become useSubmitAction. - Row-shift, row-blank, and CSI/DCS sequence construction extracted in bun-vt. - Un-export symbols with no external consumer; inline single-use aliases, pass-throughs, and injection points nothing supplies. Restore four invariants that the comment pass deleted with their header blocks, as one-line notes on the declarations that enforce them. Typecheck clean and 746 tests pass, unchanged throughout. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
apps/cli and apps/fagent carried a copy-pasted client layer; git-bun and tmux-bun a copy-pasted command base. Each pair now shares one package. - fleet-cli-kit holds normalizeUrl, the bridge client, renderTable, and unwrap, which takes the program name as a parameter rather than baking in the message prefix. The seven normalizeUrl tests move with it, so fagent's previously untested copy is now covered. - cli-bun holds RunResult, Backend, CliError, toInt, and an abstract CliCommand whose only abstract member is globalArgs(). GitError and TmuxError still extend it, so fleet-ship's catch-by-name keeps working. ShellBackend stays separate per package: sharing it would have added an env parameter to tmux's public constructor, which never had one. Typecheck clean; 751 tests pass, up from 746 by the five new tests pinning the shared command base. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The mapError catch tail was inlined 40 times across the two API layers. Register it once per Elysia plugin instead and let handlers throw. The hook guards on instanceof against Elysia's own error types: it derives its error code from error.code, so an unguarded hook renders validation failures as 500 and a code-string guard lets an ENOENT-tagged error escape unmapped. Two sites keep their inline catch deliberately. Ship's GET /armory needs mapArmoryError, which maps ArmorySyncError to its own status rather than 500. The terminal proxy's upstream.onmessage binary site closes ws before upstream, the reverse of its three siblings, and the ordering could not be shown immaterial. Also drop createApp's never-read config parameter, de-export TERMINAL_INIT_TIMEOUT_MS, and name the terminal proxy's repeated socket state and teardown. Differential probes over every route by error class confirm status, content-type, and body are byte-identical: 647/647 on the bridge, and on the ship every reachable case, the 10 exceptions all requiring an async rejection from agentStatus, which returns synchronously. Typecheck clean; 751 tests pass. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
upsertShip, upsertRepo, and deleteShip have no caller anywhere in the repo. Ship removal goes through replaceAllShips, and upsertShip was a pass-through to createShip that nothing invoked. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A pure reduction pass over every workspace. No feature work, no bug fixes.
What changed
c1fae784abd2765bc3c0af6b43e686cecc63106995Net −1,353 lines. Existing source shrank by ~1,900; the two new shared
packages add ~560 back, so the headline number understates the reduction.
751 tests pass, 0 fail, typecheck clean — verified after every step.
Baseline was 746: seven tests moved into
fleet-cli-kit, five are new andpin
cli-bun's shared command base.Reviewing this
4abd276is comment-only. Filteringgit diff -U0to non-comment,non-blank lines yields four items: three trailing-comment strips and one
catch { /* ignore */ }collapsing tocatch {}. It can be read at a glanceor trusted wholesale; the later commits are where the substance is.
Eight ghost comments went with it — text describing code that no longer
exists, including a
restoreAltthat is calledleaveAlt, a header claimingwebsockets were out of scope with
attach170 lines below, a doc calling thealready-shipped Eden client hypothetical, and a documented
BRIDGE_URLenvvar nothing reads.
Worth a closer look
86cecc6removed 39 of 40 inlinedmapErrorcatches. Two keep theirinline catch deliberately: ship's
GET /armoryneedsmapArmoryError, andthe terminal proxy's
upstream.onmessagesite closes sockets in the reverseorder of its siblings. The hook guards on
instanceofagainst Elysia's ownerror types — Elysia derives its error code from
error.code, so anunguarded hook renders validation failures as 500.
Differential probes over every route by error class confirm status,
content-type and body are byte-identical: 647/647 on the bridge, and on the
ship every reachable case.
f6b43e6keepsShellBackendseparate per package. Sharing it wouldhave added an
envparameter to tmux's public constructor, which never hadone.
Two things this pass found but did not fix
fagent/src/agent-ship.tsparses JSON outside its try and before the!response.okcheck, so a 500 with a non-JSON body throwsSyntaxErrorinstead of the intended message.
Session.exists()andTmux.hasSession()calltryRun, which neverthrows, so an unreachable tmux server reports "session does not exist".
Also noted: Eden Treaty's
.data/.errorresolve toanyin this repo,before and after this change. The route paths are typed; the payloads are
not.
🤖 Generated with Claude Code