@sequenceholdings/studio-cli 0.1.27 → 0.1.29

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 (61) hide show
  1. package/README.md +255 -72
  2. package/dist/app/adapters.d.ts +9 -0
  3. package/dist/app/adapters.js +176 -0
  4. package/dist/app/commands.d.ts +2 -2
  5. package/dist/app/commands.js +98 -22
  6. package/dist/app/deploy.d.ts +9 -10
  7. package/dist/app/deploy.js +83 -141
  8. package/dist/app/graph.d.ts +15 -0
  9. package/dist/app/graph.js +36 -0
  10. package/dist/app/manifest-validation.d.ts +16 -0
  11. package/dist/app/manifest-validation.js +99 -0
  12. package/dist/app/manifest.d.ts +27 -9
  13. package/dist/app/manifest.js +23 -107
  14. package/dist/app/paths.d.ts +14 -0
  15. package/dist/app/paths.js +77 -0
  16. package/dist/app/primitive-scaffold.d.ts +18 -0
  17. package/dist/app/primitive-scaffold.js +136 -0
  18. package/dist/app/readme.d.ts +4 -18
  19. package/dist/app/readme.js +105 -233
  20. package/dist/app/run-deployment.d.ts +8 -0
  21. package/dist/app/run-deployment.js +50 -0
  22. package/dist/app/scaffold-files.d.ts +13 -0
  23. package/dist/app/scaffold-files.js +68 -0
  24. package/dist/app/scaffold.d.ts +11 -3
  25. package/dist/app/scaffold.js +77 -245
  26. package/dist/app/workspace-compile.d.ts +18 -0
  27. package/dist/app/workspace-compile.js +143 -0
  28. package/dist/app/workspace-model.d.ts +70 -0
  29. package/dist/app/workspace-model.js +159 -0
  30. package/dist/app/workspace-scaffold.d.ts +27 -0
  31. package/dist/app/workspace-scaffold.js +126 -0
  32. package/dist/app/workspace.d.ts +14 -0
  33. package/dist/app/workspace.js +147 -0
  34. package/dist/atlas-client.js +28 -6
  35. package/dist/auth-cmds/commands.d.ts +1 -1
  36. package/dist/auth-cmds/commands.js +5 -2
  37. package/dist/functions/commands.js +7 -1
  38. package/dist/functions/manifest.d.ts +18 -0
  39. package/dist/functions/manifest.js +29 -4
  40. package/dist/main.js +8 -3
  41. package/dist/pat-hints.js +1 -0
  42. package/dist/pipeline/commands.js +27 -9
  43. package/dist/pipeline/lifecycle.d.ts +2 -0
  44. package/dist/pipeline/lifecycle.js +91 -11
  45. package/dist/process/build.js +59 -43
  46. package/dist/process/codegen.d.ts +3 -2
  47. package/dist/process/codegen.js +143 -27
  48. package/dist/process/commands.d.ts +2 -0
  49. package/dist/process/commands.js +63 -18
  50. package/dist/process/discover.d.ts +6 -3
  51. package/dist/process/discover.js +11 -3
  52. package/dist/process/lint.d.ts +14 -0
  53. package/dist/process/lint.js +143 -5
  54. package/dist/process/plan-diff.d.ts +8 -0
  55. package/dist/process/plan-diff.js +61 -4
  56. package/dist/process/safety-baseline.d.ts +154 -0
  57. package/dist/process/safety-baseline.js +387 -0
  58. package/dist/process/simulate.js +64 -22
  59. package/dist/repos/commands.d.ts +1 -1
  60. package/dist/repos/commands.js +29 -3
  61. package/package.json +7 -6
@@ -1,300 +1,172 @@
1
- /**
2
- * README seeded by `seq-studio init` (and kept equivalent to the git-service
3
- * createRepo initial commit). Third-party developers should be able to clone
4
- * a new app repo and start building on Artifact Studio, the ORM, and
5
- * Managed Functions without guessing the platform model.
6
- *
7
- * Keep in sync with atlas/src/server/services/git-service/initial-readme.ts.
8
- */
1
+ /** App README generated by init; git-service seed detection stays stable. */
9
2
  import { titleizeSlug } from './manifest.js';
10
3
  export const SEQUENCE_DOCS_URL = 'https://docs.seqholdings.com/';
11
- /**
12
- * Hidden marker written into the git-service createRepo README.
13
- * `seq-studio init .` only overwrites a non-empty target when this is present,
14
- * so an ordinary docs-only repository is not treated as a seed clone.
15
- *
16
- * Keep identical to atlas/src/server/services/git-service/initial-readme.ts.
17
- */
4
+ /** Keep identical to atlas/src/server/services/git-service/initial-readme.ts. */
18
5
  export const GIT_SERVICE_SEED_MARKER = '<!-- seq-studio:git-service-seed -->';
19
6
  export function isGitServiceSeedReadme(body) {
20
7
  return body.includes(GIT_SERVICE_SEED_MARKER);
21
8
  }
22
9
  export const README_REQUIRED_SECTIONS = [
23
- 'https://docs.seqholdings.com/',
24
- 'Artifact Studio',
25
- 'ORM',
26
- 'Managed Function',
27
- 'seq-studio init',
28
- 'seq.functions.invoke',
10
+ 'https://docs.seqholdings.com/', 'Artifact Studio', 'ORM', 'Managed Function',
11
+ 'seq-studio init', 'seq.functions.invoke',
29
12
  ];
