@sequenceholdings/studio-cli 0.6.1 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +186 -21
  2. package/dist/app/commands.d.ts +1 -1
  3. package/dist/app/commands.js +11 -6
  4. package/dist/app/deploy.js +4 -3
  5. package/dist/app/env-bindings.d.ts +3 -4
  6. package/dist/app/env-bindings.js +14 -77
  7. package/dist/app/readme.js +2 -2
  8. package/dist/app/repository-admission.d.ts +5 -0
  9. package/dist/app/repository-admission.js +32 -0
  10. package/dist/app/scaffold-files.js +8 -1
  11. package/dist/artifact/delegate.d.ts +4 -0
  12. package/dist/artifact/delegate.js +18 -8
  13. package/dist/artifact/sandbox.d.ts +29 -0
  14. package/dist/artifact/sandbox.js +109 -0
  15. package/dist/atlas-client.d.ts +1 -0
  16. package/dist/atlas-client.js +11 -2
  17. package/dist/auth-cmds/commands.js +3 -0
  18. package/dist/command-contract.d.ts +8 -2
  19. package/dist/command-contract.js +3 -2
  20. package/dist/command-help.d.ts +7 -4
  21. package/dist/command-help.js +43 -3
  22. package/dist/env-flags.d.ts +6 -0
  23. package/dist/env-flags.js +23 -1
  24. package/dist/envs/commands.js +30 -4
  25. package/dist/feedback/commands.d.ts +3 -0
  26. package/dist/feedback/commands.js +108 -0
  27. package/dist/main.d.ts +1 -0
  28. package/dist/main.js +14 -16
  29. package/dist/orm/delegate.js +30 -11
  30. package/dist/orm/discover-schema.d.ts +196 -0
  31. package/dist/orm/discover-schema.js +84 -0
  32. package/dist/orm/discover.d.ts +13 -0
  33. package/dist/orm/discover.js +289 -0
  34. package/dist/pipeline/lifecycle.js +2 -1
  35. package/dist/pipeline/repin-orm.js +8 -1
  36. package/dist/pipeline/source.js +3 -0
  37. package/dist/repos/commands.js +9 -0
  38. package/dist/repos/identity-file.d.ts +17 -0
  39. package/dist/repos/identity-file.js +39 -0
  40. package/dist/repos/identity.d.ts +2 -0
  41. package/dist/repos/identity.js +69 -0
  42. package/dist/sandbox-auth.d.ts +11 -0
  43. package/dist/sandbox-auth.js +22 -0
  44. package/dist/update-check.d.ts +3 -1
  45. package/dist/update-check.js +38 -12
  46. package/package.json +3 -3
package/README.md CHANGED
@@ -141,6 +141,8 @@ a file and exports two variables:
141
141
  export SEQ_STUDIO_BASE_URL=https://<your-atlas-origin>
142
142
  export SEQ_STUDIO_TOKEN_FILE=/run/seq/token
143
143
  seq-studio auth whoami # authMode: sandbox
144
+ seq-studio orm namespaces # what data can I read?
145
+ seq-studio orm describe lending loans # columns, types, actions
144
146
  seq-studio orm read lending loans --limit 5 --json
145
147
  ```
146
148
 
@@ -161,9 +163,29 @@ git config --global credential."$SEQ_STUDIO_BASE_URL".useHttpPath true
161
163
  ```
162
164
 
163
165
  Repository sources for `--repo` builds are materialized through the JSON API,
164
- like other headless callers; public `--git-url` sources are refused. Artifact
165
- commands are not available in sandbox token mode: like `--token`, Artifact Studio
166
- accepts only credentials the CLI obtained itself.
166
+ like other headless callers; public `--git-url` sources are refused.
167
+
168
+ Artifact Studio apps deploy from a Git Service repository. The sandbox has no
169
+ package registry, so nothing is installed or built from a local directory:
170
+
171
+ ```bash
172
+ seq-studio repos create acme/portal
173
+ seq-studio repos clone acme/portal # clones into ./portal
174
+ cd portal
175
+ seq-studio artifact init . # keep dependencies and optionalDependencies empty
176
+ git add -A && git commit -m "Portal" && git push
177
+ seq-studio artifact deploy --repo acme/portal
178
+ ```
179
+
180
+ Atlas builds Next.js applications from the pushed commit. A static (React/Vite)
181
+ application is bundled in the sandbox against the CLI's pinned platform
182
+ packages, so its `package.json` must have no entries in `dependencies` or
183
+ `optionalDependencies`; one that does is refused rather than installed. Atlas
184
+ needs a committed `pnpm-lock.yaml` for a Next.js build, which a sandbox cannot
185
+ generate, so start new sandbox apps from the default static template. `build`, `plan` and `deploy` require `--repo`;
186
+ `dev`, `login`, `logout`, `--git-url`, `--source-env`, `--pr` and `--env-url`
187
+ are unavailable, and `--token` is refused as everywhere else. List, show,
188
+ status, whoami, pull, link, promote and rollback work as usual.
167
189
 
168
190
  ## Environments
169
191
 
@@ -390,13 +412,15 @@ primitives:
390
412
 
391
413
  Every primitive appears in the graph, including agents, pipelines and
392
414
  workspaces. `seq-studio deploy` and `seq-studio artifact deploy` resolve these
