Skip to content

refactor(core): replace legacy logger with Effect logging - #31310

Merged
thdxr merged 18 commits into
devfrom
refactor/effect-logging
Jun 8, 2026
Merged

refactor(core): replace legacy logger with Effect logging#31310
thdxr merged 18 commits into
devfrom
refactor/effect-logging

Conversation

@thdxr

@thdxr thdxr commented Jun 8, 2026

Copy link
Copy Markdown
Member

Summary

  • remove the legacy core logger and Effect logger wrapper
  • route Effect logs to one shared append-only opencode.log with readable logfmt output and a per-run run_id
  • preserve --print-logs via an explicit stderr sink and --log-level via Effect minimum log levels
  • migrate Effect-context logs to native Effect.log* calls and remove imperative logging outside Effect contexts

Testing

  • bun typecheck in packages/core
  • bun typecheck in packages/opencode
  • bun typecheck in packages/server
  • bun typecheck in packages/desktop
  • bun test test/effect/observability.test.ts in packages/core
  • bun test test/effect/app-runtime-logger.test.ts in packages/opencode
  • git diff --check origin/dev...HEAD

Notes

  • the shared log file intentionally appends across concurrent runs; every line includes run_id
  • LSP stderr pipes continue to be drained without logging to avoid child-process deadlocks