13
+ function primitivePath({ kind, appId, functionName }) {
14
+ switch (kind) {
15
+ case 'orm': return `orm/${appId.replace(/-/g, '_')}`;
16
+ case 'function': return `functions/${functionName}`;
17
+ case 'agent': return `agents/${appId}`;
18
+ case 'process': return `processes/${appId}`;
19
+ case 'pipeline': return `pipelines/${appId}`;
20
+ case 'artifact': return 'artifact';
21
+ }
22
+ }
23
+ const PRIMITIVE_LABELS = {
24
+ orm: 'ORM namespace', function: 'Managed Function', agent: 'Typed agent',
25
+ process: 'Lattice process', pipeline: 'Data Pipeline', artifact: 'Artifact Studio UI',
26
+ };
30
27
  export function renderAppReadme(input) {
31
28
  const title = input.title?.trim() || titleizeSlug(input.appId);
32
- const description = input.description?.trim() ||
33
- 'A Sequence Platform app. Keep source in Git and deploy with seq-studio.';
29
+ const description = input.description?.trim() || 'A Sequence Platform app. Keep source in Git and deploy with seq-studio.';
34
30
  const kinds = new Set(input.primitives);
35
31
  const functionName = input.functionName ?? 'hello';
36
- const tree = renderAppTree({
37
- appId: input.appId,
38
- kinds,
39
- functionName,
40
- });
41
- const primitiveRows = [
42
- kinds.has('artifact')
43
- ? '| **Artifact Studio** | Frontend | `artifact/` — React UI + `artifact.bundle.yml` |'
44
- : null,
45
- kinds.has('orm')
46
- ? `| **ORM** | Data | \`orm/${snake(input.appId)}/\` — tables, policies, named GraphQL operations |`
47
- : null,
48
- kinds.has('function')
49
- ? `| **Managed Function** | Backend | \`functions/${functionName}/\` — TypeScript handler + \`managed-function.yml\` |`
50
- : null,
51
- ]
52
- .filter((row) => row !== null)
53
- .join('\n');
32
+ const locations = input.primitives.map((kind) => ({
33
+ kind, path: primitivePath({ kind, appId: input.appId, functionName }),
34
+ }));
54
35
  return `# ${title}
55
36
 
56
37
  ${description}
57
38
 
58
- This folder is a **seq-studio app**. You keep source in Git (this repository, or a platform git-service clone). You validate, plan, and deploy with \`seq-studio\`. You do not need a checkout of Sequence Platform itself.
59
-
60
- **Platform documentation:** [${SEQUENCE_DOCS_URL}](${SEQUENCE_DOCS_URL})
61
-
62
- You still need an environment name, an Atlas URL, and resource grants from your platform administrator before Preview or deploy. Login proves identity; it does not grant every action.
39
+ This repository is a **seq-studio app bundle**. Its root \`sequence.app.yml\` defines the app's deployable primitives, source locations, and deployment prerequisites. Keep this file, shared packages, primitive manifests, and the root lockfile together in Git.
63
40
 
64
- ## What this repository is
41
+ **Platform documentation:** [Sequence Platform](${SEQUENCE_DOCS_URL})
65
42
 
66
- A Sequence app is a folder with a \`sequence.app.yml\` manifest plus one subdirectory per platform primitive. The CLI owns that manifest (\`seq-studio init\` / \`seq-studio add\`). Do not invent a new layout by hand.
43
+ ## What this repository contains
67
44
 
68
- \`\`\`
69
- ${tree}
45
+ \`\`\`text
46
+ ${input.appId}/
47
+ sequence.app.yml app deployment graph + shared package declarations
48
+ package.json app workspace scripts and CLI version
49
+ pnpm-workspace.yaml package membership and install policy
50
+ packages/shared/ @${input.appId}/shared
51
+ ${locations.map(({ kind, path }) => ` ${path}/ ${PRIMITIVE_LABELS[kind]}`).join('\n')}
70
52
  \`\`\`
71
53
 
72
- This app currently includes:
54
+ \`seq-studio init\` creates the bundle; \`seq-studio add <kind> <name>\` adds another primitive. All six kinds can be added more than once. Additional Artifact Studio UIs live under \`artifacts/<name>/\`; the initial UI lives in \`artifact/\`.
73
55
 
74
- | Primitive | Role | Where it lives |
75
- | --- | --- | --- |
76
- ${primitiveRows}
56
+ ## Platform primitives
77
57
 
78
- Add another function later with \`seq-studio add function <name>\` from this directory. \`seq-studio add\` supports \`function\` and \`artifact\` only — an ORM namespace is created at init.
58
+ | Primitive | What you author | What the platform runs |
59
+ | --- | --- | --- |
60
+ | **ORM** | TypeScript tables, policies, named GraphQL operations | Governed Data API and schema migrations |
61
+ | **Managed Function** | TypeScript handler + \`managed-function.yml\` | Server-side code with declared secrets and egress |
62
+ | **Typed agent** | \`agent.ts\` using \`defineAgent(...)\` | Agents-api conversation and task runtime |
63
+ | **Lattice process** | \`process.ts\` definitions | Workflow graphs and human review steps |
64
+ | **Data Pipeline** | \`*.stage.yml\` and transformation source | Databricks ingestion, transformation, and serving jobs |
65
+ | **Artifact Studio** | React UI + \`artifact.bundle.yml\` | Sandboxed browser app inside Atlas |
79
66
 
80
- ## Platform primitives
67
+ The app manifest composes these primitives. Each primitive's own definition still controls its runtime behavior, permissions, and capabilities. Secret values belong in the platform's Managed Secrets, never in the app manifest or a shared package.
81
68
 
82
- Build each app from these three primitives. Use only the ones the product needs.
69
+ ## Install and authenticate
83
70
 
84
- | Primitive | Role | What you write | What the platform runs |
85
- | --- | --- | --- | --- |
86
- | **Artifact Studio** | Frontend | React UI + \`artifact.bundle.yml\` | Sandboxed browser app inside Atlas |
87
- | **ORM** | Data | TypeScript tables, row policies, named GraphQL operations | Governed Data API in front of Postgres (you never open a connection) |
88
- | **Managed Function** | Backend | TypeScript handler + \`managed-function.yml\` | Server-side code with declared secrets, egress, and invoke permissions |
71
+ Use Node.js 20 or later and pnpm 10.28.2. Ask your platform administrator for your environment name, Atlas URL, and the grants needed to create or update this app's resources.
89
72
 
90
- \`\`\`
91
- Browser user
92
- │
93
- ▼
94
- Artifact Studio UI
95
- │ seq.api.* / seq.functions.invoke (declared capabilities only)
96
- ├──► ORM Data API persisted rows, policy-scoped to the caller
97
- └──► Managed Function secrets, egress, work that must not run in the browser
73
+ \`\`\`bash
74
+ corepack enable
75
+ corepack prepare pnpm@10.28.2 --activate
76
+ pnpm install
77
+ seq-studio envs add <environment-name> <atlas-url>
78
+ seq-studio login --env <environment-name>
79
+ seq-studio doctor -e <environment-name>
98
80
  \`\`\`
99
81
 
100
- **Artifact Studio** is the screen. In Atlas the UI runs in a sandboxed iframe and talks to the platform through \`seq\` from \`@sequenceholdings/artifact-studio\`. It has no raw network access and must not contain secrets. Every table, operation, API path, or function the UI uses must be listed in \`artifact.bundle.yml\` first. Prefer \`@sequenceholdings/atlas-ui\`. Docs: [Artifact Studio](${SEQUENCE_DOCS_URL}artifact-studio/overview).
82
+ Run \`pnpm install\` **once from the app root**. Commit the generated root \`pnpm-lock.yaml\`; CI uses \`pnpm install --frozen-lockfile\`. App scaffolding consolidates the standalone templates' install configuration at the root. The root workspace retains the seven-day dependency age gate and explicit build-script allowlist.
101
83
 
102
- **ORM** is the data layer. You author tables and policies in TypeScript (\`defineNamespace\`, \`defineTable\`) and persist reads/writes as named GraphQL documents. \`seq-studio orm apply\` compiles that into a reviewed migration and publishes persisted operations. The UI calls \`{ op: <hash>, variables }\` on the Atlas Data API. Policies are the row boundary — stamp identity from \`claim('sub')\` rather than trusting the browser. There is no ad-hoc SQL; exotic writes go through a declared table action. See the ORM section of the [CLI command reference](${SEQUENCE_DOCS_URL}seq-studio/commands) and \`seq-studio orm --help\`; a reference app (for example Pokedex: Artifact UI + trainer-scoped \`pokemon\` rows) shows the working model.
84
+ Use the environment name your administrator supplies. \`local\` means a real Atlas server at \`http://localhost:5001\`, not a standalone Vite server. Login proves identity; resource permissions are still required. ORM and pipeline commands require the matching \`@sequenceholdings/orm\` / \`@sequenceholdings/pipeline-spec\` SDK installed alongside the CLI.
103
85
 
104
- **Managed Function** is the backend. Use it for an external API, a write-only secret, or any work that must not run in the browser. The handler receives JSON and returns JSON. The manifest declares secret *names* (never values) and an egress allowlist — functions do not get arbitrary outbound network. Docs: [Managed Functions](${SEQUENCE_DOCS_URL}managed-functions/overview), [Managed Secrets](${SEQUENCE_DOCS_URL}managed-secrets/overview).
86
+ ## Shared packages
105
87
 
106
- How the examples split:
88
+ Export common types, validation, and helpers from \`packages/shared/src/index.ts\`. JavaScript primitives depend on \`@${input.appId}/shared\` through \`workspace:*\`; ordinary imports work across the app:
107
89
 
108
- | Example | Primitives | Use it for |
109
- | --- | --- | --- |
110
- | Pokedex-style app | Artifact + ORM | UI that reads and writes governed tables |
111
- | [Basketball player lookup](${SEQUENCE_DOCS_URL}examples/basketball-player-lookup) | Artifact + Function + Secret | UI that calls protected server-side code |
112
- | \`seq-studio init --with orm,function,artifact\` | All three | The intended three-primitive app shape |
90
+ \`\`\`ts
91
+ import { /* your exports */ } from '@${input.appId}/shared'
92
+ \`\`\`
113
93
 
114
- A function calling the ORM under a service account is **not** a supported public path yet. Keep user-scoped table access in the artifact; keep secrets and egress in the function.
94
+ Create another shared package with \`seq-studio add package contracts\`, then add it to a consumer using pnpm:
115
95
 
116
- The public [CLI command reference](${SEQUENCE_DOCS_URL}seq-studio/commands) covers standalone \`artifact\` / \`functions\` / \`secrets\` commands. App-monorepo verbs (\`init\`, \`add\`, \`deploy\`) and \`orm\` are on \`seq-studio --help\`. Prefer \`--help\` when the two disagree.
96
+ \`\`\`bash
97
+ pnpm --filter @${input.appId}/primitive-<primitive-id> add '@${input.appId}/contracts@workspace:*'
98
+ \`\`\`
117
99
 
118
- ## Before you write code
100
+ Declare every shared package's \`name\` and \`path\` under \`packages\` in \`sequence.app.yml\`. Shared packages are build inputs; they are not separately deployed resources. Agent definitions compile to declarative data; they do not run imported helper functions at runtime. Lattice mapper closures cannot capture arbitrary shared executable code. Put shared runtime business logic in a managed function and reference that primitive from the workflow. App deployment prepares self-contained function and artifact sources so local workspace paths do not escape the deployed bundle. To share packages across app repositories, publish versioned packages and use pinned registry dependencies.
119
101
 
120
- Ask your administrator for:
102
+ ## Implement this app
121
103
 
122
- 1. **Environment name** — the exact \`-e\` / \`--env\` value. Do not invent it from this repository name.
123
- 2. **Atlas URL** — the origin used with \`seq-studio envs add\`. It is not docs.seqholdings.com. The CLI discovers login config at \`{url}/api/auth/cli-config\`.
124
- 3. **What you should create** — new Artifact Studio project, new function, new ORM namespace, or updates to existing ones.
125
- 4. **Grants** — create/deploy an artifact; runtime access to open the deployed UI; create/deploy/invoke a function; create secrets if you need them; apply an ORM namespace if you will persist data; permission to **share** the artifact (scaffolds create \`visibility: private\`, and a later deploy will not change that).
126
- 5. **\`@sequenceholdings/orm\` v2 (Preview)** — \`seq-studio init --with orm\` and namespace \`package.json\` files depend on \`@sequenceholdings/orm@^2.0.0\`. Install the matching Preview CLI and SDK pair before scaffolding an ORM namespace:
104
+ ${renderImplementSection({ appId: input.appId, functionName, kinds })}
127
105
 
128
- \`\`\`bash
129
- pnpm add -g @sequenceholdings/studio-cli@0.1.27 @sequenceholdings/orm@2.0.0
130
- \`\`\`
106
+ ## Define deployment prerequisites
131
107
 
132
- Without that pair you can still ship Artifact + Function apps.
108
+ Set a primitive's \`depends_on\` to the IDs that must deploy successfully before it. Use the app's primitive IDs here; agent runtime IDs and process IDs stay in their typed definitions. For example, a workflow that invokes the agent should depend on that agent primitive:
133
109
 
134
- \`local\`, \`staging\`, \`production\`, and \`banksouth\` are **reserved built-in CLI names**. \`seq-studio envs add banksouth …\` fails. Use the OpCo name you were given.
110
+ \`\`\`bash
111
+ seq-studio add agent reviewer
112
+ seq-studio add process approvals --depends-on reviewer-agent
113
+ \`\`\`
135
114
 
136
- See [Before you build](${SEQUENCE_DOCS_URL}getting-started/understand-your-workspace).
115
+ Version 2 derives a deterministic order from this graph. An optional \`deploy.order\` only prioritizes primitives whose prerequisites are ready. \`--only <id>\` includes that primitive's prerequisites. \`deploy.on_error: stop\` stops on failure; \`continue\` runs independent primitives and skips dependents of failed or skipped prerequisites. Deployment is not an atomic transaction: already successful primitives remain deployed if a later one fails. Removing an entry does not delete its deployed resource.
137
116
 
138
- ## Install and sign in
117
+ Version 2 preflight validates and compiles the selected sources before deployment. Pipeline preflight reads the remote repository and pins its commit, so its dry run requires network access and authentication. Results are saved under \`.sequence/deployments/<encoded-env>.json\`.
139
118
 
140
- | Tool | Requirement |
141
- | --- | --- |
142
- | Node.js | 20 or later (22 is the documented baseline) |
143
- | pnpm | 10.28.2 |
144
- | Git | Required for official Artifact Studio deploys |
145
- | \`seq-studio\` | \`@sequenceholdings/studio-cli\` (match \`studio.min_cli\` in \`sequence.app.yml\`) |
119
+ Review and deploy from this directory:
146
120
 
147
121
  \`\`\`bash
148
- corepack enable
149
- corepack prepare pnpm@10.28.2 --activate
150
- pnpm setup # once; restart the terminal afterwards
151
- pnpm add -g @sequenceholdings/studio-cli
152
- seq-studio version
153
-
154
- seq-studio envs add <environment-name> <atlas-url>
155
- seq-studio login --env <environment-name>
156
- seq-studio artifact list -e <environment-name>
157
- seq-studio functions list -e <environment-name>
158
- seq-studio doctor -e <environment-name>
122
+ seq-studio deploy -e <environment-name> --dry-run
123
+ seq-studio deploy -e <environment-name> --yes
159
124
  \`\`\`
160
125
 
161
- Details: [Install seq-studio](${SEQUENCE_DOCS_URL}getting-started/prerequisites), [Authenticate](${SEQUENCE_DOCS_URL}getting-started/authentication).
162
-
163
- \`local\` (\`http://localhost:5001\`) is a real Atlas process, not Vite. After init the CLI may print \`seq-studio deploy -e local --yes\` — ignore that unless you actually run Atlas locally.
126
+ ## Runtime boundaries
164
127
 
165
- ## Implement this app
128
+ - **Artifact Studio** runs in a sandbox. Declare every table, operation, function, and API path under the artifact's capabilities. Invoke functions with \`seq.functions.invoke('<slug>', body)\`. Keep secrets and privileged logic server-side.
129
+ - **Managed Functions** declare secret names and outbound hosts in \`managed-function.yml\`. Keep local values in ignored \`.env\` files.
130
+ - **ORM** policies enforce caller access. Change TypeScript schema and operations, then generate migrations; do not edit generated migrations by hand.
131
+ - **Agent and process identities** are durable. Keep the generated identities stable when changing implementation; generate new identities when copying a resource.
132
+ - **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.
166
133
 
167
- ${renderImplementSection({ kinds, functionName, appId: input.appId })}
168
-
169
- ## Everyday loop
170
-
171
- | You want to… | Command |
172
- | --- | --- |
173
- | Validate / build an artifact | \`seq-studio artifact validate artifact\` / \`artifact build artifact\` |
174
- | Preview uncommitted UI | \`seq-studio artifact dev artifact -e <env>\` |
175
- | Official UI deploy | \`seq-studio artifact deploy artifact -e <env>\` from clean \`main\` |
176
- | Build / deploy a function | \`seq-studio functions build --dir functions/<name>\` then \`functions deploy --dir … -e <env>\` |
177
- | Function logs | \`seq-studio functions logs --fn <slug> -e <env>\` |
178
- | Apply an ORM namespace | \`seq-studio orm apply orm/<namespace> -e <env>\` |
179
- | Deploy every primitive | \`seq-studio deploy -e <env>\` from this directory |
180
-
181
- Official Artifact Studio deploys require a **clean \`main\`** with a committed revision. Uncommitted work is Preview (\`artifact dev\`). Open the URL the CLI prints.
182
-
183
- ## Rules that waste a day if you skip them
184
-
185
- - **Manifests are the authorization surface.** A new \`seq.api\` call, ORM mutation, secret, or outbound host in source is not enough. Update \`artifact.bundle.yml\` or \`managed-function.yml\` and validate again.
186
- - **Never commit secret values.** \`.env\` is gitignored. Never put secrets in the artifact — that bundle is browser code.
187
- - **Delete the Chainguard \`.npmrc\`** in a new function unless you have Sequence-internal registry credentials. Without them \`pnpm install\` 401s. Removing the file is the supported public path.
188
- - **Invoke functions with \`seq.functions.invoke('<slug>', body)\`**, not a raw \`seq.api.post\` to \`/api/managed-functions/…\`. Declare the slug under \`capabilities.functions.invoke\`.
189
- - **Atlas wraps many \`seq.api\` responses** as \`{ success, data }\`. Use the scaffold \`unwrap\` helper. \`seq.functions.invoke\` is already the payload.
190
- - **Do not reuse another app's identities.** If you copy files, change \`app.id\`, every primitive \`id\`, the ORM \`namespace\`, the artifact \`project_id\`, capability paths, and \`targets\`.
191
- - **Do not edit ORM \`migrations/\`.** Change \`schema/*.ts\` / \`graphql/**/*.ts\`, then generate/apply.
192
- - **Do not hardcode user emails** in policies or UI. Use \`claim('sub')\` / \`claim('org')\` and the Permissions / sharing UI.
193
-
194
- ## Further reading
195
-
196
- - [Sequence Platform docs](${SEQUENCE_DOCS_URL})
197
- - [Create your first project](${SEQUENCE_DOCS_URL}projects/create-first-project)
198
- - [Artifact Studio](${SEQUENCE_DOCS_URL}artifact-studio/overview)
199
- - [Managed Functions](${SEQUENCE_DOCS_URL}managed-functions/overview)
200
- - [Managed Secrets](${SEQUENCE_DOCS_URL}managed-secrets/overview)
201
- - [Basketball player lookup](${SEQUENCE_DOCS_URL}examples/basketball-player-lookup)
202
- - [CLI command reference](${SEQUENCE_DOCS_URL}seq-studio/commands)
203
- - [Troubleshooting](${SEQUENCE_DOCS_URL}troubleshooting)
134
+ 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](${SEQUENCE_DOCS_URL}seq-studio/commands).
204
135
  `;
205
136
  }
