Skip to content

Commit 0560abc

Browse files
authored
Merge pull request #192 from ably/spaces-get
rename spaces get-all to get to align with the rest of the cli
2 parents 0060c3b + b4816fa commit 0560abc

30 files changed

Lines changed: 467 additions & 565 deletions

File tree

.claude/skills/ably-codebase-review/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,14 @@ Launch these agents **in parallel**. Each agent gets a focused mandate and uses
132132
- Subscribe/stream commands must have `durationFlag`
133133
- Subscribe commands with replay must have `rewindFlag`
134134
- History/stats commands must have `timeRangeFlags`
135-
- Commands creating realtime connections or performing mutations (publish, update, delete, append) must have `clientIdFlag`
135+
- Commands that perform writes (subscribe, publish, enter, set, acquire, update, delete, append) must have `clientIdFlag`; read-only queries (get, get-all, history, occupancy get) must NOT have `clientIdFlag`
136136
- Control API commands must use `ControlBaseCommand.globalFlags`
137137
138138
**Method (LSP — for ambiguous cases):**
139139
3. Use `LSP goToDefinition` on flag spread references to confirm they resolve to `src/flags.ts` (not a local redefinition)
140140
141141
**Reasoning guidance:**
142-
- A command that creates a realtime client or performs a mutation (publish, update, delete, append) but doesn't have `clientIdFlag` is a deviation
142+
- A write command (subscribe, publish, enter, set, acquire, update, delete, append) without `clientIdFlag` is a deviation; a read-only query (get, get-all, history, occupancy get) WITH `clientIdFlag` is also a deviation
143143
- A non-subscribe command having `durationFlag` is suspicious but might be valid (e.g., presence enter)
144144
- Control API commands should NOT have `productApiFlags`
145145

