Skip to content

Commit aef197d

Browse files
authored
Merge pull request #15 from prisma/fix/project-resolution
fix(project): resolution hierarchy
2 parents 720e29a + badae64 commit aef197d

49 files changed

Lines changed: 1580 additions & 2245 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/product/cli-style-guide.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,13 @@ Recommended symbols:
6464
Human-oriented command output in TTY mode should usually start with a compact header:
6565

6666
```text
67-
project linkLinking the current repo to an existing project.
67+
project showShowing the project resolved for this directory.
6868
6969
│ project: Acme Dashboard
7070
│ workspace: Acme Inc
71+
│ source: package-name
7172
72-
│ Read more docs/product/command-spec.md#prisma-cli-project-link-project
73+
│ Read more docs/product/command-spec.md#prisma-cli-project-show
7374
```
7475

7576
Rules:

docs/product/command-principles.md

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,12 @@ Change local CLI context only.
8383

8484
`use` must never mutate a remote resource.
8585

86-
`use` is intentionally different from `link`:
87-
88-
- `use` changes local active context only
89-
- `link` binds local repo context to an existing remote resource
86+
`use` changes local active context only.
9087

9188
Example:
9289

9390
- `branch use production`
9491

95-
### `link`
96-
97-
Connect local repo context to an existing remote resource.
98-
99-
Example:
100-
101-
- `project link`
102-
10392
### `deploy`
10493

10594
Build and release an app into a target branch.

docs/product/command-spec.md

Lines changed: 34 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Out of scope for the current preview:
3939
- Long flags use kebab-case.
4040
- Boolean negation uses `--no-<flag>`.
4141
- `--json` and non-interactive mode must not block on prompts.
42-
- `prisma.config.ts` stores only the linked project id.
42+
- Public Beta does not read or write `prisma.config.ts`, `.prisma/settings.json`, or any repo config file for Project -> Branch -> App resolution.
4343
- Remote commands do not silently change local context.
4444

4545
## Context Resolution
@@ -48,18 +48,23 @@ Out of scope for the current preview:
4848

4949
Commands resolve project context in this order:
5050

51-
1. linked project id in `prisma.config.ts`
52-
2. explicit `project link`
53-
3. implicit creation by `app deploy` when no project is linked
51+
1. explicit `--project <id-or-name>` when present
52+
2. durable platform mapping when available
53+
3. remembered local project context, revalidated against platform data
54+
4. `package.json` name matched exactly against accessible project id, name, or slug
55+
5. unambiguous project creation for commands that are allowed to create projects
56+
6. prompt in interactive mode, or structured failure in `--json` / `--no-interactive` mode
5457

55-
Only `app deploy` may create project context implicitly.
58+
`--project` is an escape hatch for ambiguous or unavailable automatic
59+
resolution, not a setup step. Only `app deploy` may create a missing project,
60+
and only when the inferred name is unambiguous.
5661

5762
### App Selection
5863

5964
Preview app commands that need an app resolve it in this order:
6065

6166
1. `--app <name>`
62-
2. locally selected app for the linked project
67+
2. locally selected app for the resolved project
6368
3. interactive select-or-create flow in TTY mode
6469
4. `USAGE_ERROR` in non-interactive or `--json` mode when unresolved
6570