206
- /** README for a brand-new git-service repo that does not yet have an app scaffold. */
207
- export function renderEmptyRepoReadme({ repoName, namespaceSlug, }) {
208
- const title = titleizeSlug(repoName);
137
+ export function renderEmptyRepoReadme({ repoName, namespaceSlug }) {
209
138
  const qualified = namespaceSlug ? `${namespaceSlug}/${repoName}` : repoName;
210
139
  return `${GIT_SERVICE_SEED_MARKER}\n${renderAppReadme({
211
140
  appId: repoName,
212
- title,
213
- description: `Sequence Platform git-service repository \`${qualified}\`. Scaffold an app in this clone with \`seq-studio init\`, then validate and deploy with the same CLI.`,
141
+ description: `Sequence Platform git-service repository \`${qualified}\`. Scaffold an app in this clone, then validate and deploy with seq-studio.`,
214
142
  primitives: ['orm', 'function', 'artifact'],
215
- functionName: 'hello',
216
143
  }).replace('## Implement this app', `## Scaffold the app
217
144
 
218
- This repository was created empty except for this README. From the clone root:
145
+ From this clone's root:
219
146
 
220
147
  \`\`\`bash
221
- # into this directory (keeps the git-service remote)
222
- seq-studio init . --with function,artifact --function-name hello --description "${title}"
223
- # or the three-primitive Preview shape:
224
- # seq-studio init . --with orm,function,artifact --function-name hello
148
+ seq-studio init . --with function,artifact --function-name hello
149
+ # Include other primitives as needed:
150
+ # seq-studio init . --with orm,function,agent,process,pipeline,artifact
225
151
  \`\`\`
226
152
 
227
- \`init\` into a clone that only has this seed README (and \`.git\`) is allowed — it writes \`sequence.app.yml\` and the primitive folders, and replaces this file with an app-specific copy. \`init\` will not overwrite a README that does not contain the seed marker.
153
+ \`init\` replaces this seed README and creates the app workspace while preserving the git remote. It refuses to overwrite ordinary docs-only repositories.
228
154
 
229
155
  ## Implement this app`)}`;
230
156
  }
231
- function snake(appId) {
232
- return appId.replace(/-/g, '_');
233
- }
234
- function renderAppTree({ appId, kinds, functionName, }) {
235
- const lines = [
236
- `${appId}/`,
237
- ' README.md',
238
- ' sequence.app.yml primitives + deploy order',
239
- ];
240
- if (kinds.has('artifact')) {
241
- lines.push(' artifact/ Artifact Studio UI');
242
- }
243
- if (kinds.has('orm')) {
244
- lines.push(` orm/${snake(appId)}/ ORM namespace`);
245
- }
246
- if (kinds.has('function')) {
247
- lines.push(` functions/${functionName}/ Managed Function`);
248
- }
249
- return lines.join('\n');
250
- }
251
- function renderImplementSection({ kinds, functionName, appId, }) {
157
+ function renderImplementSection({ kinds, functionName, appId }) {
252
158
  const steps = [];
253
- if (kinds.has('function')) {
254
- steps.push(`1. **Function** — implement \`functions/${functionName}/index.ts\`. Declare every outbound host under \`egress\` in \`managed-function.yml\` (the scaffold ships with none). Declare secret *names* in \`secrets:\` and keep values in an ignored \`functions/${functionName}/.env\`.
255
-
256
- **Before \`pnpm install\`, delete \`functions/${functionName}/.npmrc\`** unless you have Sequence-internal Chainguard credentials. Without them that install 401s. Removing the file is the supported public path — the deploy worker re-resolves dependencies server-side.`);
257
- }
258
- if (kinds.has('orm')) {
259
- steps.push(`2. **ORM** — author tables and named operations under \`orm/${snake(appId)}/\` (\`sequence.config.ts\`, \`schema/*.ts\`, \`graphql/**/*.ts\`). Then:
260
-
261
- \`\`\`bash
262
- seq-studio orm generate orm/${snake(appId)}
263
- seq-studio orm plan orm/${snake(appId)} -e <environment-name>
264
- seq-studio orm apply orm/${snake(appId)} -e <environment-name>
265
- \`\`\`
266
-
267
- Grant the artifact matching \`capabilities.data\` entries (\`<namespace>/<table>\` for reads, \`<namespace>/ops/<MutationName>\` for named writes) and the Data API paths you call.`);
268
- }
269
- if (kinds.has('artifact')) {
270
- const n = steps.length + 1;
271
- steps.push(`${n}. **UI** — \`artifact/src/App.tsx\` with \`@sequenceholdings/atlas-ui\`. Delete the scaffold's \`alert()\` Atlas ping; native \`alert\` / \`confirm\` / \`prompt\` are blocked in the sandbox.
272
-
273
- If this app has a function, declare it and invoke it:
274
-
275
- \`\`\`yaml
276
- capabilities:
277
- functions:
278
- invoke:
279
- - ${functionName}
280
- \`\`\`
281
-
282
- \`\`\`ts
283
- import { seq } from './lib/api'
284
- const result = await seq.functions.invoke('${functionName}', { /* input */ })
285
- \`\`\`
286
-
287
- \`pnpm dev\` in \`artifact/\` is standalone Vite. Platform calls only work inside Preview or an official Atlas deployment.`);
288
- }
289
- steps.push(`${steps.length + 1}. **Targets** — put your environment in \`artifact.bundle.yml\` \`targets\` (if this app has an artifact). Scaffolds create \`visibility: private\`. Set \`shared\` before first create if other people must open the app.
290
-
291
- ${steps.length + 2}. **Validate, then deploy** from this directory:
292
-
293
- \`\`\`bash
294
- seq-studio deploy -e <environment-name> --dry-run
295
- seq-studio deploy -e <environment-name> --yes
296
- \`\`\`
297
-
298
- \`--dry-run\` lists which primitives would run. Until \`git status\` is clean on \`main\`, use \`seq-studio artifact dev artifact -e <environment-name>\` for the UI.`);
299
- return steps.join('\n\n');
159
+ if (kinds.has('function'))
160
+ steps.push(`- **Function:** implement \`functions/${functionName}/index.ts\`; declare egress and secret names in \`managed-function.yml\`.`);
161
+ if (kinds.has('orm'))
162
+ steps.push(`- **ORM:** author tables and operations under \`orm/${appId.replace(/-/g, '_')}/\`, then run \`seq-studio orm generate orm/${appId.replace(/-/g, '_')}\` and \`seq-studio orm diff orm/${appId.replace(/-/g, '_')}\`. Review and commit the generated \`migrations/\` ledger before the first deployment and after schema changes. Init creates namespace source; it does not create the migration baseline automatically.`);
163
+ if (kinds.has('agent'))
164
+ steps.push(`- **Agent:** edit \`agents/${appId}/agent.ts\`; run \`seq-studio agents validate --dir agents/${appId}\`.`);
165
+ if (kinds.has('process'))
166
+ steps.push(`- **Lattice:** edit \`processes/${appId}/${appId}/process.ts\`; run \`seq-studio process lint --dir processes/${appId} --offline\`.`);
167
+ if (kinds.has('pipeline'))
168
+ steps.push(`- **Pipeline:** complete \`pipelines/${appId}/${appId}.stage.yml\` and its source; run \`seq-studio pipeline validate pipelines/${appId}\`. The template is a transformation stage by default; \`--pipeline-type\` selects ingestion or serving. Pipeline deployment uses a platform git-service release unit: set this primitive's \`repo: pipelines/<repository>\` and \`ref\` in \`sequence.app.yml\`, and commit/push its source to that repository before deployment. A serving template also requires a real producing stage.`);
169
+ if (kinds.has('artifact'))
170
+ steps.push(`- **UI:** implement \`artifact/src/App.tsx\` with \`@sequenceholdings/atlas-ui\`; declare capabilities and deployment \`targets\` in \`artifact.bundle.yml\`. Scaffolds are private; set sharing intentionally. Validate with \`seq-studio artifact validate artifact\`.`);
171
+ return steps.join('\n');
300
172
  }
