Skip to content

Commit 0f63bb6

Browse files
feat(cli): add shared workspace profiles
1 parent 45006ab commit 0f63bb6

15 files changed

Lines changed: 854 additions & 60 deletions

File tree

apps/docs/content/docs/en/cli/authentication.mdx

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,20 @@ sim workflows list --workspace ws_other
5353
`sim login --workspace <id>` preselects a workspace in the picker, and
5454
re-logging into an existing profile preselects the one already configured.
5555

56+
To save another workspace without minting or copying another personal key, add
57+
a workspace profile:
58+
59+
```bash
60+
sim workspaces list
61+
sim profile add acme --workspace ws_acme
62+
sim --profile acme whoami
63+
```
64+
65+
The new profile stores `auth_profile = default` and its own workspace. Omit
66+
`--workspace` in an interactive terminal to choose from the workspaces the
67+
active key can access; scripts must provide the workspace ID explicitly. The
68+
picker is capped at 1,000 entries and asks for an explicit ID above that.
69+
5670
## Checking who you are
5771

5872
```bash
@@ -76,6 +90,12 @@ sim logout # remove the stored key
7690
sim logout --all # remove the profile entirely, including its settings
7791
```
7892

93+
A workspace profile that shares authentication cannot remove the shared key.
94+
Remove only that local profile with `sim logout --all --profile <name>`, or log
95+
out of the authentication profile named by the error message. Removing an
96+
authentication profile entirely is refused until its workspace profiles are
97+
removed, so it cannot leave dangling references.
98+
7999
<Callout type="warn">
80100
`sim logout` removes the key from disk but does **not** revoke it. Revoke keys in
81101
Sim under **Settings → API keys**.
@@ -116,9 +136,9 @@ jobs:
116136
SIM_WORKSPACE: ${{ vars.SIM_WORKSPACE }}
117137
```
118138
119-
## Several accounts at once
139+
## Several accounts and workspaces
120140
121-
Each profile holds one identity and one set of defaults:
141+
Use separate logins for separate identities or deployments:
122142
123143
```bash
124144
sim login --profile dev --endpoint http://localhost:3000
@@ -128,6 +148,16 @@ sim workflows list --profile dev
128148
sim workflows list --profile prod
129149
```
130150

151+
Use workspace profiles when one personal key should target several workspaces:
152+
153+
```bash
154+
sim profile add marketing --workspace ws_marketing
155+
sim profile add support --workspace ws_support
156+
157+
sim workflows list --profile marketing
158+
sim workflows list --profile support
159+
```
160+
131161
See [Configuration](/cli/configuration) for how profiles are stored and resolved.
132162

133163
## Self-hosted and non-production deployments

apps/docs/content/docs/en/cli/commands.mdx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ These apply to every command, and may be written before or after it.
3030

3131
| Group | Description |
3232
| --- | --- |
33+
| [`sim profiles`](/cli/profiles) | List profiles or add a workspace profile that shares a stored login |
3334
| [`sim audit-logs`](/cli/audit-logs) | Manage audit logs |
3435
| [`sim billing`](/cli/billing) | Manage billing |
3536
| [`sim credentials`](/cli/credentials) | Manage credentials |
@@ -94,14 +95,6 @@ sim whoami [options]
9495

9596
</CommandTable>
9697

97-
## List the profiles defined in the config and credentials files
98-
99-
```bash
100-
sim profiles
101-
```
102-
103-
Also available as `sim profile`.
104-
10598
## Set a profile's endpoint, default workspace, or output format
10699

107100
```bash

apps/docs/content/docs/en/cli/configuration.mdx

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ for a single command.
99

1010
## Profiles
1111

12-
A profile is one identity plus one set of defaults, in the style of the AWS CLI.
13-
Select one with `-P`, `--profile`, or `SIM_PROFILE`:
12+
A profile selects one set of defaults, in the style of the AWS CLI. It normally
13+
uses its same-named stored identity, but a workspace profile can share another
14+
profile's identity through `auth_profile`. Select one with `-P`, `--profile`, or
15+
`SIM_PROFILE`:
1416

1517
```bash
1618
sim workflows list --profile dev
@@ -23,6 +25,12 @@ The profile is named `default` when you do not pick one.
2325
sim profiles # list them; * marks the active one
2426
```
2527

28+
Add a profile for another workspace without creating or copying an API key:
29+
30+
```bash
31+
sim profile add acme --workspace ws_acme
32+
```
33+
2634
## Setting defaults
2735

2836
```bash
@@ -51,7 +59,7 @@ Each setting resolves independently, and the first match wins:
5159
| --- | --- |
5260
| 1 | Command-line flag — `--endpoint`, `--workspace`, `--output` |
5361
| 2 | Environment — `SIM_ENDPOINT`, `SIM_API_KEY`, `SIM_WORKSPACE`, `SIM_OUTPUT` |
54-
| 3 | `~/.sim/config` and `~/.sim/credentials`, for the selected profile |
62+
| 3 | `~/.sim/config` for the selected profile and `~/.sim/credentials` for its `auth_profile`, when set |
5563
| 4 | Built-in default — `https://www.sim.ai` and `table` |
5664

5765
`sim whoami` prints the winning source for each setting:
@@ -74,6 +82,10 @@ output = table
7482
[profile dev]
7583
endpoint = http://localhost:3000
7684
workspace = ws_local
85+
86+
[profile acme]
87+
auth_profile = default
88+
workspace = ws_acme
7789
```
7890

7991
Keys live in `~/.sim/credentials`, written `0600`:
@@ -89,6 +101,10 @@ api_key = sim_…
89101
Section naming follows the AWS convention: `[profile dev]` in config, `[dev]` in
90102
credentials. The `default` profile is `[default]` in both.
91103

104+
`auth_profile` references one direct profile and shares only its endpoint and
105+
API key; workspace and output remain local. References cannot be chained, and a
106+
shared profile cannot also set its own endpoint or API key.
107+
92108
## Environment variables
93109

94110
| Variable | Effect |
@@ -121,6 +137,19 @@ sim configure --set-workspace ws_abc123
121137
export SIM_WORKSPACE=ws_abc123
122138
```
123139

140+
For a reusable selection, create a workspace profile backed by the current
141+
stored login:
142+
143+
```bash
144+
sim workspaces list
145+
sim profile add acme --workspace ws_acme
146+
sim --profile acme tables list
147+
```
148+
149+
When `--workspace` is omitted in a terminal, `profile add` presents an
150+
interactive picker, capped at 1,000 entries. It refuses environment-only keys
151+
and endpoint overrides because those values would disappear in another shell.
152+
124153
`sim billing status`, `sim billing logs`, and `sim audit-logs list` accept
125154
`--all-workspaces` to drop the filter instead. It cannot be combined with
126155
`--workspace`.