@@ -107,8 +112,7 @@ In `--json`, `result` uses this shape:
107112
"workspace": {
108113
"id": "ws_123",
109114
"name": "Acme Inc"
110-
},
111-
"linkedProjectId": "proj_123"
115+
}
112116
}
113117
```
114118

@@ -118,7 +122,6 @@ Rules:
118122
- `provider` is `github`, `google`, or `null`
119123
- `user` contains the current user email or is `null`
120124
- `workspace` is the active workspace or `null`
121-
- `linkedProjectId` is the linked project id for the current repo or `null`
122125
- signed-out state is an empty auth state, not an error
123126

124127
## `prisma-cli auth login`
@@ -189,7 +192,8 @@ Behavior:
189192

190193
- requires auth
191194
- lists projects visible to the active workspace
192-
- marks the locally linked project when one is present
195+
- does not resolve the current directory
196+
- does not mutate local state
193197

194198
Examples:
195199

@@ -202,50 +206,35 @@ prisma-cli project list --json
202206

203207
Purpose:
204208

205-
- show the Prisma project linked to this directory
209+
- show the Prisma project resolved for this directory
206210

207211
Behavior:
208212

209-
- reads the linked project id from `prisma.config.ts`
210-
- requires auth when resolving remote project details
211-
- fails with `PROJECT_NOT_LINKED` when no project is linked
213+
- requires auth
214+
- resolves project context without creating projects
215+
- does not prompt for project selection
216+
- does not mutate local state
217+
- `--project <id-or-name>` resolves only the explicit project
218+
- returns Workspace, Project, and `resolution.projectSource`
219+
- fails with `PROJECT_UNRESOLVED`, `PROJECT_NOT_FOUND`, `PROJECT_AMBIGUOUS`, or `LOCAL_STATE_STALE` when resolution cannot continue safely
212220

213221
Examples:
214222

215223
```bash
216224
prisma-cli project show
217225
prisma-cli project show --json
218-
```
219-
220-
## `prisma-cli project link [project]`
221-
222-
Purpose:
223-
224-
- link this directory to a Prisma project
225-
226-
Behavior:
227-
228-
- writes only the project id to `prisma.config.ts`
229-
- prompts for a project when no project id is passed and prompting is allowed
230-
- fails with `USAGE_ERROR` when no project can be selected non-interactively
231-
- does not change active branch context
232-
233-
Examples:
234-
235-
```bash
236-
prisma-cli project link
237-
prisma-cli project link proj_123
226+
prisma-cli project show --project proj_123 --json
238227
```
239228

240229
## `prisma-cli branch list`
241230

242231
Purpose:
243232

244-
- list active Platform branches linked to this project
233+
- list active Platform branches for the resolved project
245234

246235
Behavior:
247236

248-
- shows known remote branches for the linked project
237+
- shows known remote branches for the resolved project
249238
- marks active context
250239
- does not create remote state
251240
- does not expose branch `role` or `durability` fields yet
@@ -266,7 +255,7 @@ Purpose:
266255
Behavior:
267256

268257
- reads local branch context
269-
- shows linked project context when known
258+
- shows resolved project context when known
270259
- does not mutate local or remote state
271260
- does not expose branch `role` or `durability` fields yet
272261

@@ -347,7 +336,7 @@ prisma-cli app deploy --app hello-world --build-type tanstack-start
347336

348337
## `prisma-cli project env`
349338

350-
Manage durable, platform-stored environment variables for the linked
339+
Manage durable, platform-stored environment variables for the resolved
351340
project. Replaces the legacy `prisma app update-env` / `prisma app
352341
list-env` workflow, which mutated env vars on a single Foundry version
353342
and is now deprecated. The `env` namespace operates on the
@@ -373,9 +362,10 @@ Purpose:
373362

374363
Behavior:
375364

376-
- requires auth and a linked project
365+
- requires auth and a resolved project; accepts `--project <id-or-name>` as an explicit fallback
377366
- KEY=VALUE is parsed from a single positional; KEY must match
378367
`[A-Z_][A-Z0-9_]*`
368+
- KEY without `=VALUE` reads the value from the current process environment
379369
- if a variable with the same key already exists in the scope, the
380370
command fails with a clear error directing to `env update`
381371
- the response carries metadata only — the value is never echoed back
@@ -385,6 +375,7 @@ Examples:
385375
```bash
386376
prisma-cli project env add STRIPE_KEY=sk_test_xxx --role production
387377
prisma-cli project env add STRIPE_KEY=sk_test_xxx --role preview
378+
API_URL=https://api.example prisma-cli project env add API_URL --project proj_123 --role preview
388379
```
389380

390381
### `prisma-cli project env update KEY=VALUE --role <production|preview>`
@@ -396,9 +387,10 @@ Purpose:
396387

397388
Behavior:
398389

399-
- requires auth and a linked project
390+
- requires auth and a resolved project; accepts `--project <id-or-name>` as an explicit fallback
400391
- KEY=VALUE is parsed from a single positional; KEY must match
401392
`[A-Z_][A-Z0-9_]*`
393+
- KEY without `=VALUE` reads the value from the current process environment
402394
- if no variable with the key exists in the scope, the command fails
403395
with a clear error directing to `env add`
404396
- the response carries metadata only — the value is never echoed back
@@ -418,7 +410,7 @@ Purpose:
418410

419411
Behavior:
420412

421-
- requires auth and a linked project
413+
- requires auth and a resolved project; accepts `--project <id-or-name>` as an explicit fallback
422414
- defaults to `--role production` when `--role` is not supplied
423415
- never prints values (never-reveal)
424416
- emits `key`, `id`, `last updated`, and a `scope` annotation per row
@@ -438,7 +430,7 @@ Purpose:
438430

439431
Behavior:
440432

441-
- requires auth and a linked project
433+
- requires auth and a resolved project; accepts `--project <id-or-name>` as an explicit fallback
442434
- looks the variable up by natural key in the scope and `DELETE`s it
443435
- returns a focused error when no matching variable exists
444436

docs/product/error-conventions.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,10 @@ These codes are the minimum stable set for the MVP:
147147

148148
- `USAGE_ERROR`
149149
- `AUTH_REQUIRED`
150-
- `PROJECT_NOT_LINKED`
150+
- `PROJECT_UNRESOLVED`
151151
- `PROJECT_NOT_FOUND`
152+
- `PROJECT_AMBIGUOUS`
153+
- `LOCAL_STATE_STALE`
152154
- `BRANCH_NOT_DEPLOYABLE`
153155
- `DEPLOYMENT_NOT_FOUND`
154156
- `NO_DEPLOYMENTS`
@@ -166,8 +168,10 @@ Recommended meanings:
166168

167169
- `USAGE_ERROR`: invalid arguments or invalid command combination
168170
- `AUTH_REQUIRED`: command needs an authenticated session
169-
- `PROJECT_NOT_LINKED`: command needs project context and none is linked
171+
- `PROJECT_UNRESOLVED`: command needs project context and none could be resolved
170172
- `PROJECT_NOT_FOUND`: requested project does not exist or is not accessible
173+
- `PROJECT_AMBIGUOUS`: multiple safe project candidates matched
174+
- `LOCAL_STATE_STALE`: remembered local project context no longer matches platform data and continuing would be ambiguous
171175
- `BRANCH_NOT_DEPLOYABLE`: command tried to deploy to a non-deployable branch context
172176
- `DEPLOYMENT_NOT_FOUND`: requested deployment id does not exist
173177
- `NO_DEPLOYMENTS`: command resolved a branch or app but found no deployments

docs/product/output-conventions.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ Current MVP commands map to patterns like this:
6767
| `auth whoami` | `show` |
6868
| `project list` | `list` |
6969
| `project show` | `show` |
70-
| `project link` | `mutate` |
7170
| `branch list` | `list` |
7271
| `branch show` | `show` |
7372
| `branch use` | `mutate` |
@@ -99,7 +98,6 @@ Rules:
9998
- each list row uses `` and repeats the same item noun
10099
- annotations are limited to one per row and use:
101100
- `(active)` for current context
102-
- `(linked)` for the current local repo binding
103101
- `(default)` when the command defines a default item
104102
- human output prefers display labels over opaque ids
105103
- empty lists render a single dim sentence in the item area such as `No projects found.`
@@ -122,7 +120,7 @@ In `--json`, all list commands use this result shape:
122120
}
123121
```
124122