@@ -0,0 +1,8 @@
1
+ import type { DeployAppResult, DeployPrimitiveArgs, PrimitiveDeployers } from './deploy.js';
2
+ import type { PrimitiveEntry } from './manifest.js';
3
+ export declare function executeDeployment({ entries, onError, deployers, argsFor }: {
4
+ entries: readonly PrimitiveEntry[];
5
+ onError: 'stop' | 'continue';
6
+ deployers: PrimitiveDeployers;
7
+ argsFor: (entry: PrimitiveEntry) => DeployPrimitiveArgs;
8
+ }): Promise<DeployAppResult>;
@@ -0,0 +1,50 @@
1
+ const LOG = '[seq-studio]';
2
+ export async function executeDeployment({ entries, onError, deployers, argsFor }) {
3
+ const attempted = [];
4
+ const succeeded = [];
5
+ const failed = [];
6
+ const skipped = [];
7
+ /** Failed or dependency-skipped ids — blocks transitive `depends_on` edges. */
8
+ const unavailable = new Set();
9
+ let stop = false;
10
+ for (const entry of entries) {
11
+ if (stop) {
12
+ skipped.push(entry.id);
13
+ unavailable.add(entry.id);
14
+ console.log(`${LOG} skip ${entry.id} (stopped after earlier failure)`);
15
+ continue;
16
+ }
17
+ const blockedBy = entry.depends_on.filter((id) => unavailable.has(id));
18
+ if (blockedBy.length > 0) {
19
+ skipped.push(entry.id);
20
+ unavailable.add(entry.id);
21
+ console.log(`${LOG} skip ${entry.id} (depends on failed/skipped: ${blockedBy.join(', ')})`);
22
+ continue;
23
+ }
24
+ attempted.push(entry.id);
25
+ console.log(`${LOG} → ${entry.kind} ${entry.id}`);
26
+ let code;
27
+ try {
28
+ code = await deployers[entry.kind](argsFor(entry));
29
+ }
30
+ catch (error) {
31
+ const message = error instanceof Error ? error.message : String(error);
32
+ console.error(`${LOG} ${entry.id} threw: ${message}`);
33
+ code = 1;
34
+ }
35
+ if (code === 0) {
36
+ succeeded.push(entry.id);
37
+ console.log(`${LOG} ✓ ${entry.id}`);
38
+ }
39
+ else {
40
+ failed.push(entry.id);
41
+ unavailable.add(entry.id);
42
+ console.error(`${LOG} ✗ ${entry.id} exited ${code}`);
43
+ if (onError === 'stop')
44
+ stop = true;
45
+ }
46
+ }
47
+ const exitCode = failed.length > 0 ? 1 : 0;
48
+ console.log(`${LOG} deploy finished: ${succeeded.length} ok, ${failed.length} failed, ${skipped.length} skipped`);
49
+ return { attempted, succeeded, failed, skipped, exitCode };
50
+ }
@@ -0,0 +1,13 @@
1
+ export declare function mergeGitignore(existing: string | null): string;
2
+ interface ScaffoldSnapshot {
3
+ existed: boolean;
4
+ previousReadme: string | null;
5
+ previousGitignore: string | null;
6
+ }
7
+ export declare function inspectScaffoldTarget(appRoot: string): Promise<ScaffoldSnapshot>;
8
+ export declare function rollbackAppScaffold({ appRoot, snapshot, paths }: {
9
+ appRoot: string;
10
+ snapshot: ScaffoldSnapshot;
11
+ paths: readonly string[];
12
+ }): Promise<void>;
13
+ export {};
@@ -0,0 +1,68 @@
1
+ /** Protect existing repository content and roll back only generated scaffold files. */
2
+ import { existsSync } from 'node:fs';
3
+ import { readdir, readFile, rm, writeFile } from 'node:fs/promises';
4
+ import { join } from 'node:path';
5
+ import { isGitServiceSeedReadme } from './readme.js';
6
+ import { WORKSPACE_ROOT_FILES } from './workspace-scaffold.js';
7
+ const INIT_METADATA_ONLY = new Set(['.git', '.gitattributes', '.DS_Store']);
8
+ const INIT_ALLOWED_EXISTING = new Set([
9
+ ...INIT_METADATA_ONLY, '.gitignore', 'README.md', 'LICENSE', 'LICENSE.md',
10
+ ]);
11
+ const DEFAULT_GITIGNORE_LINES = [
12
+ 'node_modules/', 'dist/', '.env', '.env.*', '!.env.example', '.DS_Store',
13
+ '*.log', '.sequence/deployments/', '.sequence/builds/',
14
+ ];
15
+ export function mergeGitignore(existing) {
16
+ if (existing === null)
17
+ return `${DEFAULT_GITIGNORE_LINES.join('\n')}\n`;
18
+ const present = new Set(existing.split(/\r?\n/).map((line) => line.trim()));
19
+ const missing = DEFAULT_GITIGNORE_LINES.filter((line) => !present.has(line));
20
+ const base = existing.endsWith('\n') ? existing : `${existing}\n`;
21
+ return missing.length === 0 ? base : `${base}${missing.join('\n')}\n`;
22
+ }
23
+ export async function inspectScaffoldTarget(appRoot) {
24
+ if (existsSync(join(appRoot, 'sequence.app.yml'))) {
25
+ throw new Error(`${join(appRoot, 'sequence.app.yml')} already exists — refusing to re-init`);
26
+ }
27
+ const existed = existsSync(appRoot);
28
+ const entries = existed ? await readdir(appRoot) : [];
29
+ if (entries.some((name) => !INIT_ALLOWED_EXISTING.has(name))) {
30
+ 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
+ }
32
+ const previousReadme = existsSync(join(appRoot, 'README.md'))
33
+ ? await readFile(join(appRoot, 'README.md'), 'utf8') : null;
34
+ if (entries.some((name) => !INIT_METADATA_ONLY.has(name))) {
35
+ if (previousReadme === null) {
36
+ throw new Error(`${appRoot} is not empty — a git-service clone must have a README.md containing the seq-studio seed marker`);
37
+ }
38
+ if (!isGitServiceSeedReadme(previousReadme)) {
39
+ throw new Error(`${appRoot} already has a README.md that is not a git-service seed — refusing to overwrite it`);
40
+ }
41
+ }
42
+ const previousGitignore = existsSync(join(appRoot, '.gitignore'))
43
+ ? await readFile(join(appRoot, '.gitignore'), 'utf8') : null;
44
+ return { existed, previousReadme, previousGitignore };
45
+ }
46
+ export async function rollbackAppScaffold({ appRoot, snapshot, paths }) {
47
+ if (!snapshot.existed) {
48
+ await rm(appRoot, { recursive: true, force: true }).catch(() => { });
49
+ return;
50
+ }
51
+ const generated = new Set([
52
+ 'sequence.app.yml', ...WORKSPACE_ROOT_FILES,
53
+ ...paths.map((path) => path.split('/')[0]).filter((name) => Boolean(name)),
54
+ ]);
55
+ for (const name of generated) {
56
+ await rm(join(appRoot, name), { recursive: true, force: true }).catch(() => { });
57
+ }
58
+ for (const [name, previous] of [
59
+ ['README.md', snapshot.previousReadme], ['.gitignore', snapshot.previousGitignore],
60
+ ]) {
61
+ if (previous === null) {
62
+ await rm(join(appRoot, name), { force: true }).catch(() => { });
63
+ }
64
+ else {
65
+ await writeFile(join(appRoot, name), previous).catch(() => { });
66
+ }
67
+ }
68
+ }
@@ -1,27 +1,35 @@
1
1
  /**
2
- * Scaffold ORM / function / artifact into an app monorepo and keep
2
+ * Scaffold platform primitives into an app monorepo and keep
3
3
  * sequence.app.yml in sync. Delegates to each primitive's real `init`.
4
4
  */