393
- names in the selected environment and refuse the deployment when source still
394
- points at another environment. An artifact's `targets.<environment>.url` is
395
- that environment's API origin. The `targets` map may list every environment.
396
- Application source may contain only the origin selected by `-e`. A `uses` edge
397
- to a workspace resolves that workspace by name in the selected environment. A
398
- workspace UUID in source must be one that exists there; an ID from another
399
- environment fails the deployment. `uses` needs schema version 2 or later.
415
+ names in the selected environment and validate explicit manifest bindings.
416
+ An artifact's selected `targets.<environment>.url` must match that environment's
417
+ API origin; the `targets` map may list every environment. A `uses` edge to a
418
+ workspace resolves its name in the selected environment (`uses` needs schema
419
+ version 2 or later). Workspace IDs declared in `artifact.bundle.yml` under
420
+ `capabilities.storage` or `server.capabilities.storage` must exist there.
421
+ Source files, shared packages, arbitrary config keys, and environment-variable
422
+ values are not scanned for URLs or UUIDs. Repository tenant identity admission,
423
+ manifest validation, deployment permissions, and runtime authorization still apply.
400
424
 
401
425
  After changing an ORM schema, run
402
426
  `seq-studio orm generate <namespace-path>` followed by
@@ -405,10 +429,12 @@ ledger. `init` authors the baseline for its initial namespace (unless
405
429
  `--skip-install`); namespaces added later still need this workflow. A namespace without migrations fails deployment
406
430
  preflight with instructions to run `orm diff`.
407
431
 
408
- Before any deployment, versions 2 and 3 validate and compile the selected sources.
409
- `--dry-run` performs this preflight without deploying. Pipeline preflight reads
410
- the remote repository, validates its source, and pins the resolved commit, so a
411
- pipeline dry run needs network access and authentication. Other local primitive
432
+ Before any deployment, all versions check the repository's adopted identity and
433
+ committed receipt against the selected server. Versions 2 and 3 then validate and
434
+ compile the selected sources. `--dry-run` performs this preflight without deploying;
435
+ it still needs network access and an existing authenticated session for identity
436
+ admission and never opens a login browser. Pipeline preflight additionally reads
437
+ the remote repository, validates its source, and pins the resolved commit. Local primitive
412
438
  checks do not deploy resources. Official artifact deployments require the full app
413
439
  checkout to be clean on `main`, including shared packages and the app manifest;
414
440
  local deployments retain the local development path.
@@ -822,6 +848,8 @@ compiled to canonical SQL before registration.
822
848
  | `seq-studio orm diff [dir] [--check]` | Author the next committed migration, or verify the migration/snapshot chain offline for CI. |
823
849
  | `seq-studio orm apply [dir] -e <env>` | Author a migration if needed, register/apply the namespace, activate its operation set, publish roles/capabilities, and refresh generated outputs. |
824
850
  | `seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>` | Execute one named persisted operation from `operations.manifest.json` with variables from a JSON object file, as the signed-in caller. |
851
+ | `seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]` | List the namespaces you can read. |
852
+ | `seq-studio orm describe <namespace> [<table>] -e <env> [--json]` | Show a namespace's tables, views, and persisted operations, or one table's columns, actions, and the operations that write it. |
825
853
  | `seq-studio orm read <namespace> <table> -e <env> [--where …] [--select …] [--order …] [--limit N] [--offset N] [--json\|--jsonl]` | Read rows of a deployed v2 namespace's table as the caller. |
826
854
  | `seq-studio orm sql <namespace> --query <sql> \| --file <path> -e <env> [--param …] [--json\|--jsonl]` | Run read-only SQL against a deployed v2 namespace as the caller. |
827
855
  | `seq-studio orm migrate-from-yaml <dir>` | Convert a legacy YAML namespace to TypeScript authoring while preserving its committed migrations. |
@@ -862,6 +890,33 @@ starting another rehearsal.
862
890
  > depends on `@sequenceholdings/orm@^2.0.0`; use the matching published major
863
891
  > version and keep generated manifests and migrations committed with source.
864
892
 
893
+ ### Discovering data (`orm namespaces`, `orm describe`)
894
+
895
+ Find what you can read before you query it. Both commands run as you and are
896
+ read-only.
897
+
898
+ ```bash
899
+ seq-studio orm namespaces -e <env> # NAMESPACE FORMAT TABLES OPERATIONS DESCRIPTION
900
+ seq-studio orm namespaces -e <env> --limit 20 --offset 20 --json
901
+ seq-studio orm describe lending -e <env> # tables, views, persisted operations
902
+ seq-studio orm describe lending loans -e <env> # columns, enum values, links, actions
903
+ ```
904
+
905
+ - `namespaces` lists only namespaces you can read, ordered by name, with their
906
+ format (`v2`, `v1`, or `not applied`), table count, and persisted-operation count.
907
+ It pages with `--limit` (default 50) and `--offset`; the total and the next
908
+ page go to stderr. `--json` prints the page as the server returns it, with
909
+ `total`, `limit`, and `offset`.
910
+ - `describe <namespace>` lists the active version's tables and views, and the
911
+ persisted operations it serves with the capability or role each requires.
912
+ `describe <namespace> <table>` lists the table's columns (type, nullability,
913
+ primary key or unique), the values of its enums, its links and actions, and
914
+ the persisted operations that write it. The column names are the ones `read`
915
+ and `sql` accept.
916
+ - A namespace you cannot read reports not found, the same as one that does not
917
+ exist. `--json` prints the full description, including read and write
918
+ policies, but not the generated GraphQL SDL.
919
+
865
920
  ### Ad-hoc reads (`orm read`, `orm sql`)
866
921
 
867
922
  `read` and `sql` query a deployed ORM v2 namespace without authoring an
@@ -1483,10 +1538,11 @@ successfully. Help does not initialize files, authenticate, or deploy.
1483
1538
 
1484
1539
  Artifact commands reject unknown options before authentication or network
