Skip to content

feat(cli): onboarding wires selected agents inline + memory-share callout#408

Merged
rohitg00 merged 1 commit into
mainfrom
feat/cli-onboarding-wire
May 15, 2026
Merged

feat(cli): onboarding wires selected agents inline + memory-share callout#408
rohitg00 merged 1 commit into
mainfrom
feat/cli-onboarding-wire

Conversation

@rohitg00
Copy link
Copy Markdown
Owner

@rohitg00 rohitg00 commented May 15, 2026

Summary

Today the first-run wizard stores the multi-select in ~/.agentmemory/preferences.json and exits. Users then have to re-run agentmemory connect <agent> per agent by hand. This PR closes that loop.

Two changes, one PR:

  1. Memory-share callout. After the agents multi-select (only when >=1 agent selected, before provider select), print a callout explaining that all picked agents share the same memory at :3111 — a save by Claude Code is visible to Codex + Cursor instantly.

  2. Wire selected agents inline. After provider selection + .env write, ask "Run agentmemory connect <agent> for each selected agent now? [Y/n]". On yes, dispatch each through the existing runAdapter (same code path the standalone agentmemory connect <agent> command uses today), collect per-agent results, and summarize Wired: ... / Skipped/failed: .... On no/cancel, print the exact commands to run later.

Edge cases handled:

  • Stubbed adapters (hermes / pi / openhuman) print their manual-install hint and are bucketed as "manual install required — see "; not a failure.
  • Per-adapter errors are caught + logged; the loop keeps going for remaining agents.
  • Zero-agents case (user hit enter on empty multi-select / chose skip) bypasses both the callout and the wire prompt entirely.

Scope-limited to src/cli/onboarding.ts (callout + wire flow) and src/cli/connect/index.ts (export runAdapter).

Sample first-run flow

┌── first-run setup ──
Welcome to agentmemory.

Persistent memory for your AI coding agents. We'll pick which
agents to wire up and which provider (if any) handles compression
and consolidation. Either step can be changed later in ~/.agentmemory/.env.

? Which agents will use agentmemory? (space to toggle, enter to confirm)
  [x] ⟁ Claude Code
  [x] ◎ Codex
  [x] ◫ Cursor
  [x] ◇ Hermes
  ...

━ how this works ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
All selected agents share the same memory at :3111.
A memory saved by Claude Code is visible to Codex + Cursor instantly.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

? Which LLM provider should agentmemory use for compress/consolidate?
  > Skip — BM25-only mode (no LLM key)

┌── ready ──
✓ Saved preferences to ~/.agentmemory/preferences.json
✓ Wrote ~/.agentmemory/.env (edit to add your API key)
  No provider chosen — agentmemory will run in BM25-only mode.

┌── next step ──
Wire selected agents now?

? Run `agentmemory connect <agent>` for each selected agent now? [Y/n] › y

▶ Wiring claude-code...
▶ Wiring codex...
▶ Wiring cursor...
▶ Wiring hermes...

