Repository navigation
lean-agentic 0.3.4: working root entry point, quiet MCP stdout (fixes #5) - #6
Merged
Merged
Conversation
- `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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5.
What was broken (reproduced from a fresh registry install of 0.3.3)
require("lean-agentic")Cannot find module '../wasm/leanr_wasm.js'import "lean-agentic"ERR_MODULE_NOT_FOUND .../wasm/leanr_wasm.jsimport "lean-agentic/node"dist/node.mjsis a copy of the CommonJS file (require is not defined)require("lean-agentic/node")Initializing Lean-Agentic WASM...and per-call logs to stdoutInitializing Lean-Agentic WASM...as soon as a tool runs, which breaks JSON-RPClean-agentic mcp startserver.jsskips itsrequire.mainstart)Changes
lean-agentic/node, plusinit()), instead of the bundler-targetwasm/that was never published. Browsers uselean-agentic/web; the README platform table now says so.scripts/build.jswrites real ESM wrappers fordist/node.mjsanddist/index.mjs(they load the CommonJS build throughcreateRequire, so both module systems share one WASM instance).web_sys::console::log_1inleanr-wasm. They are now off by default, go toconsole.error(stderr) when on, and are controlled byLEAN_AGENTIC_DEBUG=1orsetDebug(true).wasm-node/andwasm-web/are rebuilt from source withwasm-pack --release(public WASM API unchanged apart from the newsetDebug; each.wasmis about 2 KB smaller).console.log/info/debugto stderr, no longer answers notifications such asnotifications/initialized, and exportsstartServer(), whichlean-agentic mcp startnow calls.exportsadds./package.json;filesdrops the unusedwasm;build:wasmbuilds thenodejsandwebtargets that ship;prepublishOnlyrunsbuild:jsonly, so the published tarball is the one CI tested. Version 0.3.4..d.tsfiles match the real API (getStats,benchmarkEquality,setDebug,initon the root entry). Checked withtsc --strict --module nodenext.scripts/check-package.mjs. The scriptrequires andimports every entry point (.,./node,./web,./package.json), requires that each prints nothing to stdout, runs the CLI, and drives the MCP server (directly and throughlean-agentic mcp start) withinitialize,notifications/initializedand twotools/calls that construct the WASM demo. It then asserts that the first stdout line is theinitializeresult 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()throwsunreachablein WASM because it usesstd::time::Instant. This is a separate issue that already exists in 0.3.3.AgentIdentity,SignedProof,ProofConsensusfromrequire('lean-agentic')) lists symbols the npm package does not export.initializereportscapabilitiesas booleans (tools: true). The MCP spec expects objects.🤖 Generated with claude-flow