5
5
  import { type AppManifest, type PrimitiveEntry, type PrimitiveKind } from './manifest.js';
6
+ import { type AppPipelineType } from './primitive-scaffold.js';
7
+ export type { AppPipelineType } from './primitive-scaffold.js';
6
8
  export interface ScaffoldNames {
7
9
  functionName: string;
8
10
  }
9
11
  export declare function defaultScaffoldNames(_appId: string): ScaffoldNames;
10
- export declare function initAppMonorepo({ rootDir, appId, kinds, names, description, }: {
12
+ export declare function initAppMonorepo({ rootDir, appId, kinds, names, description, pipelineType, }: {
11
13
  rootDir: string;
12
14
  appId: string;
13
15
  kinds: readonly PrimitiveKind[];
14
16
  names?: ScaffoldNames;
15
17
  description?: string;
18
+ pipelineType?: AppPipelineType;
16
19
  }): Promise<AppManifest>;
17
- export declare function addPrimitiveToApp({ rootDir, kind, name, }: {
20
+ export declare function addPrimitiveToApp({ rootDir, kind, name, pipelineType, dependsOn, }: {
18
21
  rootDir: string;
19
22
  kind: PrimitiveKind;
20
23
  name: string;
24
+ pipelineType?: AppPipelineType;
25
+ dependsOn?: string[];
21
26
  }): Promise<{
22
27
  manifest: AppManifest;
23
28
  entry: PrimitiveEntry;
24
29
  }>;
30
+ export declare function printOrmPreparation({ primitives }: {
31
+ primitives: readonly PrimitiveEntry[];
32
+ }): void;
25
33
  export declare function printInitNextSteps({ appRoot, manifest, }: {
26
34
  appRoot: string;
27
35
  manifest: AppManifest;