┌── wire summary ──
Wired: claude-code, codex, cursor.
Skipped/failed: hermes (manual install required — see https://github.com/rohitg00/agentmemory/tree/main/integrations/hermes).

Test plan

  • npm run build passes
  • npx vitest run test/cli-connect.test.ts — 13/13 pass (dispatcher + claude-code adapter unchanged)
  • Drove runOnboarding() non-interactively with mocked @clack/prompts + connect/index.js: callout renders, wire prompt fires, per-agent step lines print, summary buckets wired vs manual correctly
  • Manual smoke on a real first-run via npx agentmemory@latest --reset once published

Diff stat

 src/cli/connect/index.ts |  2 +-
 src/cli/onboarding.ts    | 86 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 87 insertions(+), 1 deletion(-)

Summary by CodeRabbit

New Features

  • Agent wiring is now integrated into the onboarding process
  • After selecting agents, users can wire them immediately or opt to run manual connection commands later
  • Onboarding displays information about shared memory behavior when agents are selected
  • Wiring summary shows successful connections, agents requiring manual setup, and any failures

Review Change Stack

…lout

After the agents multi-select, show a callout explaining that all picked agents share the same memory at :3111 (Claude Code saves visible to Codex + Cursor instantly).

After provider selection + .env write, ask whether to run agentmemory connect <agent> for each selected agent right now. On yes, dispatch through the existing connect adapter (same code path as agentmemory connect <agent>) and summarize wired vs manual vs failed. On no/cancel, print the exact commands to run later.

Expose runAdapter from src/cli/connect/index.ts so onboarding reuses the same install path the CLI uses today.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 2026

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

Project Deployment Actions Updated (UTC)
agentmemory Ready Ready Preview, Comment May 15, 2026 4:16pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

📝 Walkthrough

Walkthrough

The PR exports the runAdapter function from the connect module as a public API and integrates automatic agent wiring into the onboarding flow. After agent selection, users are prompted to wire agents immediately or defer wiring, with real-time feedback on success, manual installation requirements, and failures.

Changes

Onboarding with Agent Wiring

Layer / File(s) Summary
Export runAdapter function
src/cli/connect/index.ts
runAdapter is changed from non-exported internal helper to export async function, making it reusable by other CLI flows.
Implement onboarding agent wiring
src/cli/onboarding.ts
Imports runAdapter and resolveAdapter to enable agent wiring; adds shared memory behavior note after agent selection; calls wireSelectedAgents to prompt user for immediate or deferred wiring; implements wireSelectedAgents orchestration that resolves adapters, runs wiring per agent, categorizes results, and prints a consolidated summary.

Sequence Diagram

sequenceDiagram
  participant User
  participant Onboarding
  participant wireSelectedAgents
  participant resolveAdapter
  participant runAdapter
  User->>Onboarding: Complete agent selection
  Onboarding->>User: Show shared memory note (if agents selected)
  Onboarding->>wireSelectedAgents: Call wireSelectedAgents(agents)
  wireSelectedAgents->>User: Prompt: wire now or later?
  alt User declines wiring
    wireSelectedAgents->>User: Display "Wire later with:" commands
  else User accepts wiring
    loop For each selected agent
      wireSelectedAgents->>resolveAdapter: Resolve adapter for agent
      resolveAdapter-->>wireSelectedAgents: Adapter or undefined
      alt Adapter resolved
        wireSelectedAgents->>runAdapter: Execute adapter wiring
        runAdapter-->>wireSelectedAgents: ConnectResult (success/failure)
        wireSelectedAgents->>wireSelectedAgents: Categorize result (wired/manual/failed)
      else No adapter
        wireSelectedAgents->>wireSelectedAgents: Mark as failed
      end
    end
    wireSelectedAgents->>User: Print wiring summary
  end
  Onboarding-->>User: Return onboarding result
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • rohitg00/agentmemory#402: The PR's refactor of runAdapter export and new onboarding wiring flow directly depend on the adapter resolution infrastructure introduced in PR #402.

Poem

🐰 A rabbit hops through onboarding's door,
With agents wired, connecting more and more,
runAdapter now exported, shared with care,
Automatic wiring flows through the air! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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 pull request title clearly summarizes the main changes: adding inline agent wiring and a memory-share callout to the onboarding flow, which matches the primary objectives.
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 feat/cli-onboarding-wire

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/cli/onboarding.ts (1)

163-173: 💤 Low value

Optional: eliminate redundant variable.

pickedAgentsList (line 163) is derived from the same source as agents (line 186) but only used for the length check on line 164. You could move this callout block after line 186 and use agents.length > 0 directly.

♻️ Suggested refactor

Move the callout block after the agents assignment:

   }