@thdxr
thdxr requested review from Brendonovich and Hona as code owners June 8, 2026 04:49
@thdxr
thdxr merged commit c06ad7c into dev Jun 8, 2026
13 of 14 checks passed
@thdxr
thdxr deleted the refactor/effect-logging branch June 8, 2026 19:41
shoootyou added a commit to shoootyou/opencode that referenced this pull request Jun 10, 2026
* test(core): cover skill directory output (anomalyco#31263)

* fix(opencode): avoid duplicate skill catalog (anomalyco#31269)

* chore(opencode): update MCP SDK to 1.29.0 (anomalyco#31268)

* chore: generate

* chore: update nix node_modules hashes

* run: make minimal mode more minimal (anomalyco#31227)

* chore: generate

* chore: update web and desktop code owners (anomalyco#31289)

* fix(desktop): few WSL bugs (anomalyco#31095)

* chore: generate

* fix(opencode): respect MCP server capabilities (anomalyco#31271)

* console: update email

* zen: fix

* fix(opencode): include acp pending tool input (anomalyco#31321)

* fix(lsp): resolve JDTLS root to topmost pom.xml in Java Maven multi-module projects (anomalyco#28761)

Co-authored-by: Shoubhit Dash <shoubhit2005@gmail.com>

* chore: generate

* fix(session): merge per-call tool rules into session permission (anomalyco#30529)

Co-authored-by: Simon Klee <hello@simonklee.dk>

* docs(go): update MiniMax M3 pricing (anomalyco#31350)

* fix: speed up fff file search (anomalyco#31366)

* chore: generate

* fix(stats): show new for leaderboard deltas

* fix: stabilize fff file results (anomalyco#31369)

* chore: generate

* fix(core): restore npm proxy agent patch (anomalyco#31373)

* chore: update nix node_modules hashes

* chore: upgrade OpenTUI to v0.3.4 (anomalyco#31326)

* chore: update nix node_modules hashes

* fix(core): disable fff trace logs (anomalyco#31380)

* fix(session): avoid sticky prompt tool overrides (anomalyco#31394)

* fix(opencode): await run event loop (anomalyco#31389)

* refactor(core): replace legacy logger with Effect logging (anomalyco#31310)

* chore: generate

* fix(tui): trim select footer action highlight (anomalyco#31411)

* fix(opencode): support MiniMax M3 thinking toggle (anomalyco#31426)

* fix: adjust item id stripping to happen prior to request signing (anomalyco#31429)

* fix(opencode): generate reasoning variants for all OpenRouter models. (anomalyco#30332)

Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
Co-authored-by: Aiden Cline <aidenpcline@gmail.com>

* feat(app): add draft tab support to tabs store (anomalyco#31343)

* chore: generate

* fix(opencode): paginate MCP catalogs (anomalyco#31442)

* fix(opencode): pass abort signal to MCP tool calls (anomalyco#31455)

* feat(app): draft prompt state (anomalyco#31452)

* chore: generate

* feat(app): tabs help button (anomalyco#31454)

* feat: add "reasoning" as interleaved field option for vLLM providers (anomalyco#30477)

Co-authored-by: Ben Sandbrook <1126483+delta9000@users.noreply.github.com>
Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>

* fix(app): clip rounded session panels (anomalyco#31462)

* core: fix idle CPU use in file logger (anomalyco#31478)

* docs: add uninstall troubleshooting steps (anomalyco#31424)

Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>

* leave a breadcrumb comment about batchWindow zero (anomalyco#31508)

* chore: stats -> data

* test(core): avoid Windows worker close race (anomalyco#31532)

* refactor(tui): centralize application exit (anomalyco#31524)

* chore: generate

* feat(opencode): configure Cohere North model (anomalyco#31536)

* refactor(core): consolidate references (anomalyco#31539)

* feat(tui): show project copy in session list (anomalyco#31421)

* chore: generate

* fix(stats): use data branding assets

* drop citation_options from cohere (anomalyco#31543)

* zen: add north mini code model

* fix(data): timestamp formatting

* fix(opencode): support Claude Fable reasoning (anomalyco#31546)

* fix(mcp): log actionable connection statuses (anomalyco#31544)

* refactor(core): simplify location filesystem (anomalyco#31545)

* chore: generate

* chore: update nix node_modules hashes

* fix(opencode): restore effect error logging (anomalyco#31551)

* chore: generate

* feat(opencode): add typed application layer graph (anomalyco#31531)

* zen: add claude fable 5

* chore: generate

* refactor(mcp): simplify service helpers (anomalyco#31549)

* feat: add X-Session-Id header for proxy cache routing affinity (anomalyco#31511)

* zen: update email

* fix(desktop): update Electron stack and panel layout (anomalyco#31571)

* chore: generate

* chore: update nix node_modules hashes

---------

Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: Simon Klee <hello@simonklee.dk>
Co-authored-by: Luke Parker <10430890+Hona@users.noreply.github.com>
Co-authored-by: Filip <34747899+neriousy@users.noreply.github.com>
Co-authored-by: Frank <frank@anoma.ly>
Co-authored-by: Shoubhit Dash <shoubhit2005@gmail.com>
Co-authored-by: huangli <areyouok@gmail.com>
Co-authored-by: Tommy D. Rossi <beats.by.morse@gmail.com>
Co-authored-by: Jack <jack@anoma.ly>
Co-authored-by: Adam <2363879+adamdotdevin@users.noreply.github.com>
Co-authored-by: Dax <mail@thdxr.com>
Co-authored-by: James Long <longster@gmail.com>
Co-authored-by: Anthony Lau <anthony.lau2000@live.com>
Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
Co-authored-by: Brendan Allan <14191578+Brendonovich@users.noreply.github.com>
Co-authored-by: Ben Sandbrook <sandbrookvt@gmail.com>
Co-authored-by: Ben Sandbrook <1126483+delta9000@users.noreply.github.com>
Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: Sebastian <hasta84@gmail.com>
Co-authored-by: Songchao Wang <songchaow@outlook.com>
Co-authored-by: yui-soul <yui-soul@users.noreply.github.com>
avion23 pushed a commit to avion23/opencode that referenced this pull request Jun 10, 2026
isaacfinnegan pushed a commit to isaacfinnegan/whispercode that referenced this pull request Jun 15, 2026
androidand added a commit to androidand/opencode-skein that referenced this pull request Jun 17, 2026
Conflicts resolved:
- index.ts: upstream relocated the process handlers + processMetadata out of
  index.ts; took upstream's version, kept only the fork ForkCommands import
  (the .command(ForkCommands) registration auto-merged).
- provider.ts: took upstream's new snowflake-cortex provider and upstream's
  removal of the openai itemId-strip block (old upstream code from anomalyco#9006, not a
  fork patch). Fork's mergeDiscoveredModel / ThemeState.get / X-Loading-Theme
  all preserved.
- tui/dialog-model.tsx: kept both imports (fork useToast + upstream useSync).
- sdk gen.ts: kept fork Local* SDK types + upstream's LocationRef.
- bun.lock: regenerated via bun install.

Fork build fix: upstream removed core/util/log in anomalyco#31310 (legacy logger →
Effect logging). Re-created it as a fork-owned compatibility shim at the same
path (upstream has abandoned it, so no future conflict) and restored the
provider.ts logger that the merge dropped. Fork-only modules (beads, local
sync, provider discovery) keep working unchanged.

Verified: opencode/tui/sdk typecheck clean (0 errors); fork:verify reports no
new regressions (14/14 owned files, 6/7 markers; theme.tsx ThemeState.set still
pending recovery).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
markjaquith pushed a commit to markjaquith/opencode that referenced this pull request Jun 23, 2026
BenGu3 pushed a commit to BenGu3/opencode that referenced this pull request Jun 27, 2026
zackslash pushed a commit to zackslash/opencode that referenced this pull request Jun 28, 2026
miminashi added a commit to miminashi/opencode that referenced this pull request Jul 23, 2026
- agent.ts: dedupe plan-mode `task` permission key (fork's explore-only
  policy supersedes upstream's general-deny default)
- processor.ts/compaction.ts/prompt.ts: replace removed legacy `Log`
  (upstream anomalyco#31310) with Effect.logInfo/logWarning (Effect contexts) and
  console.warn (async/timer contexts)
- prompt.test.ts: drop obsolete Reference/RepositoryCache provides
  (modules moved to core; no longer required by ToolRegistry.layer)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
banlanzs pushed a commit to banlanzs/opencode that referenced this pull request Aug 6, 2026
androidand added a commit to androidand/opencode-skein that referenced this pull request Aug 12, 2026
Rebased local dev onto m5's dev (24 commits, real fetch-based ancestry
check — an earlier report of "1215 commits ahead" was measured against
m5's own stale cached origin/dev and was not the real gap). Two conflicts
in mdns.ts/package.json/types.gen.ts were the same fix landing on both
sides independently; resolved trivially.

fork:verify itself caught two real regressions once its package.json
script entries (silently dropped by the automatic merge on package.json)
were restored:

- installation/index.ts had reverted to hardcoded upstream identifiers
  (anomalyco/opencode, anomalyco/tap, opencode-ai, bare "opencode") across
  every distribution touch point — install URL, GitHub release API, brew
  formula/tap, npm/scoop/choco package IDs — meaning the in-app updater
  would again resolve against upstream's releases instead of the fork's.
  Re-wired to import and use ForkDistribution throughout, plus restored
  two lost fork error-message improvements (curl failure cause, upgrade
  failure output tail) dropped in the same diff.
- packages/core/src/util/log.ts (owned) no longer exists — confirmed
  intentional (upstream now has its own logger, per anomalyco#31310), not a
  regression. Removed from the manifest instead of restored.

fork:verify: 10/10 owned, 18/18 patched, no regressions.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
androidand added a commit to androidand/opencode-skein that referenced this pull request Aug 13, 2026
packages/core/src/util/log.ts (the fork's legacy-logger compatibility
shim, upstream's own replaced in anomalyco#31310) was deleted without migrating
its callers first — its own doc comment specified that order ("migrate
those callers to upstream's Effect logging and delete this file"). Left
provider.ts, local/placement.ts, local/sync.ts, beads/beads.ts, and
beads/sync.ts importing a module that no longer exists, breaking the
server at boot for anyone on dev right now, not just this branch.

Call sites already inside Effect.gen (local/sync.ts, beads/sync.ts)
migrated to proper `yield* Effect.logInfo/logError/logDebug(...)` — they
inherit the app's real Observability layer for free.

Call sites outside any Effect context (provider.ts, local/placement.ts —
a .catch() callback, a plain try/catch) do NOT use bare
`Effect.runSync(Effect.logX(...))`: verified empirically that with no app
runtime provided, Effect's default logger writes straight to stdout —
exactly the TUI-corruption bug a prior fork commit (bd7527e) fixed for
the now-deleted shim. New util/sync-log.ts preserves that shim's exact
safe behavior (file-append to opencode.log, mirror to stderr only when
OPENCODE_PRINT_LOGS=1) without reintroducing the retired compatibility
layer itself.

beads/beads.ts's `const log` was entirely unused (no call sites) — removed
outright rather than migrated.

tsgo --noEmit -p packages/opencode: zero new errors from this change
(confirmed against the pre-existing error set). Unblocks `bun run serve`
past its first crash; further boot verification blocked by unrelated
pre-existing issues (tracked separately, not fixed here).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
androidand added a commit to androidand/opencode-skein that referenced this pull request Aug 14, 2026
The 2026-08-11 sync resolved package.json and several source files as
"ours", which silently reverted upstream's dependency work and kept
pre-refactor copies of files upstream had since rewritten. The build was
broken in four places and the binary crashed during schema construction.
None of it was a fork feature failing — it was drift presenting as
breakage.

Dependencies
- Restore upstream catalog: opentui 0.3.4 -> 0.4.5, effect beta.74 ->
  beta.83, marked 17 -> 18, @tanstack/solid-virtual, re-add @corvu/drawer
  and the six dropped patchedDependencies entries. package.json now
  differs from upstream only by the five fork scripts.
- Re-add @modelcontextprotocol/sdk 1.29.0; the repo genuinely uses both
  SDK generations (see the mcp-dual-era fixture).
- Restore patches/solid-js@1.9.10.patch, which a `bun patch` re-run had
  clobbered (146 lines of upstream's cleanNode fix, replaced by
  machine-specific .bun-tag junk). Drop three orphaned downgrade-era
  patches.

The opentui downgrade was the whole "parser.worker cannot be resolved"
story: 0.3.4's export map points at a file absent from its own tarball.
build.ts needed no patch.

Drift reverted to upstream
- project.ts inlined duplicates of @opencode-ai/schema/project
- app-runtime.ts was the legacy Layer.mergeAll graph
- layer-node.ts was a gutted copy, 285 lines short
- registry.ts, session/prompt.ts imported modules that no longer exist
  (max-steps.txt, withStatics)
- run.ts had deleted runMini, which attach.ts calls
- provider.ts carried a narrowed copy of ProviderInterleavedField that
  was silently compensating for the stale SDK
- delete packages/core/src/effect/dfdf (a stray editor prompt string)

Retire the legacy defaultLayer DI pattern
Upstream's unify-layer-node-graph work replaced per-service defaultLayer
exports with the LayerNode graph; 167 references across 21 files had not
followed. src now uses the graph throughout.

Retire the legacy logger shim
packages/core/src/util/log.ts re-implemented a logger upstream deleted in
anomalyco#31310. All 17 call sites migrated to Effect logging and the file is
gone. Two of them are plain promise code, so they report outcomes and let
the Effect caller log rather than growing a second shim: pick() returns a
PickOutcome (it must keep its slot reservation synchronous, so an
Effect.gen yield boundary through it would be a real concurrency bug),
and discoverOpenAICompatibleModels returns { models, warnings }.

Regenerate the SDK
sdk.gen.ts referenced symbols absent from types.gen.ts. Regenerating
fixed that and the downstream plugin/tui errors. Note the root
script/generate.ts builds the client before regenerating the spec, so it
would have rebuilt from the stale spec; run in the correct order.

This exposed that the fork's loop.updated and side-question.response
events were lost from the event manifest in the merge. Both services own
HTTP routes and the TUI subscribes to loop.updated, but the events were
absent from the generated Event union, so no client could subscribe.
Re-registered in packages/opencode's manifest (their schemas are
fork-only and cannot live in packages/schema), with Loop and SideQuestion
wired into the app graph.

Fork features preserved throughout; both new divergences are recorded in
fork/manifest.json. fork:verify reports 9/9 owned, 9/9 patched.

typecheck 260 -> 30 errors, all in the in-flight MCP 2.0 migration.
Build and smoke test green.

Plan and remaining work: openspec/changes/retire-legacy-compat-shims
(#13).
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