1485
1540
  access, so a misspelled flag cannot be silently ignored. `seq-studio artifact
1486
- deploy` also refuses source that still points at another environment's API
1487
- origin or workspace UUID. Declare each environment's API origin under
1488
- `targets.<environment>.url`. A workspace UUID in source must exist in the
1489
- environment selected by `-e`.
1541
+ deploy` validates explicit manifest bindings: the selected
1542
+ `targets.<environment>.url` must match `-e`, and workspace IDs in
1543
+ `capabilities.storage` and `server.capabilities.storage` must exist in that
1544
+ environment. It does not infer bindings from source text or arbitrary config
1545
+ values. This does not relax repository identity or runtime access checks.
1490
1546
 
1491
1547
  `pull` writes the **active deployment's** source files (default out dir:
1492
1548
  `./<project-id>`) and errors when the project has no active deployment.
@@ -1796,6 +1852,87 @@ a human identity or extend a human login's expiry.
1796
1852
  Add `--help` to a repo command to read its usage offline, without an
1797
1853
  environment or credentials.
1798
1854
 
1855
+ ### Repository identity
1856
+
1857
+ New repositories created on identity-capable Atlas releases contain a committed
1858
+ `.seq/identity.json` next to their starter README. `repos clone` retains it;
1859
+ `seq-studio init .` preserves it byte-for-byte, including additional metadata.
1860
+
1861
+ ```json
1862
+ {
1863
+ "schemaVersion": 1,
1864
+ "identity": {
1865
+ "tenantId": "example",
1866
+ "repositoryId": "00000000-0000-4000-8000-000000000001",
1867
+ "generation": 1
1868
+ },
1869
+ "metadata": {}
1870
+ }
1871
+ ```
1872
+
1873
+ The platform owns `identity`. Tenant ownership comes from the hosting
1874
+ deployment, not the creator's organization, repository name, remote URL, or
1875
+ editable file. Renaming a repository does not change its ID. Staging and
1876
+ production share a tenant; this file intentionally does not select an environment.
1877
+ Separate hosted repositories still have distinct IDs: copying this file does
1878
+ not register a mirror or authorize promotion.
1879
+
1880
+ `metadata` is an extensible JSON object for non-secret annotations (for example,
1881
+ `{"example.com": {"team": "engineering"}}`). Prefer namespaced keys for tools.
1882
+ It is never an authorization or deployment-routing input. The whole file is
1883
+ limited to 64 KiB and 32 levels; unknown schema versions and identity fields are
1884
+ rejected. The file is editable, not a cryptographic attestation of its source.
1885
+ Do not add credentials or attempt to transfer ownership by editing it.
1886
+
1887
+ ```bash
1888
+ # Inspect the platform-held identity (read-only; JSON output).
1889
+ seq-studio repos identity apps/example -e <env>
1890
+ # Restore a missing receipt in the matching clone; existing metadata is retained.
1891
+ seq-studio repos identity apps/example -e <env> --write --dir .
1892
+ # Explicit legacy backfill, only for a repository administrator:
1893
+ seq-studio repos identity apps/example -e <env> --adopt --write --yes --dir .
1894
+ git add .seq/identity.json
1895
+ git commit -m "Record repository identity"
1896
+ # Push a review branch and open a pull request using your normal workflow.
1897
+ ```
1898
+
1899
+ Backfill binds an unadopted repository to its hosting tenant once, then writes the
1900
+ receipt locally. It does not push, merge, change grants, deploy, or rewrite Git
1901
+ history. Run it from the Git worktree root (or pass that root with `--dir`);
1902
+ nested directories are rejected before adoption or receipt writes. It requires
1903
+ `origin` to match the addressed repository and refuses an
1904
+ existing conflicting receipt. If the local write fails after binding, rerun with
1905
+ `--write`; the platform binding is retained. An older Atlas release must be
1906
+ upgraded before adoption. Legacy repositories are not bulk-adopted implicitly.
1907
+
1908
+ Repository-backed deployment requires an adopted server identity and a matching
1909
+ `.seq/identity.json` in the **selected commit**, not just in your working tree.
1910
+ Atlas enforces this for repository-backed Next.js builds, pipeline planning and
1911
+ execution (including queued plans), and native repository CI/CD activation. The
1912
+ CLI also checks it before resolving `--repo` build/deploy sources and before
1913
+ `seq-studio deploy` runs any primitive, including dry runs. App deployment requires
1914
+ a platform clone whose origin matches the selected server and repository ID.
1915
+ Existing deployment permissions, environment binding and production approvals
1916
+ still apply; a receipt is not permission to deploy.
1917
+
1918
+ For legacy repositories, adopt once, commit the receipt through the normal PR
1919
+ workflow, then deploy that new revision. Old receipt-free commits cannot be
1920
+ redeployed through these paths. Running deployments are untouched; existing native
1921
+ compensation/promote/rollback authorization is not replaced. Upgrade Atlas before
1922
+ the CLI: a missing admission endpoint fails closed, with no legacy bypass.
1923
+
1924
+ This is **not universal source attestation**: direct primitive uploads and arbitrary
1925
+ local/Git-URL primitive commands remain separate, permission-checked surfaces.
1926
+ Copying a receipt does not register a cross-environment mirror; explicit mirror
1927
+ registration and gating those unassociated uploads are not part of this change.
1928
+ For Next.js and pipelines, `--source-env` uses the canonical source directly,
1929
+ without a destination repository copy. The source must support deployment
1930
+ admission and have an adopted identity plus a matching receipt at the selected
1931
+ commit. Its tenant must match the destination tenant. Authentication to both
1932
+ environments alone does not permit cross-tenant deployment.
1933
+
1934
+ ### Repository operations
1935
+
1799
1936
  `repos create` creates the hosted repository; it does not configure Git in your
1800
1937
  current folder. For a new local checkout, use `seq-studio login`, then `repos clone --full` to get `origin`, branch tracking, and complete history for your
1801
1938
  editor's Git graph. For an existing folder, discover the clone URL with
@@ -1819,6 +1956,7 @@ JSON API — the same repos `--repo <ns>/<name>` sources build from.
1819
1956
  | `seq-studio repos list -e <env> [--namespace <slug>] [--mine]` | repos visible on the environment (permission-filtered) |
1820
1957
  | `seq-studio repos namespaces [create <slug>] -e <env>` | list namespaces, or create one (creator becomes owner) |
1821
1958
  | `seq-studio repos show <ns>/<name> -e <env>` | detail: id, branches, clone URL; artifact project id when slug matches |
1959
+ | `seq-studio repos identity <ns>/<name> -e <env> [--write --dir .]` | inspect the server-issued identity; `--write` restores its receipt at the matching clone's Git worktree root; admin-only `--adopt --write --yes` binds a legacy repository once |
1822
1960
  | `seq-studio repos create <ns>/<name> -e <env> [--default-branch <b>] [--git-backend walgit]` | create a repo, seeded with a README on `main`. The server picks the backend (walgit wherever it is configured). `--git-backend walgit` creates it empty, for pushing existing history. Needs namespace write. |
1823
1961
  | `seq-studio repos clone <ns>/<name> \| --url <clone-url> \| --id <uuid> -e <env> [--ref <r>] [--output <dir>] [--force] [--full] [--transport auto\|git\|json]` | smart-HTTP `git clone --depth 1` using login (`--full` fetches history; a commit SHA stays full). Configures login for subsequent Git commands. Use files-only `--transport json` for `<ns>/<name>`. `--out` remains an alias for `--output`. |
1824
1962
  | `seq-studio repos pull <ns>/<name> -e <env> [--ref <r>] [--out <dir>] [--force]` | always materialize via JSON API (no `.git` dir); refuses a non-empty destination unless `--force` |
@@ -2002,13 +2140,16 @@ re-plan must verify its source again. This increment supports only the server-ow
2002
2140
  first-party source origins (`banksouth`, `staging`, and `production`). Registered
2003
2141
  OpCo source environments are not supported yet. A local CLI environment entry or
2004
2142
  the target's own `APP_ORIGIN` does not establish trust for a remote source; the
2005
- server never accepts a caller-selected source URL.
2143
+ server never accepts a caller-selected source URL. Both environments must belong
2144
+ to the same tenant, as verified from the source repository's server-owned identity
2145
+ and the destination's configured owner. Release identity admission on the source
2146
+ before using this flow; the target refuses missing or conflicting admission.
2006
2147
  First-time creation retains the existing target repository Writer requirement;
2007
2148
  creating a new release unit solely from a remote repository is not supported yet.
2008
2149
 
2009
2150
  ```bash
