Commit Graph

7 Commits

Author SHA1 Message Date
fullex
7cbf30222d refactor(shared-error): route error cluster to real homes; drop dead @shared AI-SDK guards
- Slim @shared/types/error.ts to the cross-process SerializedError shape
- Relocate serializeError (+ toSerializable) to src/main/ai/utils/serializeError.ts;
  re-point the 4 main/ai consumers
- Delete the @shared-side dead AI-SDK subtype family + 23 isSerialized* guards
  (utils/error.ts) and the unused ProviderSpecificError class
  (renderer keeps its own live parallel copy)
- Move the serializeError test to main/ai/utils; assert discriminant fields directly
  instead of via the deleted guards
- Doc: mark the section 6 error/serializable row resolved
2026-06-27 06:16:26 -07:00
fullex
bf5910f424 refactor(shared): clean up @shared residue, single-process residents, barrels, naming
- Drop dead @deprecated LanFileChunk{,Ack}Message types; de-Redux a stale comment
- Relocate single-process modules out of @shared (Invariant 1.1):
  - types/plugin.ts -> main/utils (markdownParser-only)
  - utils/ocr.ts + types/ocr.ts -> renderer (renderer-only; types now standalone)
  - utils/searchSnippet.ts, utils/pdf.ts -> main/utils (main-only)
  - utils/externalApp.ts EXTERNAL_APPS -> inlined into ExternalAppsService
- Convert types/file, utils/file, utils/command, utils/api barrels from
  `export *` to explicit named exports (section 3.1)
- Naming: urlUtil.ts->url.ts; api/utils.ts->api/format.ts (+fold formatApiHost/
  formatOllamaApiHost); hasAPIVersion->hasApiVersion; URLString/FileURLString->
  UrlString/FileUrlString; enum codeCLI->CodeCli, terminalApps->TerminalApp with
  UPPER_SNAKE_CASE members
- Sync docs to the moves/renames; track data/types route-by-shape as an open question
2026-06-27 06:16:26 -07:00
fullex
42a5b6320f docs(shared-layer): note Cache schema registry carve-out to cross-process rule 2026-06-23 06:39:01 -07:00
fullex
577829e25e refactor(shared): drop dead LoaderReturn type and its renderer-layer import
Remove the unused `LoaderReturn` from `@shared/types/codeTools.ts` (no consumers on main or the feat/chat-page truth branch). Its `status` field was the sole reason `@shared` imported `ProcessingStatus` from `@types` (src/renderer/types) — a Layer-4 layering violation now eliminated.

Record the remaining types/utils single-process residue (searchSnippet, pdf, EXTERNAL_APPS) and the error/serializable duplication cluster as a migration backlog in shared-layer-architecture.md; keywordSearch and SerializableSchema were verified cross-process via feat/chat-page and correctly stay.
2026-06-19 22:28:36 -07:00
fullex
1c6ff30a18 refactor(shared): dissolve config/ and move logic out of types/ into utils/
Dissolve the by-kind @shared/config junk drawer per shared-layer governance: route each member by shape and actual consumer process — cross-process slices into types//utils//ai/, single-process code back into main/renderer (Invariant 1.1). Confirm each item's real consumer process rather than trusting the directional plan (API_SERVER_DEFAULTS is renderer-only, MIN_WINDOW_* is cross-process, providers.ts is renderer-only), and drop dead consts (ZOOM_LEVELS/ZOOM_OPTIONS, bookExts, thirdPartyApplicationExts).

Purge runtime logic from types/ so the bucket holds only declarations: move serializeError + AI-SDK error guards to utils/error.ts, the FileHandle factories/guards to utils/file/handle.ts, isSerializable + SerializableSchema to utils/serializable.ts, and the tab-instance guard/normalizer to utils/tabInstanceMetadata.ts. Tests follow the logic to utils/__tests__; the type-level ipc contract test is retired (its invariants kept as a breadcrumb for the future IpcApi Zod schema). types/ is now logic-free and test-free.

Also: remove the dead @shared mock from the packages/ui code-editor test so packages/ui no longer references production code; fix the data-classify preference generator prompts import and the update-languages output path to the relocated modules.

Update shared-layer-architecture (3.1 type/util test rule, 5/6 config dissolution) and renderer-architecture cross-references.
2026-06-19 20:41:18 -07:00
fullex
ff6de394f6 refactor(shared): dissolve command/file/shortcuts/externalApp into types/ and utils/ by shape
Move the four ad-hoc top-level @shared dirs into the closed top-level set, routed by shape: pure logic + class blueprints to utils/, type/contract declarations to types/.

command -> utils/command + types/command; file -> utils/file + types/file; shortcuts -> utils/shortcut + types/shortcut; externalApp -> utils/externalApp + types/externalApp.

Replace the exported menuRegistry singleton with a pure resolveMenu over a frozen contribution set (Invariant 1.2: no exported instance); keep MenuRegistry as a per-process blueprint sharing the same resolve algorithm.

Rewrite all consumer imports per symbol origin and align shared-layer-architecture and renderer-architecture docs.
2026-06-19 18:52:21 -07:00
fullex
67ad952cd9 docs(shared-layer-architecture): add @shared governance doc and align cross-references
Add docs/references/shared-layer-architecture.md as the authoritative reference for src/shared: two invariants (cross-process; no mutable runtime state), the closed top-level set {ai, data, ipc, types, utils} by category, types/utils shape rules (single-file vs subdirectory, barrels, constants guardrail), the placement decision, anti-patterns, and a deferred migration section (config dissolution with constant.ts itemized).

Relocate @shared-internal rules out of renderer-architecture.md and architecture-overview.md into the new doc (leaving pointers); repoint command's cross-process cell to @shared/utils/command + @shared/types/command in renderer-architecture sections 6 and 8; link the per-root applications of the closed-top-level rule from naming-conventions section 4.8.
2026-06-19 09:19:03 -07:00