125-
`status` may be `"active"`, `"linked"`, or `null`.
123+
`status` may be `"active"`, `"default"`, or `null`.
126124

127125
#### `show`
128126

@@ -219,12 +217,13 @@ Human output should:
219217
Recommended header shape:
220218

221219
```text
222-
project linkLinking the current repo to an existing project.
220+
project showShowing the project resolved for this directory.
223221
224222
│ project: Acme Dashboard
225223
│ workspace: Acme Inc
224+
│ source: package-name
226225
227-
│ Read more docs/product/command-spec.md#prisma-cli-project-link-project
226+
│ Read more docs/product/command-spec.md#prisma-cli-project-show
228227
```
229228

230229
Rules:
@@ -238,7 +237,7 @@ Rules:
238237
Recommended summary lines:
239238

240239
```text
241-
✔ Project linked
240+
✔ Project resolved
242241
✘ Authentication required [AUTH_REQUIRED]
243242
```
244243

docs/product/resource-model.md

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,16 @@ Preview relevance:
3131

3232
### Project
3333

34-
`project` is the remote Prisma resource linked to a local repo.
34+
`project` is the remote Prisma resource resolved for local work.
3535

3636
Rules:
3737

3838
- `project` is not the same thing as `app`
39-
- `prisma.config.ts` stores only the linked project id
40-
- `app deploy` may create project context when none is linked
39+
- Public Beta does not read or write `prisma.config.ts`, `.prisma/settings.json`, or any repo config file for project resolution
40+
- `app deploy` may create missing project context only when resolution is unambiguous
4141
- other commands must not create project context implicitly
4242
- everything under a project happens in a branch
4343

