Skip to content

refactor(core): deduplicate local plugin, formatter, and session shims - #67205

Merged
kitlangton merged 1 commit into
devfrom
prune-core-shims
Nov 30, 2026
Merged

kitlangton merged 1 commit into
devfrom
prune-core-shims

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

Removes about 130 lines of duplicated or unused code in the core package. Nothing a user sees changes.
This is cleanup only. Commands, formatting, image notices, and session delivery work exactly as before.

❌ Before

  • Prettier and Biome each spelled out the same list of 26 file extensions.
  • Two command plugins each had their own identical copy of the command-argument parser. The /init and /review commands were two copy-pasted blocks.
  • The image-job notice lived in a separate 8-line file, while the video notice lives in its tool module.
  • A managed-config document subclass with no fields, an experimental "resolve a typed cwd" helper with its error, and a connection-update method had no callers.
  • The inbox's delivery-change update was split across a private helper and a one-line wrapper.

✅ After

  • One shared extension list. One shared argument parser on the command module. /init and /review come from one loop, in the same order.
  • The image notice sits in the image tool, next to its video twin.
  • The unused pieces are gone. Managed config uses the ordinary config document.
  • The delivery-change update is one function. Model-resolution errors for text generation are mapped once instead of listing all six error types.

🟰 Behavior change: none. Output strings, event metadata, and the order of error mapping are unchanged.

- prettier.extensions = [26 entries]; biome.extensions = [same 26 entries]
+ prettier.extensions = biome.extensions = WEB_EXTENSIONS
- catchTag([6 resolver error tags], toGenerateError)   // auth error passed through untouched
+ mapError(auth error ? pass through : toGenerateError)

📊 Size: source −100 lines net (+84 / −184), tests −33 lines (a test for the removed cwd helper, plus stale mock fields).

👀 Read: generate.ts, the new mapError. The resolver's error set is exactly the six old tags plus the authorization error, and the authorization error must still pass through when no model is named. The rest is routine.

🔍 Found in a code audit · no user reports · several candidates were checked and left alone because they would change behavior (listed under Checks run)

Checks run
  • bun test from packages/core on formatter, command, config, generate, model-resolver, session-cwd, session-inbox, session-prompt, session-execution, shell-restart, shell-result, tool-shell, image and video tools, integration, voice, usage-limits, MCP, instruction-discovery, and plugin tests: 672 pass, 7 skip, 3 fail. The 3 failures are in tool-shell.test.ts (process substitution, sh/zsh arithmetic) and fail the same way on dev without this change.
  • bun typecheck (packages/core): no errors
  • bun run typecheck:tsc (packages/core): no errors
  • bun run check (repo root): 37/37 tasks pass
  • Cross-model review before push: no findings.

Left alone on purpose:

  • MCP config plugin → shared config observer: the current loop logs reload failures and keeps listening. The shared observer would stop listening after the first failure.
  • Shell background tool result → generic builder: metadata key order differs in the stored event.
  • Shell metadata() derived from output(): it would leak extra tool fields into metadata.
  • Integration method arms in the plugin host: merging them breaks the typed union without casts.
  • Instruction-discovery update event: it reaches unfiltered event-stream subscribers, and its tests wait on it.
  • provideService calls for the image, decision, and video clients in generate.ts: they are not no-ops. The layer provides those clients only while it is being built, so the effects need them again when they run.
  • Inbox admit guard: it is not tautological, because the conflict path can return a stored item from another session or of another type.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sound. The deduplicated pieces behave the same as before, and the removed helpers have no remaining callers in packages/. I checked the generate.ts mapError change most closely. The resolver's error set is exactly the six old tags plus Integration.Authorization. With no model named, that error passes through as before. With a model named, it goes through resolutionError, which also returns it unchanged. bun run typecheck:tsc in packages/core is clean, and the related core tests pass. The only failures (GitLab OAuth on a busy port 8080, and one MCP process-cleanup test) fail the same way on dev.

Public API is unchanged: the removed Integration connection.update, SessionCwd.locate/CwdError and ConfigManaged.Document were internal to packages/core and are not exposed through the plugin API, server or SDK.

@kitlangton
kitlangton merged commit a6f39f9 into dev Nov 30, 2026
11 checks passed
@kitlangton
kitlangton deleted the prune-core-shims branch November 30, 2026 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant