From 058b5d0def04c8d55a52dab6cb13dd5dd14a47a5 Mon Sep 17 00:00:00 2001 From: leemour Date: Wed, 25 Nov 2026 02:53:08 +0100 Subject: [PATCH 1/5] feat(session)!: session list and session status, and account list is gone The owner moved the profile list from `account list` to `session list` with no alias, and gave every messenger `session status` (NEED-2915 A, WC-CMD-8, WC-ACCT-12). - The session group mounts cli-core's messengerSessionCommands. - cli-core 0.734.0 -> 0.751.0 for now; the next push pins the cli-core release that drops `account list` from the shared account group. - Docs, the skill, the help and manifest contracts and the tests say `session list`; a test drives `session status` with and without --check. Co-Authored-By: Claude Opus 5.5 --- changes/feat-session-list.md | 12 +++++++++ contracts/help.snap | 2 +- contracts/wirecat.json | 28 ++++++++++++++------- docs/commands.md | 48 +++++++++++++++++++++++------------- docs/dev/test-matrix.md | 2 +- docs/profiles.md | 4 +-- docs/sessions.md | 4 +-- docs/usage.md | 2 +- scripts/commands.ts | 2 +- skills/tg-cli/SKILL.md | 2 +- src/commands/session.test.ts | 32 ++++++++++++++++++++++++ src/commands/session.ts | 4 ++- 12 files changed, 106 insertions(+), 36 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 00000000..bc7ca77b --- /dev/null +++ b/changes/feat-session-list.md @@ -0,0 +1,12 @@ +### Changed — may break callers + +- **`tg session list` lists the profiles on this computer, and `tg account list` is gone** (WC-ACCT-12, WC-CMD-8). + It answers the same rows, takes the same query (`profile:`, `current:`) and needs no profile. There is no alias: + a script that runs `tg account list` must say `tg session list`. `account show`, `account update`, + `account sessions` and the rest of `account` stay. + +### Added + +- **`tg session status` says whether the profile is logged in, and as whom**, from this computer alone. + `--check` asks the messenger whether the session still works, and leaves the phone number out (`account show` + has it). From cli-core 0.751.0 (was 0.734.0). diff --git a/contracts/help.snap b/contracts/help.snap index e476ffcf..3ed09278 100644 --- a/contracts/help.snap +++ b/contracts/help.snap @@ -32,7 +32,7 @@ Works with: 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 guide scenarios: command sequences for common tasks tg help options output, offline, timeouts, dry run diff --git a/contracts/wirecat.json b/contracts/wirecat.json index 5793ece3..fbf43636 100644 --- a/contracts/wirecat.json +++ b/contracts/wirecat.json @@ -30,27 +30,37 @@ }, { "path": [ - "setup" + "session", + "status" ], - "summary": "set up Telegram and connect your agent", + "summary": "show whether this profile is logged in, and as whom", "effects": { - "remote": "write", - "local": "write" + "remote": "read", + "local": "read" } }, { "path": [ - "account", + "session", "list" ], - "summary": "profiles on this computer and their signed-in accounts", + "summary": "list the profiles on this computer and the account each is logged in as", "effects": { - "remote": "read", + "remote": "none", "local": "read" }, - "permission": "account.list", "entity": "account_profile" }, + { + "path": [ + "setup" + ], + "summary": "set up Telegram and connect your agent", + "effects": { + "remote": "write", + "local": "write" + } + }, { "path": [ "account", @@ -7649,7 +7659,7 @@ "tagline": "Your Telegram account, searchable on your computer", "profiles": { "args": [ - "account", + "session", "list", "--no-record", "--json" diff --git a/docs/commands.md b/docs/commands.md index f14d46c8..1c99157f 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -17,7 +17,7 @@ tg [profile] [options] [arguments] profile `work`. `TG_PROFILE` does the same for a whole shell session. **No profile is assumed**, not even the only one: without either, a command that uses an account stops with exit 2 and lists the profiles on this computer. Commands that use no -account (`--help`, `--version`, `commands`, `skill show`, `account list`, `config show`) run +account (`--help`, `--version`, `commands`, `skill show`, `session list`, `config show`) run without one. ## Options for every command @@ -82,6 +82,36 @@ tg session end **Example:** `tg personal session end` +### `tg session status` + +show whether this profile has a session on this computer and the account it was logged in as; --check asks the messenger whose the session is, without the phone number (`account show` has it) + +```sh +tg session status [options] +``` + +| Option | What it does | +|---|---| +| `--check` | ask the messenger whether the session still works, and whose it is. | + +**Example:** `tg personal session status`, `tg personal session status --check --json` + +### `tg session list` + +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 + +```sh +tg session list [query] +``` + +| Argument | | What it is | +|---|---|---| +| `query` | optional | field:value terms that narrow the list — the fields are below. | + +**Returns:** account profile — profile, current, account, name, signed_in, bot; every field: tg commands info session list + +**Example:** `tg session list`, `tg session list --json` + ## `tg setup` set up Telegram and connect your agent @@ -104,22 +134,6 @@ tg setup [options] the logged-in account -### `tg account list` - -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 - -```sh -tg account list [query] -``` - -| Argument | | What it is | -|---|---|---| -| `query` | optional | field:value terms that narrow the list — the fields are below. | - -**Returns:** account profile — profile, current, account, name, signed_in, bot; every field: tg commands info account list - -**Example:** `tg personal account list` - ### `tg account show` who this profile is logged in as, with the phone number diff --git a/docs/dev/test-matrix.md b/docs/dev/test-matrix.md index e5fdb3ae..f47ab0e4 100644 --- a/docs/dev/test-matrix.md +++ b/docs/dev/test-matrix.md @@ -20,7 +20,7 @@ Measured from the test run (`coverage/argv.jsonl`), not searched for — see | `setup` | `--agent` | ✅ | | | `setup` | `--app` | ✅ | | | `setup` | `--method` | ✅ | | -| `account list` | | ✅ | | +| `session list` | | ✅ | | | `account show` | | ✅ | | | `account show` | `--hide-phone` | ✅ | | | `account update` | | ✅ | | diff --git a/docs/profiles.md b/docs/profiles.md index 3fc20cab..b8096323 100644 --- a/docs/profiles.md +++ b/docs/profiles.md @@ -17,7 +17,7 @@ settings, and how to switch to a bot. | Give your agent fewer rights than you have | A profile with its own [permissions](permissions.md) | | Keep an agent on that one profile | `TG_PROFILE_LOCK` ([profiles in login and sessions](sessions.md#profiles)) | | Run a Telegram bot next to your account | A bot profile: `tg support bot api get-me` | -| See every profile on this computer | `tg account list` | +| See every profile on this computer | `tg session list` | ## Choose a profile @@ -27,7 +27,7 @@ Put the profile name before the command: tg work config show ``` -`tg account list` shows every profile on this computer and the account each is logged in as; +`tg session list` shows every profile on this computer and the account each is logged in as; `tg work session end` logs the profile `work` out. A setting under `profiles.work` in the config file applies to that profile; values under `defaults` diff --git a/docs/sessions.md b/docs/sessions.md index 6eafe76c..bf5e7734 100644 --- a/docs/sessions.md +++ b/docs/sessions.md @@ -160,7 +160,7 @@ If your account has a two-step password (2FA), `tg` asks for it after the scan. ```sh tg personal account show # who this profile is logged in as -tg account list # every profile on this computer, and the account each is logged in as +tg session list # every profile on this computer, and the account each is logged in as tg personal account sessions list # every device and app logged in to the account; ends nothing tg personal session end # log out on Telegram's side, and delete the session file here ``` @@ -223,7 +223,7 @@ The order, first match wins: the first word, then `TG_PROFILE`. With none of them, a command that uses an account stops with exit code `2` and lists the profiles on this computer; with none there yet, it says to run `tg personal setup`. `tg` never picks one, not even the only one. Commands that use no account run without a profile: `--help`, `--version`, `commands`, -`skill show`, `account list` and `config show`. +`skill show`, `session list` and `config show`. A word that is not a command and has no command after it is an error that says so: diff --git a/docs/usage.md b/docs/usage.md index 932497f7..23b0a735 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -137,7 +137,7 @@ tg personal account show --hide-phone # the same without the phone number ``` ```sh -tg account list # every profile on this computer and the account each is logged in as +tg session list # every profile on this computer and the account each is logged in as ``` ```sh diff --git a/scripts/commands.ts b/scripts/commands.ts index 773a9aad..a8b2a4ec 100644 --- a/scripts/commands.ts +++ b/scripts/commands.ts @@ -44,7 +44,7 @@ tg [profile] [options] [arguments] profile \`work\`. \`TG_PROFILE\` does the same for a whole shell session. **No profile is assumed**, not even the only one: without either, a command that uses an account stops with exit 2 and lists the profiles on this computer. Commands that use no -account (\`--help\`, \`--version\`, \`commands\`, \`skill show\`, \`account list\`, \`config show\`) run +account (\`--help\`, \`--version\`, \`commands\`, \`skill show\`, \`session list\`, \`config show\`) run without one.`, globalHeading: "Options for every command", globalIntro: "", diff --git a/skills/tg-cli/SKILL.md b/skills/tg-cli/SKILL.md index 3bd28531..ce25af0f 100644 --- a/skills/tg-cli/SKILL.md +++ b/skills/tg-cli/SKILL.md @@ -24,7 +24,7 @@ for a write to Telegram); `tg --help` is shorter; `tg guide` lists sce **The first word is the profile when it is not a command.** `tg work chats list` is profile `work`. There is no `--profile` flag; `TG_PROFILE` does the same. No profile is assumed: without one, an account command exits -`2` and lists the profiles (`tg account list` shows them too). **Never pick one for the owner**; ask which, +`2` and lists the profiles (`tg session list` shows them too). **Never pick one for the owner**; ask which, unless the task or `TG_PROFILE` says. `personal` below stands for the profile the owner chose. ## Answer a question from the chats diff --git a/src/commands/session.test.ts b/src/commands/session.test.ts index 41114c32..8d0d2141 100644 --- a/src/commands/session.test.ts +++ b/src/commands/session.test.ts @@ -471,3 +471,35 @@ describe("session end", () => { }, ) }) + +describe("session status and session list", () => { + it("**says a profile with no session is not logged in**, even with --check, asking Telegram nothing", async () => { + const asked = () => + scripted({ + login: async () => { + throw new Error("must not ask Telegram") + }, + }) + + for (const argv of [ + ["fresh", "session", "status", "--json=profile,signed_in,verified"], + ["fresh", "session", "status", "--check", "--json=profile,signed_in,verified"], + ]) { + const { code, stdout } = await tg(argv, { adapter: asked }) + expect(code).toBe(0) + expect(JSON.parse(stdout.join("\n")).item).toMatchObject({ profile: "fresh", signed_in: false, verified: false }) + } + }) + + it("**lists the profiles with no profile named**, and `account list` is gone", async () => { + const { TG_PROFILE: _, ...unnamed } = process.env + + const listed = await tg(["session", "list", "--json=profile,account"], { env: unnamed }) + const gone = await tg(["account", "list", "--json=profile"], { env: unnamed }) + + expect(listed.stderr).toEqual([]) + expect(listed.code).toBe(0) + expect(Array.isArray(JSON.parse(listed.stdout.join("\n")).items)).toBe(true) + expect(gone.code).not.toBe(0) + }) +}) diff --git a/src/commands/session.ts b/src/commands/session.ts index c40ae344..a3542986 100644 --- a/src/commands/session.ts +++ b/src/commands/session.ts @@ -11,6 +11,7 @@ import { environmentOf, logsInOrOut, mayRevoke, + messengerSessionCommands, printItem, REMOTE_WRITE, refuseCommandName, @@ -28,7 +29,7 @@ import { SHELL_OVERRIDES } from "../contract-overrides.js" import { usesOwnersSession } from "../paths.js" import { type ApiCredentials, parseApiHash, parseApiId } from "../telegram/credentials.js" import { MY_TELEGRAM, registerApp } from "../telegram/registration.js" -import { type CommandContext, type Environment, forCommand } from "./context.js" +import { type CommandContext, type Environment, forCommand, TELEGRAM } from "./context.js" /** `field` names the question for a window that answers it (`--answer-stdin`). */ type Ask = (prompt: string, echo: boolean, field: string) => Promise @@ -343,6 +344,7 @@ const sessionCommandDefinition = () => { printItem(context, { profile: context.profile, ended: true }) }) + for (const command of messengerSessionCommands(TELEGRAM)) session.addCommand(command) return session } From 2ec8b259fe720db518929dfd171fc36676dbdf0f Mon Sep 17 00:00:00 2001 From: leemour Date: Wed, 25 Nov 2026 03:20:11 +0100 Subject: [PATCH 2/5] docs(test-matrix): session status rows, and session list beside the other session commands Co-Authored-By: Claude Opus 5.5 --- docs/dev/test-matrix.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/dev/test-matrix.md b/docs/dev/test-matrix.md index f47ab0e4..fec42b9b 100644 --- a/docs/dev/test-matrix.md +++ b/docs/dev/test-matrix.md @@ -7,7 +7,7 @@ ran it · ⛔ not tested offline, with the reason and where it is checked instea Measured from the test run (`coverage/argv.jsonl`), not searched for — see [TESTING.md](TESTING.md) for how, and for the states and failures that cut across commands. -**2413 ✅ · 155 ⛔ · 0 ❌** — 547 commands, 2021 options. +**2415 ✅ · 154 ⛔ · 0 ❌** — 548 commands, 2021 options. | Command | Option | | Note | |---|---|---|---| @@ -16,11 +16,13 @@ Measured from the test run (`coverage/argv.jsonl`), not searched for — see | `session start` | `--sms` | ✅ | | | `session start` | `--answer-stdin` | ✅ | | | `session end` | | ✅ | | +| `session status` | | ✅ | | +| `session status` | `--check` | ✅ | | +| `session list` | | ✅ | | | `setup` | | ✅ | | | `setup` | `--agent` | ✅ | | | `setup` | `--app` | ✅ | | | `setup` | `--method` | ✅ | | -| `session list` | | ✅ | | | `account show` | | ✅ | | | `account show` | `--hide-phone` | ✅ | | | `account update` | | ✅ | | @@ -423,7 +425,6 @@ Measured from the test run (`coverage/argv.jsonl`), not searched for — see | `store info` | | ✅ | | | `store check` | | ✅ | | | `store migrate` | | ✅ | | -| `store migrate` | `--no-backup` | ⛔ | cli-core src/cli/messenger/store-maintenance.test.ts covers store migrate; consumer mounts the shared command | | `store rebuild` | | ✅ | | | `store backup` | | ✅ | | | `store backup` | `--encrypt` | ✅ | | From 7dcc5e47149ce8ffd7385fd48a158d21d3a0dc2f Mon Sep 17 00:00:00 2001 From: leemour Date: Thu, 26 Nov 2026 00:59:29 +0100 Subject: [PATCH 3/5] chore(contracts): regenerate the manifest and test matrix against the cli-core session list branch Co-Authored-By: Claude Opus 5.5 --- contracts/wirecat.json | 4 ++++ docs/dev/test-matrix.md | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/contracts/wirecat.json b/contracts/wirecat.json index fbf43636..acc159e9 100644 --- a/contracts/wirecat.json +++ b/contracts/wirecat.json @@ -7409,6 +7409,8 @@ "label", "list", "is", + "type", + "reach", "chat", "date", "source", @@ -7452,6 +7454,8 @@ "label", "list", "is", + "type", + "reach", "chat", "date", "source", diff --git a/docs/dev/test-matrix.md b/docs/dev/test-matrix.md index fec42b9b..92374ae8 100644 --- a/docs/dev/test-matrix.md +++ b/docs/dev/test-matrix.md @@ -7,7 +7,7 @@ ran it · ⛔ not tested offline, with the reason and where it is checked instea Measured from the test run (`coverage/argv.jsonl`), not searched for — see [TESTING.md](TESTING.md) for how, and for the states and failures that cut across commands. -**2415 ✅ · 154 ⛔ · 0 ❌** — 548 commands, 2021 options. +**2415 ✅ · 155 ⛔ · 0 ❌** — 548 commands, 2022 options. | Command | Option | | Note | |---|---|---|---| @@ -425,6 +425,7 @@ Measured from the test run (`coverage/argv.jsonl`), not searched for — see | `store info` | | ✅ | | | `store check` | | ✅ | | | `store migrate` | | ✅ | | +| `store migrate` | `--no-backup` | ⛔ | cli-core src/cli/messenger/store-maintenance.test.ts covers store migrate; consumer mounts the shared command | | `store rebuild` | | ✅ | | | `store backup` | | ✅ | | | `store backup` | `--encrypt` | ✅ | | From 788ed702ffd224b1aa7695e01e0293f6477e93fc Mon Sep 17 00:00:00 2001 From: leemour Date: Thu, 26 Nov 2026 02:06:39 +0100 Subject: [PATCH 4/5] build(deps): cli-core 1.3.0, which drops account list and adds session status and list Co-Authored-By: Claude Opus 5.5 --- changes/feat-session-list.md | 4 +++- package.json | 2 +- pnpm-lock.yaml | 10 +++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/changes/feat-session-list.md b/changes/feat-session-list.md index bc7ca77b..4a6e0c01 100644 --- a/changes/feat-session-list.md +++ b/changes/feat-session-list.md @@ -4,9 +4,11 @@ It answers the same rows, takes the same query (`profile:`, `current:`) and needs no profile. There is no alias: a script that runs `tg account list` must say `tg session list`. `account show`, `account update`, `account sessions` and the rest of `account` stay. +- **The store moves to version 77** on its first open (cli-core 1.1.0 and 1.2.0). Like every store migration it only + goes forward. ### Added - **`tg session status` says whether the profile is logged in, and as whom**, from this computer alone. `--check` asks the messenger whether the session still works, and leaves the phone number out (`account show` - has it). From cli-core 0.751.0 (was 0.734.0). + has it). From cli-core 1.3.0 (was 1.0.0). diff --git a/package.json b/package.json index 316863c3..8cf60143 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "dependencies": { "@mtcute/node": "0.32.7", "@wirecat/cli-base": "1.0.0", - "@wirecat/cli-core": "1.0.0", + "@wirecat/cli-core": "1.3.0", "commander": "15.0.0", "undici": "8.12.3", "valibot": "1.5.0" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ee165974..c53b618d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -19,8 +19,8 @@ importers: specifier: 1.0.0 version: 1.0.0(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5) '@wirecat/cli-core': - specifier: 1.0.0 - version: 1.0.0(@napi-rs/canvas@1.0.13)(@wirecat/cli-base@1.0.0(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5))(commander@15.0.0)(typescript@7.0.2)(zod@4.6.7) + specifier: 1.3.0 + version: 1.3.0(@napi-rs/canvas@1.0.13)(@wirecat/cli-base@1.0.0(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5))(commander@15.0.0)(typescript@7.0.2)(zod@4.6.7) commander: specifier: 15.0.0 version: 15.0.0 @@ -1320,8 +1320,8 @@ packages: '@wirecat/cli-core-sqlite@1.1.0': resolution: {integrity: sha512-GpGlh/dAIX/nblBYCdT6DfWSLFxav9mxxeELQAfEuw+QZdT9unKxbi5xa02s/s4JS1P7n0PQx2sCABj4FlMRNw==} - '@wirecat/cli-core@1.0.0': - resolution: {integrity: sha512-0avQTqu3FAFKE0s+8Pz1Up/TMHTYqCdDn37lcZmkH30sMCMrgJwHzoG4Q0fjVzPsB85u+zBVHHhtQjF/eSTpuw==} + '@wirecat/cli-core@1.3.0': + resolution: {integrity: sha512-tCRgrnXf2YXNkRLFqRHf8iHcm6v1G4D2jn7coSsmqobmOqJvALPOvCiWpoPlVYGprIkXC4Twp+rR367Md2XULg==} engines: {node: ^22.16.0 || >=24} hasBin: true peerDependencies: @@ -3683,7 +3683,7 @@ snapshots: '@wirecat/cli-core-sqlite@1.1.0': {} - '@wirecat/cli-core@1.0.0(@napi-rs/canvas@1.0.13)(@wirecat/cli-base@1.0.0(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5))(commander@15.0.0)(typescript@7.0.2)(zod@4.6.7)': + '@wirecat/cli-core@1.3.0(@napi-rs/canvas@1.0.13)(@wirecat/cli-base@1.0.0(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5))(commander@15.0.0)(typescript@7.0.2)(zod@4.6.7)': dependencies: '@anthropic-ai/sdk': 1.3.0(zod@4.6.7) '@bomb.sh/tab': 0.0.22(commander@15.0.0) From 23323d99e4a0308f6cf46af81a06b10c7c853e98 Mon Sep 17 00:00:00 2001 From: leemour Date: Thu, 26 Nov 2026 02:13:59 +0100 Subject: [PATCH 5/5] docs(mcp): session status and session list are among the commands the server leaves out Co-Authored-By: Claude Opus 5.5 --- docs/mcp.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/mcp.md b/docs/mcp.md index 24fb0d3f..cd9746e1 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -202,7 +202,7 @@ of account settings. The catalogue includes read and write commands, subject to the profile permissions and exclusions below. Read-only access is a choice you configure in those permissions. A few commands are never offered, and you run them in a terminal: -- **Login and setup**: `setup`, `session start|end`, `complete`, `mcp config|add|check|revoke`, +- **Login and setup**: `setup`, `session start|status|list|end`, `complete`, `mcp config|add|check|revoke`, `bot auth set|show|remove`, `bot mcp config`. An agent call cannot use them, or they need you at the keyboard. `mcp` and `bot mcp` alone only print their help. - **Removing an account**: `account remove` signs a profile out and forgets it on this computer, so only you start