Skip to main content
J

dsh-ocr-review

jayyuen666/dsh-ocr-review

Wraps the external `ocr` (open-code-review) CLI in seven model tools — review, whole-tree scan, deterministic file selection and rule scaffolding, session history with comment filtering, compare and export, rule diagnostics and read-only LLM catalogue queries — with its own shape, type and enum gates, and reports what OCR found separately from whether the run covered the selected files; its settings card selects a provider/model from the host settings catalogue, edits the CLI `mcp_servers` JSON, reports `ocr auth` status, switches the ChatGPT model and measures the installed CLI version. The external CLI must be installed separately; the plugin never installs or upgrades it.

Install

dsh plugin --profile web add github:jayyuen666/dsh-ocr-review

README

dsh-ocr-review logo

dsh-ocr-review

The external `ocr` (open-code-review) CLI as seven dsh model tools and one settings card — you install the CLI, the plugin only discovers, verifies and drives it.

npm version npm downloads (total) ci MIT node dsh powered by dsh

tech stack

GitHub Email Twitter/X 简体中文

A code-review bridge for dsh: seven model tools (ocr_review, ocr_scan, delegate preview & rule, ocr_session, ocr_rules_check, ocr_llm) plus a settings card that applies the host's provider/model selection to the external CLI's own config — as a runtime command, never a plaintext key.

Contents

What it does

  • One settings card also carries the admin surfaces: a validated MCP servers JSON editor (saving touches only mcp_servers) and a ChatGPT section that reports ocr auth status and switches OCR's provider/model. Both are human-managed; neither is a model tool (a stdio MCP server runs commands, and OAuth sign-in needs a browser plus a local callback).
  • Wraps the external ocr (open-code-review) CLI into seven model tools, with shared v3 tool rows in the Web Client. The seven wire names register keyed tool.call.toolview slots; each row is shared ToolRow + ToolRowGrid and only renders fields the host actually projected (args plus result JSON), never a replayed raw payload. The host validates tool arguments not at all, so every shape, type and enum gate lives in this package: user-controlled strings are single-quote escaped, enums are whitelist-clamped, and wrong-typed values error instead of silently narrowing or widening a review.
  • One settings card (the web client half) picks provider/model from the host's model namespace (llm-pi-ai, plus the single-section llm-deepseek-api-key provider deepseek-official) and key status from the host credentials service. Catalogue defaultBaseURL values fill in settings that omit a URL; a provider with no catalogue models gets a free-text model field instead of an empty dropdown. When a service is absent the card shows the degradation reason; tools and settings keep working.
  • Applying a selection writes the CLI's own ~/.opencodereview/config.json — as an api_key_cmd command that reads the host credential ref at OCR runtime. The plugin never writes a plaintext key into config.json; the .bak it copies before the first rewrite keeps whatever the file held before, which may include a pre-migration plaintext key (mode 0600) — delete that backup after migrating.
  • Results are a structured summary with two distinct notions: what OCR found (status, aggregation, topComments, warnings) and whether the run actually covered the selected files (coverage, budgetExceeded, toolCalls). The CLI is invoked with --audience agent, which suppresses its progress output — the second notion is only reachable through those fields.
  • CLI availability is one judgement (resolveOcrAvailability in lib/cli.ts): pure filesystem, never a spawn, re-read per call. The card status row, the detail-page badge and the activation guidance all render that one answer, so "which copy is in use" cannot be told three ways.
  • Background runs (wait: false) are official host jobs: job_list / job_output / job_kill can observe and stop a review that outlives the tool call.

Install

dsh plugin --profile web add @jayyuen66/dsh-ocr-review