2010
- seq-studio pipeline plan --repo apps/example --root pipelines/feed --ref staging --source-env banksouth -e staging --json
2011
- seq-studio pipeline deploy --repo apps/example --root pipelines/feed --ref <reviewed-commit> --source-env banksouth -e staging
2151
+ seq-studio pipeline plan --repo apps/example --root pipelines/feed --ref main --source-env staging -e production --json
2152
+ seq-studio pipeline deploy --repo apps/example --root pipelines/feed --ref <reviewed-commit> --source-env staging -e production
2012
2153
  ```
2013
2154
 
2014
2155
  This does not create a repository in the target or change pipeline permissions,
@@ -2017,6 +2158,10 @@ Do not combine `--source-env` with `--dir`, existing plan/deployment IDs, or
2017
2158
  coordinated migrations. Existing IDs already identify their immutable source;
2018
2159
  execute and poll them using target authentication only. A rollback to a deployment
2019
2160
  that retained a source snapshot reuses that snapshot without source credentials.
2161
+ Snapshots captured before identity admission remain retained for history, but
2162
+ cannot execute or materialize without verified identity. After adopting and
2163
+ committing the source receipt, explicitly create and review a new plan; workers
2164
+ never replace historical captures implicitly.
2020
2165
  Older deployments may still depend on their original repository. To deploy a
2021
2166
  historical canonical commit when that repository is unavailable, create a fresh
2022
2167
  source-qualified plan with `deploy --ref <sha> --source-env <env>` and review its
@@ -2613,3 +2758,23 @@ branch points at now unless `--commit` names another. `checks` returns one objec
2613
2758
  runs, CI plan and runs, and merge gates (mergeability, review, code-owner, and check
2614
2759
  gates). `close` needs authorship or repository write and is idempotent.
2615
2760
  `repos pull` remains the singular source-snapshot command.
2761
+
2762
+ ## Agent feedback
2763
+
2764
+ Report errors, confusing behavior, missing docs or capabilities, repeated retries, and
2765
+ successful workarounds with normal Sequence credentials. A report needs only a title
2766
+ and observed behavior; do not include transcripts, customer records, or secrets.
2767
+ Do not search for duplicates before submitting. Report each independently encountered
2768
+ occurrence, including known issues; group repeated symptoms within one incident.
2769
+ Independent tasks and reporters should submit their own evidence.
2770
+
2771
+ ```json
2772
+ {"title":"Deploy returned 503","observedBehavior":"Validation results were not shown.","agent":{"application":"Codex","provider":"OpenAI","modelId":"unknown"}}
2773
+ ```
2774
+
2775
+ Save this as `report.json`, then run `seq-studio feedback submit --file report.json -e <env> --json`.
2776
+ A confirmed receipt includes a ticket ID and link. Keep the file and submission
2777
+ evidence if no receipt is confirmed; do not blindly resubmit an uncertain write.
2778
+ See `<environment-url>/docs/raw/seq-studio/feedback.md` for the direct API
2779
+ contract and retry guidance. Agents only see this guidance when their instructions
2780
+ load the page or the installed feedback skill.
@@ -7,7 +7,7 @@
7
7
  import type { ParsedArgs } from '../process/commands.js';
8
8
  export declare const APP_INIT_USAGE: string;
9
9
  export declare const APP_ADD_USAGE: string;
10
- export declare const APP_DEPLOY_USAGE = "usage:\n seq-studio deploy -e <env> [options]\n\n Deploy the app declared in sequence.app.yml. Versions 2 and 3 use\n depends_on prerequisites; deploy.order optionally orders ready primitives.\n Runs each kind's existing command:\n orm \u2192 seq-studio orm apply <path> -e <env>\n function \u2192 seq-studio functions deploy --dir <path> -e <env> [--yes]\n agent \u2192 seq-studio agents apply --dir <path> -e <env> [--yes], config-only (access stays in Atlas)\n process \u2192 seq-studio process apply --dir <path> -e <env>\n pipeline \u2192 seq-studio pipeline deploy --repo <repo> --ref <ref> -e <env>\n artifact \u2192 seq-studio artifact deploy <path> -e <env>\n\n Options:\n -e, --env <name> target environment (required)\n --dir <path> app root (default: cwd; must contain sequence.app.yml)\n --only <id1,id2> deploy these ids and their prerequisites (v2)\n --yes non-interactive (forwarded to primitive commands)\n --dry-run validate/compile selected sources without deploying (v2)\n --approved-by <sub> recorded caller approval for protected pipeline targets\n --wait-timeout <d> pipeline polling timeout, e.g. 10m or 2h\n\n Examples:\n seq-studio deploy -e staging --yes\n seq-studio deploy -e local --only get-pokemon --yes\n seq-studio deploy --dir ./pokedex -e staging --dry-run\n\n Run from the app root (directory with sequence.app.yml), or pass --dir.\n Version 1 manifests keep their existing ordering and exact --only behavior.\n Pipelines require repo and ref in their manifest entry.\n ORM namespaces require generated code and a reviewed migration ledger:\n seq-studio orm generate <path> && seq-studio orm diff <path>\n Commit generated migrations before the first deployment and schema changes.\n Pipeline preflight reads the remote source and pins its commit; dry-run\n therefore needs network/auth for pipelines. Version 1 dry-run only lists.\n A dry-run never opens a browser login: without a session it skips the\n workspace-binding check and says so. It warns, rather than fails, when the\n artifact source is not committed and clean on main.\n Version 2 writes the result to .sequence/deployments/<environment>.json.\n";
10
+ export declare const APP_DEPLOY_USAGE = "usage:\n seq-studio deploy -e <env> [options]\n\n Requires a platform repository clone with an adopted identity and a matching\n .seq/identity.json committed on the selected server. Checked before any\n primitive runs, including --dry-run; there is no legacy bypass.\n\n Deploy the app declared in sequence.app.yml. Versions 2 and 3 use\n depends_on prerequisites; deploy.order optionally orders ready primitives.\n Runs each kind's existing command:\n orm \u2192 seq-studio orm apply <path> -e <env>\n function \u2192 seq-studio functions deploy --dir <path> -e <env> [--yes]\n agent \u2192 seq-studio agents apply --dir <path> -e <env> [--yes], config-only (access stays in Atlas)\n process \u2192 seq-studio process apply --dir <path> -e <env>\n pipeline \u2192 seq-studio pipeline deploy --repo <repo> --ref <ref> -e <env>\n artifact \u2192 seq-studio artifact deploy <path> -e <env>\n\n Options:\n -e, --env <name> target environment (required)\n --dir <path> app root (default: cwd; must contain sequence.app.yml)\n --only <id1,id2> deploy these ids and their prerequisites (v2)\n --yes non-interactive (forwarded to primitive commands)\n --dry-run validate/compile selected sources without deploying (v2)\n --approved-by <sub> recorded caller approval for protected pipeline targets\n --wait-timeout <d> pipeline polling timeout, e.g. 10m or 2h\n\n Examples:\n seq-studio deploy -e staging --yes\n seq-studio deploy -e local --only get-pokemon --yes\n seq-studio deploy --dir ./pokedex -e staging --dry-run\n\n Run from the app root (directory with sequence.app.yml), or pass --dir.\n Version 1 manifests keep their existing ordering and exact --only behavior.\n Pipelines require repo and ref in their manifest entry.\n ORM namespaces require generated code and a reviewed migration ledger:\n seq-studio orm generate <path> && seq-studio orm diff <path>\n Commit generated migrations before the first deployment and schema changes.\n Repository admission reads the remote receipt at HEAD; all dry-runs need\n network/auth. Version 1 dry-run only lists after that check.\n A dry-run never opens a browser login: sign in beforehand. It warns,\n rather than fails, when the\n artifact source is not committed and clean on main.\n Version 2 writes the result to .sequence/deployments/<environment>.json.\n";
11
11
  /**
12
12
  * Hosted Next.js apps deploy only where the deployment runs the Next.js
13
13
  * runtime, which not every deployment does yet; the server then refuses with
@@ -85,6 +85,10 @@ export const APP_ADD_USAGE = `usage:
85
85
  export const APP_DEPLOY_USAGE = `usage:
86
86
  seq-studio deploy -e <env> [options]
87
87
 
88
+ Requires a platform repository clone with an adopted identity and a matching
89
+ .seq/identity.json committed on the selected server. Checked before any
90
+ primitive runs, including --dry-run; there is no legacy bypass.
91
+
88
92
  Deploy the app declared in ${APP_MANIFEST_FILENAME}. Versions 2 and 3 use
89
93
  depends_on prerequisites; deploy.order optionally orders ready primitives.
90
94
  Runs each kind's existing command:
@@ -115,10 +119,10 @@ export const APP_DEPLOY_USAGE = `usage:
115
119
  ORM namespaces require generated code and a reviewed migration ledger:
