From 98d7373a5fe8ff6a982b39e197ba1ae2635a9902 Mon Sep 17 00:00:00 2001 From: leemour Date: Wed, 25 Nov 2026 02:32:07 +0100 Subject: [PATCH] feat(messenger)!: session list replaces account list, and the session contract needs status and list The owner moved the messenger profile list from `account list` to `session list` with no alias (NEED-2915 A, WC-CMD-8, WC-ACCT-12). - The shared messenger `account` group drops `list`; `listProfiles` stays and only `session list` calls it. - The `session` contract template mounts `messengerSessionCommands`, so a messenger whose session shell lacks status or list no longer matches. - parity.json drops `account list` and lists `session list` and `session status --check` in tg, max and wa; STANDARD.md re-rendered. - The first help screen points at ` session list`. - Tests and the pinned MCP catalogue follow. `session list` is not an MCP tool, like the rest of `session`: the all-profiles server already names every profile in each tool's `profile` field. Co-Authored-By: Claude Opus 5.5 --- changes/feat-session-list.md | 15 ++++++++++++ docs/dev/GLOSSARY.md | 2 +- docs/dev/STANDARD.md | 2 +- parity.json | 12 +++++++--- src/cli/contract-templates.ts | 2 ++ src/cli/help/first-screen.test.ts | 4 ++-- src/cli/help/first-screen.ts | 4 ++-- src/cli/messenger/account-command.ts | 17 ------------- src/cli/messenger/accounts.ts | 2 +- src/cli/messenger/admin-commands.test.ts | 24 ++++++++++++------- src/cli/messenger/context.ts | 2 +- src/cli/messenger/session-commands.test.ts | 7 ++---- src/cli/messenger/session-commands.ts | 2 +- src/cli/settings.ts | 6 ++--- src/entities/store-maintenance.ts | 2 +- src/mcp/__snapshots__/personal-catalogue.snap | 1 - src/mcp/mcp.test.ts | 1 - 17 files changed, 56 insertions(+), 49 deletions(-) create mode 100644 changes/feat-session-list.md diff --git a/changes/feat-session-list.md b/changes/feat-session-list.md new file mode 100644 index 000000000..0b4f5f88c --- /dev/null +++ b/changes/feat-session-list.md @@ -0,0 +1,15 @@ +### Changed — experimental + +- **A messenger's profiles are listed by `session list`, and `account list` is gone (WC-CMD-8, WC-ACCT-12).** The + shared messenger `account` group no longer has `list`, with no alias. `session list` answers the same rows. The + shared `session` contract (`sharedCommandTemplate(app, "session")`) now has `status` and `list` beside `start` and + `end`, so a messenger CLI mounts `messengerSessionCommands(messenger)` in its own `session` group, or its session + shell no longer matches the contract. The parity manifest lists `session list` and `session status` in tg, max and + wa, and the first help screen points at ` session list`. Like the rest of the `session` group, `session list` + is not an MCP tool: the all-profiles MCP server already names every profile, and whether it is signed in, in each + tool's `profile` field. The commands a CLI mounts are not part of the stable API: `accountCommand` and + `messengerSessionCommands` keep their signatures, so this ships in a minor. +- **slk loses its duplicate `account list`** on its next cli-core bump: it mounts the shared `account` group, and its + own `session list` stays. Every CLI with a `session list` (drive, gcal, zm, mail, b24, slk and others) gains the + line ` session list your profiles and their logged-in accounts` on its first help screen, so its + `contracts/help.snap` changes on that bump. diff --git a/docs/dev/GLOSSARY.md b/docs/dev/GLOSSARY.md index b53c22cd3..d1e33258f 100644 --- a/docs/dev/GLOSSARY.md +++ b/docs/dev/GLOSSARY.md @@ -96,7 +96,7 @@ Verbs used but not in cli-base's vocabulary, by CLI (2026-10-12). Each needs a r | reference | the typed name of any stored thing: `msg:`, `chat:`, `contact:`, `note:`, `document:`, `person:`, `task:`, `fact:`, `memory:` (`src/domain/references.ts`) | ref, id | see [Output keys](#output-keys) | | locator | the reference of one message: `msg:///` only (`src/domain/locator.ts`) | ref | memo `search` puts `note:` and `task:` references in `locator` (`cli-memo/src/search/command.ts:82,123`) | | profile | the name of one login of this CLI on this machine; chosen, never assumed | account (for this meaning) | memo `mail `, `--account`; drive help "account profiles"; tg/max `contacts show` (a person's card: another meaning) | -| account | the messenger or mail account behind a profile; also `provider/account` in the store key | profile | tg/max `account list` lists profiles | +| account | the messenger or mail account behind a profile; also `provider/account` in the store key | profile | tg/max/wa `session list` lists profiles | | source | where stored data came from: a messenger, a mailbox, a notes folder, Google Drive | — | memo `tags add` "Put labels on one source" (means one stored thing); drive "imported sources" (means documents) | | search hit | one result of a search | result, match, item | JSON key is `items` in some searches and `hits` in others; see below | | context | **open (NEED-987)**: two meanings | — | entity card: memo `context`, `projects context`, `organizations context`, drive `documents context`, tg/max `contacts context`; messages around one message: tg/max `messages context` | diff --git a/docs/dev/STANDARD.md b/docs/dev/STANDARD.md index 7987244b4..100f6a0ae 100644 --- a/docs/dev/STANDARD.md +++ b/docs/dev/STANDARD.md @@ -1069,7 +1069,7 @@ its meaning, and this table is regenerated from it. **Bold** marks a clash still | `--chart-kind` | `` | what to draw: messages, active authors, or joins and leaves | `messages` | `stats charts` | | `--chat` | `` | a chat, by id or name; repeat it for more. **chat addressing follows each messenger's supported names, usernames and Saved Messages aliases, so it differs on purpose (Help text rule 4)** | | `attachments download`, `attachments extract`, `attachments jobs install`, `chats folders create`, `contacts context`, `conversations batches show`, `conversations batches status`, `conversations consents remove`, `conversations embed`, `conversations embeddings clear`, `conversations embeddings status`, `conversations links clear`, `conversations links rebuild`, `conversations rebuild`, `conversations status`, `images embed`, `metadata show` (planned), `metadata sync` (planned), `search conversations`, `searches create`, `stats messages counters show`, `stats messages counters sync`, `stats messages show`, `tags add`, `tags rebuild`, `tags remove`, `tasks link` | | `--chat-invites` | `` | who may add the account to groups and channels: everyone, contacts or nobody | | `account privacy set` (planned) | -| `--check` | | say whether a newer version exists, and install nothing | | `bot list` (planned), `upgrade` | +| `--check` | | say whether a newer version exists, and install nothing | | `bot list` (planned), `session status`, `upgrade` | | `--checkpoints` | `` | elapsed joining ages to inspect, such as 1d,7d,30d | | `stats chats retention` | | `--chunk-bytes` | `` | maximum source bytes returned from a retained attachment; 1–1048576 | `524288` | `attachments show` | | `--claim` | `` | remove only this ownership claim: manual or auto | | `tags remove` | diff --git a/parity.json b/parity.json index c83246342..24262669d 100644 --- a/parity.json +++ b/parity.json @@ -1226,9 +1226,6 @@ "account": { "in": "all" }, - "account list": { - "in": "all" - }, "account privacy": { "in": ["max"], "planned": { @@ -4525,6 +4522,9 @@ "session end": { "in": "all" }, + "session list": { + "in": "all" + }, "session start": { "in": "all", "options": { @@ -4548,6 +4548,12 @@ } } }, + "session status": { + "in": "all", + "options": { + "--check": "all" + } + }, "setup": { "in": "all", "options": { diff --git a/src/cli/contract-templates.ts b/src/cli/contract-templates.ts index aa192c3e0..720f19b44 100644 --- a/src/cli/contract-templates.ts +++ b/src/cli/contract-templates.ts @@ -11,6 +11,7 @@ import type { Messenger } from "./messenger/context.js" import { doctorCommand } from "./messenger/doctor-command.js" import { mcpCommand } from "./messenger/mcp-command.js" import { searchCommand } from "./messenger/search-command.js" +import { messengerSessionCommands } from "./messenger/session-commands.js" import { pagingOf } from "./paging.js" import { settingsFor } from "./settings.js" @@ -103,6 +104,7 @@ export const sharedCommandTemplate = ( .description("link this account") .argument("[method]", "login method") annotate(session.command("end"), { effects: REMOTE_WRITE }).description("end this account's login") + for (const command of messengerSessionCommands(messenger)) session.addCommand(command) return session } const notes = annotate(new Command("notes"), { effects: NO_EFFECTS }).description("notes kept in the shared store") diff --git a/src/cli/help/first-screen.test.ts b/src/cli/help/first-screen.test.ts index bee0a469e..456768871 100644 --- a/src/cli/help/first-screen.test.ts +++ b/src/cli/help/first-screen.test.ts @@ -25,7 +25,7 @@ const fakeTool: ProgramDefinition = { }, commands: () => [ leaf("setup", "guided first run"), - new Command("account").description("the logged-in account").addCommand(leaf("list", "every profile")), + new Command("session").description("log in or out").addCommand(leaf("list", "every profile")), new Command("chats").description("the account's chats").addCommand(leaf("list", "chats, newest first")), new Command("skill").description("agent instructions").addCommand(leaf("show", "print the skill")), commandsCommand(app), @@ -71,7 +71,7 @@ describe("the first screen", () => { linear Linear issues and projects, searchable with your other WireCat data Start here: tg personal setup (any profile name works) - tg account list your profiles and their logged-in accounts + tg session list your profiles and their logged-in accounts Next: tg commands every command, by section tg help options output, offline, timeouts, dry run For agents: tg skill show rules and the discovery loop" diff --git a/src/cli/help/first-screen.ts b/src/cli/help/first-screen.ts index a00044a8a..fcb61217d 100644 --- a/src/cli/help/first-screen.ts +++ b/src/cli/help/first-screen.ts @@ -60,8 +60,8 @@ const pointers = (program: Command, cli: string, start: string | undefined, prof ].filter((row) => row !== undefined) const rows: Row[] = [ ...(start ? [["Start here:", start, profile ? "(any profile name works)" : ""] as const] : []), - ...(has("account list") - ? [["", `${cli} account list`, "your profiles and their logged-in accounts"] as const] + ...(has("session list") + ? [["", `${cli} session list`, "your profiles and their logged-in accounts"] as const] : []), ...next.map(([command = "", does = ""], at) => [at === 0 ? "Next:" : "", command, does] as const), ...(has("skill show") ? [["For agents:", `${cli} skill show`, "rules and the discovery loop"] as const] : []), diff --git a/src/cli/messenger/account-command.ts b/src/cli/messenger/account-command.ts index 104089819..e032a72f5 100644 --- a/src/cli/messenger/account-command.ts +++ b/src/cli/messenger/account-command.ts @@ -5,34 +5,17 @@ import { accountRemoveCommand } from "../account-remove.js" import { accountRenameCommand } from "../account-rename.js" import { REMOTE_READ, REMOTE_WRITE } from "../effects.js" import { itemOf, renderAnswer } from "../envelope.js" -import { withQuery } from "../list-query.js" -import { ACCOUNT_PROFILES_QUERY } from "./account-profile-query.js" import { accountSessionsCommand } from "./account-sessions-command.js" import { photoHelp, readProfilePhoto } from "./admin-commands.js" import { accountAnswer, renderItem } from "./chat-answers.js" import { type Messenger, messengerContext } from "./context.js" import { hideNever } from "./lacks.js" import { privacyCommand } from "./records-command.js" -import { listProfiles } from "./session-commands.js" export const accountCommand = (messenger: Messenger): Command => { const tool = `${messenger.app.command} personal` const account = new Command("account") .description("the logged-in account") - .addCommand( - withQuery( - annotate(new Command("list"), { effects: REMOTE_READ, examples: [`${tool} account list`] }), - ACCOUNT_PROFILES_QUERY, - ) - .summary("profiles on this computer and their signed-in accounts") - .description( - "every account profile on this computer, and the account each is logged in as; a name that is only a bot " + - "is left out (`bot list` has it), one that is a bot too says `bot: true`; asks the messenger nothing", - ) - .action(async function (this: Command, words: string[]) { - await listProfiles(this, messenger, words, "account list") - }), - ) .addCommand( annotate(new Command("show"), { effects: REMOTE_READ, diff --git a/src/cli/messenger/accounts.ts b/src/cli/messenger/accounts.ts index 42451105b..fa888ee47 100644 --- a/src/cli/messenger/accounts.ts +++ b/src/cli/messenger/accounts.ts @@ -35,6 +35,6 @@ export const profilesWithAccounts = (app: AppIdentity, env: NodeJS.ProcessEnv): .map((name) => name.slice(0, -".json".length)) } -/** The profiles on this computer, as `account list` shows them: named in the configuration file, or logged in to. */ +/** The profiles on this computer, as `session list` shows them: named in the configuration file, or logged in to. */ export const profilesHere = (app: AppIdentity, configured: readonly string[], env: NodeJS.ProcessEnv): string[] => [...new Set([...configured, ...profilesWithAccounts(app, env)])].sort() diff --git a/src/cli/messenger/admin-commands.test.ts b/src/cli/messenger/admin-commands.test.ts index 4dacf6e77..8040adcc0 100644 --- a/src/cli/messenger/admin-commands.test.ts +++ b/src/cli/messenger/admin-commands.test.ts @@ -3,6 +3,7 @@ import { tmpdir } from "node:os" import { join } from "node:path" import { CliError, captureStreams } from "@wirecat/cli-base" import type { CommandInfo } from "@wirecat/cli-base/commands" +import { Command } from "commander" import * as v from "valibot" import { describe, expect, it } from "vitest" import type { Chat, GroupCard, Id, MembershipState } from "../../domain/models.js" @@ -13,6 +14,7 @@ import { openStore } from "../../store/store.js" import { commandsCommand } from "../commands-command.js" import { run } from "../program.js" import { settingsFor } from "../settings.js" +import { messengerSessionCommands } from "../shared-command-exports.js" import { accountCommand } from "./account-command.js" import { rememberAccount } from "./accounts.js" import { groupCommands } from "./admin-commands.js" @@ -77,6 +79,10 @@ const call = async ( chatsCommand(messenger), contactsCommand(messenger), accountCommand(messenger), + messengerSessionCommands(messenger).reduce( + (session, command) => session.addCommand(command), + new Command("session").addCommand(new Command("start")), + ), commandsCommand(app), ], }, @@ -1042,13 +1048,13 @@ describe("chats create, join and leave", () => { const offline: MessengerAdapter = { ...base, me: async () => { - throw new Error("account list must not ask the messenger") + throw new Error("session list must not ask the messenger") }, } const { CHAT_PROFILE: _, ...unnamed } = env - const listed = await call(["account", "list", "--json"], offline, unnamed) - const named = await call(["work", "account", "list", "--json"], offline, unnamed) + const listed = await call(["session", "list", "--json"], offline, unnamed) + const named = await call(["work", "session", "list", "--json"], offline, unnamed) expect(listed.code).toBe(0) expect(answer(listed).items).toEqual([ @@ -1057,14 +1063,14 @@ describe("chats create, join and leave", () => { ]) expect(answer(named).items.map((item: { current: boolean }) => item.current)).toEqual([false, true]) for (const item of answer(listed).items) expect(v.safeParse(ENTITIES.account_profile, item).success).toBe(true) - const byProfile = await call(["account", "list", "profile:work", "--json=profile,account"], offline, unnamed) + const byProfile = await call(["session", "list", "profile:work", "--json=profile,account"], offline, unnamed) expect(byProfile.code).toBe(0) expect(answer(byProfile).items).toEqual([{ profile: "work", account: "501" }]) - const withoutCurrent = await call(["account", "list", "current:true", "--json"], offline, unnamed) + const withoutCurrent = await call(["session", "list", "current:true", "--json"], offline, unnamed) expect(answer(withoutCurrent).items).toEqual([]) - const currentOnly = await call(["work", "account", "list", "current:true", "--json"], offline, unnamed) + const currentOnly = await call(["work", "session", "list", "current:true", "--json"], offline, unnamed) expect(answer(currentOnly).items).toEqual([{ profile: "work", current: true, account: "501", name: null }]) - const unsupported = await call(["account", "list", "name:Owner", "--json"], offline, unnamed) + const unsupported = await call(["session", "list", "name:Owner", "--json"], offline, unnamed) expect(unsupported.code).toBe(2) expect(unsupported.stderr.join("\n")).toContain("query.unsupported-field") }) @@ -1074,7 +1080,7 @@ describe("chats create, join and leave", () => { rememberAccount(app, "work", "501", env) rememberAccount(app, "old", "502", env) const { CHAT_PROFILE: _, ...unnamed } = env - const listed = await call(["account", "list", "--json"], base, unnamed, { + const listed = await call(["session", "list", "--json"], base, unnamed, { profileState: (profile) => (profile === "old" ? "signed-out" : "signed-in"), }) expect( @@ -1099,7 +1105,7 @@ describe("chats create, join and leave", () => { rememberAccount(app, "work", "501", env) const { CHAT_PROFILE: _, ...unnamed } = env - const listed = await call(["account", "list", "--json"], base, unnamed, { profileState: () => "signed-out" }) + const listed = await call(["session", "list", "--json"], base, unnamed, { profileState: () => "signed-out" }) expect(listed.code).toBe(0) expect(answer(listed).items).toEqual([ diff --git a/src/cli/messenger/context.ts b/src/cli/messenger/context.ts index 37256a0ca..da4753072 100644 --- a/src/cli/messenger/context.ts +++ b/src/cli/messenger/context.ts @@ -171,7 +171,7 @@ export interface Messenger extends ServiceMessenger { /** * A profile's state, read from the messenger's own files without connecting: `signed-in` has a session, `signed-out` * has none yet, `bot` speaks for a bot. ` mcp` with no profile offers the personal ones and marks those not - * signed in; `account list` and the profile errors say so too. Unset: every profile counts as signed in. + * signed in; `session list` and the profile errors say so too. Unset: every profile counts as signed in. */ profileState?: (profile: string, env: NodeJS.ProcessEnv) => ProfileState /** Opts in to `account remove`: what signing out and forgetting a profile means for this messenger. */ diff --git a/src/cli/messenger/session-commands.test.ts b/src/cli/messenger/session-commands.test.ts index 4822858f1..61002c889 100644 --- a/src/cli/messenger/session-commands.test.ts +++ b/src/cli/messenger/session-commands.test.ts @@ -56,7 +56,7 @@ const never = async (): Promise => { } describe("messenger session status and list", () => { - it("**lists the profiles with no profile named**, as `account list` does, asking the messenger nothing", async () => { + it("**lists the profiles with no profile named**, asking the messenger nothing", async () => { const env = sandbox() await call(["work", "account", "show", "--json"], env, asked) rememberAccount(app, "work", "500", env) @@ -65,16 +65,13 @@ describe("messenger session status and list", () => { const listed = await call(["session", "list", "--json"], env, never, { profileState: (profile: string) => (profile === "old" ? "signed-out" : "signed-in"), }) - const account = await call(["account", "list", "--json"], env, never, { - profileState: (profile: string) => (profile === "old" ? "signed-out" : "signed-in"), - }) expect(listed.code).toBe(0) expect(listed.body.items).toEqual([ { profile: "old", current: false, account: "502", name: null, signed_in: false }, { profile: "work", current: false, account: "500", name: "Owner", signed_in: true }, ]) - expect(account.body.items).toEqual(listed.body.items) + expect((await call(["account", "list", "--json"], env, never)).code).not.toBe(0) for (const item of listed.body.items) expect(v.safeParse(ENTITIES.account_profile, item).success).toBe(true) }) diff --git a/src/cli/messenger/session-commands.ts b/src/cli/messenger/session-commands.ts index 425a1354e..63cf240bf 100644 --- a/src/cli/messenger/session-commands.ts +++ b/src/cli/messenger/session-commands.ts @@ -17,7 +17,7 @@ import { type Messenger, messengerContext } from "./context.js" const storeOf = async (env: NodeJS.ProcessEnv) => existsSync(storePath(env)) ? await openStore({ env }).catch(() => undefined) : undefined -/** What `account list` and `session list` answer: the profiles here and the account each is logged in as. */ +/** What `session list` answers: the profiles here and the account each is logged in as. */ export const listProfiles = async (command: Command, messenger: Messenger, words: string[], label: string) => { const terms = queryTerms(words, ACCOUNT_PROFILES_QUERY, label) const context = messengerContext(command, messenger, { needsProfile: false }) diff --git a/src/cli/settings.ts b/src/cli/settings.ts index e8c4145df..05e6b7a1f 100644 --- a/src/cli/settings.ts +++ b/src/cli/settings.ts @@ -415,12 +415,12 @@ export interface Settings extends AISettings { /** Every profile on this computer, bots included — what a missing profile's error lists. */ profilesHere: string[] /** - * The profiles here that are an account, not only a bot — what `account list` shows. A name only the file's bot + * The profiles here that are an account, not only a bot — what `session list` shows. A name only the file's bot * section names, with no personal section, recorded login or messenger profile of its own, is a bot. Absent for an * app that builds `Settings` itself; `profilesHere` stands in. */ accountProfiles?: string[] - /** Every name with a bot: the file's bot section, or a bot's own files. `account list` marks these. */ + /** Every name with a bot: the file's bot section, or a bot's own files. `session list` marks these. */ botProfiles?: string[] /** Where each value came from — `config show` prints it. */ sources: Record @@ -445,7 +445,7 @@ export interface ResolveOptions { /** `personal` unless given. */ kind?: ProfileKind /** - * `false` for a command that touches no account — `account list`, `config show` — so it still runs + * `false` for a command that touches no account — `session list`, `config show` — so it still runs * when no profile is named. Its `profile` is then `default`, from `none named`. */ needsProfile?: boolean diff --git a/src/entities/store-maintenance.ts b/src/entities/store-maintenance.ts index cceab3e6c..d43d22526 100644 --- a/src/entities/store-maintenance.ts +++ b/src/entities/store-maintenance.ts @@ -48,7 +48,7 @@ const perAccount = { chats: count, messages: count, emails: count, documents: co const contents = { by_provider: v.optional(v.array(v.strictObject({ provider: text, accounts: count, ...perAccount }))), by_chat_kind: v.optional(v.array(v.strictObject({ provider: text, kind: text, chats: count, messages: count }))), - /** `name` is the one `account list` shows; the messenger's own id for the account is left out. */ + /** `name` is the one `session list` shows; the messenger's own id for the account is left out. */ by_account: v.optional( v.array(v.strictObject({ provider: text, account_id: count, name: v.nullable(text), ...perAccount })), ), diff --git a/src/mcp/__snapshots__/personal-catalogue.snap b/src/mcp/__snapshots__/personal-catalogue.snap index 218f91987..902b76496 100644 --- a/src/mcp/__snapshots__/personal-catalogue.snap +++ b/src/mcp/__snapshots__/personal-catalogue.snap @@ -1,4 +1,3 @@ -read account list read account privacy show read account sessions list read account show diff --git a/src/mcp/mcp.test.ts b/src/mcp/mcp.test.ts index 7bbda50a9..f2cba3186 100644 --- a/src/mcp/mcp.test.ts +++ b/src/mcp/mcp.test.ts @@ -757,7 +757,6 @@ describe("the MCP server", () => { .map((one) => one.command) .sort(), ).toEqual([ - "account list", "account sessions list", "account show", "attachments check",