Skip to content

Fix onboarding stat drift, relax engine gate, one-command demo#852

Merged
rohitg00 merged 3 commits into
mainfrom
fix/onboarding-trust
Jun 7, 2026
Merged

Fix onboarding stat drift, relax engine gate, one-command demo#852
rohitg00 merged 3 commits into
mainfrom
fix/onboarding-trust

Conversation

@rohitg00

@rohitg00 rohitg00 commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Onboarding trust and correctness fixes. Five focused changes so the first-run experience matches what the docs claim and never silently drifts again.

1. Stat correctness (derive, do not hardcode)

The MCP registry truth is 53 tools. Corrected stale 51 references in the standalone shim comments and the registry comment. The --tools help text now interpolates the count straight from getAllTools() so it cannot drift. Updated README test-count stats from 1,390+ to 1,423+ (badge alt text, stats line, and the inline comment).

2. Relax engine version gate

When an iii binary on PATH differs from the pinned engine version, the CLI used to hard-fail with process.exit(1) on first run. agentmemory installs and uses its own pinned engine in ~/.agentmemory/bin regardless, so this is now a non-fatal warning. Execution continues and the pinned engine is used. Users can set AGENTMEMORY_III_VERSION to track a different engine.

3. Sharper MCP fallback banner

The standalone shim's no-server-reachable stderr line now states it is running a reduced LOCAL FALLBACK tool set (count derived from IMPLEMENTED_TOOLS.size) and that starting npx @agentmemory/agentmemory with AGENTMEMORY_URL pointing at it unlocks all 53 tools.

4. CI guard against count drift

New test/tool-count-consistency.test.ts asserts the registry exposes 53 tools and that the CLI help and README reflect the same number. Any future tool add or removal fails CI until docs and help are updated. Runs under the existing npm test config.

5. agentmemory demo --serve one-shot

The demo previously needed two terminals. The new --serve flag boots the server (starting the engine the same way the normal start path does), waits for :3111 health, runs the existing seed and query demo, prints results, then tears the server down cleanly on exit. Reuses existing start and stop helpers. Added one line to the README install block.

Validation

  • npm run build passes
  • npm test passes (1410 in the default run; full surface 1423)

Summary by CodeRabbit

  • New Features

    • Added a --serve option to the demo command
    • CLI now reports live tool counts in help text
  • Bug Fixes

    • Engine version mismatch now logs a warning instead of exiting
  • Documentation

    • README test count updated to 1,423+
    • Clarified messaging when a service/worker is unreachable
  • Tests

    • New tests ensuring CLI/docs and registry tool counts remain consistent

rohitg00 added 2 commits June 7, 2026 11:39
Correct stale 51-tool references to the registry truth of 53 across the
standalone shim comments and the registry comment, derive the visible
tool count from the registry, update README test-count stats to 1,423+,
add the demo --serve README line, and add a vitest guard that fails CI
if the registry count, README, or CLI help drift out of sync.
Convert the hard process.exit on a PATH iii version mismatch into a
non-fatal warning so a mismatched iii on PATH no longer blocks first
run; agentmemory continues with its own pinned engine in
~/.agentmemory/bin and honors AGENTMEMORY_III_VERSION. Add a --serve
flag to the demo subcommand that boots the server, waits for health,
runs the seed and query demo, and tears the server down on exit, all
in one invocation. Derive the --tools help counts from the registry.
@vercel

vercel Bot commented Jun 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agentmemory Ready Ready Preview, Comment Jun 7, 2026 11:09am

Request Review

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 90d0b088-fc8c-4f5b-9a50-8cda8e7449f2

📥 Commits

Reviewing files that changed from the base of the PR and between 87964c3 and 7189096.

📒 Files selected for processing (1)
  • src/cli.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/cli.ts

📝 Walkthrough

Walkthrough

Tool counts are derived from the registry and propagated to CLI help and MCP messaging; ESSENTIAL_TOOLS is exported and tested for consistency with README. The demo command gains --serve with conditional engine/worker start, readiness checks, teardown, and engine-version handling changed from error to warning. README test counts updated to 1,423+.

Changes

Tool Count Synchronization Across Registry, CLI, and Documentation

