Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions changes/feat-session-list.md
Original file line number Diff line number Diff line change
@@ -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 `<tool> 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 `<tool> session list your profiles and their logged-in accounts` on its first help screen, so its
`contracts/help.snap` changes on that bump.
2 changes: 1 addition & 1 deletion docs/dev/GLOSSARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:<provider>/<account>/<chat>/<message>` 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>`, `--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` |
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/STANDARD.md
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ its meaning, and this table is regenerated from it. **Bold** marks a clash still
| `--chart-kind` | `<messages\|active\|membership>` | what to draw: messages, active authors, or joins and leaves | `messages` | `stats charts` |
| `--chat` | `<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>` | 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` | `<durations>` | elapsed joining ages to inspect, such as 1d,7d,30d | | `stats chats retention` |
| `--chunk-bytes` | `<n>` | maximum source bytes returned from a retained attachment; 1–1048576 | `524288` | `attachments show` |
| `--claim` | `<claim>` | remove only this ownership claim: manual or auto | | `tags remove` |
Expand Down
12 changes: 9 additions & 3 deletions parity.json
Original file line number Diff line number Diff line change
Expand Up @@ -1226,9 +1226,6 @@
"account": {
"in": "all"
},
"account list": {
"in": "all"
},
"account privacy": {
"in": ["max"],
"planned": {
Expand Down Expand Up @@ -4525,6 +4522,9 @@
"session end": {
"in": "all"
},
"session list": {
"in": "all"
},
"session start": {
"in": "all",
"options": {
Expand All @@ -4548,6 +4548,12 @@
}
}
},
"session status": {
"in": "all",
"options": {
"--check": "all"
}
},
"setup": {
"in": "all",
"options": {
Expand Down
2 changes: 2 additions & 0 deletions src/cli/contract-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions src/cli/help/first-screen.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/cli/help/first-screen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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] : []),
Expand Down
17 changes: 0 additions & 17 deletions src/cli/messenger/account-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/cli/messenger/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
24 changes: 15 additions & 9 deletions src/cli/messenger/admin-commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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),
],
},
Expand Down Expand Up @@ -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([
Expand All @@ -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")
})
Expand All @@ -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(
Expand All @@ -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([
Expand Down
2 changes: 1 addition & 1 deletion src/cli/messenger/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. `<tool> 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. */
Expand Down
7 changes: 2 additions & 5 deletions src/cli/messenger/session-commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const never = async (): Promise<typeof owner> => {
}

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)
Expand All @@ -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)
})

Expand Down
2 changes: 1 addition & 1 deletion src/cli/messenger/session-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
6 changes: 3 additions & 3 deletions src/cli/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, Source>
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/entities/store-maintenance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })),
),
Expand Down
1 change: 0 additions & 1 deletion src/mcp/__snapshots__/personal-catalogue.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
read account list
read account privacy show
read account sessions list
read account show
Expand Down
Loading
Loading