Skip to content

refactor: code consistency pass against cella house style - #41

Merged
flipvh merged 10 commits into
mainfrom
refactor/consistency-review
Oct 8, 2026
Merged

flipvh merged 10 commits into
mainfrom
refactor/consistency-review

Conversation

@flipvh

@flipvh flipvh commented Oct 6, 2026

Copy link
Copy Markdown
Member

A consistency pass over the whole repo against cella's house style, from a 7-agent review (5 analysis + 2 adversarial verification passes). Net −828 lines with core functionality and concepts unchanged. One commit per theme:

Dead code (cbb10b1)

  • Removes getRemoteUrl, write-only fields (AnalysisSummary.total, AnalyzedFile.hasConflict, FileChange.newPath, unread vulnerability/registry fields), stats' unreachable json option, an unreachable else in analyze-core, and the unreachable (and incorrect) pinned-rename fallback in merge-engine.
  • Unexports ~20 symbols with no consumer outside their own file; deletes the dead and misleading tests/integration/FIXTURE-REPO.md.
  • Adds root config.ts to tsconfig include so the published ./config entry is typechecked.

Consolidation and structure (a06def7)

  • One pnpm-JSON runner replaces the twin getOutdatedPackages/runPnpmAudit rescue blocks; one parseSyncManifest; shared SYNC_APPLIED_STATUSES, PACKAGE_JSON_SYNC_KEYS, CommitRangeEntry, commit-list cap, dividers, maxBuffer and errorMessage helpers.
  • Every service entry is now run<Service>(config) (audit and stats no longer take option bags that echoed config fields).
  • git.ts: fetch renamed fetchRemote (stops shadowing the global), merge() flags hardcoded (every caller passed the same two), listCommitsBetween pagination simplified and its always-true oldestFirst option removed.
  • Extractions where length hurt: audit's prompt flow, contributions' fork selection and item builder, shared engine-spinner/report helpers for analyze+sync.