44-
Example config:
45-
46-
```ts
47-
export default {
48-
project: "proj_123",
49-
};
50-
```
51-
5244
### Branch
5345

5446
`branch` is the named project-scoped isolation boundary for app and database
@@ -107,7 +99,7 @@ accidental destructive actions.
10799
Rules:
108100

109101
- `app` is not the same thing as `project`
110-
- the app belongs to the linked project
102+
- the app belongs to the resolved project
111103
- app work is scoped by branch in the platform model
112104
- the app may be selected or created as part of app deployment workflows
113105
- app selection is local CLI state when needed for the preview package
@@ -187,26 +179,31 @@ Long-term, branch is where app and database relationships meet.
187179
- `local` is CLI context, not a branch or deploy target
188180
- `production` is protected and durable
189181
- every other named branch is preview by default
190-
- `prisma.config.ts` stores only the linked project id
182+
- Public Beta does not use repo config files for Project -> Branch -> App resolution
191183

192184
## Resolution Rules
193185

194186
### Project Resolution
195187

196188
Commands resolve project context in this order:
197189

198-
1. linked project id in `prisma.config.ts`
199-
2. explicit `project link`
200-
3. implicit creation by `app deploy` when no project is linked
190+
1. explicit `--project <id-or-name>` when present
191+
2. durable platform mapping when available
192+
3. remembered local project context, revalidated against platform data
193+
4. `package.json` name matched exactly against accessible project id, name, or slug
194+
5. unambiguous project creation for commands that are allowed to create projects
195+
6. prompt in interactive mode, or structured failure in `--json` / `--no-interactive` mode
201196

202-
Only `app deploy` may create projects implicitly.
197+
Remembered local project context is an internal convenience after successful
198+
resolution. It must be revalidated before use and must not be described to users
199+
as durable linking. Only `app deploy` may create projects implicitly.
203200

204201
### App Selection Resolution
205202

206203
Preview app commands that need an app resolve it in this order:
207204

208205
1. explicit `--app <name>`
209-
2. locally selected app for the linked project
206+
2. locally selected app for the resolved project
210207
3. interactive selection or creation in a TTY
211208
4. structured usage error when no app can be resolved non-interactively
212209

@@ -229,7 +226,7 @@ Consequences:
229226
Commands that inspect deployments resolve in this order:
230227

231228
1. exact deployment id if the command accepts one
232-
2. selected app for the linked project
229+
2. selected app for the resolved project
233230
3. latest known live deployment for that app
234231

235232
### Promote Resolution

0 commit comments

Comments
 (0)