116
120
  seq-studio orm generate <path> && seq-studio orm diff <path>
117
121
  Commit generated migrations before the first deployment and schema changes.
118
- Pipeline preflight reads the remote source and pins its commit; dry-run
119
- therefore needs network/auth for pipelines. Version 1 dry-run only lists.
120
- A dry-run never opens a browser login: without a session it skips the
121
- workspace-binding check and says so. It warns, rather than fails, when the
122
+ Repository admission reads the remote receipt at HEAD; all dry-runs need
123
+ network/auth. Version 1 dry-run only lists after that check.
124
+ A dry-run never opens a browser login: sign in beforehand. It warns,
125
+ rather than fails, when the
122
126
  artifact source is not committed and clean on main.
123
127
  Version 2 writes the result to .sequence/deployments/<environment>.json.
124
128
  `;
@@ -177,8 +181,9 @@ export async function runAppInitCommand(args) {
177
181
  try {
178
182
  if (args.flags.template === true)
179
183
  throw new Error('--template requires <name>@<version>.');
180
- const env = args.flags.env ?? args.flags.e;
181
- if (typeof env !== 'string')
184
+ const requested = args.flags.env ?? args.flags.e;
185
+ const env = explicitOrSandboxEnv(typeof requested === 'string' ? requested : undefined);
186
+ if (!env)
182
187
  throw new Error('--template requires -e <deployment>.');
183
188
  if (kinds.length > 0)
184
189
  throw new Error('Use either --template or --with/primitive flags.');
@@ -24,6 +24,7 @@ export { createDefaultDeployers } from './adapters.js';
24
24
  import { defaultDeployOrder, loadAppManifest, usesAppGraph, } from './manifest.js';
25
25
  import { warnOnManifestRoles } from '../manifest-roles-notice.js';
26
26
  import { assertAppEnvironmentBindings } from './env-bindings.js';
27
+ import { assertAppRepositoryAdmission } from './repository-admission.js';
27
28
  const LOG = '[seq-studio]';
28
29
  const APP_MANIFEST_HINT = 'sequence.app.yml';
29
30
  /**
@@ -97,13 +98,14 @@ function assertAppDeploymentSource({ manifest, options, rootDir, entries }) {
97
98
  }
98
99
  }
99
100
  export async function deployApp(options) {
100
- // A dry-run never signs anyone in: it uses an existing session or skips
101
- // the checks that need one.
101
+ // A dry-run never signs anyone in. Repository admission still requires an
102
+ // existing session; offline validation is not deployment admission.
102
103
  return options.dryRun ? withoutAutoLogin(() => runDeployApp(options)) : runDeployApp(options);
103
104
  }
104
105
  async function runDeployApp(options) {
105
106
  const rootDir = resolve(options.rootDir);
106
107
  const manifest = await loadAppManifest(rootDir);
108
+ await assertAppRepositoryAdmission({ rootDir, env: options.env });
107
109
  await warnOnManifestRoles({ dir: rootDir, file: 'sequence.app.yml', kind: 'application' });
108
110
  const entries = resolveDeployEntries({ manifest, only: options.only });
109
111
  const onError = manifest.deploy.on_error;
@@ -127,7 +129,6 @@ async function runDeployApp(options) {
127
129
  manifest,
128
130
  entries,
129
131
  paths: resolvedPaths,
130
- rootDir,
131
132
  deployEnvironment: options.env,
132
133
  ...(options.environmentBindings ? { loadContext: options.environmentBindings } : {}),
133
134
  });
@@ -8,14 +8,13 @@ export interface EnvironmentBindingContext {
8
8
  }
9
9
  /**
10
10
  * Resolve `uses` workspace names and artifact `targets` in the selected
11
- * environment, then refuse the deploy when source still points elsewhere.
12
- * Apps with no scannable source and no workspace edges skip the lookup.
11
+ * environment. Do not inspect source files or shared packages for bindings.
12
+ * Apps with no artifact manifests and no workspace edges skip the lookup.
13
13
  */
14
- export declare function assertAppEnvironmentBindings({ manifest, entries, paths, rootDir, deployEnvironment, loadContext, }: {
14
+ export declare function assertAppEnvironmentBindings({ manifest, entries, paths, deployEnvironment, loadContext, }: {
15
15
  manifest: AppManifest;
16
16
  entries: readonly PrimitiveEntry[];
17
17
  paths: ReadonlyMap<string, string>;
18
- rootDir: string;
19
18
  deployEnvironment: string;
20
19
  loadContext?: () => Promise<EnvironmentBindingContext>;
21
20
  }): Promise<void>;
@@ -1,23 +1,17 @@
1
- import { existsSync, lstatSync } from 'node:fs';
2
- import { readdir, readFile } from 'node:fs/promises';
3
- import { join, relative } from 'node:path';
4
- import { assertNoCrossEnvironmentBindings, canonicalDeploymentOrigin, readArtifactStudioSource, } from '@sequenceholdings/artifact-studio/deployment-validation';
5
- import { loadWorkspacePackages, packageClosure, readWorkspacePackage } from './workspace-model.js';
6
- const SKIP_DIRS = new Set(['node_modules', '.git', 'dist', '.next', '.artifact-studio', 'coverage']);
7
- const TEXT_EXTENSIONS = new Set(['.ts', '.tsx', '.mts', '.cts', '.js', '.jsx', '.mjs', '.cjs', '.json', '.yml', '.yaml']);
1
+ import { existsSync } from 'node:fs';
2
+ import { readFile } from 'node:fs/promises';
3
+ import { join } from 'node:path';
4
+ import { assertNoCrossEnvironmentBindings, canonicalDeploymentOrigin, } from '@sequenceholdings/artifact-studio/deployment-validation';
8
5
  /**
9
6
  * Resolve `uses` workspace names and artifact `targets` in the selected
10
- * environment, then refuse the deploy when source still points elsewhere.
11
- * Apps with no scannable source and no workspace edges skip the lookup.
7
+ * environment. Do not inspect source files or shared packages for bindings.
8
+ * Apps with no artifact manifests and no workspace edges skip the lookup.
12
9
  */
13
- export async function assertAppEnvironmentBindings({ manifest, entries, paths, rootDir, deployEnvironment, loadContext, }) {
14
- const files = [
15
- ...(await Promise.all(entries.map(async (entry) => {
16
- const directory = paths.get(entry.id);
17
- return directory ? primitiveBindingFiles({ entry, directory }) : [];
18
- }))).flat(),
19
- ...await sharedPackageFiles({ rootDir, manifest, entries, paths }),
20
- ];
10
+ export async function assertAppEnvironmentBindings({ manifest, entries, paths, deployEnvironment, loadContext, }) {
11
+ const files = (await Promise.all(entries.map(async (entry) => {
12
+ const directory = paths.get(entry.id);
13
+ return directory ? primitiveBindingFiles({ entry, directory }) : [];
14
+ }))).flat();
21
15
  const workspaces = namedWorkspaces({ manifest, entries });
22
16
  if (files.length === 0 && workspaces.length === 0)
23
17
  return;
@@ -57,68 +51,11 @@ function namedWorkspaces({ manifest, entries, }) {
57
51
  }
58
52
  return workspaces;
59
53
  }
60
- async function sharedPackageFiles({ rootDir, manifest, entries, paths, }) {
61
- if (!manifest.packages?.length)
62
- return [];
63
- const packages = await loadWorkspacePackages({ rootDir, manifest });
64
- const directories = new Map();
65
- for (const entry of entries) {
66
- const directory = paths.get(entry.id);
67
- if (!directory || !existsSync(join(directory, 'package.json')))
68
- continue;
69
- const json = await readWorkspacePackage({ dir: directory });
70
- for (const pkg of packageClosure({ json, packages })) {
71
- directories.set(pkg.dir, pkg.path);
72
- }
73
- }
74
- return (await Promise.all([...directories].map(([directory, label]) => readBindingFiles({ directory, label })))).flat();
75
- }
76
54
  async function primitiveBindingFiles({ entry, directory, }) {
77
- if (entry.kind !== 'artifact' || !existsSync(join(directory, 'artifact.bundle.yml'))) {
78
- return readBindingFiles({ directory, label: entry.path });
79
- }
80
- const source = await readArtifactStudioSource(directory);
81
- return source.files.map((file) => ({
82
- path: `${entry.path}/${file.path}`,
83
- content: file.content,
84
- ...(file.encoding ? { encoding: file.encoding } : {}),
85
- }));
86
- }
87
- async function readBindingFiles({ directory, label, }) {
88
- if (!existsSync(directory))
55
+ const path = join(directory, 'artifact.bundle.yml');
56
+ if (entry.kind !== 'artifact' || !existsSync(path))
89
57
  return [];
90
- const files = [];
91
- async function walk(current) {
92
- const entries = await readdir(current, { withFileTypes: true });
93
- for (const entry of entries) {
94
- if (entry.isSymbolicLink() || SKIP_DIRS.has(entry.name))
95
- continue;
96
- const absolute = join(current, entry.name);
97
- if (entry.isDirectory()) {
98
- await walk(absolute);
99
- continue;
100
- }
101
- if (!entry.isFile() || !isBindingText(entry.name))
102
- continue;
103
- const stat = lstatSync(absolute);
104
- if (!stat.isFile() || stat.size > 2_000_000)
105
- continue;
106
- files.push({
107
- path: `${label}/${relative(directory, absolute)}`,
108
- content: await readFile(absolute, 'utf8'),
109
- });
110
- }
111
- }
112
- await walk(directory);
113
- return files;
114
- }
115
- function isBindingText(name) {
116
- if (name === 'pnpm-lock.yaml' || name === 'package-lock.json' || name === 'yarn.lock' || name.endsWith('.md'))
117
- return false;
118
- if (name === '.env')
119
- return true;
120
- const extension = name.includes('.') ? name.slice(name.lastIndexOf('.')) : '';
121
- return TEXT_EXTENSIONS.has(extension);
58
+ return [{ path: `${entry.path}/artifact.bundle.yml`, content: await readFile(path, 'utf8') }];
122
59
  }
123
60
  async function defaultBindingContext(envName) {
124
61
  const { readConfig, resolveConfiguredEnv } = await import('../config.js');
@@ -180,7 +180,7 @@ seq-studio deploy -e <environment-name> --yes
180
180
  - **ORM** policies enforce caller access. Change TypeScript schema and operations, then generate migrations; do not edit generated migrations by hand.
181
181
  - **Agent and process identities** are durable. Keep the generated identities stable when changing implementation; generate new identities when copying a resource.
182
182
  - **Official artifact deployments** require the full app checkout to be clean on \`main\`, including shared packages and the root manifest. Use \`seq-studio artifact dev artifact -e <environment-name>\` to preview uncommitted UI.
183
- - **Environment bindings** are resolved at deploy time. \`-e\` selects the environment. Source may not hardcode another environment's API origin or workspace UUID. Declare API origins in \`artifact.bundle.yml\` \`targets\`, and workspace use with \`uses\` on the workspace primitive.
183
+ - **Environment bindings** are resolved at deploy time. \`-e\` selects the environment. Explicit \`artifact.bundle.yml\` target URLs and storage capability workspace IDs are validated, as are named workspace dependencies declared with \`uses\`. Source text and arbitrary config values are not scanned for URLs or UUIDs. Repository identity and runtime access checks still apply.
184
184
 
185
185
  The per-primitive commands remain available for validation and operation; \`seq-studio deploy\` is the app-level deployment entry point. See \`seq-studio deploy --help\` and the CLI command reference at ${docsLink({ atlasOrigin, label: 'CLI command reference', slug: 'seq-studio/commands' })}.
186
186
  `;
