@yugabytedb/meko-mcp 2.2.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +168 -61
  2. package/assets/hooks-handlers/lib/capture-cleanup-cli.js +2134 -0
  3. package/assets/hooks-handlers/lib/capture-notices.js +224 -14
  4. package/assets/hooks-handlers/lib/capture-state.js +206 -1
  5. package/assets/hooks-handlers/lib/capture-status-cli.js +6 -2
  6. package/assets/hooks-handlers/lib/capture.js +1364 -139
  7. package/assets/hooks-handlers/lib/checkpoint-timer.js +445 -18
  8. package/assets/hooks-handlers/lib/journal-bridge.js +218 -0
  9. package/assets/hooks-handlers/lib/kiro-handler.js +26 -4
  10. package/assets/hooks-handlers/lib/opencode-handler.js +643 -0
  11. package/assets/hooks-handlers/lib/opencode-normalizer.js +145 -0
  12. package/assets/hooks-handlers/lib/terminal-handoff.js +10 -1
  13. package/assets/opencode-plugin/meko.js +213 -0
  14. package/assets/scripts/meko-statusline.sh +102 -19
  15. package/assets/skills/meko-mcp-tools/SKILL.md +59 -16
  16. package/assets/skills/meko-mcp-tools/references/_sections.md +2 -2
  17. package/assets/skills/meko-mcp-tools/references/tools-agent-id-conventions.md +15 -7
  18. package/assets/skills/meko-mcp-tools/references/tools-cookbook.md +275 -19
  19. package/assets/skills/meko-mcp-tools/references/tools-datapack-workflow.md +7 -4
  20. package/assets/skills/meko-mcp-tools/references/tools-known-limitations.md +39 -11
  21. package/assets/skills/meko-mcp-tools/references/tools-memory-vs-conversation.md +10 -6
  22. package/assets/skills/meko-mcp-tools/references/tools-overview.md +44 -29
  23. package/assets/skills/meko-mcp-tools/references/tools-rag-workflow.md +79 -14
  24. package/assets/skills/meko-mcp-tools/references/tools-troubleshooting.md +47 -1
  25. package/assets/skills/meko-mcp-tools/references/tools-user-id-conventions.md +6 -39
  26. package/assets/skills/meko-mcp-tools-desktop/SKILL.md +57 -21
  27. package/assets/skills/meko-mcp-tools-desktop/desktop/README.md +4 -4
  28. package/assets/skills/meko-mcp-tools-desktop/references/_sections.md +1 -1
  29. package/assets/skills/meko-mcp-tools-desktop/references/tools-agent-id-conventions.md +8 -6
  30. package/assets/skills/meko-mcp-tools-desktop/references/tools-cookbook.md +284 -38
  31. package/assets/skills/meko-mcp-tools-desktop/references/tools-known-limitations.md +32 -10
  32. package/assets/skills/meko-mcp-tools-desktop/references/tools-memory-vs-conversation.md +16 -12
  33. package/assets/skills/meko-mcp-tools-desktop/references/tools-overview.md +46 -31
  34. package/assets/skills/meko-mcp-tools-desktop/references/tools-rag-workflow.md +79 -14
  35. package/assets/skills/meko-mcp-tools-desktop/references/tools-troubleshooting.md +69 -1
  36. package/assets/skills/meko-select-datapack-desktop/SKILL.md +93 -14
  37. package/assets/skills/meko-select-datapack-desktop/references/cookbook.md +44 -12
  38. package/assets/skills/meko-select-datapack-desktop/references/role-display-future.md +14 -10
  39. package/assets/skills/meko-select-datapack-desktop/references/troubleshooting.md +17 -5
  40. package/bin/create-meko-setup.mjs +186 -30
  41. package/lib/autofix.mjs +100 -0
  42. package/lib/browser-login.mjs +495 -0
  43. package/lib/capture-cleanup.mjs +63 -0
  44. package/lib/clients/claude-code.mjs +1 -0
  45. package/lib/clients/codex.mjs +80 -35
  46. package/lib/clients/common.mjs +7 -0
  47. package/lib/clients/index.mjs +2 -0
  48. package/lib/clients/kiro.mjs +5 -5
  49. package/lib/clients/opencode.mjs +537 -0
  50. package/lib/config.mjs +68 -1
  51. package/lib/installer.mjs +18 -2
  52. package/lib/migrate/adapters/claude-code.mjs +11 -2
  53. package/lib/migrate/adapters/codex.mjs +9 -2
  54. package/lib/migrate/adapters/memory-md.mjs +27 -8
  55. package/lib/migrate/adapters/opencode.mjs +148 -0
  56. package/lib/migrate/claude-parser.mjs +153 -9
  57. package/lib/migrate/datapack.mjs +254 -16
  58. package/lib/migrate/id.mjs +195 -13
  59. package/lib/migrate/mcp-client.mjs +59 -1
  60. package/lib/migrate/opencode-normalizer.mjs +132 -0
  61. package/lib/migrate/orchestrator.mjs +294 -78
  62. package/lib/migrate/progress.mjs +239 -5
  63. package/lib/migrate/registry.mjs +72 -0
  64. package/lib/migrate.mjs +97 -9
  65. package/lib/validate.mjs +111 -22
  66. package/package.json +5 -5
  67. package/scripts/bundle-assets.mjs +4 -0