Remove with dsh plugin --profile web remove @jayyuen66/dsh-ocr-review. The package is on the public npm registry, so installation needs no credentials.

  • Upgrading an installed copy is remove-then-add. On a profile running HMR (the shipped ones do), add on a package the profile already depends on refuses before pnpm runs (already-installed) — run remove first, then add the target version; the new one starts without a restart. Without HMR the same add runs pnpm and reports restart-required.
  • Requires Node.js ^24.22.3 || >=26.13.1 and host dsh on the 0.2.3-alpha.2 line or later. The host reads engines.dsh (^0.2.3-alpha.2) and decides on it alone; prereleases participate in the comparison. An incompatible host needs the explicit risk grant dsh plugin --profile <p> allow-version @jayyuen66/dsh-ocr-review@<version> --dsh-version <exact> --accept-risk. The support window rolls: this package is verified against every released host version inside the window at publish time and re-verified once the window moves, so the version number in this bullet is not a standing promise.
  • No @deepseek-ai/* under dependencies, by contract (test/publish-manifest.test.ts enforces it). Consumer profiles install with nodeLinker: hoisted and autoInstallPeers: false, so a host package there is materialized as a real directory next to the copy the running host already loaded. @deepseek-ai/dsh-tools keys its scheduler with a plain Symbol (not Symbol.for), so symbol identity is per instance and every native tool call in that profile throws — while this package's build, typecheck and coverage gates stay green right up to that moment.
  • The five host packages host.js imports as values are required peers: @deepseek-ai/schemastery (the host fork — only it resolves .volatile() fields), @deepseek-ai/dsh-credentials, @deepseek-ai/dsh-home-paths, @deepseek-ai/dsh-atomic-write and @deepseek-ai/dsh-typert-protocol (the Remote service base). Each also appears in devDependencies pinned to the compile-time host line (which may differ from the peer support window above) so this repository's own typecheck resolves them; the build externalizes all manifest tables, keeping bare specifiers in the artifact.
  • What ships (see files in package.json): host.js, client.js, cordis.patch.yml, scripts/, locale/*.json, docs/, icon.svg, CHANGELOG.md and THIRD_PARTY_NOTICES.md. prepare rebuilds the bundles, so nothing stale is published.

Shared version floor

If your profile pins @jayyuen66/dsh-plugin-shared with a pnpm overrides entry, that pin must be at least the version this package declares. A lower pin installs a copy without the names imported at runtime, and the host then reports N entries did not activate together with does not provide an export named ... at boot — the package installs fine and never loads, and no per-repository CI run can see it.

The external CLI

This package spawns ocr; it never installs or upgrades it. The command contract is verified against 1.14.3 (EXPECTED_OCR_CLI_VERSION in lib/cli.ts, declared once as ocrCliVersion in package.json — tests pin the manifest, the code constant and both READMEs to the same string).

brew install open-code-review                        # the formula tracks the newest release
npm i -g @alibaba-group/open-code-review@1.14.3      # pinned to the version this plugin verifies against
  • brew cannot pin. homebrew/core carries one stable formula and no versioned variant, so brew install / brew upgrade always yields whatever is newest upstream. The npm command is the only one that can carry the verified version.
  • PATH wins, and the refusal is honest. Command resolution takes the first ocr on PATH, then a copy inside this package's own dependency tree (skipped on Windows — a shebang script pwsh/cmd cannot execute); with neither, the tools refuse before spawning and hand the model the install commands above with the version filled in. "How it was installed" is read off the real target of the bin symlink: npm-style under node_modules, a formula under Cellar / Homebrew, otherwise reported as unrecognised rather than guessed.
  • Version is measured, not assumed. Reading it spawns ocr version (15 s wall clock, always with OCR_NO_UPDATE=1) — on the card's Detect button, and once at apply when startupVerify is on. Rendering a page never spawns: the card shows the last measurement, or nothing measured yet. A disagreement names both numbers, flips the badge and appends a note to the review summary's hint; it is never a hard failure, and this package runs no installer.
  • Upstream self-update is real. The npm wrapper runs npm i -g @alibaba-group/open-code-review@<latest> during invocations on its own. The version probe always suppresses that; ocrNoAutoUpdate extends the suppression to every command this package spawns (see Settings).
  • Upgrading from a release that bundled the CLI (optionalDependencies, up to and including 0.1.5-rc): nothing to do — PATH now wins, so the stale copy stops shadowing yours. To clean the profile's tree, remove the package there and delete the allowBuilds entry that release needed in the profile's pnpm-workspace.yaml.
  • Platforms. macOS and Linux are the targets: the process reaper and the HOME= injection behind a custom ocrConfigPath are POSIX-only. Windows runs the bare command without reaping (a hard host exit can leave an orphaned OCR process) and requires a global ocr on PATH.

Verify it is live

  1. Mounted: dsh --profile web --dump-config ends with this package's layer (# == @jayyuen66/dsh-ocr-review).
    • That command is the only accepted "it is in the layer stack" signal, and it is not read-only — it rewrites the profile's root assembly file. Read layer lines from stdout and check stderr separately: an unmatched patch target appears only on stderr, so the exit code alone proves nothing. Accept both # == <layer> and # == <layer>, patched by <path>.
  2. The card renders: the settings page shows the card, and its External CLI row names which copy is in use, how it was installed, and which version this plugin verifies against.
  3. Detect version works: pressing it runs one ocr version and fills the measured version into the row — or names the failure arm (command missing, non-zero exit, timeout, nothing parseable).
  4. Tools answer honestly without the CLI: on a machine with no ocr, ocr_review refuses before spawning and returns the install commands with the verified version — not an exit-127 to reverse-derive.

What it does not provide

  • It does not install or upgrade the CLI. The brew/npm commands are shown, never run; there is no update action and no clipboard API (a non-secure context would fail silently, looking like a dead button).
  • No HTTP route of its own. The data plane is one official Typert Remote namespace (ocrReview) through the host /api gateway; authentication, Host / DNS-rebinding / Origin checks and body limits are the gateway's. This package holds no CSRF token, no body cap and no route disposer.
  • No CLI subcommand. dsh ocr … does not exist.
  • The plugin itself reads no file outside the CLI's config path, the host credential document and $DSH_HOME/.env (through scripts/get-cred.mjs), the PATH directories it probes for the ocr binary, the OCR session store it lists, the temp files it creates, and the host settings / credentials services it is handed. Repository contents are read by the ocr child process as the reviewed input.
  • What it does consume: the host settings and credentials services (provider list, key status), shell (every ocr subprocess), jobs (background runs) and systemPrompt (one routing section). A missing settings or credentials service degrades the card only — the tools keep working.

Enabling it in dsh

  • dsh.bundle.patch in package.json points at cordis.patch.yml, which carries a - id: dsh-plugin-shared supplier row (keep it enabled; disabling it removes the cards' shared component supply) plus the - id: ocr-review entry with name set to the bare package name — the bare name is what makes the host scan the client half. The card components come from the shared client row, externalized as @jayyuen66/dsh-plugin-shared/client; the host module table provides react, zod and that shared row.
  • The card needs a web profile (dsh.client.platform: web, immediately: true). The nine ocrReview methods are installed unconditionally on the apply fiber, so a host whose web layer never comes up (a TUI) still has the tools and settings.
  • The gateway exposes the methods only to clients of this profile; this package adds nothing in front of it.
  • Deployment defaults go on the registration line's config: (cordis validates through the exported Config schema); precedence: settings-card runtime value > line config > built-in default.

Tools exposed to the model

ToolArguments and constraints
ocr_reviewrepo (absolute path, default = the session workspace), scope workspace/commit/branch (branch requires from; to is optional — OCR 1.13.10+ defaults it to HEAD when only --from is given — and is mutually exclusive with commit), effort, background, exclude, provider/model/resume — resume works for workspace/commit/branch alike (OCR 1.13.10+); whether a session can be resumed is decided by OCR itself, and a rejected resume comes back as a localized hint. analysis / analysisMaxTokensBudget (OCR 1.14 behavior/impact analysis; commit or branch only, not with preview/resume; with wait=true the report is returned as analysis, while background runs leave it under the session's analysis/ directory; an analysis failure never changes the review result). preview (file-selection only), noFilter, maxGitProcs, rule/backgroundFile (repo-root files only), wait
Numeric group (review and scan)concurrency / timeoutMinutes / maxTools / maxTokens / maxTokensBudget, mapped to --concurrency --timeout --max-tools --max-tokens --max-tokens-budget. The timeoutMinutes here is the call argument (OCR's --timeout), not the settings-card foregroundWaitMinutes; values pass through faithfully, min floors are 1 for concurrency and 0 for the rest, and non-integers or below-floor values error instead of clamping
ocr_scanrepo, path, exclude, batch none/by-language/by-directory, provider/model (the CLI's native shared flags), the same numeric group, maxTools (raise-only: values below the template default of 60 do nothing), maxTokens (the 58888 template default trips the 80% prompt gate), preview, noPlan/noDedup/noSummary, resume, maxGitProcs, rule (repo-root file), wait. The scan-depth knobs default to the plugin settings (scanMaxTokens / scanConcurrency / scanMaxTools / scanNoPlan / scanNoDedup), and an explicit argument always wins. The repo is normalized to the git top level (path/exclude are rebased from the original directory, so the scan scope is unchanged), which makes scan sessions started in a subdirectory visible to ocr_session. Whole-repo scanning, no git diff required
ocr_delegate_preview / ocr_delegate_rulepreview: repo, scope/commit/from/to, exclude, background, backgroundFile/rule/maxGitProcs; returns up to 1000 files per bucket (reviewableDropped / excludedDropped report the omitted count), while totalFiles / reviewableCount / excludedCount still count the complete list. rule: repo plus paths — required, up to 200 entries, positional after --, each escaped — plus rule (repo-root JSON). Zero LLM cost on the OCR side: they return the file list and the rule groups
ocr_sessionrepo, action list/show/comments/compare/export, id, before/after (compare), severity/category (comments filter), branch (list filter; exact match, applied before limit — show/comments with an id reject it), limit (list, default 10; 1–100), commentLimit (comments, default 100; 1–500), includeThinking (comments, default false — thinking is usually the largest field). list/show/comments return a structured projection: the summary carries identity, scope, counts, run_manifest terminal state/failure cause/coverage, and analysisDir when analysis was enabled; comments omit thinking by default. compare returns the four buckets; export returns an HTML path and verifies the file exists (older export directories are cleaned up by TTL on later exports)
ocr_rules_checkrepo, path (required), rule (repo-root file): print the winning rule layer, glob and body; no LLM call
ocr_llmaction providers/models: read-only LLM catalogue queries; no review and no connectivity test
List capsexclude and path take up to 2000 entries each; exceeding the cap rejects the call. Entries are never silently dropped — "reviewed fewer files than the list" must not be reportable as success

wait: false starts a background run with no host deadline (poll ocr_session; the subprocess is also an official job, see Background runs as host jobs), and on POSIX the reaper guard takes the OCR process tree down when dsh exits in any way (Windows has no reaper, see Platforms). Cancelling the tool call stops the corresponding background process.

Settings

The namespace is the entry id ocr-review; the card fields are the .volatile() ones.

Do not conflate the four timeout fields:

  • foregroundWaitMinutes (settings card): only the host-shell wall clock while wait=true waits for ocr; 0/unset = request the host cap. It is not OCR's --timeout.
  • timeoutMinutes (ocr_review / ocr_scan call argument): the per-task --timeout passed to OCR for this call; unrelated to the settings card.
  • toolTimeoutMs (deployment key): the host ToolDefinition.timeoutMs backstop, reported as TOOL_TIMEOUT; the default background path never goes through it.
  • ocrBackgroundMaxMs (deployment key): backstop window for wait=false background jobs; 0 = no window.
FieldValues, default, use
effortauto/low/medium/high, default auto; auto omits --effort so OCR's own configured effort wins. Used when ocr_review is called without an explicit effort. Review only — OCR registers --effort on review, and the one thing it changes (MaxReviewRounds) does not exist in the scan template, so it cannot make a scan deeper; use the scan* keys below for that
language中文/English, default 中文; written as the top-level language key of the CLI config when a selection is applied
autoVerifydefault true; a successful select also runs ocr llm test (capped by llmTestTimeoutMs)
maxCommentsdefault 12, the number of comments kept in the summary; 0 = no truncation, non-integers and negatives fall back to 12. This is a settings-card key, not an ocr_review / ocr_scan tool parameter
foregroundWaitMinutesUnset by default (treated as 0) = request the host cap; it only affects the wait=true foreground wait and is not OCR's --timeout. A positive value is minutes enforced by this plugin (onExpiry is turned off so the host cap does not shorten it). The legacy timeoutMinutes setting name in older profiles is still read once; editing this row and saving writes the new name, while leaving it untouched keeps the old value effective
ocrConfigPathWhere the CLI config lives; empty derives <home>/.opencodereview/config.json, ~ and ~/ prefixes accepted, relative paths error. A custom value must follow the <X>/.opencodereview/config.json layout — the CLI has no file-level path override, so the plugin injects HOME=<X> into the subprocess (config and sessions redirect together); anything else is rejected at the setting layer. POSIX-only: Windows has no such channel
scanMaxTokensdefault 0 = omit --max-tokens and use the OCR template's 58888. OCR warns once prompt tokens pass 80% of it (47110), so raise this when a large file keeps hitting that gate
scanConcurrencydefault 0 = omit --concurrency and use the OCR template's 8. Lower it to be gentler on the provider's rate limit (OCR still retries internally)

The deployment keys below are deliberately not on the card — they are plain (non-volatile) fields of the exported Config, settable only on the profile's config: line and taking effect on restart:

KeyDefaultUse
llmTestTimeoutMs90000Wall clock for ocr llm test, shared by autoVerify and the card's test connection; raise it on slow machines
startupVerifytrueRun one CLI version measurement at apply (local, no network). Turn it off if loads must stay process-free. The provider endpoint is never called at apply — that is a real, billed request, and it happens only when you press “Test connection” or when autoVerify runs on apply
ocrBackgroundMaxMs0Backstop window for background reviews (registry wait to the deadline, then kill); 0 = no window — an owned run also ends when its session stops, while an agentless one ends only when the host exits, the plugin unloads or the job is killed
stdoutMaxBytes400000Shell executor stdout cap, shared by foreground and background runs (review results go through the --output temp file precisely to step outside it)
scanMaxTools0Default --max-tools for ocr_scan; 0 = omit it and use the template's 60. Scan treats it as raise-only: values below 60 do nothing (review is the one that lifts 1-49 up to 50)
scanNoPlanfalsePass --no-plan by default: skip the per-file plan pre-check (files under 200 lines already skip it)
scanNoDedupfalsePass --no-dedup by default: skip the in-batch dedup task
toolTimeoutMs3600000Backstop ceiling handed to the host as ToolDefinition.timeoutMs (rc.2's timeout policy enforces it and reports TOOL_TIMEOUT on expiry). It is not a review's time budget, and it only bounds foreground tool calls (wait=true); the default wait=false path returns at start and never goes through it. When foregroundWaitMinutes is above 0 this package runs with onExpiry: "none" and its own deadline, deliberately bypassing shell.maxTimeoutMs. The 1-hour default only constrains foreground calls; use the background path for multi-hour reviews, or raise both foregroundWaitMinutes and this value together — compressing only this value cuts a healthy long review with nothing but the host's tool call timed out, while this package's timeout attribution never gets to speak. Unlike foregroundWaitMinutes it cannot be volatile: the host validates it at tools.register and never recomputes it
ocrNoAutoUpdatefalsetrue puts OCR_NO_UPDATE=1 on every command this package spawns, stopping upstream's mid-review npm i -g of a newer release; false keeps upstream behaviour. The version probe sets the variable regardless
ocrInstallHintbothWhich install command to lead with when nothing is installed: both / brew / npm. A fallback, not an override — an existing copy is always described by its own source, because telling a formula user to run npm i -g leaves a second copy behind while PATH still resolves the old one. The npm command always carries the verified version; the brew one never can
ocrSandboxfullFile fence for the ocr subprocesses. full requests danger-full-access (the behaviour since 0.1.14: ocr keeps its state in $HOME/.opencodereview, outside the workspace, and a confined run loses finished reviews at finalize session). inherit follows the sandbox mode the host executor reports instead: workspace-write narrows to the workspace root plus additionalWritableRoots for the OCR state directory and the system temp area, while read-only and unrecognised modes are refused; workspace-write on Windows is refused too — since dsh 0.2.2-rc.2, Windows applies additional writable roots to file tools only and never to a confined subprocess, so the OCR state directory cannot be granted. The inherited policy never carries the deployment's own additionalWritableRoots — deployments that need more paths should use full

Public interface

One official Typert Remote namespace, ocrReview (OCR_REMOTE_NAMESPACE in lib/remote-shape.ts), its nine methods marked programmatically in host.ts. The service registers at construction and is withdrawn with its fiber, so a hot reload cannot leave a stale namespace behind.

MethodInputSuccess payload
providers()—{providers (each with a hasKey boolean), current, getCredReady, source, ocrBinary} — never a key. ocrBinary carries the filesystem-only availability verdict plus the version context (source, channel, expectedVersion, measuredVersion: string | null, installHint); reading this method never spawns
select(request){provider, model}, both must hit the list describe() returns{ok, applied, llmTest} (llmTest is null when autoVerify is off)
migrate()—{ok, migrated, skippedUnknown}
test()—{ok, output} — ok is the test verdict, not whether the call ran; output is redacted first, then cut to 8000 characters
probe()—{ok, version, expectedVersion, consistent, output, reason, changeText} — one ocr version under a 15 s wall clock, with OCR_NO_UPDATE=1. consistent is three-state (null = nothing was measured, where claiming a mismatch would be claiming without evidence); reason names the failure arm; changeText carries the install/upgrade sentence only when there is a command to give
mcp()—{ok, json, revision} — only the mcp_servers object as pretty JSON, never providers or keys; revision is that branch's digest
saveMcp(request){json, revision?} — raw JSON text, at most 64 KiB; stdio/remote entries are validated field by field; revision is the digest from mcp(){ok, count, revision, warnings} — writes only mcp_servers; other config is preserved. A stale revision refuses the whole write (nothing is written) and returns a readable "changed after it was read" error; omitting it keeps the old last-writer-wins behavior. warnings is non-blocking: the save succeeded, but a remote header references an environment variable that is empty in the current process, which OCR would expand to an empty string and reject at connect time
auth()—{ok, output, loginCommand} — read-only ocr auth status --provider chatgpt; sign-in itself stays a terminal action because it needs a browser and a local callback
chatGpt(request){model}{ok, model} — sets provider: "chatgpt" and providers.chatgpt.model, writes no key

Refusals answer {ok: false, error, status} where status is a retained semantic code, not an HTTP status (400 for an empty or off-list selection, 500 for a failed write or a missing credential script) — the number lets the tests pin which rule fired, and the client renders error only. There is deliberately no client-side wall clock on these calls: the timeout belongs to the gateway, and a second one in the card is how a slow write gets reported lost while it actually landed.

Credentials and the OCR config file

AspectFact
What lands in the configA command, not a secret: api_key_cmd = node '<path of scripts/get-cred.mjs in this package>' '<REF>' '<dsh data dir>' — single-quote escaped on POSIX, double-quote escaped on Windows (the CLI runs credential commands through cmd.exe there). The data directory is the host's current resolved home, so get-cred's fallback layers stay correct when HOME is redirected; the REF name must satisfy the official ref-name rule or the command is refused
Provider bucketA selection writes providers.<name> when the name is in the CLI's built-in provider list (compared after trim and lowercasing) and custom_providers.<name> otherwise — the CLI resolves by name, and a built-in name filed under custom_providers fails with "not configured in providers section". Reading current, migrate() and the dangling-script repoint all cover both buckets, so a config written by an older version keeps working
Layer orderget-cred reads the same three layers in the same order as the official credentials-local: refs.<REF> in the managed credentials file first, then the inherited process environment, then $DSH_HOME/.env. The host treats the managed file as the effective credential, so a wrong order fails silently — OCR authenticates against a different key than the card reports while both sides show success
Reachability gateselect and migrate refuse a key the CLI cannot read at runtime: dsh strips KEY/PASSWORD/SECRET/TOKEN-named and DSH_-prefixed variables from spawned shells, and the reviewed repository's .env is deliberately not read. Keys living only in the dsh process environment or the workspace .env resolve on the host side yet fail at OCR runtime — previously a silent "select succeeded, OCR 401". The refusal happens before any write and names the fix
WritesAtomic replacement through the official atomic-write helper: a random-suffixed temp sibling, then rename, with 0600 on the new inode; the .bak backup is copied by this package before the rename. The whole read→decide→write span runs under the official file lock — a short-lived config.json.lock appears and is removed in finally. An existing config that is invalid JSON or not an object aborts the write instead of being treated as empty
migrate()Replaces the plaintext api_key of provider entries (both providers and custom_providers) with api_key_cmd and deletes the plaintext; entries whose key source is unreachable at CLI runtime (same gate as select) or whose apiKeyEnv is missing from settings are left untouched and listed in skippedUnknown; nothing is written when nothing migrated
scripts/get-cred.mjsSpawned by the CLI itself; the only place in this package that still reads host credential files. When all three layers miss it exits non-zero and names every location it checked

Background runs as host jobs

AspectFact
What the model gainsjob_list shows the review, job_output reads its stdout/stderr (non-consuming — it never steals bytes from the session reader), job_kill stops it. Results still come from the ocr_session record
No registry, no backgroundA host without the jobs service makes wait: false throw an error naming the missing piece instead of starting a subprocess nobody can observe; foreground runs are unaffected
OwnershipWhen the calling agent resolves to a live session, the job is started with that session as its owner; job_list / job_output / job_kill then only reach it from that session. A call with no live agent starts an agentless job
Capacity bucketsOwned jobs count against their owner's bucket; agentless jobs share the unowned bucket host-wide. Overflow refuses a new start, so one hung CLI can park a slot — the optional ocrBackgroundMaxMs backstop uses the registry's own wait + kill, not a host timer
CleanupBefore each start, settled records of this kind visible to that caller (the shared unowned bucket plus the caller's own) are pruned to a fixed window; live and stopping records are never pruned (the registry answers overflow by refusing, not by killing somebody's review). A session disposal kills or removes only that session's jobs; unload reclaims everything, using a small id → owner ledger because the registry hides other owners' jobs
ExposureAn owned job is visible to, and killable by, its own session only. Agentless jobs remain visible to every caller — the residual exposure, present only when no live agent could be resolved
Nothing may throwAn error raised inside a host event handler takes the whole host process down, and the official package does not cover producers either — the cancel chain catches at two layers, each pinned by its own test

Data and privacy

AspectFact
Process boundaryThe reviewed repository's paths and diff content go into the ocr child process, and the CLI sends them to the LLM endpoint configured in its own config.json — that egress is the review feature itself and does not pass through the dsh host. Plaintext keys never appear in tool results or Remote payloads; a value resolved by the host is used only to confirm "it resolves right now" and is discarded on the spot
RedactionAll raw CLI stdout/stderr leaving this package (failure details, llm test, parse-failure echoes, session passthrough) goes through redactKeyMaterial(): bearer and assignment forms strictly, the standalone-key form only with random-string features, so file paths handed to the model are not erased with it
On diskThe CLI's config.json (plus its temp sibling, the .bak backup and the short-lived lock), the ocr-review-* / ocr-scan-* temp files (deleted right after reading), and ocr-session-export-* directories, which hold the HTML returned by ocr_session export. Export directories are kept for 7 days; each later export sweeps older ones, and a failed sweep never blocks the export. Pre-migration plaintext may persist in that .bak (mode 0600) — delete the backup yourself to be rid of it. Outside these, the only writer is the CLI's own npm wrapper unless ocrNoAutoUpdate is on

Known boundaries

  • Windows gets no reaper and no custom config path. Both rest on a POSIX toolchain (bash traps, process-group semantics, the HOME= assignment prefix); on Windows the package runs the bare command un-reaped, and a hard host exit can leave an orphaned OCR process.
  • A version mismatch is never a hard failure. A newer CLI usually works; both numbers are shown, the badge flips, and the summary's hint says so. This package never runs an installer.
  • Version reads cost a spawn and never happen on render; the card shows the last measurement or nothing — a page render cannot install, update or probe anything.
  • The atomic-write lock timeout surfaces in English. Contention past the official wait budget throws the official package's own timeout text — the one user-visible error here that bypasses the bilingual message table.
  • partial is a terminal success state. Some files failed but coverage stands and the comments are valid; it is neither upgraded to success nor folded into failure. From OCR 1.13.12 a partial with operational failures (timeouts, provider errors) exits non-zero while still publishing results — the foreground path returns the summary with an "incomplete review" note in hint when usable coverage is present, and only raises the error when it is not.
  • Agentless background jobs are visible to every session (see Background runs). A call that cannot resolve a live agent starts one; owned jobs are fenced to their session.

FAQ

Question / symptomAnswer
Exit 0 was taken as a successful reviewExit 0 is not success: any status outside success / complete / partial / completed_with_warnings / completed_with_errors / skipped reports as failure. partial means some files failed while coverage and the comments stand. A parse failure echoes the first 500 redacted UTF-16 code units of the raw output
Did the summary cover everything?Two notions, neither replaces the other. droppedCount / invalidCommentCount say whether this summary listed every comment (raise maxComments or set 0 and re-check). Whether the run covered the selected files is coverage (selected is the denominator, failedItems names the files with their reasons) plus budgetExceeded and toolCalls
add was refused with already-installedHMR profiles refuse add on an already-installed package before pnpm runs — remove first, then add the target version (see Install)
What happens to background processes when dsh exits?On POSIX the reaper guard takes the review/scan process tree down with TERM→1s→KILL on any host exit (including kill -9 followed by adoption); Windows has no reaper, so a hard host exit can leave an orphaned process. Cancelling the tool call stops the corresponding background process
Where might a plaintext key still sit?Nowhere this package writes. A pre-migration config's plaintext may survive in the .bak produced by the first write after you migrate (mode 0600); delete that backup to be rid of it

Development

pnpm install
pnpm run check   # typecheck (both sides) → lint → client build → host build → tests with coverage → format
  • Coverage thresholds are 100% across four metrics over the surface vitest.config.ts opts into (coverageInclude: host.ts + lib/**); two areas are deliberately outside it: the client half (src/**) is exercised through the bundle and the settings-card tests, and scripts/get-cred.mjs is driven by process-level tests spawning a child (v8 coverage cannot see a child process) — its behavioral gate lives in test/get-cred.test.ts.
  • Adding this package's local directory to a profile (pnpm add <path>) needs pnpm ≥ 12.3.0: earlier pnpm 12 releases resolve an unaliased local path as a registry package name (upstream #14437, fixed in 12.3.0). Installing from the registry is unaffected.
  • Bundle freshness is pinned by test/build-host.test.ts: a stale host.js / client.js fails the suite. Never hand-edit the bundles; prepare rebuilds them.
  • The plugin source is TypeScript loaded directly by the host's cordis loader (Node ≥ 22.18 type stripping); the bundles exist for the published npm surface. Installing from a local path (pnpm add <path>) therefore reads the source and needs Node ≥ 22.18, while this package's own declared floor is engines.node (^24.22.3 || >=26.13.1).

Feedback

Issues and pull requests are welcome: https://github.com/JayYuen666/dsh-ocr-review/issues.

If a plugin fails to boot, include the dsh host version, the profile install shape, and the browser console line. The missed the module table line is especially useful: it tells us whether the shared client row was materialized.

License

MIT. Source at github.com/JayYuen666/dsh-ocr-review. Issues go to that repository's tracker.

Runtime dependencies carry their own licenses; THIRD_PARTY_NOTICES.md records that artifact boundary and how to re-check it.

Related plugins