Skip to content

fix(logging): suppress cursor-sdk shell-parser tree-sitter warn from TUI - #111

Merged
justin-carper merged 1 commit into
mainfrom
fix/cursor-sdk-shell-parser-warn
Aug 26, 2026
Merged

fix(logging): suppress cursor-sdk shell-parser tree-sitter warn from TUI#111
justin-carper merged 1 commit into
mainfrom
fix/cursor-sdk-shell-parser-warn

Conversation

@justin-carper

Copy link
Copy Markdown
Collaborator

Problem

@cursor/sdk's bundled shell-parser emits a one-shot console.warn:

shell-parser: tree-sitter natives are unavailable in this artifact; shell command analysis degrades to parsingFailed

This fires when the SDK's vendored tree-sitter natives fail to load (e.g. when opencode runs the plugin under Bun). opencode renders plugin stderr into the TUI prompt, so the line appeared visually in the prompt even though it is benign — shell command analysis simply degrades to parsingFailed, which the SDK handles.

The repo already intercepts the SDK's console.log rules/skills load diagnostics and routes them to opencode logging; console.warn was never covered.

Fix

Extends the existing interceptor pattern to console.warn on both transports:

  • In-process (src/provider/cursor-log-intercept.ts): installCursorLogInterceptor now wraps console.warn; known SDK warning prefixes are routed through pluginLog("warn") (opencode app.log) instead of reaching stderr. Everything else passes through unchanged.
  • Sidecar (src/sidecar/agent-host.mjs): the Node child gets the same wrapper; matched lines are forwarded as {ev:"log", level:"warn"} over the existing JSONL protocol, so nothing hits child stderr.

The message remains visible in opencode logs (service opencode-cursor, level warn) — just not in the prompt.

Tests

  • test/cursor-log-intercept.test.ts: exact shell-parser line routes to client.app.log with level warn; unrelated warns pass through the original.
  • test/sidecar.test.ts + test/fixtures/fake-cursor-sdk.mjs: new emitShellParserWarn fixture option; asserts the sidecar forwards the warn via onLog and drops unrelated warns.

Verification

  • npx tsc --noEmit — clean
  • npm test — 616/616 pass

@cursor/sdk's bundled shell-parser emits a one-shot console.warn
("shell-parser: tree-sitter natives are unavailable...") when its
vendored tree-sitter natives fail to load (e.g. under Bun). opencode
renders plugin stderr into the prompt, so the diagnostic appeared
visually even though it is benign (shell analysis degrades to
parsingFailed).

Extend the existing console.log interceptor pattern to console.warn on
both transports:

- in-process: installCursorLogInterceptor now wraps console.warn;
  known SDK warning prefixes route through pluginLog("warn") to
  opencode's app.log instead of stderr
- sidecar: agent-host.mjs wraps console.warn and forwards matched
  lines as {ev:"log", level:"warn"} over the JSONL protocol

Adds tests for both paths; unrelated console.warn calls still pass
through unchanged.
@justin-carper
justin-carper merged commit a2c6585 into main Aug 26, 2026
8 checks passed
@justin-carper
justin-carper deleted the fix/cursor-sdk-shell-parser-warn branch August 26, 2026 17:24
This was referenced Aug 26, 2026
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