Surface polish (bdd357c, 5a236db, 3e041eb, b1fe49c)

  • Unknown --fork (and the other soft-fail paths in contributions/forks) now throw and exit 1; previously they printed red and exited 0, which silently fooled tooling callers.
  • --list is now a clean machine mode like --json: human output goes to stderr, machine rows to stdout (audit's --list keeps its report on stdout, it only skips prompts).
  • Command/flag descriptions unified across cli.ts and the README; contributions --list is now correctly described as tab-separated rows.

Tests (509d881, 940e095)

  • One tests/helpers/test-env.ts replaces ~15 copy-pasted exec/createRepo/write/commitAll scaffolds (including a drifted git identity in packages.test.ts); shared pnpm/gh child-process stub.
  • sync-gates and sync-worktree move to tests/e2e/ where their full-service runs belong; 88 should-style titles renamed to the suite's verb-first form.

Style (bb68251)

  • ~110 narration comments deleted, 12 "Sync CLI v2" headers rewritten to say what each module is, 118 em dashes removed, ~20 history-contrast comments reworded, ~35 empty JSDoc blocks deleted and voices normalized, banner comments dropped, utf8/named-import/console idioms unified, user messages lowercased, sanitizeCredentials renamed redactUrlSecrets.

Verification

pnpm check, pnpm test (271 tests / 26 files, identical to the pre-branch baseline) and pnpm test:release all green; commitlint clean across the branch. The only observable behavior changes are the surface-polish items above; --json shapes, flags and the sync/merge semantics are untouched.

🤖 Generated with Claude Code

flipvh and others added 9 commits October 6, 2026 14:20
- drop getRemoteUrl, FileChange.newPath, AnalyzedFile.hasConflict, AnalysisSummary.total and the write-only audit fields
- remove the unreachable identical fallback in analyze-core and the dead pinned-rename fallback in merge-engine
- delete runStats' unused json option, tests/integration/FIXTURE-REPO.md, the unused vitest globals flag and the src test include glob
- unexport 20 file-local declarations; none had outside consumers
- typecheck the published config.ts entry via tsconfig include
- reword the syncWithPackages JSDoc and runSync's caller note to match reality

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Duplication consolidated:
- one private pnpm-JSON runner behind getOutdatedPackages/runPnpmAudit
- SYNC_APPLIED_STATUSES shared by merge-engine totalResolved and sync's
  hasStagedSyncChanges; PACKAGE_JSON_SYNC_KEYS spells the 10 keys once
  (type and zod schema derive from it)
- parseSyncManifest shared by readSyncManifest and readManifestAtRef
- runEngineWithSpinner and printEngineReports/printLogFileReport replace
  the engine-call and report-tail blocks duplicated by analyze and sync
- audit: one severity-count formatter, vuln icons as a record lookup,
  DIVIDER instead of inline rules
- isUpstreamRepo shared by the menu context and contributions
- COMMIT_LIST_MAX (50-commit display cap), MENU_DIVIDER and MAX_BUFFER
  (50MB subprocess buffer) each defined once
- errorMessage(error) replaces seven inline instanceof-Error ternaries
  (non-Error throws now stringify instead of 'unknown error')
- display's checkMark replaces inline pc.green checkmarks
- CommitRangeEntry in config/types used by git, display, merge-engine,
  sync and MergeResult
- forks reuses getWorkingTreeChangeCount (wrapped in catch)
- cli readOptions collapses its ladders onto str()/flag(); option
  literals shared verbatim across services are hoisted

Structure unified:
- runAudit and runStats take the RuntimeConfig like every service;
  cella-cli switch cases consistently braced
- preflight and getMenuContext are synchronous
- git: fetch renamed fetchRemote (shadowed global fetch), merge
  hardcodes --no-commit/--no-edit (every caller passed both),
  listCommitsBetween drops oldestFirst and paginates with slice,
  getFileChanges dedupes the zero-hash ternary
- merge-engine: isProtectedFile predicate ties the batch plan to the
  phase-5 skip; protected-conflict membership test via a Set
- contributions: toItem closure, selectFork extraction, constant
  bounds memo inlined
- audit: promptForUpdates split into buildUpdateChoices and
  executeUpdates, workspace map flattened to Map<string, string[]>,
  dependent package.json reader hoisted to module level
- stats: PackageStats type alias; sync: printFinishSteps inlined
- display: printSummary maxCount derived from statusOrder, stranded
  flag-warnings JSDoc moved onto printFlagWarnings

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- contributions: unknown --fork, no valid forks, and multiple forks without --fork in non-interactive mode now throw instead of console.error + return (exit 0)
- forks: unknown --fork throws too
- contributions --diff with an unknown path throws like analyze --diff, so one mechanism reports all invalid targets via main's handler

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- --list now routes header/steps/warnings to stderr exactly as --json and --diff do
- the machine lines themselves bypass the redirect: analyze's path-per-line loop and contributions' tab-separated rows write via writeStdout
- contributions keeps its comparison banner suppressed under --list/--diff to hold the stderr noise budget; comment updated

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- one canonical phrasing per shared flag: --fork hoisted as forkOption, contributions reuses jsonOption, --diff gets the same core wording in analyze and contributions
- contributions --list description now says tab-separated rows, not one file per line; the readme contributions section names the columns
- sync one-liner unified on the accurate form (fresh branch, package.json sync, squash-merge PR); the menuDescription override folded in and dropped
- forks, contributions, audit and -h descriptions aligned between cli.ts and readme; audit spells out 'and'
- types.ts: the diff field doc covers analyze too, not contributions only
- readme contributions section: a single fork is selected, not one or more

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Audit's --list skips interactive prompts; it has no machine stdout
payload, so routing its report to stderr left stdout empty.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- tests/helpers/test-env.ts is the one home for exec, write, commitAll,
  createRepo, GIT_USER and UPSTREAM_REMOTE; the ~14 local exec copies and
  7 createRepo variants are deleted
- packages.test.ts builds its upstream+fork pair with the shared
  createTestEnv, whose initial upstream files are now parameterizable
- the three ensure-sync-base/graft e2e files import the shared scaffolding
  instead of carrying verbatim copies
- the duplicated pnpm/gh spawnSync stub lives in tests/helpers/mock-pnpm-gh.ts;
  it stays a standalone module because a vi.mock factory importing anything
  that pulls node:child_process deadlocks the mock resolution
- sync-gates and sync-worktree run the full sync against real repo pairs,
  so they move to tests/e2e/ next to the suites they belong with

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- the 88 "should <verb> X" it-titles become the suite's dominant
  verb-first "<verb>s X" form (negations as "does not" / "never"),
  across audit, git-parsing, overrides, packages and sync-e2e

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- narration: deleted ~115 comments that restated the adjacent code, trimming the
  ones that held a constraint down to that constraint
- history: rewrote the 12 'sync CLI v2' file headers as noun-phrase module
  descriptions; purged body vestiges (preflight's 'no longer cares', the old
  VS Code diff reference, the upstream-view-worktree line, audit's catalogMode
  story, the 'previously' comments in git/sync/merge-engine); the documented
  compat contracts (LEGACY_CONFIG_FILE, legacy worktree sweep, fileLinkMode
  'local', migrate's 'no longer upstream' label) stay
- punctuation: removed all 108 em dashes in src/ and 10 in README (punctuation
  only), plus the hyphen-dashes used the same way; reworded ~20 'instead of /
  rather than / as opposed to' comments to state current behavior
- jsdoc: deleted empty-calorie docs (getCurrentBranch, main, spinner one-liners,
  stats format helpers, runAudit/runForks/runAnalyze duplicates, ...), reworded
  'Gets X' / imperative one-liners to noun phrases, fixed runContributions'
  stale plural, and documented compareVersions, hasEnv and getEnvSnapshot
- naming: sanitizeCredentials -> redactUrlSecrets, comments now name the proof
  (tokens/passwords embedded in remote URLs)
- mechanical: section banners dropped or replaced with plain one-liners,
  'utf-8' -> 'utf8' (17 sites), import * as fs/path -> named imports (audit,
  audit-utils, coverage-utils), packages' console.warn x4 -> console.info with
  pc.yellow, ~10 user messages lowercased ('sync merge staged', 'counted raw
  lines of code', 'interrupted (SIGINT)', ...), cherrypick -> cherry-pick,
  '&' -> 'and', the sync/forks 'command' prose now says 'service'
- tests: one assertion updated to the new 'nothing to sync:' punctuation

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…review

Brings in stats --since (#42). Conflicts resolved by keeping this branch's
structure and wording and adding #42's feature on top:

- src/cli.ts: since/md read through the str()/flag() helpers; --md joins
  the machine-output modes next to the audit --list exception
- src/cella-cli.ts: braced stats case, runStats(config) for the snapshot
  mode, runBranchStats for --since
- src/services/stats.ts: this branch's comments, plus the exports
  stats-since.ts imports
- README.md: this branch's wording, plus the --since row and section

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@flipvh
flipvh merged commit b673615 into main Oct 8, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant