@sequenceholdings/studio-cli 0.3.0 → 0.4.2

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 (111) hide show
  1. package/README.md +506 -32
  2. package/dist/agents/commands.d.ts +1 -1
  3. package/dist/agents/commands.js +5 -0
  4. package/dist/agents/scaffold.js +5 -7
  5. package/dist/agents/voice-authoring.d.ts +5 -0
  6. package/dist/agents/voice-authoring.js +75 -0
  7. package/dist/agents/voice-publication.d.ts +5 -0
  8. package/dist/agents/voice-publication.js +63 -0
  9. package/dist/agents/voice-shared.d.ts +20 -0
  10. package/dist/agents/voice-shared.js +112 -0
  11. package/dist/agents/voice.d.ts +3 -0
  12. package/dist/agents/voice.js +57 -0
  13. package/dist/app/adapters.d.ts +6 -0
  14. package/dist/app/adapters.js +17 -2
  15. package/dist/app/agent-refs.d.ts +16 -0
  16. package/dist/app/agent-refs.js +36 -0
  17. package/dist/app/application-registration.d.ts +45 -8
  18. package/dist/app/application-registration.js +112 -22
  19. package/dist/app/commands.js +19 -2
  20. package/dist/app/deploy.d.ts +3 -0
  21. package/dist/app/deploy.js +18 -4
  22. package/dist/app/env-bindings.d.ts +21 -0
  23. package/dist/app/env-bindings.js +184 -0
  24. package/dist/app/manifest-validation.d.ts +8 -0
  25. package/dist/app/manifest-validation.js +97 -5
  26. package/dist/app/manifest.d.ts +45 -9
  27. package/dist/app/manifest.js +27 -1
  28. package/dist/app/primitive-scaffold.d.ts +4 -1
  29. package/dist/app/primitive-scaffold.js +4 -4
  30. package/dist/app/readme.js +11 -0
  31. package/dist/app/scaffold-files.js +1 -1
  32. package/dist/app/scaffold.d.ts +6 -4
  33. package/dist/app/scaffold.js +7 -4
  34. package/dist/app/workspace-scaffold.js +12 -7
  35. package/dist/argv.d.ts +7 -0
  36. package/dist/argv.js +56 -0
  37. package/dist/artifact/delegate.js +8 -4
  38. package/dist/atlas-client.d.ts +6 -0
  39. package/dist/atlas-client.js +39 -2
  40. package/dist/auth.d.ts +32 -0
  41. package/dist/auth.js +170 -33
  42. package/dist/bin.js +23 -4
  43. package/dist/command-contract.d.ts +137 -0
  44. package/dist/command-contract.js +43 -0
  45. package/dist/command-help.d.ts +8 -0
  46. package/dist/command-help.js +71 -0
  47. package/dist/functions/commands.d.ts +1 -1
  48. package/dist/functions/commands.js +19 -3
  49. package/dist/functions/deploy-preflight.d.ts +21 -0
  50. package/dist/functions/deploy-preflight.js +58 -0
  51. package/dist/functions/egress-postgres.d.ts +7 -0
  52. package/dist/functions/egress-postgres.js +36 -0
  53. package/dist/functions/manifest.d.ts +8 -0
  54. package/dist/functions/manifest.js +9 -0
  55. package/dist/functions/source-selection.js +4 -1
  56. package/dist/main.js +58 -20
  57. package/dist/orm/delegate.d.ts +16 -0
  58. package/dist/orm/delegate.js +140 -7
  59. package/dist/pipeline/clone-deploy.d.ts +37 -0
  60. package/dist/pipeline/clone-deploy.js +125 -0
  61. package/dist/pipeline/codegen.js +6 -2
  62. package/dist/pipeline/commands.js +21 -5
  63. package/dist/pipeline/lifecycle.d.ts +1 -0
  64. package/dist/pipeline/lifecycle.js +95 -44
  65. package/dist/pipeline/repin-orm.js +6 -2
  66. package/dist/pipeline/stage-secrets.js +1 -1
  67. package/dist/process/build.js +17 -0
  68. package/dist/process/codegen.js +16 -0
  69. package/dist/process/commands.d.ts +15 -7
  70. package/dist/process/commands.js +291 -99
  71. package/dist/process/lint.js +35 -0
  72. package/dist/process/plan-diff.js +9 -0
  73. package/dist/process/simulate.js +8 -0
  74. package/dist/release-age.d.ts +12 -0
  75. package/dist/release-age.js +24 -0
  76. package/dist/repos/commands.d.ts +1 -1
  77. package/dist/repos/commands.js +36 -7
  78. package/dist/scaffold-guidance.d.ts +4 -0
  79. package/dist/scaffold-guidance.js +15 -0
  80. package/dist/storage/commands.js +23 -1
  81. package/dist/storage/gcs-download.d.ts +13 -0
  82. package/dist/storage/gcs-download.js +41 -0
  83. package/dist/storage/import-cycle.d.ts +41 -0
  84. package/dist/storage/import-cycle.js +123 -0
  85. package/dist/storage/import-files.d.ts +30 -0
  86. package/dist/storage/import-files.js +133 -0
  87. package/dist/storage/import-gcloud.d.ts +12 -0
  88. package/dist/storage/import-gcloud.js +54 -0
  89. package/dist/storage/import-identity.d.ts +12 -0
  90. package/dist/storage/import-identity.js +15 -0
  91. package/dist/storage/import-plan.d.ts +120 -0
  92. package/dist/storage/import-plan.js +189 -0
  93. package/dist/storage/import-preflight.d.ts +36 -0
  94. package/dist/storage/import-preflight.js +62 -0
  95. package/dist/storage/import-progress-map.d.ts +5 -0
  96. package/dist/storage/import-progress-map.js +22 -0
  97. package/dist/storage/import-recover.d.ts +97 -0
  98. package/dist/storage/import-recover.js +186 -0
  99. package/dist/storage/import-run.d.ts +14 -0
  100. package/dist/storage/import-run.js +140 -0
  101. package/dist/templates/guidance/AGENTS.md +10 -0
  102. package/dist/templates/guidance/CLAUDE.md +1 -0
  103. package/dist/templates/process/package.json +2 -2
  104. package/dist/templates/process/pnpm-workspace.yaml +7 -4
  105. package/dist/validation-detail.d.ts +2 -0
  106. package/dist/validation-detail.js +20 -0
  107. package/package.json +10 -10
  108. package/templates/guidance/AGENTS.md +10 -0
  109. package/templates/guidance/CLAUDE.md +1 -0
  110. package/templates/process/package.json +2 -2
  111. package/templates/process/pnpm-workspace.yaml +7 -4
@@ -1,14 +1,18 @@
1
1
  import { dependencyOrder } from './graph.js';
2
2
  /** Primitive kinds an Application role can reach into. */
3
- const ROLE_MEMBER_KINDS = new Set(['artifact', 'function', 'orm', 'process']);
3
+ const ROLE_MEMBER_KINDS = new Set(['artifact', 'function', 'orm', 'process', 'agent']);
4
4
  /** Kinds whose floor YAML may also spell `invoker` (their native term). */
5
- const INVOKER_FLOOR_KINDS = new Set(['function', 'process']);
5
+ const INVOKER_FLOOR_KINDS = new Set(['function', 'process', 'agent']);
6
6
  /** The member tiers each kind lets a collaborator role bundle (mirrors Atlas). */
7
7
  const COLLABORATOR_TIERS_BY_KIND = {
8
8
  artifact: ['reader', 'writer'],
9
9
  function: ['reader', 'editor'],
10
10
  orm: ['reader', 'writer'],
11
11
  process: ['editor'],
12
+ pipeline: ['viewer', 'operator', 'editor'],
13
+ agent: ['editor'],
14
+ secret: ['editor'],
15
+ service_account: ['actor'],
12
16
  };
13
17
  /** v2 and v3 share the deployment graph (manifest.ts `usesAppGraph`; inlined to avoid an import cycle). */
14
18
  const usesGraph = (manifest) => manifest.schema_version >= 2;
@@ -23,7 +27,11 @@ function validateRoles({ manifest, ctx }) {
23
27
  ctx.addIssue({ code: 'custom', message: 'roles require schema_version: 3', path: ['roles'] });
24
28
  return;
25
29
  }
26
- const kindById = new Map(manifest.primitives.map((entry) => [entry.id, entry.kind]));
30
+ const kindById = new Map([
31
+ ...manifest.primitives.map((entry) => [entry.id, entry.kind]),
32
+ ...(manifest.secrets ?? []).map((secret) => [secret.id, 'secret']),
33
+ ...(manifest.service_accounts ?? []).map((account) => [account.id, 'service_account']),
34
+ ]);
27
35
  const entryById = new Map(manifest.primitives.map((entry) => [entry.id, entry]));
28
36
  const definitions = manifest.roles.definitions;
29
37
  for (const [key, definition] of Object.entries(definitions)) {
@@ -43,6 +51,18 @@ function validateRoles({ manifest, ctx }) {
43
51
  // static grant can't express it. Apps reach storage as their own identity.
44
52
  ctx.addIssue({ code: 'custom', message: "Application roles can't include workspace primitives — grant workspace access in Workspaces V2", path: at('includes', index, 'primitive') });
45
53
  }
54
+ else if (kind === 'pipeline') {
55
+ // A pipeline runs as a service principal: nothing about it is "used" at runtime.
56
+ ctx.addIssue({ code: 'custom', message: "pipelines have no runtime access to bundle — give their viewer, operator or editor tier under collaborators", path: at('includes', index, 'primitive') });
57
+ }
58
+ else if (kind === 'secret') {
59
+ // Functions and stages read a secret through their attachments; people never open one.
60
+ ctx.addIssue({ code: 'custom', message: "secrets have no runtime access to bundle — give their editor tier under collaborators", path: at('includes', index, 'primitive') });
61
+ }
62
+ else if (kind === 'service_account') {
63
+ // Members run as an account whoever uses them; people never act as it at runtime.
64
+ ctx.addIssue({ code: 'custom', message: "service accounts have no runtime access to bundle — give their actor tier under collaborators", path: at('includes', index, 'primitive') });
65
+ }
46
66
  else if (!ROLE_MEMBER_KINDS.has(kind)) {
47
67
  ctx.addIssue({ code: 'custom', message: `Application roles can't include ${kind} primitives yet`, path: at('includes', index, 'primitive') });
48
68
  }
@@ -52,6 +72,9 @@ function validateRoles({ manifest, ctx }) {
52
72
  else if (kind === 'process') {
53
73
  processIncludeIssue({ entry: entryById.get(include.primitive), include, path: at('includes', index), ctx });
54
74
  }
75
+ else if (kind === 'agent') {
76
+ agentIncludeIssue({ entry: entryById.get(include.primitive), include, path: at('includes', index), ctx });
77
+ }
55
78
  }
56
79
  }
57
80
  }
@@ -64,6 +87,8 @@ function validateCollaborators({ manifest, ctx }) {
64
87
  return;
65
88
  }
66
89
  const entryById = new Map(manifest.primitives.map((entry) => [entry.id, entry]));
90
+ const secretIds = new Set((manifest.secrets ?? []).map((secret) => secret.id));
91
+ const accountIds = new Set((manifest.service_accounts ?? []).map((account) => account.id));
67
92
  const definitions = manifest.collaborators.definitions;
68
93
  for (const [key, definition] of Object.entries(definitions)) {
69
94
  const at = (...path) => ['collaborators', 'definitions', key, ...path];
@@ -73,6 +98,18 @@ function validateCollaborators({ manifest, ctx }) {
73
98
  }
74
99
  }
75
100
  for (const [index, include] of definition.includes.entries()) {
101
+ if (accountIds.has(include.primitive)) {
102
+ if (include.tier !== 'actor') {
103
+ ctx.addIssue({ code: 'custom', message: 'service accounts offer actor — admin stays a direct grant', path: at('includes', index, 'tier') });
104
+ }
105
+ continue;
106
+ }
107
+ if (secretIds.has(include.primitive)) {
108
+ if (include.tier !== 'editor') {
109
+ ctx.addIssue({ code: 'custom', message: 'secrets offer editor — admin and owner stay direct grants', path: at('includes', index, 'tier') });
110
+ }
111
+ continue;
112
+ }
76
113
  const entry = entryById.get(include.primitive);
77
114
  const allowed = entry ? COLLABORATOR_TIERS_BY_KIND[entry.kind] : undefined;
78
115
  if (!entry) {
@@ -84,9 +121,15 @@ function validateCollaborators({ manifest, ctx }) {
84
121
  else if (!allowed.includes(include.tier)) {
85
122
  ctx.addIssue({ code: 'custom', message: `${entry.kind} primitives offer ${allowed.join(', ')} — admin and owner stay direct grants`, path: at('includes', index, 'tier') });
86
123
  }
124
+ else if (entry.kind === 'pipeline' && !entry.repo) {
125
+ ctx.addIssue({ code: 'custom', message: `set repo on "${entry.id}" so the role reaches its pipeline`, path: at('includes', index) });
126
+ }
87
127
  else if (entry.kind === 'process' && entry.only?.length !== 1) {
88
128
  ctx.addIssue({ code: 'custom', message: `set only: [<process-id>] on "${entry.id}" so the role reaches exactly one process`, path: at('includes', index) });
89
129
  }
130
+ else if (entry.kind === 'agent' && (entry.only?.length ?? 1) !== 1) {
131
+ ctx.addIssue({ code: 'custom', message: severalAgentsMessage(entry.id), path: at('includes', index) });
132
+ }
90
133
  }
91
134
  }
92
135
  }
@@ -136,12 +179,13 @@ function validateInventory({ manifest, ctx }) {
136
179
  if (usesGraph(manifest))
137
180
  validateV2Entry({ entry, index, ctx });
138
181
  }
182
+ const useTargets = validateSecrets({ manifest, ids, ctx });
139
183
  for (const [index, entry] of manifest.primitives.entries()) {
140
184
  for (const [depIndex, dep] of entry.depends_on.entries()) {
141
185
  if (!ids.has(dep))
142
186
  ctx.addIssue({ code: 'custom', message: `depends_on references unknown primitive id "${dep}"`, path: ['primitives', index, 'depends_on', depIndex] });
143
187
  }
144
- validateUses({ entry, index, ids, ctx });
188
+ validateUses({ entry, index, ids: useTargets, ctx });
145
189
  }
146
190
  const names = new Set();
147
191
  for (const [index, pkg] of (manifest.packages ?? []).entries()) {
@@ -159,7 +203,40 @@ function validateInventory({ manifest, ctx }) {
159
203
  }
160
204
  }
161
205
  }
162
- /** `uses` edges (runtime dependencies) must point at other primitives in this app, once each. */
206
+ /**
207
+ * `secrets` (schema_version 3): ids unique across primitives and secrets, one
208
+ * entry per secret name. Returns every id a `uses` edge may point at.
209
+ */
210
+ function validateSecrets({ manifest, ids, ctx, }) {
211
+ const targets = new Set(ids);
212
+ const lists = [
213
+ { field: 'secrets', what: 'secret', entries: (manifest.secrets ?? []).map((secret) => ({ id: secret.id, name: secret.name })) },
214
+ {
215
+ field: 'service_accounts',
216
+ what: 'service account',
217
+ entries: (manifest.service_accounts ?? []).map((account) => ({ id: account.id, name: account.slug })),
218
+ },
219
+ ];
220
+ for (const { field, what, entries } of lists) {
221
+ if (!manifest[field])
222
+ continue;
223
+ if (manifest.schema_version !== 3) {
224
+ ctx.addIssue({ code: 'custom', message: `${field} require schema_version: 3`, path: [field] });
225
+ continue;
226
+ }
227
+ const names = new Set();
228
+ for (const [index, entry] of entries.entries()) {
229
+ if (targets.has(entry.id))
230
+ ctx.addIssue({ code: 'custom', message: `duplicate primitive or ${what} id "${entry.id}"`, path: [field, index, 'id'] });
231
+ if (names.has(entry.name))
232
+ ctx.addIssue({ code: 'custom', message: `${what} "${entry.name}" is listed twice`, path: [field, index] });
233
+ targets.add(entry.id);
234
+ names.add(entry.name);
235
+ }
236
+ }
237
+ return targets;
238
+ }
239
+ /** `uses` edges (runtime dependencies) must point at other primitives or secrets in this app, once each. */
163
240
  function validateUses({ entry, index, ids, ctx, }) {
164
241
  const seen = new Set();
165
242
  for (const [useIndex, use] of entry.uses.entries()) {
@@ -221,3 +298,18 @@ export function validateManifestGraph(manifest, ctx) {
221
298
  }
222
299
  }
223
300
  }
301
+ const severalAgentsMessage = (id) => `"${id}" deploys several agents; set only: [<agent-id>] so the role reaches exactly one agent`;
302
+ /**
303
+ * An agent member is floor-only for runtime roles (an agent has no roles or
304
+ * capabilities), and the entry must deploy exactly one agent. `only` with
305
+ * several ids is caught here; a directory of several agents without `only`
306
+ * is caught when the deploy resolves which agent the entry deploys.
307
+ */
308
+ function agentIncludeIssue({ entry, include, path, ctx, }) {
309
+ if (include.capability !== undefined || (include.role !== 'end_user' && include.role !== 'invoker')) {
310
+ ctx.addIssue({ code: 'custom', message: 'agent primitives offer only end_user (or invoker) — not roles or capabilities', path });
311
+ }
312
+ else if ((entry?.only?.length ?? 1) !== 1) {
313
+ ctx.addIssue({ code: 'custom', message: severalAgentsMessage(entry?.id ?? ''), path });
314
+ }
315
+ }
@@ -19,12 +19,12 @@ declare const primitiveEntrySchema: z.ZodObject<{
19
19
  id: z.ZodString;
20
20
  kind: z.ZodEnum<{
21
21
  function: "function";
22
- agent: "agent";
23
22
  process: "process";
23
+ artifact: "artifact";
24
+ pipeline: "pipeline";
24
25
  orm: "orm";
26
+ agent: "agent";
25
27
  workspace: "workspace";
26
- pipeline: "pipeline";
27
- artifact: "artifact";
28
28
  }>;
29
29
  path: z.ZodString;
30
30
  depends_on: z.ZodDefault<z.ZodArray<z.ZodString>>;
@@ -81,7 +81,7 @@ export declare const applicationCapabilitiesSchema: z.ZodRecord<z.ZodString, z.Z
81
81
  * kind offers is checked in manifest-validation.ts; admin and owner never
82
82
  * are — they stay direct grants.
83
83
  */
84
- export declare const COLLABORATOR_TIERS: readonly ["reader", "writer", "editor"];
84
+ export declare const COLLABORATOR_TIERS: readonly ["viewer", "reader", "operator", "writer", "editor", "actor"];
85
85
  export type CollaboratorTier = (typeof COLLABORATOR_TIERS)[number];
86
86
  /**
87
87
  * Application collaborator roles (schema_version 3): bundle the tiers that
@@ -95,13 +95,38 @@ export declare const applicationCollaboratorsSchema: z.ZodObject<{
95
95
  includes: z.ZodDefault<z.ZodArray<z.ZodObject<{
96
96
  primitive: z.ZodString;
97
97
  tier: z.ZodEnum<{
98
+ viewer: "viewer";
99
+ editor: "editor";
98
100
  reader: "reader";
99
101
  writer: "writer";
100
- editor: "editor";
102
+ operator: "operator";
103
+ actor: "actor";
101
104
  }>;
102
105
  }, z.core.$strict>>>;
103
106
  }, z.core.$strict>>;
104
107
  }, z.core.$strict>;
108
+ /**
109
+ * Managed secrets the app's functions and pipelines read (schema_version 3).
110
+ * Not deployed from here — create and set them with `seq-studio secrets` —
111
+ * but named so collaborator roles can bundle their editor tier and `uses`
112
+ * can point at them. `name` is the secret's name in each environment.
113
+ */
114
+ declare const appSecretSchema: z.ZodObject<{
115
+ id: z.ZodString;
116
+ name: z.ZodString;
117
+ }, z.core.$strict>;
118
+ export type AppSecretEntry = z.infer<typeof appSecretSchema>;
119
+ /**
120
+ * Service accounts the app's members run as (schema_version 3). Not created
121
+ * from here — the account's admins create it in Atlas — but named so
122
+ * collaborator roles can bundle its actor tier (deploy members that run as
123
+ * it) and `uses` can point at it. `slug` is the account's slug here.
124
+ */
125
+ declare const appServiceAccountSchema: z.ZodObject<{
126
+ id: z.ZodString;
127
+ slug: z.ZodString;
128
+ }, z.core.$strict>;
129
+ export type AppServiceAccountEntry = z.infer<typeof appServiceAccountSchema>;
105
130
  export declare const appManifestSchema: z.ZodObject<{
106
131
  schema_version: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>;
107
132
  app: z.ZodObject<{
@@ -117,12 +142,12 @@ export declare const appManifestSchema: z.ZodObject<{
117
142
  id: z.ZodString;
118
143
  kind: z.ZodEnum<{
119
144
  function: "function";
120
- agent: "agent";
121
145
  process: "process";
146
+ artifact: "artifact";
147
+ pipeline: "pipeline";
122
148
  orm: "orm";
149
+ agent: "agent";
123
150
  workspace: "workspace";
124
- pipeline: "pipeline";
125
- artifact: "artifact";
126
151
  }>;
127
152
  path: z.ZodString;
128
153
  depends_on: z.ZodDefault<z.ZodArray<z.ZodString>>;
@@ -150,6 +175,14 @@ export declare const appManifestSchema: z.ZodObject<{
150
175
  stop: "stop";
151
176
  }>>;
152
177
  }, z.core.$strict>>;
178
+ secrets: z.ZodOptional<z.ZodArray<z.ZodObject<{
179
+ id: z.ZodString;
180
+ name: z.ZodString;
181
+ }, z.core.$strict>>>;
182
+ service_accounts: z.ZodOptional<z.ZodArray<z.ZodObject<{
183
+ id: z.ZodString;
184
+ slug: z.ZodString;
185
+ }, z.core.$strict>>>;
153
186
  roles: z.ZodOptional<z.ZodObject<{
154
187
  definitions: z.ZodRecord<z.ZodString, z.ZodObject<{
155
188
  description: z.ZodOptional<z.ZodString>;
@@ -168,9 +201,12 @@ export declare const appManifestSchema: z.ZodObject<{
168
201
  includes: z.ZodDefault<z.ZodArray<z.ZodObject<{
169
202
  primitive: z.ZodString;
170
203
  tier: z.ZodEnum<{
204
+ viewer: "viewer";
205
+ editor: "editor";
171
206
  reader: "reader";
172
207
  writer: "writer";
173
- editor: "editor";
208
+ operator: "operator";
209
+ actor: "actor";
174
210
  }>;
175
211
  }, z.core.$strict>>>;
176
212
  }, z.core.$strict>>;
@@ -134,7 +134,7 @@ export const applicationCapabilitiesSchema = z.record(roleKeySchema, z.object({
134
134
  * kind offers is checked in manifest-validation.ts; admin and owner never
135
135
  * are — they stay direct grants.
136
136
  */
137
- export const COLLABORATOR_TIERS = ['reader', 'writer', 'editor'];
137
+ export const COLLABORATOR_TIERS = ['viewer', 'reader', 'operator', 'writer', 'editor', 'actor'];
138
138
  const applicationCollaboratorDefinitionSchema = z
139
139
  .object({
140
140
  description: z.string().max(1024).optional(),
@@ -152,6 +152,30 @@ const applicationCollaboratorDefinitionSchema = z
152
152
  export const applicationCollaboratorsSchema = z
153
153
  .object({ definitions: z.record(roleKeySchema, applicationCollaboratorDefinitionSchema) })
154
154
  .strict();
155
+ /**
156
+ * Managed secrets the app's functions and pipelines read (schema_version 3).
157
+ * Not deployed from here — create and set them with `seq-studio secrets` —
158
+ * but named so collaborator roles can bundle their editor tier and `uses`
159
+ * can point at them. `name` is the secret's name in each environment.
160
+ */
161
+ const appSecretSchema = z
162
+ .object({
163
+ id: z.string().min(1).max(128),
164
+ name: z.string().max(255).regex(/^[A-Z][A-Z0-9_]*$/, 'secret names are UPPER_SNAKE_CASE'),
165
+ })
166
+ .strict();
167
+ /**
168
+ * Service accounts the app's members run as (schema_version 3). Not created
169
+ * from here — the account's admins create it in Atlas — but named so
170
+ * collaborator roles can bundle its actor tier (deploy members that run as
171
+ * it) and `uses` can point at it. `slug` is the account's slug here.
172
+ */
173
+ const appServiceAccountSchema = z
174
+ .object({
175
+ id: z.string().min(1).max(128),
176
+ slug: z.string().min(1).max(100).regex(/^[a-z0-9][a-z0-9-]*$/, 'service account slugs are lowercase kebab-case'),
177
+ })
178
+ .strict();
155
179
  const relativeDirectorySchema = z.string().min(1).refine((path) => path.trim() === path && !path.includes('\\') && !/^[A-Za-z]:/.test(path) &&
156
180
  !/[\x00-\x1f]/.test(path) && path.split('/').every((part) => part !== '' && part !== '.' && part !== '..'), 'path must be a relative directory within the app root');
157
181
  export const appManifestSchema = z
@@ -177,6 +201,8 @@ export const appManifestSchema = z
177
201
  on_error: z.enum(['stop', 'continue']).default('stop'),
178
202
  }).strict()
179
203
  .default({ on_error: 'stop' }),
204
+ secrets: z.array(appSecretSchema).optional(),
205
+ service_accounts: z.array(appServiceAccountSchema).optional(),
180
206
  roles: applicationRolesSchema.optional(),
181
207
  collaborators: applicationCollaboratorsSchema.optional(),
182
208
  capabilities: applicationCapabilitiesSchema.optional(),
@@ -1,5 +1,7 @@
1
1
  import { type PrimitiveEntry, type PrimitiveKind } from './manifest.js';
2
2
  export type AppPipelineType = 'ingestion' | 'transformation' | 'serving';
3
+ /** Same templates as `seq-studio artifact init --template`. */
4
+ export type AppArtifactTemplate = 'react-vite' | 'nextjs';
3
5
  export declare function primitiveIdFor({ kind, name }: {
4
6
  kind: PrimitiveKind;
5
7
  name: string;
@@ -9,10 +11,11 @@ export declare function relativePathFor({ kind, appId, name, }: {
9
11
  appId: string;
10
12
  name: string;
11
13
  }): string;
12
- export declare function scaffoldKind({ kind, appRoot, appId, name, pipelineType, }: {
14
+ export declare function scaffoldKind({ kind, appRoot, appId, name, pipelineType, artifactTemplate, }: {
13
15
  kind: PrimitiveKind;
14
16
  appRoot: string;
15
17
  appId: string;
16
18
  name: string;
17
19
  pipelineType?: AppPipelineType;
20
+ artifactTemplate?: AppArtifactTemplate;
18
21
  }): Promise<PrimitiveEntry>;
@@ -91,9 +91,9 @@ async function scaffoldOrm({ absPath }) {
91
91
  '(workspace / internal installs today; not yet available via public npm).');
92
92
  }
93
93
  }
94
- async function scaffoldArtifact({ absPath, appId, }) {
94
+ async function scaffoldArtifact({ absPath, appId, template, }) {
95
95
  const { runCli } = await import('@sequenceholdings/artifact-studio/cli');
96
- const code = await runCli(['init', absPath]);
96
+ const code = await runCli(['init', absPath, '--template', template]);
97
97
  if (code !== 0) {
98
98
  throw new Error(`artifact init failed for ${absPath} (exit ${code})`);
99
99
  }
@@ -105,7 +105,7 @@ async function scaffoldFunction({ absPath }) {
105
105
  throw new Error(`functions init failed for ${absPath} (exit ${code})`);
106
106
  }
107
107
  }
108
- export async function scaffoldKind({ kind, appRoot, appId, name, pipelineType = 'transformation', }) {
108
+ export async function scaffoldKind({ kind, appRoot, appId, name, pipelineType = 'transformation', artifactTemplate = 'react-vite', }) {
109
109
  const relPath = relativePathFor({ kind, appId, name }).replace(/\\/g, '/');
110
110
  const absPath = join(appRoot, relPath);
111
111
  const entry = buildPrimitiveEntry({ kind, appId, name, dependsOn: [] });
@@ -119,7 +119,7 @@ export async function scaffoldKind({ kind, appRoot, appId, name, pipelineType =
119
119
  break;
120
120
  case 'artifact':
121
121
  await mkdir(absPath, { recursive: true });
122
- await scaffoldArtifact({ absPath, appId: name });
122
+ await scaffoldArtifact({ absPath, appId: name, template: artifactTemplate });
123
123
  break;
124
124
  case 'agent':
125
125
  if (await agentsInitCommand(parseArgs([absPath])) !== 0) {
@@ -83,6 +83,16 @@ seq-studio doctor -e <environment-name>
83
83
 
84
84
  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.
85
85
 
86
+ For a fullstack app, scaffold with \`seq-studio init <app> --with artifact --template nextjs\`.
87
+ Its Next.js artifact uses Node.js 24 and a separate install root: run \`pnpm install\`
88
+ inside \`artifact/\` and commit \`artifact/pnpm-lock.yaml\` as well. Keep its generated
89
+ \`lint\`, \`type-check\`, \`test\` and \`build\` scripts. Repository CI runs these checks
90
+ and an SSR/API smoke test on Buildkite before packaging the validated standalone
91
+ output for the managed runtime. Configure registered resource bindings and automatic
92
+ CI in Atlas; \`sequence.app.yml\` supplies the inventory, so \`.seq/ci.json\` is optional.
93
+ Build-time values belong in \`build.public_env\` and must use \`NEXT_PUBLIC_*\` names.
94
+ Server secrets and resource credentials are attached only at runtime.
95
+
86
96
  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.
87
97
 
88
98
  ## Shared packages
@@ -132,6 +142,7 @@ seq-studio deploy -e <environment-name> --yes
132
142
  - **ORM** policies enforce caller access. Change TypeScript schema and operations, then generate migrations; do not edit generated migrations by hand.
133
143
  - **Agent and process identities** are durable. Keep the generated identities stable when changing implementation; generate new identities when copying a resource.
134
144
  - **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.
145
+ - **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.
135
146
 
136
147
  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).
137
148
  `;
@@ -49,7 +49,7 @@ export async function rollbackAppScaffold({ appRoot, snapshot, paths }) {
49
49
  return;
50
50
  }
51
51
  const generated = new Set([
52
- 'sequence.app.yml', ...WORKSPACE_ROOT_FILES,
52
+ 'sequence.app.yml', 'AGENTS.md', 'CLAUDE.md', ...WORKSPACE_ROOT_FILES,
53
53
  ...paths.map((path) => path.split('/')[0]).filter((name) => Boolean(name)),
54
54
  ]);
55
55
  for (const name of generated) {
@@ -3,25 +3,27 @@
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
+ import { type AppArtifactTemplate, type AppPipelineType } from './primitive-scaffold.js';
7
+ export type { AppArtifactTemplate, AppPipelineType } from './primitive-scaffold.js';
8
8
  export interface ScaffoldNames {
9
9
  functionName: string;
10
10
  }
11
11
  export declare function defaultScaffoldNames(_appId: string): ScaffoldNames;
12
- export declare function initAppMonorepo({ rootDir, appId, kinds, names, description, pipelineType, }: {
12
+ export declare function initAppMonorepo({ rootDir, appId, kinds, names, description, pipelineType, artifactTemplate, }: {
13
13
  rootDir: string;
14
14
  appId: string;
15
15
  kinds: readonly PrimitiveKind[];
16
16
  names?: ScaffoldNames;
17
17
  description?: string;
18
18
  pipelineType?: AppPipelineType;
19
+ artifactTemplate?: AppArtifactTemplate;
19
20
  }): Promise<AppManifest>;
20
- export declare function addPrimitiveToApp({ rootDir, kind, name, pipelineType, dependsOn, }: {
21
+ export declare function addPrimitiveToApp({ rootDir, kind, name, pipelineType, artifactTemplate, dependsOn, }: {
21
22
  rootDir: string;
22
23
  kind: PrimitiveKind;
23
24
  name: string;
24
25
  pipelineType?: AppPipelineType;
26
+ artifactTemplate?: AppArtifactTemplate;
25
27
  dependsOn?: string[];
26
28
  }): Promise<{
27
29
  manifest: AppManifest;
@@ -9,6 +9,7 @@ import { currentVersion, isNewerVersion } from '../update-check.js';
9
9
  import { extendDeployOrder, loadAppManifest, titleizeSlug, writeAppManifest, } from './manifest.js';
10
10
  import { inspectScaffoldTarget, mergeGitignore, rollbackAppScaffold } from './scaffold-files.js';
11
11
  import { renderAppReadme } from './readme.js';
12
+ import { writeScaffoldGuidance } from '../scaffold-guidance.js';
12
13
  import { primitiveIdFor, relativePathFor, scaffoldKind } from './primitive-scaffold.js';
13
14
  import { joinAppWorkspace, scaffoldAppWorkspace, scaffoldSharedPackage } from './workspace-scaffold.js';
14
15
  const LOG = '[seq-studio]';
@@ -31,7 +32,7 @@ function applyDefaultDependsOn(primitives) {
31
32
  return { ...entry, depends_on: [orm.id] };
32
33
  });
33
34
  }
34
- export async function initAppMonorepo({ rootDir, appId, kinds, names = defaultScaffoldNames(appId), description, pipelineType, }) {
35
+ export async function initAppMonorepo({ rootDir, appId, kinds, names = defaultScaffoldNames(appId), description, pipelineType, artifactTemplate, }) {
35
36
  if (kinds.length === 0) {
36
37
  throw new Error('select at least one primitive via --with orm,workspace,function,agent,process,pipeline,artifact (or --orm --function …)');
37
38
  }
@@ -41,11 +42,12 @@ export async function initAppMonorepo({ rootDir, appId, kinds, names = defaultSc
41
42
  const snapshot = await inspectScaffoldTarget(appRoot);
42
43
  await mkdir(appRoot, { recursive: true });
43
44
  try {
45
+ await writeScaffoldGuidance({ directory: appRoot });
44
46
  const version = currentVersion();
45
47
  const primitives = [];
46
48
  for (const kind of kinds) {
47
49
  const name = kind === 'function' ? names.functionName : appId;
48
- primitives.push(await scaffoldKind({ kind, appRoot, appId, name, pipelineType }));
50
+ primitives.push(await scaffoldKind({ kind, appRoot, appId, name, pipelineType, artifactTemplate }));
49
51
  }
50
52
  const withDeps = applyDefaultDependsOn(primitives);
51
53
  const shared = await scaffoldSharedPackage({ rootDir: appRoot, appId, name: 'shared' });
@@ -89,7 +91,7 @@ export async function initAppMonorepo({ rootDir, appId, kinds, names = defaultSc
89
91
  throw error;
90
92
  }
91
93
  }
92
- export async function addPrimitiveToApp({ rootDir, kind, name, pipelineType, dependsOn, }) {
94
+ export async function addPrimitiveToApp({ rootDir, kind, name, pipelineType, artifactTemplate, dependsOn, }) {
93
95
  const appRoot = resolve(rootDir);
94
96
  const manifest = await loadAppManifest(appRoot);
95
97
  const appId = manifest.app.id;
@@ -115,7 +117,7 @@ export async function addPrimitiveToApp({ rootDir, kind, name, pipelineType, dep
115
117
  const workspacePath = join(appRoot, 'pnpm-workspace.yaml');
116
118
  const previousWorkspace = existsSync(workspacePath) ? await readFile(workspacePath, 'utf8') : null;
117
119
  try {
118
- let entry = await scaffoldKind({ kind, appRoot, appId, name, pipelineType });
120
+ let entry = await scaffoldKind({ kind, appRoot, appId, name, pipelineType, artifactTemplate });
119
121
  const orm = manifest.primitives.find((item) => item.kind === 'orm');
120
122
  if (dependsOn !== undefined) {
121
123
  entry = { ...entry, depends_on: dependsOn };
@@ -173,6 +175,7 @@ export function printInitNextSteps({ appRoot, manifest, }) {
173
175
  const rel = relative(process.cwd(), appRoot);
174
176
  const display = !rel || rel.startsWith('..') ? appRoot : rel;
175
177
  console.log(`${LOG} scaffolded app "${manifest.app.id}" in ${display}`);
178
+ console.log(`${LOG} AGENTS.md points to your environment's live docs; CLAUDE.md imports it`);
176
179
  console.log(`${LOG} wrote README.md (Sequence app docs) and ${APP_MANIFEST_LABEL} with ${manifest.primitives.length} primitive(s):`);
177
180
  for (const entry of manifest.primitives) {
178
181
  console.log(`${LOG} - ${entry.kind.padEnd(9)} ${entry.id} (${entry.path})`);
@@ -5,10 +5,20 @@ import { dump as yamlDump, load as yamlLoad } from 'js-yaml';
5
5
  import { z } from 'zod';
6
6
  import { loadAppManifest, usesAppGraph, writeAppManifest } from './manifest.js';
7
7
  import { currentVersion } from '../update-check.js';
8
+ import { FIRST_PARTY_RELEASE_AGE_EXCLUDE } from '../release-age.js';
8
9
  const packageSchema = z.looseObject({
9
10
  dependencies: z.record(z.string(), z.string()).optional(),
10
11
  pnpm: z.strictObject({ overrides: z.record(z.string(), z.string()).optional() }).optional(),
11
12
  });
13
+ const artifactTypeSchema = z.looseObject({ artifact: z.looseObject({ type: z.string().optional() }) });
14
+ /** Hosted Next.js builds need a standalone lockfile with one root importer and no workspace: links. */
15
+ async function isStandaloneNextArtifact({ entry, directory }) {
16
+ const manifestPath = join(directory, 'artifact.bundle.yml');
17
+ if (entry.kind !== 'artifact' || !existsSync(manifestPath))
18
+ return false;
19
+ const parsed = artifactTypeSchema.safeParse(yamlLoad(await readFile(manifestPath, 'utf8')));
20
+ return parsed.success && parsed.data.artifact.type === 'nextjs';
21
+ }
12
22
  const workspaceSchema = z.looseObject({
13
23
  packages: z.array(z.string()).optional(),
14
24
  overrides: z.record(z.string(), z.string()).optional(),
@@ -51,7 +61,7 @@ export async function joinAppWorkspace({ rootDir, manifest, entries, }) {
51
61
  for (const entry of entries) {
52
62
  const directory = join(rootDir, entry.path);
53
63
  const packagePath = join(directory, 'package.json');
54
- if (!existsSync(packagePath))
64
+ if (!existsSync(packagePath) || await isStandaloneNextArtifact({ entry, directory }))
55
65
  continue;
56
66
  const pkg = packageSchema.parse(JSON.parse(await readFile(packagePath, 'utf8')));
57
67
  const { pnpm, ...packageFields } = pkg;
@@ -89,12 +99,7 @@ export async function scaffoldAppWorkspace({ rootDir, manifest, }) {
89
99
  await writeFile(join(rootDir, 'pnpm-workspace.yaml'), yamlDump({
90
100
  packages: [],
91
101
  minimumReleaseAge: 10080,
92
- minimumReleaseAgeExclude: [
93
- '@sequenceholdings/agent-spec', '@sequenceholdings/atlas-ui',
94
- '@sequenceholdings/lattice-form-renderer', '@sequenceholdings/artifact-studio',
95
- '@sequenceholdings/lattice', '@sequenceholdings/orm',
96
- '@sequenceholdings/pipeline-spec', '@sequenceholdings/studio-cli',
97
- ],
102
+ minimumReleaseAgeExclude: [...FIRST_PARTY_RELEASE_AGE_EXCLUDE],
98
103
  strictDepBuilds: true,
99
104
  allowBuilds: { esbuild: true },
100
105
  }));
package/dist/argv.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export interface ParsedArgs {
2
+ positional: string[];
3
+ flags: Record<string, string | true>;
4
+ /** All string values for flags supplied more than once; flags keeps the last value. */
5
+ repeatedFlags?: Record<string, string[]>;
6
+ }
7
+ export declare function parseArgs(rest: string[]): ParsedArgs;
package/dist/argv.js ADDED
@@ -0,0 +1,56 @@
1
+ const SHORT_FLAG_ALIASES = { '-e': 'env', '-m': 'message', '-o': 'out' };
2
+ export function parseArgs(rest) {
3
+ const positional = [];
4
+ const flags = {};
5
+ const repeatedFlags = {};
6
+ const setFlag = (key, value) => {
7
+ flags[key] = value;
8
+ if (typeof value === 'string')
9
+ (repeatedFlags[key] ??= []).push(value);
10
+ };
11
+ for (let i = 0; i < rest.length; i++) {
12
+ const arg = rest[i];
13
+ if (arg === '--') {
14
+ positional.push(...rest.slice(i + 1));
15
+ break;
16
+ }
17
+ if (arg.startsWith('--')) {
18
+ const body = arg.slice(2);
19
+ const eqIdx = body.indexOf('=');
20
+ if (eqIdx >= 0) {
21
+ setFlag(body.slice(0, eqIdx), body.slice(eqIdx + 1));
22
+ continue;
23
+ }
24
+ const next = rest[i + 1];
25
+ if (next && !next.startsWith('-')) {
26
+ setFlag(body, next);
27
+ i += 1;
28
+ }
29
+ else
30
+ setFlag(body, true);
31
+ }
32
+ else if (arg.startsWith('-') && arg.length >= 2 && !arg.startsWith('--')) {
33
+ const eqIdx = arg.indexOf('=');
34
+ const shortName = eqIdx >= 0 ? arg.slice(0, eqIdx) : arg;
35
+ const longName = SHORT_FLAG_ALIASES[shortName];
36
+ if (!longName || shortName.length !== 2) {
37
+ positional.push(arg);
38
+ continue;
39
+ }
40
+ if (eqIdx >= 0) {
41
+ setFlag(longName, arg.slice(eqIdx + 1));
42
+ continue;
43
+ }
44
+ const next = rest[i + 1];
45
+ if (next && !next.startsWith('-')) {
46
+ setFlag(longName, next);
47
+ i += 1;
48
+ }
49
+ else
50
+ setFlag(longName, true);
51
+ }
52
+ else
53
+ positional.push(arg);
54
+ }
55
+ return { positional, flags, ...(Object.keys(repeatedFlags).length ? { repeatedFlags } : {}) };
56
+ }