.claude/skills/ably-new-command/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static flags = {
137137
- `await this.requireAppId(flags)` — resolves and validates the app ID, returns `Promise<string>` (non-nullable). Calls `this.fail()` internally if no app found — no manual null check needed.
138138
- `await this.runControlCommand(flags, api => api.method(appId))` — creates the Control API client, executes the call, and handles errors in one step. Returns `Promise<T>` (non-nullable). Useful for single API calls; for multi-step flows, use `this.createControlApi(flags)` directly.
139139

140-
**When to include `clientIdFlag`:** Add `...clientIdFlag` whenever the user might want to control which client identity performs the operation. This includes: presence enter/subscribe, spaces members, typing, cursors, publish, and any mutation where permissions may depend on the client (update, delete, annotate). The reason is that users may want to test auth scenarios — e.g., "can client B update client A's message?" — so they need the ability to set their client ID.
140+
**When to include `clientIdFlag`:** Add `...clientIdFlag` to commands where client identity affects the operation: subscribe, publish, enter, set, acquire, update, delete, append, annotate. The reason is that users may want to test auth scenarios — e.g., "can client B update client A's message?" — so they need the ability to set their client ID. Do NOT add to read-only queries (get, get-all, history, occupancy get) — Ably capabilities are operation-based, not clientId-based, so client identity is irrelevant for pure reads.
141141

142142
For history commands, also use `timeRangeFlags`:
143143
```typescript

.claude/skills/ably-new-command/references/patterns.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ async run(): Promise<void> {
253253

254254
## Get Pattern
255255

256-
Get commands perform one-shot queries for current state. They use REST clients and don't need `clientIdFlag`, `durationFlag`, or `rewindFlag`.
256+
Get commands perform one-shot read-only queries for current state. They don't need `clientIdFlag` (Ably capabilities are operation-based, not clientId-based — client identity is irrelevant for reads), `durationFlag`, or `rewindFlag`.
257257

258258
```typescript
259259
static override flags = {

.claude/skills/ably-review/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ For each changed command file, run the relevant checks. Spawn agents for paralle
110110
**Flag architecture check (grep, with LSP for ambiguous cases):**
111111
1. **Grep** for flag spreads (`productApiFlags`, `clientIdFlag`, `durationFlag`, `rewindFlag`, `timeRangeFlags`, `ControlBaseCommand.globalFlags`)
112112
2. Verify correct flag sets per the skill rules
113-
3. Check subscribe commands have `durationFlag`, `rewindFlag`, `clientIdFlag` as appropriate; mutation commands (publish, update, delete, append) should also have `clientIdFlag`
113+
3. Check subscribe commands have `durationFlag`, `rewindFlag`, `clientIdFlag` as appropriate; write commands (publish, enter, set, acquire, update, delete, append) should also have `clientIdFlag`; read-only queries (get, get-all, history, occupancy get) must NOT have `clientIdFlag`
114114
4. For ambiguous cases, use **LSP** `goToDefinition` to confirm flag imports resolve to `src/flags.ts`
115115
116116
**JSON output check (grep/read):**

README.md

Lines changed: 53 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ $ npm install -g @ably/cli
2424
$ ably COMMAND
2525
running command...
2626
$ ably (--version)
27-
@ably/cli/0.17.0 darwin-arm64 node-v25.3.0
27+
@ably/cli/0.17.0 darwin-arm64 node-v24.4.1
2828
$ ably --help [COMMAND]
2929
USAGE
3030
$ ably COMMAND
@@ -204,23 +204,22 @@ $ ably-interactive
204204
* [`ably spaces`](#ably-spaces)
205205
* [`ably spaces create SPACE_NAME`](#ably-spaces-create-space_name)
206206
* [`ably spaces cursors`](#ably-spaces-cursors)
207-
* [`ably spaces cursors get-all SPACE_NAME`](#ably-spaces-cursors-get-all-space_name)
207+
* [`ably spaces cursors get SPACE_NAME`](#ably-spaces-cursors-get-space_name)
208208
* [`ably spaces cursors set SPACE_NAME`](#ably-spaces-cursors-set-space_name)
209209
* [`ably spaces cursors subscribe SPACE_NAME`](#ably-spaces-cursors-subscribe-space_name)
210210
* [`ably spaces get SPACE_NAME`](#ably-spaces-get-space_name)
211211
* [`ably spaces list`](#ably-spaces-list)
212212
* [`ably spaces locations`](#ably-spaces-locations)
213-
* [`ably spaces locations get-all SPACE_NAME`](#ably-spaces-locations-get-all-space_name)
213+
* [`ably spaces locations get SPACE_NAME`](#ably-spaces-locations-get-space_name)
214214
* [`ably spaces locations set SPACE_NAME`](#ably-spaces-locations-set-space_name)
215215
* [`ably spaces locations subscribe SPACE_NAME`](#ably-spaces-locations-subscribe-space_name)
216216
* [`ably spaces locks`](#ably-spaces-locks)
217217
* [`ably spaces locks acquire SPACE_NAME LOCKID`](#ably-spaces-locks-acquire-space_name-lockid)
218-
* [`ably spaces locks get SPACE_NAME LOCKID`](#ably-spaces-locks-get-space_name-lockid)
219-
* [`ably spaces locks get-all SPACE_NAME`](#ably-spaces-locks-get-all-space_name)
218+
* [`ably spaces locks get SPACE_NAME [LOCKID]`](#ably-spaces-locks-get-space_name-lockid)
220219
* [`ably spaces locks subscribe SPACE_NAME`](#ably-spaces-locks-subscribe-space_name)
221220
* [`ably spaces members`](#ably-spaces-members)
222221
* [`ably spaces members enter SPACE_NAME`](#ably-spaces-members-enter-space_name)
223-
* [`ably spaces members get-all SPACE_NAME`](#ably-spaces-members-get-all-space_name)
222+
* [`ably spaces members get SPACE_NAME`](#ably-spaces-members-get-space_name)
224223
* [`ably spaces members subscribe SPACE_NAME`](#ably-spaces-members-subscribe-space_name)
225224
* [`ably spaces occupancy`](#ably-spaces-occupancy)
226225
* [`ably spaces occupancy get SPACE_NAME`](#ably-spaces-occupancy-get-space_name)
@@ -4128,17 +4127,15 @@ Get current occupancy metrics for a room
41284127

41294128
```
41304129
USAGE
4131-
$ ably rooms occupancy get ROOM [-v] [--json | --pretty-json] [--client-id <value>]
4130+
$ ably rooms occupancy get ROOM [-v] [--json | --pretty-json]
41324131
41334132
ARGUMENTS
41344133
ROOM Room to get occupancy for
41354134
41364135
FLAGS
4137-
-v, --verbose Output verbose logs
4138-
--client-id=<value> Overrides any default client ID when using API authentication. Use "none" to explicitly set
4139-
no client ID. Not applicable when using token authentication.
4140-
--json Output in JSON format
4141-
--pretty-json Output in colorized JSON format
4136+
-v, --verbose Output verbose logs
4137+
--json Output in JSON format
4138+
--pretty-json Output in colorized JSON format
41424139
41434140
DESCRIPTION
41444141
Get current occupancy metrics for a room
@@ -4573,41 +4570,39 @@ EXAMPLES
45734570
45744571
$ ably spaces cursors subscribe my-space
45754572
4576-
$ ably spaces cursors get-all my-space
4573+
$ ably spaces cursors get my-space
45774574
```
45784575

45794576
_See code: [src/commands/spaces/cursors/index.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/spaces/cursors/index.ts)_
45804577

4581-
## `ably spaces cursors get-all SPACE_NAME`
4578+
## `ably spaces cursors get SPACE_NAME`
45824579

45834580
Get all current cursors in a space
45844581

45854582
```
45864583
USAGE
4587-
$ ably spaces cursors get-all SPACE_NAME [-v] [--json | --pretty-json] [--client-id <value>]
4584+
$ ably spaces cursors get SPACE_NAME [-v] [--json | --pretty-json]
45884585
45894586
ARGUMENTS
45904587
SPACE_NAME Name of the space to get cursors from
45914588
45924589
FLAGS
4593-
-v, --verbose Output verbose logs
4594-
--client-id=<value> Overrides any default client ID when using API authentication. Use "none" to explicitly set
4595-
no client ID. Not applicable when using token authentication.
4596-
--json Output in JSON format
4597-
--pretty-json Output in colorized JSON format
4590+
-v, --verbose Output verbose logs
4591+
--json Output in JSON format
4592+
--pretty-json Output in colorized JSON format
45984593
45994594
DESCRIPTION
46004595
Get all current cursors in a space
46014596
46024597
EXAMPLES
4603-
$ ably spaces cursors get-all my-space
4598+
$ ably spaces cursors get my-space
46044599
4605-
$ ably spaces cursors get-all my-space --json
4600+
$ ably spaces cursors get my-space --json
46064601
4607-
$ ably spaces cursors get-all my-space --pretty-json
4602+
$ ably spaces cursors get my-space --pretty-json
46084603
```
46094604

4610-
_See code: [src/commands/spaces/cursors/get-all.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/spaces/cursors/get-all.ts)_
4605+
_See code: [src/commands/spaces/cursors/get.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/spaces/cursors/get.ts)_
46114606

46124607
## `ably spaces cursors set SPACE_NAME`
46134608

@@ -4769,41 +4764,39 @@ EXAMPLES
47694764
47704765
$ ably spaces locations subscribe my-space
47714766
4772-
$ ably spaces locations get-all my-space
4767+
$ ably spaces locations get my-space
47734768
```
47744769

47754770
_See code: [src/commands/spaces/locations/index.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/spaces/locations/index.ts)_
47764771

4777-
## `ably spaces locations get-all SPACE_NAME`
4772+
## `ably spaces locations get SPACE_NAME`
47784773

47794774
Get all current locations in a space
47804775

47814776
```
47824777
USAGE
4783-
$ ably spaces locations get-all SPACE_NAME [-v] [--json | --pretty-json] [--client-id <value>]
4778+
$ ably spaces locations get SPACE_NAME [-v] [--json | --pretty-json]
47844779
47854780
ARGUMENTS
47864781
SPACE_NAME Name of the space to get locations from
47874782
47884783
FLAGS
4789-
-v, --verbose Output verbose logs
4790-
--client-id=<value> Overrides any default client ID when using API authentication. Use "none" to explicitly set
4791-
no client ID. Not applicable when using token authentication.
4792-
--json Output in JSON format
4793-
--pretty-json Output in colorized JSON format
4784+
-v, --verbose Output verbose logs
4785+
--json Output in JSON format
4786+
--pretty-json Output in colorized JSON format
47944787
47954788
DESCRIPTION
47964789
Get all current locations in a space
47974790
47984791
EXAMPLES
4799-
$ ably spaces locations get-all my-space
4792+
$ ably spaces locations get my-space
48004793
4801-
$ ably spaces locations get-all my-space --json
4794+
$ ably spaces locations get my-space --json
48024795
4803-
$ ably spaces locations get-all my-space --pretty-json
4796+
$ ably spaces locations get my-space --pretty-json
48044797
```
48054798

4806-
_See code: [src/commands/spaces/locations/get-all.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/spaces/locations/get-all.ts)_
4799+
_See code: [src/commands/spaces/locations/get.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/spaces/locations/get.ts)_
48074800

48084801
## `ably spaces locations set SPACE_NAME`
48094802

@@ -4891,7 +4884,7 @@ EXAMPLES
48914884
48924885
$ ably spaces locks get my-space my-lock-id
48934886
4894-
$ ably spaces locks get-all my-space
4887+
$ ably spaces locks get my-space
48954888
```
48964889

48974890
_See code: [src/commands/spaces/locks/index.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/spaces/locks/index.ts)_
@@ -4931,68 +4924,41 @@ EXAMPLES
49314924

49324925
_See code: [src/commands/spaces/locks/acquire.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/spaces/locks/acquire.ts)_
49334926

4934-
## `ably spaces locks get SPACE_NAME LOCKID`
4927+
## `ably spaces locks get SPACE_NAME [LOCKID]`
49354928

4936-
Get a lock in a space
4929+
Get a lock or all locks in a space
49374930

49384931
```
49394932
USAGE
4940-
$ ably spaces locks get SPACE_NAME LOCKID [-v] [--json | --pretty-json] [--client-id <value>]
4933+
$ ably spaces locks get SPACE_NAME [LOCKID] [-v] [--json | --pretty-json]
49414934
49424935
ARGUMENTS
4943-
SPACE_NAME Name of the space to get lock from
4944-
LOCKID Lock ID to get
4936+
SPACE_NAME Name of the space to get locks from
4937+
LOCKID Lock ID to get (omit to get all locks)
49454938
49464939
FLAGS
4947-
-v, --verbose Output verbose logs
4948-
--client-id=<value> Overrides any default client ID when using API authentication. Use "none" to explicitly set
4949-
no client ID. Not applicable when using token authentication.
4950-
--json Output in JSON format
4951-
--pretty-json Output in colorized JSON format
4940+
-v, --verbose Output verbose logs
4941+
--json Output in JSON format
4942+
--pretty-json Output in colorized JSON format
49524943
49534944
DESCRIPTION
4954-
Get a lock in a space
4945+
Get a lock or all locks in a space
49554946
49564947
EXAMPLES
4957-
$ ably spaces locks get my-space my-lock
4958-
4959-
$ ably spaces locks get my-space my-lock --json
4948+
$ ably spaces locks get my-space
49604949
4961-
$ ably spaces locks get my-space my-lock --pretty-json
4962-
```
4950+
$ ably spaces locks get my-space --json
49634951
4964-
_See code: [src/commands/spaces/locks/get.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/spaces/locks/get.ts)_
4952+
$ ably spaces locks get my-space --pretty-json
49654953
4966-
## `ably spaces locks get-all SPACE_NAME`
4954+
$ ably spaces locks get my-space lock-id
49674955
4968-
Get all current locks in a space
4956+
$ ably spaces locks get my-space lock-id --json
49694957
4958+
$ ably spaces locks get my-space lock-id --pretty-json
49704959
```
4971-
USAGE
4972-
$ ably spaces locks get-all SPACE_NAME [-v] [--json | --pretty-json] [--client-id <value>]
49734960

4974-
ARGUMENTS
4975-
SPACE_NAME Name of the space to get locks from
4976-
4977-
FLAGS
4978-
-v, --verbose Output verbose logs
4979-
--client-id=<value> Overrides any default client ID when using API authentication. Use "none" to explicitly set
4980-
no client ID. Not applicable when using token authentication.
4981-
--json Output in JSON format
4982-
--pretty-json Output in colorized JSON format
4983-
4984-
DESCRIPTION
4985-
Get all current locks in a space
4986-
4987-
EXAMPLES
4988-
$ ably spaces locks get-all my-space
4989-
4990-
$ ably spaces locks get-all my-space --json
4991-
4992-
$ ably spaces locks get-all my-space --pretty-json
4993-
```
4994-
4995-
_See code: [src/commands/spaces/locks/get-all.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/spaces/locks/get-all.ts)_
4961+
_See code: [src/commands/spaces/locks/get.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/spaces/locks/get.ts)_
49964962

49974963
## `ably spaces locks subscribe SPACE_NAME`
49984964

@@ -5044,7 +5010,7 @@ EXAMPLES
50445010
50455011
$ ably spaces members subscribe my-space
50465012
5047-
$ ably spaces members get-all my-space
5013+
$ ably spaces members get my-space
50485014
```
50495015

50505016
_See code: [src/commands/spaces/members/index.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/spaces/members/index.ts)_
@@ -5085,13 +5051,13 @@ EXAMPLES
50855051

50865052
_See code: [src/commands/spaces/members/enter.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/spaces/members/enter.ts)_
50875053

5088-
## `ably spaces members get-all SPACE_NAME`
5054+
## `ably spaces members get SPACE_NAME`
50895055

50905056
Get all members in a space
50915057

50925058
```
50935059
USAGE
5094-
$ ably spaces members get-all SPACE_NAME [-v] [--json | --pretty-json]
5060+
$ ably spaces members get SPACE_NAME [-v] [--json | --pretty-json]
50955061
50965062
ARGUMENTS
50975063
SPACE_NAME Name of the space to get members from
@@ -5105,14 +5071,14 @@ DESCRIPTION
51055071
Get all members in a space
51065072
51075073
EXAMPLES
5108-
$ ably spaces members get-all my-space
5074+
$ ably spaces members get my-space
51095075
5110-
$ ably spaces members get-all my-space --json
5076+
$ ably spaces members get my-space --json
51115077
5112-
$ ably spaces members get-all my-space --pretty-json
5078+
$ ably spaces members get my-space --pretty-json
51135079
```
51145080

5115-
_See code: [src/commands/spaces/members/get-all.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/spaces/members/get-all.ts)_
5081+
_See code: [src/commands/spaces/members/get.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/spaces/members/get.ts)_
51165082

51175083
## `ably spaces members subscribe SPACE_NAME`
51185084

src/base-command.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ const SKIP_AUTH_INFO_COMMANDS = [
108108
export abstract class AblyBaseCommand extends InteractiveBaseCommand {
109109
protected _authInfoShown = false;
110110
protected cleanupInProgress = false;
111+
protected _suppressSdkErrorLogs = false;
111112
private _cachedRestClient: Ably.Rest | null = null;
112113
private _cachedRealtimeClient: Ably.Realtime | null = null;
113114

@@ -934,6 +935,14 @@ export abstract class AblyBaseCommand extends InteractiveBaseCommand {
934935

935936
// Always add a log handler to control SDK output formatting and destination
936937
options.logHandler = (message: string, level: number) => {
938+
// Allow commands to suppress SDK error logs during cleanup. Set by
939+
// SpacesBaseCommand.finally() to silence teardown noise (e.g. the
940+
// Spaces SDK's cursors module queues a presence enter that fails with
941+
// 80017 when the connection closes). Only suppresses error-level logs
942+
// (level <= 1); only active after run() completes — see the comment
943+
// in SpacesBaseCommand.finally() for the full safety rationale.
944+
if (this._suppressSdkErrorLogs && level <= 1) return;
945+
937946
if (isJsonMode) {
938947
// JSON Mode Handling
939948
if (flags.verbose && level <= 2) {

src/commands/rooms/occupancy/get.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Args } from "@oclif/core";
22
import { ChatClient, Room } from "@ably/chat";
33
import { ChatBaseCommand } from "../../../chat-base-command.js";
4-
import { clientIdFlag, productApiFlags } from "../../../flags.js";
4+
import { productApiFlags } from "../../../flags.js";
55
import { formatResource } from "../../../utils/output.js";
66

77
export default class RoomsOccupancyGet extends ChatBaseCommand {
@@ -23,7 +23,6 @@ export default class RoomsOccupancyGet extends ChatBaseCommand {
2323

2424
static override flags = {
2525
...productApiFlags,
26-
...clientIdFlag,
2726
};
2827

2928
private chatClient: ChatClient | null = null;

src/commands/spaces/cursors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ export default class SpacesCursors extends BaseTopicCommand {
1010
static override examples = [
1111
"<%= config.bin %> <%= command.id %> set my-space --x 100 --y 200",
1212
"<%= config.bin %> <%= command.id %> subscribe my-space",
13-
"<%= config.bin %> <%= command.id %> get-all my-space",
13+
"<%= config.bin %> <%= command.id %> get my-space",
1414
];
1515
}

0 commit comments

Comments
 (0)