From c02dff00e1f26318841ad4ccacf0f6c7bf5be3b5 Mon Sep 17 00:00:00 2001 From: Shah Hussain <95882307+shhahhussain@users.noreply.github.com> Date: Thu, 15 Oct 2026 19:06:10 +0500 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20getmnemo=200.6=20=E2=80=94=20worksp?= =?UTF-8?q?ace=20id=20optional,=20API=20key=20carries=20identity=20(0.4.0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - getmnemo ^0.5.1 -> ^0.6.0 - getClient no longer requires a workspace id; a configured one is still passed through (ignored by core 0.6) - login drops the workspace prompt (--workspace-id deprecated, saved only if given); whoami authenticates on API key alone; doctor drops the workspace check; mcp emits GETMNEMO_WORKSPACE_ID only when configured - bump to 0.4.0 (user-visible login/whoami/doctor/mcp changes) --- CHANGELOG.md | 12 ++++++++++++ README.md | 10 +++++----- package-lock.json | 12 ++++++------ package.json | 4 ++-- src/cli.test.ts | 2 +- src/commands/auth.ts | 29 +++++++++++++---------------- src/commands/doctor.ts | 1 - src/commands/mcp.ts | 6 ++++-- src/lib/client.test.ts | 37 +++++++++++++++++++++++++++++++++++++ src/lib/client.ts | 16 +++++++++------- src/lib/version.test.ts | 2 +- 11 files changed, 90 insertions(+), 41 deletions(-) create mode 100644 src/lib/client.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index e02d859..1385fac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ All notable changes to `getmnemo-cli` are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow [SemVer](https://semver.org/). +## [0.4.0] — 2026-10-15 + +### Changed +- `getmnemo` core dependency `^0.5.1` → `^0.6.0`. +- A workspace ID is no longer required: with an API key, workspace identity comes from the key. Commands no longer fail with "No workspace selected". +- `login` no longer prompts for a workspace ID; `--workspace-id` is deprecated and only saved if given. +- `whoami` reports authenticated with just an API key; `doctor` drops the "workspace configured" check; `mcp` only emits `GETMNEMO_WORKSPACE_ID` when one is still configured. + +### Notes +- Minor bump (not patch): `login`, `whoami`, `doctor` and `mcp` output change, and the core dependency moves a minor version. +- `GETMNEMO_WORKSPACE_ID` / a saved `workspaceId` are still accepted but ignored by getmnemo 0.6. + ## [0.3.0] — 2026-09-02 ### Added diff --git a/README.md b/README.md index 2b3d4f8..79f8699 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ npx getmnemo-cli --help ## Quickstart ```bash -getmnemo login # save API key + workspace to ~/.getmnemo/config.json +getmnemo login # save API key to ~/.getmnemo/config.json getmnemo add "Acme prefers blue branding" --container org:acme getmnemo search "what brand color does Acme use?" --container org:acme getmnemo doctor # verify auth + API reachability @@ -36,11 +36,11 @@ getmnemo doctor # verify auth + API reachability | Command | Description | | --- | --- | -| `getmnemo login` | Prompt for API key, workspace ID, and (optionally) API URL; persist to `~/.getmnemo/config.json`. | +| `getmnemo login` | Prompt for API key and (optionally) API URL; verify; persist to `~/.getmnemo/config.json`. The API key identifies the workspace. | | `getmnemo logout` | Remove saved credentials. | -| `getmnemo whoami` | Print the active workspace + API URL. | +| `getmnemo whoami` | Print the API key preview + API URL (and workspace, if one is still configured). | -`login` flags: `--api-key`, `--workspace-id`, `--api-url` (skip the prompt). +`login` flags: `--api-key`, `--api-url` (skip the prompt). `--workspace-id` is deprecated and optional — workspace identity comes from the API key. ### Memory operations @@ -108,7 +108,7 @@ With `--json`, runtime errors are written to stderr as `{"ok": false, "error": " | Variable | Purpose | Default | | --- | --- | --- | | `GETMNEMO_API_KEY` | Overrides the saved API key. | — | -| `GETMNEMO_WORKSPACE_ID` | Overrides the active workspace. | — | +| `GETMNEMO_WORKSPACE_ID` | Deprecated and optional — the API key identifies the workspace. | — | | `GETMNEMO_API_URL` | Overrides the API base URL. | `https://api.mnemohq.com` | | `GETMNEMO_CONTAINER` | Default container tag for the memory commands when no `--container` flag is given. | — | diff --git a/package-lock.json b/package-lock.json index 1564536..59f63b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,16 @@ { "name": "getmnemo-cli", - "version": "0.3.0", + "version": "0.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "getmnemo-cli", - "version": "0.3.0", + "version": "0.4.0", "license": "MIT", "dependencies": { "commander": "^12.1.0", - "getmnemo": "^0.5.1", + "getmnemo": "^0.6.0", "kleur": "^4.1.5", "prompts": "^2.4.2" }, @@ -1160,9 +1160,9 @@ } }, "node_modules/getmnemo": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/getmnemo/-/getmnemo-0.5.1.tgz", - "integrity": "sha512-Hrexlk8Bn1eK2ez0Cyfbm8uwLqq/CihrG0Hr1NAMlwd1ERXGB8YeIUYpqGZEyyYefrNSpbuXWJQrNI1yXcUTEA==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/getmnemo/-/getmnemo-0.6.0.tgz", + "integrity": "sha512-dFPwYl7xK45qt74bv2z3xA9EnRyMWy17QsiGpfmSAyAqcdk2Ziuf2d161ge3SvBxz1BqURe514oUI0iPpJ4CFg==", "license": "MIT", "engines": { "node": ">=18" diff --git a/package.json b/package.json index aa502c3..110993f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "getmnemo-cli", - "version": "0.3.0", + "version": "0.4.0", "description": "Official CLI for Mnemo — manage memories, workspaces, and integrations from your terminal.", "type": "module", "bin": { @@ -23,7 +23,7 @@ }, "dependencies": { "commander": "^12.1.0", - "getmnemo": "^0.5.1", + "getmnemo": "^0.6.0", "kleur": "^4.1.5", "prompts": "^2.4.2" }, diff --git a/src/cli.test.ts b/src/cli.test.ts index 4cff0fe..be7efb8 100644 --- a/src/cli.test.ts +++ b/src/cli.test.ts @@ -67,7 +67,7 @@ describe("Mnemo CLI", () => { } catch { // commander throws on version by design } - expect(stdout.trim()).toBe("0.3.0"); + expect(stdout.trim()).toBe("0.4.0"); }); it("exits 2 for an unknown option on a subcommand (exit callback is inherited)", async () => { diff --git a/src/commands/auth.ts b/src/commands/auth.ts index 11f2373..b89c3cc 100644 --- a/src/commands/auth.ts +++ b/src/commands/auth.ts @@ -20,7 +20,7 @@ export function registerAuthCommands(program: Command): void { .command("login") .description("authenticate with Mnemo and save credentials locally") .option("--api-key ", "API key (skips interactive prompt)") - .option("--workspace-id ", "workspace id (skips interactive prompt)") + .option("--workspace-id ", "deprecated: workspace comes from the API key; saved if given") .option("--api-url ", "override API base URL") .action(async (opts: { apiKey?: string; workspaceId?: string; baseUrl?: string }, cmd: Command) => { const json = rootJsonFlag(cmd); @@ -35,12 +35,6 @@ export function registerAuthCommands(program: Command): void { message: "Mnemo API key", validate: (val: string) => (val.trim().length > 0 ? true : "API key is required"), }, - { - type: opts.workspaceId ? null : "text", - name: "workspaceId", - message: "Workspace ID", - validate: (val: string) => (val.trim().length > 0 ? true : "Workspace ID is required"), - }, { type: opts.baseUrl ? null : "text", name: "baseUrl", @@ -56,14 +50,15 @@ export function registerAuthCommands(program: Command): void { ); const apiKey = opts.apiKey ?? (responses.apiKey as string); - const workspaceId = opts.workspaceId ?? (responses.workspaceId as string); + // Deprecated: the API key identifies the workspace. Only saved if given. + const workspaceId = opts.workspaceId?.trim() || undefined; const baseUrl = opts.baseUrl ?? (responses.baseUrl as string) ?? defaultApiUrl; // Verify credentials before persisting — a typo should fail loudly, // not silently overwrite a previously-working config. try { - const probe = new Mnemo({ apiKey, workspaceId, baseUrl }); - // getmnemo 0.5.1 list() throws client-side without a container, and + const probe = new Mnemo({ apiKey, baseUrl }); + // getmnemo list() throws client-side without a container, and // none is configured yet at login. Probe with a synthetic read-only // tag: we only care whether the key authenticates (401 vs 2xx), and // listing an empty container is a valid, cheap request. @@ -81,13 +76,15 @@ export function registerAuthCommands(program: Command): void { process.exit(1); } - await writeConfig({ apiKey, workspaceId, baseUrl }); + await writeConfig({ apiKey, baseUrl, ...(workspaceId ? { workspaceId } : {}) }); if (json) { - printJson({ ok: true, workspaceId, baseUrl }); + printJson({ ok: true, workspaceId: workspaceId ?? null, baseUrl }); return; } - printSuccess(`Logged in. Workspace: ${workspaceId}`); + printSuccess( + workspaceId ? `Logged in. Workspace: ${workspaceId}` : "Logged in.", + ); }); program @@ -105,7 +102,7 @@ export function registerAuthCommands(program: Command): void { program .command("whoami") - .description("show the current authenticated workspace") + .description("show the current API key, API URL, and (deprecated) workspace") .action(async (_opts: unknown, cmd: Command) => { const json = rootJsonFlag(cmd); const cfg = await readConfig(); @@ -114,7 +111,7 @@ export function registerAuthCommands(program: Command): void { const baseUrl = resolveApiUrl(cfg); const payload = { - authenticated: Boolean(apiKey && workspaceId), + authenticated: Boolean(apiKey), workspaceId: workspaceId ?? null, baseUrl, apiKeyPreview: apiKey ? `${apiKey.slice(0, 4)}…${apiKey.slice(-4)}` : null, @@ -128,7 +125,7 @@ export function registerAuthCommands(program: Command): void { printInfo("Not logged in. Run `getmnemo login`."); return; } - printInfo(`Workspace: ${payload.workspaceId}`); + if (payload.workspaceId) printInfo(`Workspace: ${payload.workspaceId}`); printInfo(`API URL: ${payload.baseUrl}`); printInfo(`API key: ${payload.apiKeyPreview}`); }); diff --git a/src/commands/doctor.ts b/src/commands/doctor.ts index c5f355c..14bc39e 100644 --- a/src/commands/doctor.ts +++ b/src/commands/doctor.ts @@ -23,7 +23,6 @@ export function registerDoctorCommand(program: Command): void { checks.push({ name: "config file present", ok: Boolean(cfg.updatedAt), detail: cfg.updatedAt }); checks.push({ name: "API key configured", ok: Boolean(apiKey) }); - checks.push({ name: "workspace configured", ok: Boolean(workspaceId), detail: workspaceId }); let healthOk = false; let healthDetail = ""; diff --git a/src/commands/mcp.ts b/src/commands/mcp.ts index 042869d..d7a653e 100644 --- a/src/commands/mcp.ts +++ b/src/commands/mcp.ts @@ -11,7 +11,9 @@ export function registerMcpCommand(program: Command): void { const json = rootJsonFlag(cmd); const cfg = await readConfig(); const apiKey = resolveApiKey(cfg) ?? ""; - const workspaceId = resolveWorkspaceId(cfg) ?? ""; + // Deprecated (the API key identifies the workspace); only emitted when + // the user still has one configured. + const workspaceId = resolveWorkspaceId(cfg); const baseUrl = resolveApiUrl(cfg); const snippet = { @@ -23,7 +25,7 @@ export function registerMcpCommand(program: Command): void { args: ["-y", "getmnemo-mcp"], env: { GETMNEMO_API_KEY: apiKey, - GETMNEMO_WORKSPACE_ID: workspaceId, + ...(workspaceId ? { GETMNEMO_WORKSPACE_ID: workspaceId } : {}), GETMNEMO_API_URL: baseUrl, }, }, diff --git a/src/lib/client.test.ts b/src/lib/client.test.ts new file mode 100644 index 0000000..cd15b87 --- /dev/null +++ b/src/lib/client.test.ts @@ -0,0 +1,37 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { ClientAuthError, getClient } from "./client.js"; + +describe("getClient", () => { + beforeEach(() => { + // Nonexistent HOME so a real ~/.getmnemo/config.json can't leak in. + vi.stubEnv("HOME", join(tmpdir(), "getmnemo-cli-client-test-nonexistent")); + vi.stubEnv("GETMNEMO_WORKSPACE_ID", undefined); + vi.stubEnv("GETMNEMO_API_URL", "https://api.test.invalid"); + }); + + afterEach(() => { + vi.unstubAllEnvs(); + }); + + it("builds a client from an API key alone (workspace comes from the key)", async () => { + vi.stubEnv("GETMNEMO_API_KEY", "mk_test_key"); + const ctx = await getClient(); + expect(ctx.apiKey).toBe("mk_test_key"); + expect(ctx.workspaceId).toBeUndefined(); + expect(ctx.client).toBeDefined(); + }); + + it("still accepts a configured (deprecated) workspace id", async () => { + vi.stubEnv("GETMNEMO_API_KEY", "mk_test_key"); + vi.stubEnv("GETMNEMO_WORKSPACE_ID", "ws_legacy"); + const ctx = await getClient(); + expect(ctx.workspaceId).toBe("ws_legacy"); + }); + + it("still requires an API key", async () => { + vi.stubEnv("GETMNEMO_API_KEY", undefined); + await expect(getClient()).rejects.toBeInstanceOf(ClientAuthError); + }); +}); diff --git a/src/lib/client.ts b/src/lib/client.ts index 7fa2c5c..a4f7fb4 100644 --- a/src/lib/client.ts +++ b/src/lib/client.ts @@ -14,7 +14,11 @@ export interface ClientContext { /** Transport for people/reminders/brief/timeline/meetings/merge. */ api: PersonalApi; apiKey: string; - workspaceId: string; + /** + * Optional and deprecated: workspace identity comes from the API key. Kept + * only so configs that still set it keep working; getmnemo 0.6 ignores it. + */ + workspaceId?: string; baseUrl: string; cfg: CliConfig; } @@ -37,11 +41,9 @@ export async function getClient(): Promise { "Not authenticated. Run `getmnemo login` or set GETMNEMO_API_KEY.", ); } - if (!workspaceId) { - throw new ClientAuthError( - "No workspace selected. Run `getmnemo login` or set GETMNEMO_WORKSPACE_ID.", - ); - } + // No workspace check: the API key carries workspace identity. A configured + // workspaceId is still passed through (getmnemo 0.6 ignores it) so existing + // configs keep working unchanged. // Backstop only: every current command resolves its container per call // (flag > env > config) and passes it explicitly, so this seed is not @@ -50,7 +52,7 @@ export async function getClient(): Promise { // of an SDK error. Per-call values always win over this. const client = new Mnemo({ apiKey, - workspaceId, + ...(workspaceId ? { workspaceId } : {}), baseUrl, defaultContainerTag: resolveContainerTag(cfg), }); diff --git a/src/lib/version.test.ts b/src/lib/version.test.ts index 9c6c22f..74ec7db 100644 --- a/src/lib/version.test.ts +++ b/src/lib/version.test.ts @@ -8,6 +8,6 @@ describe("CLI_VERSION", () => { readFileSync(new URL("../../package.json", import.meta.url), "utf8"), ) as { version: string }; expect(CLI_VERSION).toBe(pkg.version); - expect(CLI_VERSION).toBe("0.3.0"); + expect(CLI_VERSION).toBe("0.4.0"); }); }); From 3d7aebe374fb1a5027186c8fe957820fc566d809 Mon Sep 17 00:00:00 2001 From: Shah Hussain <95882307+shhahhussain@users.noreply.github.com> Date: Thu, 15 Oct 2026 19:13:23 +0500 Subject: [PATCH 2/2] fix: login honours --api-url The action read opts.baseUrl, but commander maps --api-url to opts.apiUrl, so the flag was ignored (and the URL prompt still shown). --- src/cli.test.ts | 24 +++++++++++++++++++++++- src/commands/auth.ts | 7 ++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/cli.test.ts b/src/cli.test.ts index be7efb8..6111644 100644 --- a/src/cli.test.ts +++ b/src/cli.test.ts @@ -357,7 +357,29 @@ describe("Mnemo CLI", () => { expect(fetchMock).not.toHaveBeenCalled(); }); - it("login verifies credentials with a synthetic probe container", async () => { + it("login honours --api-url without prompting", async () => { + vi.stubEnv( + "HOME", + join(tmpdir(), `getmnemo-cli-test-home-login-url-${process.pid}`), + ); + const fetchMock = vi + .fn() + .mockResolvedValue(jsonResponse({ items: [], nextCursor: null })); + vi.stubGlobal("fetch", fetchMock); + + const program = buildCli(); + program.exitOverride(); + await program.parseAsync([ + "node", "getmnemo", "--json", "login", + "--api-key", "mk_login_test", "--api-url", "https://custom.test.invalid", + ]); + + const [url] = firstCall(fetchMock); + expect(url.startsWith("https://custom.test.invalid/v1/memories")).toBe(true); + expect(stdout).toMatch(/"baseUrl": "https:\/\/custom\.test\.invalid"/); + }); + + it("login verifies credentials with a synthetic probe container", async () => { // Own HOME so the config write cannot leak into the shared stub path. vi.stubEnv( "HOME", diff --git a/src/commands/auth.ts b/src/commands/auth.ts index b89c3cc..e0e0eab 100644 --- a/src/commands/auth.ts +++ b/src/commands/auth.ts @@ -22,7 +22,7 @@ export function registerAuthCommands(program: Command): void { .option("--api-key ", "API key (skips interactive prompt)") .option("--workspace-id ", "deprecated: workspace comes from the API key; saved if given") .option("--api-url ", "override API base URL") - .action(async (opts: { apiKey?: string; workspaceId?: string; baseUrl?: string }, cmd: Command) => { + .action(async (opts: { apiKey?: string; workspaceId?: string; apiUrl?: string }, cmd: Command) => { const json = rootJsonFlag(cmd); const cfg = await readConfig(); const defaultApiUrl = resolveApiUrl(cfg); @@ -36,7 +36,7 @@ export function registerAuthCommands(program: Command): void { validate: (val: string) => (val.trim().length > 0 ? true : "API key is required"), }, { - type: opts.baseUrl ? null : "text", + type: opts.apiUrl ? null : "text", name: "baseUrl", message: "API URL", initial: defaultApiUrl, @@ -52,7 +52,8 @@ export function registerAuthCommands(program: Command): void { const apiKey = opts.apiKey ?? (responses.apiKey as string); // Deprecated: the API key identifies the workspace. Only saved if given. const workspaceId = opts.workspaceId?.trim() || undefined; - const baseUrl = opts.baseUrl ?? (responses.baseUrl as string) ?? defaultApiUrl; + // commander maps `--api-url` to `opts.apiUrl`. + const baseUrl = opts.apiUrl ?? (responses.baseUrl as string) ?? defaultApiUrl; // Verify credentials before persisting — a typo should fail loudly, // not silently overwrite a previously-working config.