You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
keepClientCwd misses Primary working directory form — env cwd dropped from scrubbed prompt #21
Title: keepClientCwd misses Claude Code's "Primary working directory:" form — env cwd dropped from scrubbed prompt
Problem
scrubOpencodeFingerprints's OPENCODE_ENV_BLOCK replacement calls keepClientCwd, whose capture regex is:
/(?:^|\n)[\t]*Workingdirectory:[\t]*([^\n<]+)/i
Claude Code's env block emits Primary working directory: (newer sessions format). The line-start anchor plus exact label means the capture misses that form, keepClientCwd returns "\n", and the kept <env> block loses the working directory entirely.
Consequence
Every consumer that reads the client working directory from the scrubbed system prompt loses it. In Meridian specifically, sessions keyed from the prompt degrade — Meridian's own diagnostics warn about exactly this class of loss:
The directory is read from the <env> block of the system prompt; a plugin implementing experimental.chat.system.transform (for example opencode-scrub) may have removed it.
It also degrades the model's own project-context awareness (no cwd visible in the prompt).
Fix
Make the capture accept the optional Primary prefix:
Verified locally against the published dist (0.2.3): legacy Working directory: form still captured, Primary working directory: now captured (case-insensitive), all other scrub rules unaffected (identity/omo-env/fingerprint removal identical), and a live round-trip through the bridge confirms the model sees the cwd while fingerprints remain scrubbed.
Happy to send the PR with tests if the fix shape looks right.
One scope correction: on Meridian's server-side plugin path, cwd/session selection occurs before the plugin transform. The dropped field therefore did not establish a server-side session-keying failure in my installation. The demonstrated defect is that the scrubbed prompt loses Primary working directory, affecting model-visible project context and consumers where scrubbing happens client-side before Meridian parses the request.
PR #22 still addresses that prompt-preservation bug. A fresh isolated check of its head passed 12 cases covering legacy/Primary forms, case/spacing, negatives, both modes and idempotence; no installed plugin or live service was modified.
Activity
mradwankhalil commentedon Oct 10, 2026
One scope correction: on Meridian's server-side plugin path, cwd/session selection occurs before the plugin transform. The dropped field therefore did not establish a server-side session-keying failure in my installation. The demonstrated defect is that the scrubbed prompt loses Primary working directory, affecting model-visible project context and consumers where scrubbing happens client-side before Meridian parses the request.
PR #22 still addresses that prompt-preservation bug. A fresh isolated check of its head passed 12 cases covering legacy/Primary forms, case/spacing, negatives, both modes and idempotence; no installed plugin or live service was modified.