-  const pickedAgentsList = (agentsPicked as string[]) ?? [];
-  if (pickedAgentsList.length > 0) {
-    p.note(
-      [
-        "━ how this works ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",
-        "All selected agents share the same memory at :3111.",
-        "A memory saved by Claude Code is visible to Codex + Cursor instantly.",
-        "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",
-      ].join("\n"),
-    );
-  }
-
   const providerPicked = await p.select<string>({
     message: "Which LLM provider should agentmemory use for compress/consolidate?",
     options: PROVIDERS.map(({ value, label }) => ({ value, label })),

Then after line 186:

   const provider = providerPicked === "skip" ? null : providerPicked;
   const agents = (agentsPicked as string[]) ?? [];
+
+  if (agents.length > 0) {
+    p.note(
+      [
+        "━ how this works ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",
+        "All selected agents share the same memory at :3111.",
+        "A memory saved by Claude Code is visible to Codex + Cursor instantly.",
+        "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",
+      ].join("\n"),
+    );
+  }

   const envPath = await seedEnvFile(provider);
🤖 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/onboarding.ts` around lines 163 - 173, The callout uses a redundant
variable pickedAgentsList (derived from agentsPicked) only to check length;
remove pickedAgentsList, move the callout block to after the agents assignment
(variable agents) and replace the length check with agents.length > 0 so the
block uses the already-computed agents array instead of
agentsPicked/pickedAgentsList.
🤖 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/onboarding.ts`:
- Line 246: Remove the duplicate "Wiring" step log in onboarding by deleting the
p.log.step(`Wiring ${name}...`) call so that runAdapter (which logs Wiring
${adapter.displayName}… in connect/index.ts:62) remains the single source of
truth; this keeps naming and ellipsis consistent with the runConnect/runAdapter
flow.

---

Nitpick comments:
In `@src/cli/onboarding.ts`:
- Around line 163-173: The callout uses a redundant variable pickedAgentsList
(derived from agentsPicked) only to check length; remove pickedAgentsList, move
the callout block to after the agents assignment (variable agents) and replace
the length check with agents.length > 0 so the block uses the already-computed
agents array instead of agentsPicked/pickedAgentsList.
🪄 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: f35d090b-dcf2-4424-a771-34463c1f0118

📥 Commits

Reviewing files that changed from the base of the PR and between c3a613a and ceccf09.

📒 Files selected for processing (2)
  • src/cli/connect/index.ts
  • src/cli/onboarding.ts

Comment thread src/cli/onboarding.ts
p.log.warn(`Wiring ${name}… no adapter available (skipped).`);
continue;
}
p.log.step(`Wiring ${name}...`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Remove duplicate "Wiring" log or use display name for consistency.

Line 246 logs Wiring ${name}... (e.g., "Wiring claude-code..."), but runAdapter (called on line 249) also logs Wiring ${adapter.displayName}… at connect/index.ts:62 (e.g., "Wiring Claude Code…"). This produces two wiring messages per agent with inconsistent naming ("claude-code" vs "Claude Code") and ellipsis styles ("..." vs "…").

The existing runConnect flow (connect/index.ts:104-109) calls runAdapter without a preceding step log, letting runAdapter handle all logging. Consider following the same pattern here.

🎨 Proposed fix

Remove the duplicate log step:

-    p.log.step(`Wiring ${name}...`);
     let result: ConnectResult;

Alternatively, if you want to keep a local log, use the display name and matching ellipsis:

-    p.log.step(`Wiring ${name}...`);
+    p.log.step(`Wiring ${adapter.displayName}…`);
     let result: ConnectResult;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
p.log.step(`Wiring ${name}...`);
let result: ConnectResult;
🤖 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/onboarding.ts` at line 246, Remove the duplicate "Wiring" step log in
onboarding by deleting the p.log.step(`Wiring ${name}...`) call so that
runAdapter (which logs Wiring ${adapter.displayName}… in connect/index.ts:62)
remains the single source of truth; this keeps naming and ellipsis consistent
with the runConnect/runAdapter flow.

@rohitg00 rohitg00 merged commit 48070ad into main May 15, 2026
5 checks passed
@rohitg00 rohitg00 deleted the feat/cli-onboarding-wire branch May 15, 2026 16:45
rohitg00 added a commit that referenced this pull request May 15, 2026
Patch bump per the established rule: additive surface only, no breaks
to MemoryProvider trait, exported types, or default behaviour. New
top-level subcommands (`--reset` already shipped 0.9.15, no new
commands here) are opt-in.

PRs included since v0.9.15:
  #408 — onboarding wires selected agents inline + memory-share callout
  #409 — clarify MCP is opt-in (REST primary)
  #410 — 5-port ready panel, iii console install, global-install prompt
  #411 — splash banner rerender + README install hoist + npx caveat
  #415 — agent-memory.dev refresh (FeaturedIn bar + Agents/Compare/
         CommandCenter/Hero updates)

Files bumped (9):
  package.json, packages/mcp/package.json, plugin/.claude-plugin/plugin.json,
  plugin/.codex-plugin/plugin.json, src/version.ts, src/types.ts,
  src/functions/export-import.ts, test/export-import.test.ts,
  CHANGELOG.md
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