Skip to content

Source-sync marketplace packaging + Cowork field-test fixes (#1 UI capability, #2 pdf error propagation, #3 status/rehydration diagnostics) - #4

Merged
zaynram merged 11 commits into
mainfrom
feat/source-sync-marketplace
Jun 6, 2026
Merged

zaynram merged 11 commits into
mainfrom
feat/source-sync-marketplace

Conversation

@zaynram

@zaynram zaynram commented Jun 5, 2026 •

Copy link
Copy Markdown
Collaborator

What this does

Two pillars land together on the road to a Cowork-uploadable plugin:

  1. Source-sync marketplace packaging — distribute scholar from GitHub source (no committed node_modules) via a single cross-OS bun ${CLAUDE_PLUGIN_ROOT}/bin/launch.mjs shim that provisions the pinned bun (vec0-ABI matched), then spawns the server (built dist/server.js if present, else from source — bun auto-installs the reached import graph). Ships the prebuilt UI (ui/app.html) and the vec0 native extensions the source path can't rebuild.
  2. Three Cowork field-test fixes — findings from a manually-built run, each verified at the layer the report actually named.

Launcher unification (bun, single cross-OS shim)

The launcher was a per-OS shell pair — /bin/sh launch.sh on Linux (which exec-replaced into bun) and cmd.exe /c launch.cmd on Windows — while the committed source-sync manifest used node launch.mjs. This PR unifies every path on bun bin/launch.mjs and deletes bin/launch.{sh,cmd}.

  • Why bun, not node: a bare node no longer resolves reliably under Claude Desktop (its "use bundled node" option was removed from settings), and bun is the operator's system-wide convention across these servers — so requiring bun-on-PATH is consistent, and one shim then serves every OS and both distribution paths (committed source-sync manifest + per-OS built .plugin/.mcpb). bun runs the .mjs directly under its node-compat runtime (process.argv/process.platform/node:child_process all work).
  • Why .mjs, not .sh-under-bun: bun's built-in shell is a limited POSIX subset (empirically: can't parse case, mis-handles "$@"/$?, mis-detects platform), so a shell launcher under bun isn't viable. launch.mjs keeps the per-OS provisioner split (ensure-bun.{sh,ps1}) it dispatches to.
  • Shape change (mitigated, not a regression): the old Linux exec made the spawned PID become the server; bun launch.mjs now spawns the pinned bun as a child on both OSes. Mitigated in-launcher — child inherits fd0 (sees the client's stdin-EOF directly), SIGINT/SIGTERM/SIGHUP forwarded, child.on("exit") → process.exit; a hard SIGKILL only leaves a pidfile, reclaimed on next start by pid-liveness. No Job Object added (no Linux equivalent — would be over-engineering).
  • Files: bin/launch.{sh,cmd} deleted; the .gitattributes *.cmd text eol=crlf rule removed (its only target is gone — the field-fixed CRLF class is now moot); scripts/build-plugin.ts buildManifest/buildMcpbManifest emit command:"bun"; manifests.test.ts + build-plugin.test.ts assertions flipped; CLAUDE.md, the 2026-06-01-slim-plugin-pivot spec, HUMAN.md, and the e2e runbook re-synced (genuine dated proofs kept under superseding notes; forward-looking legs rewritten).

Launch + initialize verified on Linux (2026-06-06). Built both targets for real (the stageBin/assemble staging paths this PR changed are exercised, not just the pure manifest functions): linux + win32 both emit command:"bun", args:["${CLAUDE_PLUGIN_ROOT}/bin/launch.mjs"], the unified bun "…/launch.mjs" --provision-only pre-warm hook, and per-OS SCHOLAR_RUNTIME_ROOT; both stage only launch.mjs + their ensure-bun (no launch.sh/launch.cmd survive). Then drove both real entry paths headless under a non-pinned on-PATH bun (1.3.14), each cold-provisioning the pinned 1.3.11 into a fresh CLAUDE_PLUGIN_DATA and returning a clean single-line MCP initialize — server start + handshake only (this path does not exercise vec0 load, Ollama, or a real corpus workflow); pdf child Ready, graceful exit on stdin-EOF:

  • built-bundle path — CLAUDE_PLUGIN_ROOT with dist/server.js present → child bun runs the bundle.
  • source-sync from-src path — CLAUDE_PLUGIN_ROOT = the git-tracked ship set (no dist/, no node_modules) → child bun runs src/server/index.ts and cold-auto-installs the entire import graph into the BUN_INSTALL cache under CLAUDE_PLUGIN_DATA (~67 MB), leaving the shipped tree pristine (no local node_modules written). This is the exact path the Cowork Linux sandbox runs — the launcher's auto-install assumption (launch.mjs:72) is now empirically validated, not assumed.

Unprovable from Linux: a bare bun resolving on PATH at the Windows Claude Desktop spawn (CreateProcess PATH semantics ≠ POSIX execvp) — the dominant residual risk.

Field findings → fixes (with verification boundaries)

#1 — Views invisible: missing MCP Apps capability declaration

The server registered view-opener tools (Layer 1) and served the text/html;profile=mcp-app resource (Layer 2) but never declared capabilities.extensions["io.modelcontextprotocol/ui"] (Layer 3), which the host checks before rendering any iframe.

  • Fix: declareUiAppCapability() calls server.server.registerCapabilities({ extensions: { [UI_EXTENSION_ID]: { mimeTypes: [MCP_APP_MIME] } } }), folded into registerUiResource (pre-connect — registerCapabilities throws after transport connect). src/server/ui/resource.ts.
  • Verified: real-SDK wire test (registry.test.ts) connects a Client over InMemoryTransport and asserts client.getServerCapabilities().extensions[UI_EXTENSION_ID].mimeTypes contains the mcp-app mime.
  • Unprovable here (live-client residual): that the host actually paints the iframe. That needs Claude Desktop / Cowork on the wire — out of reach of an in-process test.

#2 — refresh-extraction ingested pdf error sentinels as paper text

The vendored pdf child returns failures as the in-band {content:[{type:"text",text}], isError:true} envelope; callTool does not throw on it. getText flattened that text as document text, so refreshExtraction chunked the one-line sentinel and reported a bogus chunks_written:1, silently poisoning the corpus.

  • Fix: pure parseGetTextResult(r) throws PDF_GET_TEXT_FAILED on the isError envelope; getText returns through it (src/server/pdf/lifecycle.ts:320).
  • Verified across all three layers:
    • seam — parseGetTextResult unit tests (lifecycle.test.ts): throws on isError, flattens success, passes a bare string.
    • wiring — getText returns parseGetTextResult(r) at lifecycle.ts:320.
    • caller — pdf.test.ts: refreshExtraction with a getText that runs the real parseGetTextResult on an isError envelope rejects with PDF_GET_TEXT_FAILED and writes zero paper_chunks/chunk_vec rows (the "not chunks_written:1" claim, concrete). A swallowing try/catch in the caller would flip the rejection assertion red, so no-downgrade is guarded by construction.

#3 — corpus.status silently reported paper_count:0 when the DB isn't open

Same restart-state family as the earlier defect #4. status no longer errors, but a closed DB returned paper_count:0 — indistinguishable from a genuinely empty corpus.

  • Fix: corpus.status adds a db_open boolean (paper_count stays numeric — no contract break); reopenPersistedCorpus now warns on each anomalous rehydration branch (ghost activeCorpusId / archived / DB-file-missing) instead of returning undefined silently in two of three. src/server/tools/corpus.ts.
  • Scope — diagnostic-only, not a root-cause fix. A restart-simulation test (corpus.test.ts) builds a second server on the same on-disk runtimeRoot with a fresh config-DB handle (no shared in-memory state), never calls activate, and proves reopenPersistedCorpus really re-opens the prior session's per-corpus DB and recovers its rows (db_open:true, paper_count:1). It is green — so the in-process rehydration mechanism is sound. The field symptom ("query/digest still require manual re-activation") is therefore not an in-process logic bug; the leading hypothesis (not a proven cause) is a runtimeRoot mismatch across the host restart, which now lands in the DB-file-missing warn branch. The new diagnostics exist precisely to pinpoint which branch fires on the next field run.

One positive from the field run, confirmed: the session lock did its job — the diagnostic spawn died cleanly while the host held the lock.

Also included

  • bin/scholar.nu — main query retargeted at scholar.query with --label and batch (bare / list / table) input; main list keeps scholar.papers.search. nu-check parses clean, nu-lint reports 0 violations.

Residual keystone risks (not addressed here — flagging for review)

  • bun-on-PATH at MCP spawn, cross-target. bun launch.mjs assumes the host resolves a bare bun. Proven on Linux (above); the Windows CreateProcess PATH wrinkle is unproven on a real host. Fallback if it bites: edit the manifest command to an absolute bun.exe path (e.g. %USERPROFILE%\.bun\bin\bun.exe).
  • From-src cold-start needs network and amplifies cold-start latency. The source-sync path auto-installs the full import graph (~67 MB) into the BUN_INSTALL cache under CLAUDE_PLUGIN_DATA at first launch — so it requires network then, and if CLAUDE_PLUGIN_DATA is ephemeral in the Cowork sandbox, that cold install repeats every session, directly amplifying the cold-start timeout already hit in the field (the 2026-06-05 Windows field run). The built .plugin/.mcpb path is self-contained (dist/server.js bundle, no auto-install) and does not carry this. Mitigation if it bites: distribute the built bundle to Cowork rather than source-sync, or ensure CLAUDE_PLUGIN_DATA persists across sessions. This is the larger of the two environmental unknowns and, like the PATH item, is unprovable from a Linux box.
  • vec0 native load on Linux. vec0.so resolves + passes a KNN probe under the pinned bun here, but the koffi native-load + ABI pairing is unproven on the Cowork Linux sandbox specifically.
  • macOS: no .dylib shipped — macOS is not a target of this PR.
  • launch.mjs is not unit-pinned, but its generated manifests are (build-plugin.test.ts, manifests.test.ts) and both Linux entry paths (built-bundle + source-sync from-src) are now proven end-to-end headless (above). There is still no standalone unit test of the spawn/signal-forwarding logic.

Deferred (post-merge)

  • marketplace.json in zaynram/cowork-marketplace — GitHub source-sync serves from main, so the marketplace pointer should land only once these commits are on main.

Test status

bun test src tests → 386 pass / 0 fail (4 skip, 1 todo). bunx tsc --noEmit clean (runs as a hard gate inside build-plugin.ts). Both .plugin targets build (linux 2.9 MB / win32 3.0 MB, 19 files each).

🤖 Generated with Claude Code

zaynram and others added 9 commits June 5, 2026 12:04
…install

The cowork-marketplace path installs by copy-only (no build step), so the
runtime artifacts the build pipeline normally produces must be committed:

- ui/app.html — single-file inlined React bundle (resolveUiHtmlPath rung 2:
  <CLAUDE_PLUGIN_ROOT>/ui/app.html). Generated by the same buildInlinedUI the
  .plugin/.mcpb builds use, so the source-sync UI can never drift from the
  packaged one. Sandbox-safe: no external refs; resource.test.ts guards pass.
- build/vendor/sqlite-vec/vec0.{so,dll} — prebuilt sqlite-vec 0.1.9 extensions
  (resolveVec0Path's <root>/build/vendor/sqlite-vec rung). Linux .so from
  sqlite-vec-linux-x64; Windows .dll from the version-matched
  sqlite-vec-windows-x64 npm tarball. macOS .dylib is intentionally absent —
  source-sync on mac boots but fails at the first vector op (known partial).

.gitignore un-ignores only those two binaries under the otherwise-ignored
build/ tree (level-by-level re-include; git cannot re-include a file under an
ignored parent). `git add -n` confirms exactly these four paths, nothing else.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The cowork-marketplace serves ONE committed manifest to every OS (copy-only,
no per-OS selection), so the committed launcher must invoke a single command
present on all hosts. `node` is that command; bin/launch.mjs is the shim it runs.

launch.mjs:
- provisions the pinned bun via the existing ensure-bun.{sh,ps1} (sh on POSIX,
  powershell on Windows), mapping all provisioner output to stderr so fd1 stays
  clean for the JSON-RPC stream;
- spawns bun as a child with stdio:"inherit" — JSON-RPC flows client<->bun
  directly on fd 0/1 (node never touches protocol bytes), so the F1 graceful-
  teardown invariant holds on the primary stdin-EOF path; signal forwarding is a
  secondary net;
- resolves dist/server.js if present, else src/server/index.ts (the source-sync
  entry bun auto-installs the reached import graph from);
- derives BUN_INSTALL and SCHOLAR_RUNTIME_ROOT from CLAUDE_PLUGIN_DATA in JS, so
  the manifest needs no ${CLAUDE_PLUGIN_DATA} interpolation and the POSIX-only
  ${HOME} default never reaches Windows;
- supports --provision-only for the SessionStart pre-warm hook.

plugin.json (committed manifest, source-sync only): command node, args
launch.mjs, SessionStart hook runs node launch.mjs --provision-only, and
SCHOLAR_RUNTIME_ROOT is dropped from env (launch.mjs owns it cross-OS).
buildManifest() rebuilds mcpServers+hooks from scratch, so the built
.plugin/.mcpb bundles keep their per-OS shell launchers — this change is
isolated to the source-sync path.

KEYSTONE RISK (unproven on this host): `node` must be on PATH at MCP spawn. On
Windows, CreateProcess does not resolve a bare `node` via PATH the way POSIX
execvp does; if the Windows host's MCP spawn lacks a PATH-aware env, source-sync
is dead on arrival there. Must be validated on Windows hardware.

manifests.test.ts repivoted to assert the new committed contract.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…tributes

The source-sync marketplace install ships the repo's first committed binaries
(build/vendor/sqlite-vec/vec0.{so,dll}) and the marketplace performs a real
`git checkout` on Windows. Git's text=auto heuristic already detects ELF/PE by
leading NUL bytes and skips EOL conversion even under core.autocrlf=true, so
this is belt-and-suspenders: an explicit `binary` attribute removes any
dependence on that heuristic so no misconfigured checkout can CRLF-mangle the
byte stream koffi loads at runtime. .dylib reserved for a future mac drop.

Scoped additively beside the existing `*.cmd text eol=crlf` rule; the POSIX
launchers stay LF.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
)

Cowork field test (2026-06-05): every scholar view was invisible. Render
Layers 1+2 were already shipped — view-opener tools carry `_meta.ui.resourceUri`
and the UI resource is served with `text/html;profile=mcp-app` — but a host
checks whether the SERVER itself speaks MCP Apps via
`capabilities.extensions["io.modelcontextprotocol/ui"]` in the initialize result
BEFORE it renders any `_meta.ui` iframe. That third layer was missing, so all the
view hints were inert.

`declareUiAppCapability` registers the extension via the low-level server's
`registerCapabilities` (merges with the auto-registered tools/resources caps;
must run pre-connect — registerUiResource is always called before connect, so
folding it in there makes "serve the UI resource ⟹ advertise the extension" true
by construction). The value is the spec's `{ mimeTypes }` shape carrying exactly
the mime scholar serves, not a bare `{}` — satisfies a host that reads the
sub-field and one that only checks presence.

Note: ext-apps' own server helpers declare NO server-side extension
(getUiCapability only READS the client's), so the id+mime are hardcoded locally,
mirroring MCP_APP_MIME — the server bundle still imports no ext-apps. The
directions are orthogonal; server-side declaration is purely additive.

Test: a real SDK client over an in-memory transport asserts the extension (with
its mimeTypes) survives onto the SERIALIZED initialize result, not merely that
registerCapabilities was called.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…inels (#2)

Cowork field test (2026-06-05): refresh-extraction reported chunks_written:1 on a
failed extraction and silently poisoned the corpus with the child's error text.

Root cause: the vendored pdf child returns failures as the standard MCP error
envelope `{ content:[{type:"text",text:<msg>}], isError:true }`, and the SDK's
`callTool` does NOT throw on `isError` (it's an in-band tool error for the model
to read). `getText` flattened that error text and returned it as if it were
document text, so refreshExtraction chunked + embedded the one-line sentinel.

Fix: extract a pure `parseGetTextResult` that throws `PDF_GET_TEXT_FAILED` on the
isError envelope and flattens the success content otherwise; `getText` routes
through it. The failure now propagates out of refreshExtraction instead of
writing a bogus single chunk. The child responded (it's alive), so the liveness
stamp is kept. Pure helper ⇒ unit-tested directly (isError throws / success
flattens / bare-string passthrough / labelled error when isError has no message),
mirroring sanitizeRoots + buildClientCapabilities.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…lures (#3)

Cowork field test (2026-06-05), two restart-state issues:

#3a — corpus.status returned a SILENT paper_count:0 whenever the target's DB
wasn't open in this process (e.g. a restart whose startup rehydration found
nothing to open), indistinguishable from a genuinely empty corpus. Now status
surfaces an explicit `db_open` boolean and only counts when the corpus is active
AND open here; the 0 is no longer ambiguous. paper_count stays a number (no
contract change) — db_open is additive. (We deliberately do NOT rehydrate inside
status: reopenPersistedCorpus already runs once at server/CLI startup; re-running
per call would just repeat a failed open and re-log.)

#3b — when an activeCorpusId IS persisted but rehydration still can't open the
DB, every active-corpus tool (query, digest, papers, pdf — all pure ctx.db
readers with identical NO_ACTIVE_CORPUS gating) keeps failing until a manual
re-activate. reopenPersistedCorpus returned undefined SILENTLY in two of three
failure branches, leaving no trace of WHY. It now warns on each anomalous branch
(id persisted but the row is missing / archived / its DB file is absent) while
staying silent on the normal fresh-install "no activeCorpusId" branch so the
diagnostic doesn't cry wolf. This is the diagnostic, not a root-cause fix: the
wiring already calls reopenPersistedCorpus at startup in both runServer and
runCli and looks correct from static analysis, so the field symptom implies one
of these branches fires for a reason that needs the next run's logs to pinpoint.

Tests: status db_open true (active+open) / false (active, db unset) + diagnostic
warn on missing-row branch + silence on the fresh-install branch.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The source-sync manifest repivot (ba0432b) added
`expect(scholar.env.SCHOLAR_RUNTIME_ROOT).toBeUndefined()`, but TS infers the
committed env type WITHOUT that key, so the direct property access was a tsc error
(`bun test` doesn't typecheck, so it slipped through). Cast to a record for the
runtime absence assertion; the compile-time absence is itself proven by the fact
the typed access would fail. Restores a clean `tsc --noEmit`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…start (#3b)

The two #3b unit tests hand-set ctx.db = undefined to prove the symptom
surface (db_open:false / diagnostic warns). They do not exercise the real
rehydration path the Cowork field report implicated ("query/digest still
require manual re-activation" after a restart).

This adds the advisor-prescribed discriminator: a second buildServer on the
same on-disk runtimeRoot, with a FRESH config-DB handle (new openWithPragmas
on the same file, not the harness-injected handle), never calls activate, and
relies solely on reopenPersistedCorpus to recover. It seeds one paper into the
prior session's corpus DB, then asserts the fresh server recovers the slug,
re-opens the on-disk per-corpus handle, reads the seeded row back, and reports
db_open:true / paper_count:1 via corpus.status.

Result: GREEN. The rehydration mechanism is sound when (a) activeCorpusId is
persisted, (b) the corpus row exists and is not archived, (c) the DB file
exists under the SAME runtimeRoot. So the field symptom is not an in-process
logic bug — it must arise from a now-warned anomalous branch (most plausibly a
runtimeRoot mismatch across the host restart → DB-file-missing branch). This
confirms #3 is correctly diagnostic-only; the new warns will pinpoint the
real-world branch on the next field run.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…pagates get_text errors, writes zero chunks

The parseGetTextResult unit tests (lifecycle.test.ts) prove the seam throws on
the vendor isError envelope, and getText routes through it (lifecycle.ts:320).
This adds the caller-layer proof the advisor required: the field report's #2 is
about refreshExtraction, which must propagate the failure instead of chunking
the error sentinel and reporting chunks_written:1.

Highest fidelity short of a real spawn: the stubbed getText runs the REAL
parseGetTextResult on an isError envelope (exactly what the production handle
does), so the test exercises the wired path child-error → getText throws →
caller propagates — not a hand-rolled stand-in. Asserts refreshExtraction
rejects with PDF_GET_TEXT_FAILED AND that zero paper_chunks / chunk_vec rows
were written (the "not chunks_written:1" claim in concrete form). A swallowing
try/catch in the caller would flip the rejection assertion red, so this also
guards the no-downgrade property by construction.

Verified clean across all three layers: seam (helper unit tests), wiring
(getText returns parseGetTextResult at lifecycle.ts:320), caller (this test).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 5, 2026 20:13
…input

`main query` was a thin alias over `main list` (scholar.papers.search) taking
`q`/`--limit`. Retarget it at the dedicated `scholar.query` MCP tool: it now
takes `query?`/`--label` and builds `{label, query}` records, accepting a bare
query, a list, or a table of query records so batches pipe through in one call.
`main list` keeps ownership of scholar.papers.search. The `main` dispatcher's
input/output type unions gain `list` to carry those record batches, and its
stream-isolation note moves up into the docstring (logic unchanged).

nu-check parses clean; nu-lint reports 0 violations.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the repository to support “source-sync” marketplace distribution (running Scholar from GitHub source via a cross-OS Node launcher that provisions the pinned Bun), and lands three field-test fixes around MCP UI capability advertisement, PDF get_text error propagation, and corpus status/rehydration diagnostics.

Changes:

  • Switch committed plugin manifest execution to node bin/launch.mjs and add a cross-OS launcher that provisions pinned Bun then spawns the server from source.
  • Declare MCP Apps UI capabilities (io.modelcontextprotocol/ui) and add an SDK wire test verifying the capability appears in initialize capabilities.
  • Fix PDF extraction to treat isError:true tool envelopes as failures (not document text) and add tests; add db_open to corpus.status plus rehydration warning diagnostics and restart-simulation coverage.

Reviewed changes

Copilot reviewed 10 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/manifests.test.ts Updates manifest expectations for the source-sync node launcher and env contract.
src/server/ui/resource.ts Declares MCP Apps UI extension capability and ensures it’s registered pre-connect.
src/server/tools/registry.test.ts Adds a real-SDK initialize-capabilities wire test for the UI extension.
src/server/tools/pdf.test.ts Adds caller-level test ensuring PDF get_text error envelopes reject and write zero chunks.
src/server/tools/corpus.ts Adds db_open to corpus.status and adds warning diagnostics for failed rehydration branches.
src/server/tools/corpus.test.ts Adds unit tests for db_open and rehydration warning branches + a restart-simulation test.
src/server/pdf/lifecycle.ts Introduces parseGetTextResult and uses it to throw on isError envelopes.
src/server/pdf/lifecycle.test.ts Adds pure unit coverage for parseGetTextResult behaviors.
bin/scholar.nu Retargets main query to scholar.query with batch support and updates JSON parsing notes.
bin/launch.mjs Adds cross-OS Node launcher to provision Bun and spawn server from source with derived env defaults.
.gitignore Stops blanket-ignoring build/ contents while allowing committed vec0 binaries to be tracked.
.gitattributes Marks native extension binaries (*.so, *.dll, *.dylib) as binary to prevent EOL mangling.
.claude-plugin/plugin.json Switches committed manifest to node bin/launch.mjs and updates SessionStart hook to --provision-only.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zaynram zaynram left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

biggest thing: bun + sh is likely cleaner than node + mjs given my convention and precedent

Comment thread .claude-plugin/plugin.json Outdated
"scholar": {
"command": "/bin/sh",
"args": ["${CLAUDE_PLUGIN_ROOT}/bin/launch.sh"],
"command": "node",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

For those who had used the use bundled node Claude Desktop option (now missing from settings, but still showing in settings search), will a bare node invocation resolve? If not, let's swap this to Bun since its my established pattern (server itself may require specific bun version, but I use Bun runtime+API across the rest of my servers too so having it here would be consistent in that systemwide bun install is a dependency of my servers.

Comment thread .claude-plugin/plugin.json Outdated
{
"type": "command",
"command": "sh \"${CLAUDE_PLUGIN_ROOT}/bin/ensure-bun.sh\""
"command": "node \"${CLAUDE_PLUGIN_ROOT}/bin/launch.mjs\" --provision-only"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

same things here; swap to bun if builtin node won't be on PATH

Comment thread bin/scholar.nu

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

my changes; skipping further self-review

Comment thread bin/launch.mjs Resolved
Comment thread .claude-plugin/plugin.json Resolved
Comment thread tests/manifests.test.ts Outdated
Comment on lines +7 to +11
// per-OS shell-launcher form for THIS file: the marketplace installs by
// copy-only and serves one committed manifest to every OS, so the committed
// manifest must use a single cross-OS command. That command is `node`, which
// runs `bin/launch.mjs` — the shim provisions the pinned bun then spawns the
// server from source (auto-installing the reached import graph). The per-OS

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Needs reconciliation if we swap to bun + sh script

Comment thread tests/manifests.test.ts Outdated
Comment on lines +29 to +30
// Source-sync: `node` is the one command present on every host; it runs the
// launch.mjs shim (provision bun → spawn server from source).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Comment thread tests/manifests.test.ts
// so the same shim resolves the sh-vs-powershell provisioner per-OS.
const cmd = pluginManifest.hooks?.SessionStart?.[0]?.hooks?.[0]?.command
expect(cmd).toContain('ensure-bun.sh')
expect(cmd).toContain('launch.mjs')

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

…r-OS launch.{sh,cmd}

Both distribution paths now launch through one shim: the committed source-sync
`.claude-plugin/plugin.json` and the per-OS built `.plugin`/`.mcpb` manifests all
use `command:"bun"` + `${CLAUDE_PLUGIN_ROOT}/bin/launch.mjs`. The retired per-OS
shell pair (`/bin/sh launch.sh` exec-replace | `cmd.exe /c launch.cmd`) is deleted.

Why bun, not node: a bare `node` no longer resolves reliably under Claude Desktop
(its "use bundled node" option was removed from settings), and bun is the
operator's systemwide convention across these servers. bun runs the `.mjs`
directly under its node-compat runtime. Why `.mjs`, not `.sh`-under-bun: bun's
built-in shell is a limited POSIX subset (can't parse `case`, mis-handles
`"$@"`/platform detection), so a shell launcher under bun isn't viable.

Shape change (mitigated): the old Linux `exec` made the spawned PID become the
server; `bun launch.mjs` now spawns the pinned bun as a child on both OSes. The
child inherits fd0 (sees the client's stdin-EOF directly), SIGINT/SIGTERM/SIGHUP
are forwarded, and `child.on("exit") -> process.exit`; a hard SIGKILL only leaves
a pidfile reclaimed on next start by pid-liveness.

Changes:
- scripts/build-plugin.ts: buildManifest/buildMcpbManifest emit `command:"bun"`
  + launch.mjs; stageBin stages launch.mjs + per-OS ensure-bun; required-file
  lists updated. Source-sync manifest omits SCHOLAR_RUNTIME_ROOT (launch.mjs
  derives it from CLAUDE_PLUGIN_DATA); the built manifests still pin it per-OS.
- .gitattributes: drop the `*.cmd text eol=crlf` rule (its only target is gone;
  the field-fixed CRLF class is now moot).
- bin/ensure-bun.{sh,ps1}: comment-only re-pointing to launch.mjs.
- tests/manifests.test.ts + tests/build-plugin.test.ts: assertions flipped to
  the bun launcher (linux/win32/mcpb).
- CLAUDE.md, 2026-06-01-slim-plugin-pivot spec, HUMAN.md, e2e runbook, and the
  2026-06-02 maintenance-readiness audit: re-synced; genuine dated proofs kept
  under superseding notes, forward-looking legs rewritten.

Verified end-to-end headless on Linux (both entry paths): under a non-pinned
on-PATH bun (1.3.14), `bun launch.mjs` cold-provisioned the pinned 1.3.11 into a
fresh CLAUDE_PLUGIN_DATA and returned a clean single-line MCP `initialize` for
(a) the built-bundle path (dist/server.js) and (b) the source-sync from-src path
(git-tracked ship set, no dist/ or node_modules -> falls through to
src/server/index.ts; pinned bun cold-auto-installs the import graph into the
BUN_INSTALL cache under CLAUDE_PLUGIN_DATA, no local node_modules written). The
unproven leg is Windows bun-on-PATH at the Claude Desktop spawn.

Suite: 386 pass / 0 fail; `tsc --noEmit` clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@zaynram zaynram left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ready to merge

@zaynram
zaynram merged commit b0ce7e8 into main Jun 6, 2026
2 checks passed
@zaynram
zaynram deleted the feat/source-sync-marketplace branch June 6, 2026 19:12
zaynram added a commit that referenced this pull request Jun 6, 2026
…as current in isolation

Follow-up to the matcher-scoping change (this branch / PR #5), addressing the
doc-hygiene item it surfaced. The bun-launcher unification (PR #4) retired the
per-OS `launch.{sh,cmd}` shell pair, and every stale reference in the docs already
carries an adjacent supersede banner (repo convention: keep the dated record, add a
banner). The residual problem is the grep/scroll-lander: two lines state the
retired shell-pair launcher as the *current* mechanism when read without the
banner in view. Self-label them inline; the historical data stays put (the banners
say to keep it).

- docs/.../2026-06-01-slim-plugin-pivot.md: the "Both packages build" bullet-list
  intro now names the 2026-06-01 sizes + `launch.{sh,cmd}` in the bullets below as
  the retired shell-pair record and points at the current `bun launch.mjs`.
- docs/audits/2026-06-02-maintenance-readiness.md: the "Launch chain" status row is
  tagged as a 2026-06-02 snapshot superseded by the note directly below it.

Left as-is (already adequately framed): the supersede banners themselves; the
RESOLVED+moot `launch.cmd` CRLF section; HUMAN.md's "(2026-06-03)" launcher-proof
paragraph (bold dated header + adjacent banner). Docs-only; no code/test change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
zaynram added a commit that referenced this pull request Jun 7, 2026
…as current in isolation

Follow-up to the matcher-scoping change (this branch / PR #5), addressing the
doc-hygiene item it surfaced. The bun-launcher unification (PR #4) retired the
per-OS `launch.{sh,cmd}` shell pair, and every stale reference in the docs already
carries an adjacent supersede banner (repo convention: keep the dated record, add a
banner). The residual problem is the grep/scroll-lander: two lines state the
retired shell-pair launcher as the *current* mechanism when read without the
banner in view. Self-label them inline; the historical data stays put (the banners
say to keep it).

- docs/.../2026-06-01-slim-plugin-pivot.md: the "Both packages build" bullet-list
  intro now names the 2026-06-01 sizes + `launch.{sh,cmd}` in the bullets below as
  the retired shell-pair record and points at the current `bun launch.mjs`.
- docs/audits/2026-06-02-maintenance-readiness.md: the "Launch chain" status row is
  tagged as a 2026-06-02 snapshot superseded by the note directly below it.

Left as-is (already adequately framed): the supersede banners themselves; the
RESOLVED+moot `launch.cmd` CRLF section; HUMAN.md's "(2026-06-03)" launcher-proof
paragraph (bold dated header + adjacent banner). Docs-only; no code/test change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

2 participants