@@ -204,7 +204,7 @@ seq-studio init . --with function,artifact --function-name hello
204
204
  # seq-studio init . --with orm,function,agent,process,pipeline,artifact
205
205
  \`\`\`
206
206
 
207
- \`init\` replaces this seed README and creates the app workspace while preserving the git remote. It refuses to overwrite ordinary docs-only repositories.
207
+ \`init\` replaces this seed README and creates the app workspace while preserving the git remote and any platform-issued \`.seq/identity.json\` receipt (including its extensible \`metadata\`). It refuses to overwrite ordinary docs-only repositories.
208
208
 
209
209
  ## Implement this app`)}`;
210
210
  }
@@ -0,0 +1,5 @@
1
+ /** Refuse before packaging or the first primitive mutates the destination. No filename-based tenant guessing. */
2
+ export declare function assertAppRepositoryAdmission({ rootDir, env }: {
3
+ rootDir: string;
4
+ env: string;
5
+ }): Promise<void>;
@@ -0,0 +1,32 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import { checkRepositoryDeploymentIdentity } from '@sequenceholdings/artifact-studio/git-service-client';
3
+ import { gitServiceCloneUrl } from '@sequenceholdings/artifact-studio/git-clone';
4
+ import { assertRepositoryIdentity } from '@sequenceholdings/artifact-studio/repository-identity';
5
+ import { readRepositoryIdentityFile } from '../repos/identity-file.js';
6
+ import { buildContext, clientOptions } from '../functions/commands.js';
7
+ /** Refuse before packaging or the first primitive mutates the destination. No filename-based tenant guessing. */
8
+ export async function assertAppRepositoryAdmission({ rootDir, env }) {
9
+ let root;
10
+ let commit;
11
+ let origin;
12
+ try {
13
+ const options = { cwd: rootDir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] };
14
+ root = execFileSync('git', ['rev-parse', '--show-toplevel'], options).trim();
15
+ commit = execFileSync('git', ['rev-parse', 'HEAD'], options).trim();
16
+ origin = execFileSync('git', ['remote', 'get-url', 'origin'], options).trim();
17
+ }
18
+ catch {
19
+ throw new Error('App deployment requires a committed platform repository clone. Use seq-studio repos create/clone, or adopt an existing repository first.');
20
+ }
21
+ const receipt = await readRepositoryIdentityFile({ directory: root });
22
+ if (!receipt)
23
+ throw new Error('App deployment requires .seq/identity.json at the repository root. An administrator must run seq-studio repos identity <namespace/name> -e <env> --adopt --write --yes for a legacy repository, then commit the receipt.');
24
+ const context = await buildContext({ positional: [], flags: { env } });
25
+ const options = clientOptions(context);
26
+ const normalize = (value) => value.replace(/\/$/, '').replace(/\.git$/, '');
27
+ if (normalize(origin) !== normalize(gitServiceCloneUrl(options.baseUrl, receipt.identity.repositoryId))) {
28
+ throw new Error('App repository origin does not match the selected environment and identity. Use its owning environment; copied receipts do not register mirrors.');
29
+ }
30
+ const expected = await checkRepositoryDeploymentIdentity({ ...options, repoId: receipt.identity.repositoryId, commit });
31
+ assertRepositoryIdentity({ receipt, expected });
32
+ }
@@ -4,9 +4,10 @@ import { readdir, readFile, rm, writeFile } from 'node:fs/promises';
4
4
  import { join } from 'node:path';
5
5
  import { isGitServiceSeedReadme } from './readme.js';
6
6
  import { WORKSPACE_ROOT_FILES } from './workspace-scaffold.js';
7
+ import { readRepositoryIdentityFile } from '../repos/identity-file.js';
7
8
  const INIT_METADATA_ONLY = new Set(['.git', '.gitattributes', '.DS_Store']);
8
9
  const INIT_ALLOWED_EXISTING = new Set([
9
- ...INIT_METADATA_ONLY, '.gitignore', 'README.md', 'LICENSE', 'LICENSE.md',
10
+ ...INIT_METADATA_ONLY, '.gitignore', 'README.md', 'LICENSE', 'LICENSE.md', '.seq',
10
11
  ]);
11
12
  const DEFAULT_GITIGNORE_LINES = [
12
13
  'node_modules/', 'dist/', '.env', '.env.*', '!.env.example', '.DS_Store',
@@ -26,6 +27,12 @@ export async function inspectScaffoldTarget(appRoot) {
26
27
  }
27
28
  const existed = existsSync(appRoot);
28
29
  const entries = existed ? await readdir(appRoot) : [];
30
+ if (entries.includes('.seq')) {
31
+ if (!await readRepositoryIdentityFile({ directory: appRoot }) ||
32
+ (await readdir(join(appRoot, '.seq'))).some((name) => name !== 'identity.json')) {
33
+ throw new Error(`${appRoot} is not empty — only the issued .seq/identity.json is allowed in a seed clone`);
34
+ }
35
+ }
29
36
  if (entries.some((name) => !INIT_ALLOWED_EXISTING.has(name))) {
30
37
  throw new Error(`${appRoot} is not empty — init into a new directory or a git-service clone whose README contains the seq-studio seed marker`);
31
38
  }
@@ -10,6 +10,10 @@
10
10
  * 3. Install an internal token provider so auth is shared with the rest of
11
11
  * `seq-studio` without exposing the bearer in argv or environment.
12
12
  * 4. Forward all remaining argv to `runCli`.
13
+ *
14
+ * In sandbox token mode (see sandbox-auth.ts) the deployment and bearer come
15
+ * from Atlas instead, and only commands that need neither a local login nor a
16
+ * package registry run: an agent sandbox reaches its Atlas origin and nothing else.
13
17
  */
14
18
  export declare function runArtifactCommand(sub: string | undefined, rest: string[]): Promise<number>;
15
19
  /**