apps/docs/content/docs/en/cli/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"troubleshooting",
1212
"---Commands---",
1313
"commands",
14+
"profiles",
1415
"audit-logs",
1516
"billing",
1617
"credentials",
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: Profiles
3+
description: List profiles or add a workspace profile that shares a stored login — every subcommand, argument, and flag
4+
---
5+
6+
import { CommandTable } from '@/components/ui/command-table'
7+
8+
`sim profiles` is also spelled `sim profile`.
9+
10+
Every command below also accepts the [global options](/cli/commands#global-options).
11+
12+
## List configured profiles
13+
14+
```bash
15+
sim profiles list
16+
```
17+
18+
## Add a workspace profile that shares the active stored login
19+
20+
```bash
21+
sim profiles add <name> [options]
22+
```
23+
24+
**Arguments**
25+
26+
<CommandTable>
27+
28+
| Argument | Required | Description |
29+
| --- | --- | --- |
30+
| `name` | Yes | Name for the new profile |
31+
32+
</CommandTable>
33+
34+
**Options**
35+
36+
<CommandTable>
37+
38+
| Option | Required | Description |
39+
| --- | --- | --- |
40+
| `-w, --workspace <id>` | No | Existing workspace to use; omit for an interactive picker. |
41+
42+
</CommandTable>

apps/docs/content/docs/en/cli/reference.mdx

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,6 @@ sim whoami [options]
8080

8181
</CommandTable>
8282

83-
## sim profiles
84-
85-
List the profiles defined in the config and credentials files
86-
87-
```bash
88-
sim profiles
89-
```
90-
91-
Also available as `sim profile`.
92-
9383
## sim configure
9484

9585
Set a profile's endpoint, default workspace, or output format
@@ -111,6 +101,46 @@ sim configure [options]
111101

112102
</CommandTable>
113103

104+
## sim profiles
105+
106+
Also spelled `sim profile`.
107+
108+
### sim profiles list
109+
110+
List configured profiles
111+
112+
```bash
113+
sim profiles list
114+
```
115+
116+
### sim profiles add
117+
118+
Add a workspace profile that shares the active stored login
119+
120+
```bash
121+
sim profiles add <name> [options]
122+
```
123+
124+
**Arguments**
125+
126+
<CommandTable>
127+
128+
| Argument | Required | Description |
129+
| --- | --- | --- |
130+
| `name` | Yes | Name for the new profile |
131+
132+
</CommandTable>
133+
134+
**Options**
135+
136+
<CommandTable>
137+
138+
| Option | Required | Description |
139+
| --- | --- | --- |
140+
| `-w, --workspace <id>` | No | Existing workspace to use; omit for an interactive picker. |
141+
142+
</CommandTable>
143+
114144
## sim audit-logs
115145

116146
Also spelled `sim audit-log`.

packages/sim-cli/README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Full documentation: **https://docs.sim.ai/cli**
1212

1313
## Profiles
1414

15-
Profiles work like the AWS CLI: one identity and one set of defaults per named
16-
profile, selected with `-P`, `--profile`, or `SIM_PROFILE`. This is what lets you keep
17-
production and a local dev stack side by side without re-authenticating.
15+
Profiles work like the AWS CLI and are selected with `-P`, `--profile`, or
16+
`SIM_PROFILE`. A profile normally owns one identity and one set of defaults; a
17+
workspace profile can instead share a stored identity through `auth_profile`.
1818

1919
Non-secret settings live in `~/.sim/config`:
2020

@@ -27,6 +27,10 @@ output = table
2727
[profile dev]
2828
endpoint = http://localhost:3000
2929
workspace = ws_local
30+
31+
[profile acme]
32+
auth_profile = default
33+
workspace = ws_acme
3034
```
3135

3236
Keys live in `~/.sim/credentials`, written `0600`:
@@ -45,7 +49,8 @@ The section-naming asymmetry — `[profile dev]` in config, `[dev]` in credentia
4549
```bash
4650
sim configure --set-endpoint http://localhost:3000 --profile dev
4751
sim configure --set-workspace ws_local --profile dev
48-
sim profiles # list them; * marks the active one
52+
sim profiles # list them; * marks the active one
53+
sim profile add acme --workspace ws_acme # share the active stored login
4954
sim whoami # resolved values, where each came from, and whether they work
5055
```
5156

@@ -62,7 +67,7 @@ Each setting resolves independently, first match wins:
6267
indefinitely) and `SIM_DEBUG=1` traces requests to stderr. Node ignores
6368
`HTTPS_PROXY` unless `NODE_USE_ENV_PROXY=1` is also set, on Node 22.21+ or
6469
24.5+; the CLI warns when a proxy is configured but will not be used.
65-
| 3 | `~/.sim/config` / `~/.sim/credentials` for the selected profile |
70+
| 3 | `~/.sim/config` for the selected profile and credentials for its `auth_profile`, when set |
6671
| 4 | Built-in default (`https://www.sim.ai`, `table`) |
6772

6873
Formats are listed under [Output formats](#output-formats).
@@ -112,8 +117,11 @@ the key can access.
112117
`sim login --workspace <id>` preselects a workspace in the picker, and an
113118
existing profile's workspace preselects itself on re-login.
114119

115-
`sim logout` removes the stored key. It does not revoke it — do that in
116-
Settings → API keys.
120+
`sim logout` removes the stored key. A shared workspace profile cannot remove
121+
its authentication profile's key; use `sim logout --all --profile <name>` to
122+
remove only the workspace profile. An authentication profile cannot be removed
123+
entirely while workspace profiles reference it. Logging out does not revoke a
124+
key — do that in Settings → API keys.
117125

118126
## Commands
119127

@@ -147,6 +155,7 @@ sim logs get <runId>
147155
sim audit-logs list --organization <organizationId> [--all-workspaces]
148156
sim audit-logs get <id> --organization <organizationId>
149157

158+
sim workspaces list
150159
sim workspaces get
151160
sim workspaces members
152161

0 commit comments

Comments
 (0)