@@ -254,7 +254,7 @@ export function createCodexAdapter(options = {}) {
254
254
  const next = removeCodexConfigBlock(raw, name);
255
255
  if (next !== raw) writeWithBackup(path, next);
256
256
  },
257
- async registerServer({ name, url, apiKey, dryRun, verbose, log, scope, yes }) {
257
+ async registerServer({ name, url, apiKey, dryRun, verbose, log, scope }) {
258
258
  const path = settingsPathFor(scope, log);
259
259
  const useApiKey = apiKey ? "MEKO_API_KEY" : null;
260
260
  const cliCmd = buildCliRegisterCommand(name, url, useApiKey);
@@ -353,35 +353,6 @@ export function createCodexAdapter(options = {}) {
353
353
  // Cloud auth UX: env-var-only model. The key is never written to
354
354
  // config.toml; the user's runtime env supplies it. Print actionable
355
355
  // instructions and (when interactive) offer to wire things up.
356
- if (apiKey) {
357
- const platform = surfaces.app?.platform ?? process.platform;
358
- const hasApp = Boolean(surfaces.app);
359
- const shellRc = detectShellRc();
360
- printCloudAuthInstructions({ shellRc, hasApp, platform, log });
361
- if (!yes) {
362
- await maybeOfferRcAppend({
363
- apiKey,
364
- shellRc,
365
- promptUser,
366
- log,
367
- });
368
- if (hasApp && platform === "darwin") {
369
- await maybeOfferLaunchctlSetenv({
370
- apiKey,
371
- promptUser,
372
- runCommand,
373
- log,
374
- });
375
- }
376
- } else if (hasApp && platform === "darwin") {
377
- setLaunchctlMekoApiKey({
378
- apiKey,
379
- runCommand,
380
- log,
381
- });
382
- }
383
- }
384
-
385
356
  if (surfaces.app) {
386
357
  log.dim?.(" Restart Codex.app to attach the new MCP server.");
387
358
  }
@@ -427,6 +398,61 @@ export function createCodexAdapter(options = {}) {
427
398
  );
428
399
  }
429
400
  },
401
+ /**
402
+ * Cloud auth UX: env-var-only model. The key is never written to
403
+ * config.toml, so the user's runtime env must supply it. This is a
404
+ * separate adapter step (not part of registerServer) because an
405
+ * interactive reinstall where the user declines the overwrite prompt
406
+ * skips registration entirely - and the launchd env would otherwise
407
+ * never be refreshed after a key rotation. See
408
+ * yugabyte/meko-mcp-server#337.
409
+ */
410
+ async syncCloudAuthEnvironment({ apiKey, dryRun, log, yes }) {
411
+ if (!apiKey || dryRun) return;
412
+ const platform = surfaces.app?.platform ?? process.platform;
413
+ const hasApp = Boolean(surfaces.app);
414
+ const shellRc = detectShellRc();
415
+ printCloudAuthInstructions({ shellRc, hasApp, platform, log });
416
+ if (!yes) {
417
+ // Offer launchctl BEFORE rc-append, and isolate the rc-append
418
+ // failure mode. `maybeOfferRcAppend` throws when the shell rc is
419
+ // fish and the API key contains a `'` (fish single-quoting can't
420
+ // escape it). If that threw first, the launchctl offer - the
421
+ // yugabyte/meko-mcp-server#337 fix - would never run.
422
+ //
423
+ // macOS: offer launchctl setenv regardless of whether Codex.app
424
+ // is present. Spotlight- and Alfred-launched Codex CLI reads the
425
+ // launchd env too. Login-session inheritance means every
426
+ // GUI-launched process in this session then sees MEKO_API_KEY
427
+ // (visible via `launchctl getenv`, `ps e` on descendants,
428
+ // crash reports); the prompt copy calls that out so the choice
429
+ // is informed.
430
+ if (platform === "darwin") {
431
+ await maybeOfferLaunchctlSetenv({
432
+ apiKey,
433
+ promptUser,
434
+ runCommand,
435
+ log,
436
+ });
437
+ }
438
+ try {
439
+ await maybeOfferRcAppend({
440
+ apiKey,
441
+ shellRc,
442
+ promptUser,
443
+ log,
444
+ });
445
+ } catch (err) {
446
+ log?.warn?.(` Skipping shell rc append: ${err.message}`);
447
+ }
448
+ } else if (platform === "darwin") {
449
+ setLaunchctlMekoApiKey({
450
+ apiKey,
451
+ runCommand,
452
+ log,
453
+ });
454
+ }
455
+ },
430
456
  installSkills({ dryRun, log, scope, name }) {
431
457
  void scope; // Codex skills are user-scope only.
432
458
  const serverName = name ?? "meko";
@@ -1317,7 +1343,7 @@ function renderAgentsMdBlock(version, name) {
1317
1343
  `${AGENTS_MD_START} v${version}`,
1318
1344
  "## Meko memory (auto-managed by meko installer)",
1319
1345
  "",
1320
- `You have a persistent memory store via the \`${name}\` MCP server. At the start of every conversation, call \`${toolPrefix}memory_search\` for relevant personal context; use \`${toolPrefix}knowledgebase_search\` when the request concerns shared datapack knowledge. When the user shares facts, preferences, or decisions worth remembering, call \`${toolPrefix}memory_add\`. Skill details: ~/.agents/skills/meko-mcp-tools/SKILL.md`,
1346
+ `You have a persistent memory store via the \`${name}\` MCP server. At the start of every conversation, call \`${toolPrefix}context_search\` for relevant context: it returns personal memory, shared datapack knowledge, and past conversations in one call. Use \`${toolPrefix}memory_search\` or \`${toolPrefix}knowledgebase_search\` when you need a single source. When the user shares facts, preferences, or decisions worth remembering, call \`${toolPrefix}memory_add\`. Skill details: ~/.agents/skills/meko-mcp-tools/SKILL.md`,
1321
1347
  "",
1322
1348
  "Cloud auth requires `MEKO_API_KEY` exported in your shell (or, for the desktop app on macOS, set via `launchctl setenv`).",
1323
1349
  AGENTS_MD_END,
@@ -1350,9 +1376,16 @@ function printCloudAuthInstructions({ shellRc, hasApp, platform, log }) {
1350
1376
  log.dim?.(` fish: set -gx MEKO_API_KEY '<your-meko-api-key>'`);
1351
1377
  }
1352
1378
  log.dim?.(` Then open a new terminal (or run "exec $SHELL" / "exec fish").`);
1353
- if (hasApp && platform === "darwin") {
1379
+ if (platform === "darwin") {
1380
+ // Explain launchd for both Codex.app and CLI-only macOS installs.
1381
+ // GUI-launched Codex (Finder, Dock, Spotlight, Alfred, `open -a`) reads
1382
+ // launchd's env, not the shell rc, so a fresh install or a rotated key
1383
+ // needs `launchctl setenv` to propagate. Shell-launched CLI still
1384
+ // reads its shell rc.
1354
1385
  log.warn?.(
1355
- "macOS Codex.app launched from Finder/Dock does NOT inherit shell rc — set it via launchctl too:",
1386
+ hasApp
1387
+ ? "macOS Codex.app launched from Finder/Dock does NOT inherit shell rc - set it via launchctl too:"
1388
+ : "macOS Codex CLI launched from Spotlight/Alfred/`open` does NOT inherit shell rc - set it via launchctl too:",
1356
1389
  );
1357
1390
  log.dim?.(
1358
1391
  ` launchctl setenv MEKO_API_KEY '<your-meko-api-key>' # current login session`,
@@ -1360,6 +1393,9 @@ function printCloudAuthInstructions({ shellRc, hasApp, platform, log }) {
1360
1393
  log.dim?.(
1361
1394
  " (For permanence across reboots, add a ~/Library/LaunchAgents/com.meko.env.plist.)",
1362
1395
  );
1396
+ log.warn?.(
1397
+ " launchctl setenv writes to the login session's env, which every subsequently GUI-launched process inherits (visible via `launchctl getenv`, `ps e` on descendants, and crash reports).",
1398
+ );
1363
1399
  }
1364
1400
  }
1365
1401
 
@@ -1443,9 +1479,15 @@ export async function maybeOfferLaunchctlSetenv({
1443
1479
  runCommand,
1444
1480
  log,
1445
1481
  }) {
1482
+ // Default to Yes: this is the setting that makes GUI-launched Codex on
1483
+ // macOS see the fresh key. Users who habitually hit Enter at the prompt
1484
+ // otherwise leave launchd empty and Codex authenticates with whatever key
1485
+ // it had at first start. See yugabyte/meko-mcp-server#337. The prompt
1486
+ // names both Codex.app and Spotlight-launched CLI so a user without the
1487
+ // desktop app understands why the offer applies to them.
1446
1488
  const accept = await promptUser(
1447
- "Run `launchctl setenv MEKO_API_KEY ...` so Codex.app sees the key now?",
1448
- false,
1489
+ "Run `launchctl setenv MEKO_API_KEY ...` so GUI-launched Codex (App, Spotlight, Alfred, `open`) sees the key now? (writes the key into the login session env, inherited by every subsequently GUI-launched process)",
1490
+ true,
1449
1491
  );
1450
1492
  if (!accept) return { set: false };
1451
1493
  return setLaunchctlMekoApiKey({ apiKey, runCommand, log });
@@ -1463,6 +1505,9 @@ export function setLaunchctlMekoApiKey({ apiKey, runCommand, log }) {
1463
1505
  try {
1464
1506
  runCommand(`launchctl setenv MEKO_API_KEY ${shellQuote(apiKey)}`);
1465
1507
  log?.dim?.(" Set MEKO_API_KEY via launchctl (current login session).");
1508
+ log?.warn?.(
1509
+ " Fully quit any running Codex (Cmd-Q, or `pkill -x codex` for the CLI) and relaunch — a process already running will keep its previous MEKO_API_KEY.",
1510
+ );
1466
1511
  return { set: true };
1467
1512
  } catch (err) {
1468
1513
  log?.warn?.(" launchctl setenv failed; run it manually if Codex.app needs cloud auth.");
@@ -88,6 +88,13 @@ export function resolveHooksRoot() {
88
88
  return join(getAssetRoot(), "hooks-handlers");
89
89
  }
90
90
 
91
+ /**
92
+ * @returns {string} absolute path to the installer-owned OpenCode plugin source
93
+ */
94
+ export function resolveOpenCodePluginSource() {
95
+ return join(getAssetRoot(), "opencode-plugin", "meko.js");
96
+ }
97
+
91
98
  /**
92
99
  * @returns {string} absolute path to the statusline script source.
93
100
  * Lives under skills/scripts/ in source, mirrored under assets/scripts/ in
@@ -3,6 +3,7 @@ import { createClaudeDesktopAdapter } from "./claude-desktop.mjs";
3
3
  import { createCodexAdapter } from "./codex.mjs";
4
4
  import { createCursorAdapter } from "./cursor.mjs";
5
5
  import { createKiroAdapter } from "./kiro.mjs";
6
+ import { createOpenCodeAdapter } from "./opencode.mjs";
6
7
 
7
8
  /**
8
9
  * @returns {Record<string, object>}
@@ -14,5 +15,6 @@ export function getClientAdapters() {
14
15
  cursor: createCursorAdapter(),
15
16
  codex: createCodexAdapter(),
16
17
  kiro: createKiroAdapter(),
18
+ opencode: createOpenCodeAdapter(),
17
19
  };
18
20
  }
@@ -55,10 +55,10 @@ const STANDALONE_HOOKS = [
55
55
  * Kiro through the `mcp-remote` stdio bridge never presents the API key at all
56
56
  * (the bridge forwards only headers passed explicitly via `--header`), so it
57
57
  * connects unauthenticated, takes a 401, and falls through to OAuth dynamic
58
- * client registration. Both the IDE and `kiro-cli` then die on an opaque HTML
59
- * 403: each registers a loopback callback, and the Cloud WAF's SSRF ruleset
60
- * refuses internal hosts (localhost, 127.0.0.1, RFC1918, link-local) in a
61
- * redirect_uri regardless of scheme. Header auth sidesteps OAuth entirely.
58
+ * client registration with a loopback callback. The DEV WAF refuses internal
59
+ * hosts in a redirect_uri with an opaque HTML 403; production accepts them as
60
+ * of 2026-09-24, but OAuth still needs a browser. Header auth works headless
61
+ * and sidesteps OAuth entirely.
62
62
  *
63
63
  * Kiro 2.18.1 contains two hook generations. CLI 2.x reads lowercase inline
64
64
  * hooks from the selected custom agent; CLI 3.x and IDE 1.x read standalone
@@ -631,7 +631,7 @@ export function renderSteeringDoc(version, name) {
631
631
  "",
632
632
  "Follow these rules:",
633
633
  "",
634
- `- Search before you answer. Call \`${toolPrefix}memory_search\` at the start of a`,
634
+ `- Search before you answer. Call \`${toolPrefix}context_search\` at the start of a`,
635
635
  " conversation, and again whenever the user asks what you know about something.",
636
636
  `- In fallback mode, call \`${toolPrefix}memory_add\` when the user`,
637
637
  " states something worth remembering later: their role, preferences, team",