Skip to content

lean-agentic 0.3.4: working root entry point, quiet MCP stdout (fixes #5) - #6

Merged
ruvnet merged 1 commit into
mainfrom
weaver/lean-agentic-entrypoints
Nov 6, 2026
Merged

ruvnet merged 1 commit into
mainfrom
weaver/lean-agentic-entrypoints

Conversation

@ruvnet

@ruvnet ruvnet commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Fixes #5.

What was broken (reproduced from a fresh registry install of 0.3.3)

Entry 0.3.3
require("lean-agentic") fails: Cannot find module '../wasm/leanr_wasm.js'
import "lean-agentic" fails: ERR_MODULE_NOT_FOUND .../wasm/leanr_wasm.js
import "lean-agentic/node" fails: dist/node.mjs is a copy of the CommonJS file (require is not defined)
require("lean-agentic/node") works, but prints Initializing Lean-Agentic WASM... and per-call logs to stdout
MCP server stdout gets Initializing Lean-Agentic WASM... as soon as a tool runs, which breaks JSON-RPC
lean-agentic mcp start exits without serving anything (requiring server.js skips its require.main start)

Changes

  • Root entry now points at the Node.js build (same API as lean-agentic/node, plus init()), instead of the bundler-target wasm/ that was never published. Browsers use lean-agentic/web; the README platform table now says so.
  • ESM: scripts/build.js writes real ESM wrappers for dist/node.mjs and dist/index.mjs (they load the CommonJS build through createRequire, so both module systems share one WASM instance).
  • Logs: the logs came from web_sys::console::log_1 in leanr-wasm. They are now off by default, go to console.error (stderr) when on, and are controlled by LEAN_AGENTIC_DEBUG=1 or setDebug(true). wasm-node/ and wasm-web/ are rebuilt from source with wasm-pack --release (public WASM API unchanged apart from the new setDebug; each .wasm is about 2 KB smaller).
  • MCP server: sends console.log/info/debug to stderr, no longer answers notifications such as notifications/initialized, and exports startServer(), which lean-agentic mcp start now calls.
  • package.json: exports adds ./package.json; files drops the unused wasm; build:wasm builds the nodejs and web targets that ship; prepublishOnly runs build:js only, so the published tarball is the one CI tested. Version 0.3.4.
  • Types: .d.ts files match the real API (getStats, benchmarkEquality, setDebug, init on the root entry). Checked with tsc --strict --module nodenext.
  • CI: the npm job now packs the package, installs the tarball into a temp project, and runs scripts/check-package.mjs. The script requires and imports every entry point (., ./node, ./web, ./package.json), requires that each prints nothing to stdout, runs the CLI, and drives the MCP server (directly and through lean-agentic mcp start) with initialize, notifications/initialized and two tools/calls that construct the WASM demo. It then asserts that the first stdout line is the initialize result and that every stdout line is JSON-RPC. Run against the registry 0.3.3, 9 of its 12 checks fail. Run against this branch's tarball, all pass.

Not in scope (still open)

  • benchmarkEquality() throws unreachable in WASM because it uses std::time::Instant. This is a separate issue that already exists in 0.3.3.
  • The README's Ed25519 example (AgentIdentity, SignedProof, ProofConsensus from require('lean-agentic')) lists symbols the npm package does not export.
  • initialize reports capabilities as booleans (tools: true). The MCP spec expects objects.

🤖 Generated with claude-flow

- `require("lean-agentic")` and `import "lean-agentic"` loaded ../wasm/,
  a bundler-target build that was never published. The root entry is now
  the Node.js build (same API as lean-agentic/node, plus init()).
- `import "lean-agentic/node"` failed too: dist/node.mjs was a copy of the
  CommonJS file. The build now writes real ESM wrappers for node and index
  that load the CommonJS build through createRequire.
- The WASM module logged "Initializing Lean-Agentic WASM..." and per-call
  diagnostics with console.log, which went to stdout and corrupted the MCP
  server's JSON-RPC stream. Logging is now off by default, goes to
  console.error when on, and is controlled by LEAN_AGENTIC_DEBUG or
  setDebug(). wasm-node and wasm-web are rebuilt from leanr-wasm.
- The MCP server sends console.log/info/debug to stderr, no longer answers
  notifications, and `lean-agentic mcp start` now actually starts it
  (requiring server.js did not, because of its require.main guard).
- exports adds ./package.json; files drops the unused wasm/ entry;
  build:wasm builds the nodejs and web targets that ship; prepublishOnly
  runs build:js only, so the published tarball matches the tested one.
- Type definitions match the real API (getStats, benchmarkEquality,
  setDebug, init on the root entry).
- CI packs the package, installs the tarball into a temp project, loads
  every entry point with require and import, runs the CLI, and checks that
  the MCP server's stdout is nothing but JSON-RPC
  (scripts/check-package.mjs).

Co-Authored-By: claude-flow <ruv@ruv.net>
@ruvnet
ruvnet merged commit a8b10e8 into main Nov 6, 2026
3 checks passed
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.

Root entry (require/import 'lean-agentic') fails: dist/index.* loads ../wasm/ which is never published

1 participant