Layer / File(s) Summary
Export ESSENTIAL_TOOLS and update tool registry documentation
src/mcp/tools-registry.ts
ESSENTIAL_TOOLS changed from a private const to export const; registry comment updated to 53-tool wording.
Wire dynamic tool counts into CLI help text
src/cli.ts
CLI imports registry functions and computes ALL_TOOLS_COUNT and CORE_TOOLS_COUNT, interpolating them into the --tools help line.
Update MCP server announcement messaging with tool counts
src/mcp/standalone.ts
announceMode() now logs total tool count and reduced local fallback size when MCP is unreachable; proxy comment updated to 53-tool surface.
Test tool count consistency across registry, CLI, and docs
test/tool-count-consistency.test.ts
New Vitest suite ensures registry exposes expected tool count, CLI help derives counts (no hardcoded outdated numbers), ESSENTIAL_TOOLS size matches core count, and README advertises the same count.
Update README with new test statistics
README.md
Updated test passing badge, banner, and npm test note from 1,390+ to 1,423+; quick-start demo example changed to include --serve.

Demo --serve Feature and Engine Handling

Layer / File(s) Summary
Update engine version-mismatch handling
src/cli.ts
Detection of an already-running non-pinned iii-engine now emits a warning that the CLI will use its pinned engine, rather than logging an error and exiting.
Implement conditional server startup and teardown for demo --serve
src/cli.ts
Add startServerForDemo() to conditionally start iii-engine and boot/import the worker, wait for readiness, and return a teardown that stops Docker/native engines and clears pid/state files; runDemo() uses this helper when --serve is set.
Document demo --serve behavior in CLI and README
src/cli.ts, README.md
Demo command help text updated to show demo [--serve] behavior and Quick Start changed to agentmemory demo --serve.

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

A rabbit hops through counts so bright,
From 1,390 up to 1,423 in sight!
Tools now flow from registry deep,
--serve wakes engines from their sleep,
Tests keep counts snug and neat 🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and concisely summarizes the three main changes: fixing outdated statistics, relaxing the engine version check, and adding one-command demo support.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/onboarding-trust

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/cli.ts`:
- Around line 2124-2147: Importing "./index.js" can start an in-process worker
that isn’t stopped by the current teardown logic; modify the code so the import
returns a handle or exported stop function from index.js (e.g., export
stopWorker/closeServer) and capture it where import("./index.js") is awaited,
then in the teardown blocks (the one that runs when startedEngine is false and
the later block at 2158-2173) call that stop function (await stopWorker())
before returning so the in-process worker is properly shut down; alternatively,
set a shared startedEngine flag or store the worker pid from the import and use
signalAndWait/clearWorkerPidfile/clearEngineState accordingly to ensure both
external and in-process workers are stopped.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8613174f-23d4-4df3-965e-3929f16b37c4

📥 Commits

Reviewing files that changed from the base of the PR and between 2515851 and 87964c3.

📒 Files selected for processing (5)
  • README.md
  • src/cli.ts
  • src/mcp/standalone.ts
  • src/mcp/tools-registry.ts
  • test/tool-count-consistency.test.ts

Comment thread src/cli.ts
Comment on lines +2124 to +2147
await import("./index.js");
if (!(await waitForAgentmemoryReady(15000))) {
p.log.error("agentmemory worker did not become ready within 15s.");
process.exit(1);
}

return async () => {
if (!startedEngine) return;
const port = getRestPort();
const state = readEngineState();
if (state?.kind === "docker") {
await stopDockerEngine(state.composeFile, port).catch(() => {});
return;
}
const pids = new Set<number>(findEnginePidsByPort(port));
const pidfilePid = readEnginePidfile();
if (pidfilePid) pids.add(pidfilePid);
for (const pid of pids) {
await signalAndWait(pid, "SIGTERM", 3000).catch(() => {});
}
clearEnginePidfile();
clearEngineState();
clearWorkerPidfile();
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

demo --serve teardown does not stop the worker started in this process

At Line 2124, import("./index.js") starts the worker in the current CLI process, but teardown (Lines 2131-2147) only targets external engine pids and becomes a no-op when startedEngine is false. This breaks the “one-command demo then tear down” contract and can leave the worker running after the demo completes.

Also applies to: 2158-2173

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/cli.ts` around lines 2124 - 2147, Importing "./index.js" can start an
in-process worker that isn’t stopped by the current teardown logic; modify the
code so the import returns a handle or exported stop function from index.js
(e.g., export stopWorker/closeServer) and capture it where import("./index.js")
is awaited, then in the teardown blocks (the one that runs when startedEngine is
false and the later block at 2158-2173) call that stop function (await
stopWorker()) before returning so the in-process worker is properly shut down;
alternatively, set a shared startedEngine flag or store the worker pid from the
import and use signalAndWait/clearWorkerPidfile/clearEngineState accordingly to
ensure both external and in-process workers are stopped.

@rohitg00 rohitg00 merged commit cc28d61 into main Jun 7, 2026
7 checks passed
@rohitg00 rohitg00 deleted the fix/onboarding-trust branch June 7, 2026 11:47
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.

1 participant