@sequenceholdings/studio-cli 0.4.2 → 0.4.5
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.
- package/README.md +83 -18
- package/dist/app/agent-refs.d.ts +16 -0
- package/dist/app/agent-refs.js +18 -6
- package/dist/app/application-registration.d.ts +11 -3
- package/dist/app/application-registration.js +20 -6
- package/dist/app/application-suggestions.d.ts +58 -0
- package/dist/app/application-suggestions.js +164 -0
- package/dist/app/deploy.js +7 -4
- package/dist/app/env-bindings.js +2 -2
- package/dist/app/manifest-validation.d.ts +5 -0
- package/dist/app/manifest-validation.js +60 -22
- package/dist/app/manifest.d.ts +33 -0
- package/dist/app/manifest.js +16 -0
- package/dist/app/readme.d.ts +6 -3
- package/dist/app/readme.js +36 -6
- package/dist/app/scaffold.js +2 -1
- package/dist/artifact/delegate.js +6 -34
- package/dist/auth-cmds/commands.js +2 -2
- package/dist/auth.d.ts +0 -9
- package/dist/auth.js +2 -29
- package/dist/config.d.ts +7 -20
- package/dist/config.js +22 -64
- package/dist/envs/commands.js +17 -67
- package/dist/functions/commands.js +2 -2
- package/dist/login.d.ts +0 -6
- package/dist/login.js +3 -34
- package/dist/main.js +2 -2
- package/dist/orm/delegate.js +2 -2
- package/dist/pipeline/discovery.js +2 -2
- package/dist/pipeline/lifecycle.js +2 -2
- package/dist/pipeline/repin-orm.js +3 -3
- package/dist/process/commands.js +4 -8
- package/dist/repos/commands.js +2 -2
- package/dist/storage/commands.js +2 -2
- package/package.json +9 -9
- package/dist/env-catalog.d.ts +0 -63
- package/dist/env-catalog.js +0 -121
|
@@ -29,10 +29,11 @@ function validateRoles({ manifest, ctx }) {
|
|
|
29
29
|
}
|
|
30
30
|
const kindById = new Map([
|
|
31
31
|
...manifest.primitives.map((entry) => [entry.id, entry.kind]),
|
|
32
|
-
...(manifest
|
|
33
|
-
...(manifest.service_accounts ?? []).map((account) => [account.id, 'service_account']),
|
|
32
|
+
...referenceKinds(manifest),
|
|
34
33
|
]);
|
|
35
34
|
const entryById = new Map(manifest.primitives.map((entry) => [entry.id, entry]));
|
|
35
|
+
// An existing member's ref names exactly one host: the deploy-only checks don't apply.
|
|
36
|
+
const existingIds = new Set((manifest.existing ?? []).map((entry) => entry.id));
|
|
36
37
|
const definitions = manifest.roles.definitions;
|
|
37
38
|
for (const [key, definition] of Object.entries(definitions)) {
|
|
38
39
|
const at = (...path) => ['roles', 'definitions', key, ...path];
|
|
@@ -70,7 +71,7 @@ function validateRoles({ manifest, ctx }) {
|
|
|
70
71
|
ctx.addIssue({ code: 'custom', message: `invoker is the function and process floor; use end_user for ${kind} primitives`, path: at('includes', index, 'role') });
|
|
71
72
|
}
|
|
72
73
|
else if (kind === 'process') {
|
|
73
|
-
processIncludeIssue({ entry: entryById.get(include.primitive), include, path: at('includes', index), ctx });
|
|
74
|
+
processIncludeIssue({ entry: entryById.get(include.primitive), existing: existingIds.has(include.primitive), include, path: at('includes', index), ctx });
|
|
74
75
|
}
|
|
75
76
|
else if (kind === 'agent') {
|
|
76
77
|
agentIncludeIssue({ entry: entryById.get(include.primitive), include, path: at('includes', index), ctx });
|
|
@@ -87,8 +88,7 @@ function validateCollaborators({ manifest, ctx }) {
|
|
|
87
88
|
return;
|
|
88
89
|
}
|
|
89
90
|
const entryById = new Map(manifest.primitives.map((entry) => [entry.id, entry]));
|
|
90
|
-
const
|
|
91
|
-
const accountIds = new Set((manifest.service_accounts ?? []).map((account) => account.id));
|
|
91
|
+
const referenced = new Map(referenceKinds(manifest));
|
|
92
92
|
const definitions = manifest.collaborators.definitions;
|
|
93
93
|
for (const [key, definition] of Object.entries(definitions)) {
|
|
94
94
|
const at = (...path) => ['collaborators', 'definitions', key, ...path];
|
|
@@ -98,16 +98,11 @@ function validateCollaborators({ manifest, ctx }) {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
for (const [index, include] of definition.includes.entries()) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
}
|
|
101
|
+
const referencedKind = referenced.get(include.primitive);
|
|
102
|
+
if (referencedKind) {
|
|
103
|
+
const issue = referencedTierIssue(referencedKind, include.tier);
|
|
104
|
+
if (issue)
|
|
105
|
+
ctx.addIssue({ code: 'custom', message: issue, path: at('includes', index, 'tier') });
|
|
111
106
|
continue;
|
|
112
107
|
}
|
|
113
108
|
const entry = entryById.get(include.primitive);
|
|
@@ -133,16 +128,35 @@ function validateCollaborators({ manifest, ctx }) {
|
|
|
133
128
|
}
|
|
134
129
|
}
|
|
135
130
|
}
|
|
131
|
+
/** Members the manifest names without deploying — secrets, service accounts, existing members — by id. */
|
|
132
|
+
function referenceKinds(manifest) {
|
|
133
|
+
return [
|
|
134
|
+
...(manifest.secrets ?? []).map((secret) => [secret.id, 'secret']),
|
|
135
|
+
...(manifest.service_accounts ?? []).map((account) => [account.id, 'service_account']),
|
|
136
|
+
...(manifest.existing ?? []).map((entry) => [entry.id, entry.kind]),
|
|
137
|
+
];
|
|
138
|
+
}
|
|
139
|
+
/** Why a collaborator role can't give `tier` on a referenced member, or null when it can. */
|
|
140
|
+
function referencedTierIssue(kind, tier) {
|
|
141
|
+
const tiers = COLLABORATOR_TIERS_BY_KIND[kind] ?? [];
|
|
142
|
+
if (tiers.includes(tier))
|
|
143
|
+
return null;
|
|
144
|
+
if (kind === 'service_account')
|
|
145
|
+
return 'service accounts offer actor — admin stays a direct grant';
|
|
146
|
+
if (kind === 'secret')
|
|
147
|
+
return 'secrets offer editor — admin and owner stay direct grants';
|
|
148
|
+
return `${kind} members offer ${tiers.join(', ')} — admin and owner stay direct grants`;
|
|
149
|
+
}
|
|
136
150
|
/**
|
|
137
151
|
* A process member is floor-only (a Lattice process has no roles or
|
|
138
152
|
* capabilities), and the entry must deploy exactly one process so Atlas
|
|
139
153
|
* knows which one the role reaches.
|
|
140
154
|
*/
|
|
141
|
-
function processIncludeIssue({ entry, include, path, ctx, }) {
|
|
155
|
+
function processIncludeIssue({ entry, existing = false, include, path, ctx, }) {
|
|
142
156
|
if (include.capability !== undefined || (include.role !== 'end_user' && include.role !== 'invoker')) {
|
|
143
157
|
ctx.addIssue({ code: 'custom', message: 'process primitives offer only end_user (or invoker) — not roles or capabilities', path });
|
|
144
158
|
}
|
|
145
|
-
else if (entry?.only?.length !== 1) {
|
|
159
|
+
else if (!existing && entry?.only?.length !== 1) {
|
|
146
160
|
ctx.addIssue({ code: 'custom', message: `set only: [<process-id>] on "${entry?.id ?? ''}" so the role reaches exactly one process`, path });
|
|
147
161
|
}
|
|
148
162
|
}
|
|
@@ -166,16 +180,34 @@ function validateV2Entry({ entry, index, ctx }) {
|
|
|
166
180
|
issue('target is supported for agent/pipeline deployments', 'target');
|
|
167
181
|
}
|
|
168
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Why `entry` can't share its path with the entries already on it, or null.
|
|
185
|
+
* Agent and process entries may, when each selects its own definitions with
|
|
186
|
+
* `only` — so one directory of several agents can be several members.
|
|
187
|
+
*/
|
|
188
|
+
function sharedPathIssue(sharing, entry) {
|
|
189
|
+
if (sharing.length === 0)
|
|
190
|
+
return null;
|
|
191
|
+
const selective = (candidate) => (candidate.kind === 'agent' || candidate.kind === 'process') && candidate.kind === entry.kind && (candidate.only?.length ?? 0) > 0;
|
|
192
|
+
if (!selective(entry) || !sharing.every(selective)) {
|
|
193
|
+
return `duplicate primitive path "${entry.path}" — agent and process entries can share one when each selects different definitions with only`;
|
|
194
|
+
}
|
|
195
|
+
const taken = sharing.flatMap((other) => (other.only ?? []).map((id) => [id, other.id]));
|
|
196
|
+
const clash = taken.find(([id]) => entry.only?.includes(id));
|
|
197
|
+
return clash ? `"${clash[1]}" and "${entry.id}" both select "${clash[0]}" from "${entry.path}"` : null;
|
|
198
|
+
}
|
|
169
199
|
function validateInventory({ manifest, ctx }) {
|
|
170
200
|
const ids = new Set();
|
|
171
|
-
const
|
|
201
|
+
const byPath = new Map();
|
|
172
202
|
for (const [index, entry] of manifest.primitives.entries()) {
|
|
173
203
|
if (ids.has(entry.id))
|
|
174
204
|
ctx.addIssue({ code: 'custom', message: `duplicate primitive id "${entry.id}"`, path: ['primitives', index, 'id'] });
|
|
175
|
-
|
|
176
|
-
|
|
205
|
+
const sharing = byPath.get(entry.path) ?? [];
|
|
206
|
+
const issue = sharedPathIssue(sharing, entry);
|
|
207
|
+
if (issue)
|
|
208
|
+
ctx.addIssue({ code: 'custom', message: issue, path: ['primitives', index, 'path'] });
|
|
177
209
|
ids.add(entry.id);
|
|
178
|
-
|
|
210
|
+
byPath.set(entry.path, [...sharing, entry]);
|
|
179
211
|
if (usesGraph(manifest))
|
|
180
212
|
validateV2Entry({ entry, index, ctx });
|
|
181
213
|
}
|
|
@@ -188,6 +220,7 @@ function validateInventory({ manifest, ctx }) {
|
|
|
188
220
|
validateUses({ entry, index, ids: useTargets, ctx });
|
|
189
221
|
}
|
|
190
222
|
const names = new Set();
|
|
223
|
+
const paths = new Set(byPath.keys());
|
|
191
224
|
for (const [index, pkg] of (manifest.packages ?? []).entries()) {
|
|
192
225
|
if (names.has(pkg.name) || paths.has(pkg.path))
|
|
193
226
|
ctx.addIssue({ code: 'custom', message: 'duplicate shared package name or path', path: ['packages', index] });
|
|
@@ -216,6 +249,11 @@ function validateSecrets({ manifest, ids, ctx, }) {
|
|
|
216
249
|
what: 'service account',
|
|
217
250
|
entries: (manifest.service_accounts ?? []).map((account) => ({ id: account.id, name: account.slug })),
|
|
218
251
|
},
|
|
252
|
+
{
|
|
253
|
+
field: 'existing',
|
|
254
|
+
what: 'existing member',
|
|
255
|
+
entries: (manifest.existing ?? []).map((entry) => ({ id: entry.id, name: `${entry.kind} ${entry.ref}` })),
|
|
256
|
+
},
|
|
219
257
|
];
|
|
220
258
|
for (const { field, what, entries } of lists) {
|
|
221
259
|
if (!manifest[field])
|
|
@@ -298,7 +336,7 @@ export function validateManifestGraph(manifest, ctx) {
|
|
|
298
336
|
}
|
|
299
337
|
}
|
|
300
338
|
}
|
|
301
|
-
const severalAgentsMessage = (id) => `"${id}" deploys several agents;
|
|
339
|
+
const severalAgentsMessage = (id) => `"${id}" deploys several agents; give each its own entry with only: [<agent-id>] (entries may share the path) so the role reaches exactly one agent`;
|
|
302
340
|
/**
|
|
303
341
|
* An agent member is floor-only for runtime roles (an agent has no roles or
|
|
304
342
|
* capabilities), and the entry must deploy exactly one agent. `only` with
|
package/dist/app/manifest.d.ts
CHANGED
|
@@ -127,6 +127,27 @@ declare const appServiceAccountSchema: z.ZodObject<{
|
|
|
127
127
|
slug: z.ZodString;
|
|
128
128
|
}, z.core.$strict>;
|
|
129
129
|
export type AppServiceAccountEntry = z.infer<typeof appServiceAccountSchema>;
|
|
130
|
+
/** Kinds an Application can include without deploying them. */
|
|
131
|
+
export declare const EXISTING_MEMBER_KINDS: readonly ["artifact", "function", "orm", "process", "agent", "pipeline"];
|
|
132
|
+
/**
|
|
133
|
+
* Something already deployed elsewhere that the Application includes without
|
|
134
|
+
* deploying it, by the stable name Atlas knows it by: a function's slug, a
|
|
135
|
+
* namespace, a process id, an agent id, an artifact's slug, or a
|
|
136
|
+
* pipeline's release unit (`pipelines/<name>`).
|
|
137
|
+
*/
|
|
138
|
+
declare const appExistingSchema: z.ZodObject<{
|
|
139
|
+
id: z.ZodString;
|
|
140
|
+
kind: z.ZodEnum<{
|
|
141
|
+
function: "function";
|
|
142
|
+
process: "process";
|
|
143
|
+
artifact: "artifact";
|
|
144
|
+
pipeline: "pipeline";
|
|
145
|
+
orm: "orm";
|
|
146
|
+
agent: "agent";
|
|
147
|
+
}>;
|
|
148
|
+
ref: z.ZodString;
|
|
149
|
+
}, z.core.$strict>;
|
|
150
|
+
export type AppExistingEntry = z.infer<typeof appExistingSchema>;
|
|
130
151
|
export declare const appManifestSchema: z.ZodObject<{
|
|
131
152
|
schema_version: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>;
|
|
132
153
|
app: z.ZodObject<{
|
|
@@ -183,6 +204,18 @@ export declare const appManifestSchema: z.ZodObject<{
|
|
|
183
204
|
id: z.ZodString;
|
|
184
205
|
slug: z.ZodString;
|
|
185
206
|
}, z.core.$strict>>>;
|
|
207
|
+
existing: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
208
|
+
id: z.ZodString;
|
|
209
|
+
kind: z.ZodEnum<{
|
|
210
|
+
function: "function";
|
|
211
|
+
process: "process";
|
|
212
|
+
artifact: "artifact";
|
|
213
|
+
pipeline: "pipeline";
|
|
214
|
+
orm: "orm";
|
|
215
|
+
agent: "agent";
|
|
216
|
+
}>;
|
|
217
|
+
ref: z.ZodString;
|
|
218
|
+
}, z.core.$strict>>>;
|
|
186
219
|
roles: z.ZodOptional<z.ZodObject<{
|
|
187
220
|
definitions: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
188
221
|
description: z.ZodOptional<z.ZodString>;
|
package/dist/app/manifest.js
CHANGED
|
@@ -176,6 +176,21 @@ const appServiceAccountSchema = z
|
|
|
176
176
|
slug: z.string().min(1).max(100).regex(/^[a-z0-9][a-z0-9-]*$/, 'service account slugs are lowercase kebab-case'),
|
|
177
177
|
})
|
|
178
178
|
.strict();
|
|
179
|
+
/** Kinds an Application can include without deploying them. */
|
|
180
|
+
export const EXISTING_MEMBER_KINDS = ['artifact', 'function', 'orm', 'process', 'agent', 'pipeline'];
|
|
181
|
+
/**
|
|
182
|
+
* Something already deployed elsewhere that the Application includes without
|
|
183
|
+
* deploying it, by the stable name Atlas knows it by: a function's slug, a
|
|
184
|
+
* namespace, a process id, an agent id, an artifact's slug, or a
|
|
185
|
+
* pipeline's release unit (`pipelines/<name>`).
|
|
186
|
+
*/
|
|
187
|
+
const appExistingSchema = z
|
|
188
|
+
.object({
|
|
189
|
+
id: z.string().min(1).max(128),
|
|
190
|
+
kind: z.enum(EXISTING_MEMBER_KINDS),
|
|
191
|
+
ref: z.string().min(1).max(255),
|
|
192
|
+
})
|
|
193
|
+
.strict();
|
|
179
194
|
const relativeDirectorySchema = z.string().min(1).refine((path) => path.trim() === path && !path.includes('\\') && !/^[A-Za-z]:/.test(path) &&
|
|
180
195
|
!/[\x00-\x1f]/.test(path) && path.split('/').every((part) => part !== '' && part !== '.' && part !== '..'), 'path must be a relative directory within the app root');
|
|
181
196
|
export const appManifestSchema = z
|
|
@@ -203,6 +218,7 @@ export const appManifestSchema = z
|
|
|
203
218
|
.default({ on_error: 'stop' }),
|
|
204
219
|
secrets: z.array(appSecretSchema).optional(),
|
|
205
220
|
service_accounts: z.array(appServiceAccountSchema).optional(),
|
|
221
|
+
existing: z.array(appExistingSchema).optional(),
|
|
206
222
|
roles: applicationRolesSchema.optional(),
|
|
207
223
|
collaborators: applicationCollaboratorsSchema.optional(),
|
|
208
224
|
capabilities: applicationCapabilitiesSchema.optional(),
|
package/dist/app/readme.d.ts
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
/** App README generated by init; git-service seed detection stays stable. */
|
|
2
2
|
import { type PrimitiveKind } from './manifest.js';
|
|
3
|
-
export declare const SEQUENCE_DOCS_URL = "https://docs.seqholdings.com/";
|
|
4
3
|
/** Keep identical to atlas/src/server/services/git-service/initial-readme.ts. */
|
|
5
4
|
export declare const GIT_SERVICE_SEED_MARKER = "<!-- seq-studio:git-service-seed -->";
|
|
6
5
|
export declare function isGitServiceSeedReadme(body: string): boolean;
|
|
7
|
-
|
|
6
|
+
/** Keep the marker format identical to the git-service initial README renderer. */
|
|
7
|
+
export declare function readGitServiceSeedAtlasOrigin(body: string | null): string | undefined;
|
|
8
|
+
export declare const README_REQUIRED_SECTIONS: readonly ["/docs", "Artifact Studio", "ORM", "Managed Function", "seq-studio init", "seq.functions.invoke"];
|
|
8
9
|
export interface AppReadmeInput {
|
|
9
10
|
appId: string;
|
|
10
11
|
title?: string;
|
|
11
12
|
description?: string;
|
|
12
13
|
primitives: readonly PrimitiveKind[];
|
|
13
14
|
functionName?: string;
|
|
15
|
+
atlasOrigin?: string;
|
|
14
16
|
}
|
|
15
17
|
export declare function renderAppReadme(input: AppReadmeInput): string;
|
|
16
|
-
export declare function renderEmptyRepoReadme({ repoName, namespaceSlug }: {
|
|
18
|
+
export declare function renderEmptyRepoReadme({ repoName, namespaceSlug, atlasOrigin }: {
|
|
17
19
|
repoName: string;
|
|
18
20
|
namespaceSlug?: string;
|
|
21
|
+
atlasOrigin?: string;
|
|
19
22
|
}): string;
|
package/dist/app/readme.js
CHANGED
|
@@ -1,13 +1,37 @@
|
|
|
1
1
|
/** App README generated by init; git-service seed detection stays stable. */
|
|
2
2
|
import { titleizeSlug } from './manifest.js';
|
|
3
|
-
export const SEQUENCE_DOCS_URL = 'https://docs.seqholdings.com/';
|
|
4
3
|
/** Keep identical to atlas/src/server/services/git-service/initial-readme.ts. */
|
|
5
4
|
export const GIT_SERVICE_SEED_MARKER = '<!-- seq-studio:git-service-seed -->';
|
|
6
5
|
export function isGitServiceSeedReadme(body) {
|
|
7
6
|
return body.includes(GIT_SERVICE_SEED_MARKER);
|
|
8
7
|
}
|
|
8
|
+
function normalizeAtlasOrigin(value) {
|
|
9
|
+
if (!value)
|
|
10
|
+
return undefined;
|
|
11
|
+
try {
|
|
12
|
+
const url = new URL(value);
|
|
13
|
+
if (!['https:', 'http:'].includes(url.protocol) || url.username || url.password
|
|
14
|
+
|| url.pathname !== '/' || url.search || url.hash)
|
|
15
|
+
return undefined;
|
|
16
|
+
return url.origin;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** Keep the marker format identical to the git-service initial README renderer. */
|
|
23
|
+
export function readGitServiceSeedAtlasOrigin(body) {
|
|
24
|
+
if (!body || !isGitServiceSeedReadme(body))
|
|
25
|
+
return undefined;
|
|
26
|
+
return normalizeAtlasOrigin(body.match(/^<!-- seq-studio:atlas-origin=([^\r\n]+) -->\r?$/m)?.[1]);
|
|
27
|
+
}
|
|
28
|
+
function docsLink({ atlasOrigin, label, slug = '' }) {
|
|
29
|
+
return atlasOrigin
|
|
30
|
+
? `[${label}](${atlasOrigin}/docs/${slug})`
|
|
31
|
+
: `\`<atlas-url>/docs${slug ? `/${slug}` : ''}\``;
|
|
32
|
+
}
|
|
9
33
|
export const README_REQUIRED_SECTIONS = [
|
|
10
|
-
'
|
|
34
|
+
'/docs', 'Artifact Studio', 'ORM', 'Managed Function',
|
|
11
35
|
'seq-studio init', 'seq.functions.invoke',
|
|
12
36
|
];
|
|
13
37
|
function primitivePath({ kind, appId, functionName }) {
|
|
@@ -27,6 +51,7 @@ const PRIMITIVE_LABELS = {
|
|
|
27
51
|
workspace: 'Workspaces V2 workspace',
|
|
28
52
|
};
|
|
29
53
|
export function renderAppReadme(input) {
|
|
54
|
+
const atlasOrigin = normalizeAtlasOrigin(input.atlasOrigin);
|
|
30
55
|
const title = input.title?.trim() || titleizeSlug(input.appId);
|
|
31
56
|
const description = input.description?.trim() || 'A Sequence Platform app. Keep source in Git and deploy with seq-studio.';
|
|
32
57
|
const kinds = new Set(input.primitives);
|
|
@@ -40,7 +65,9 @@ ${description}
|
|
|
40
65
|
|
|
41
66
|
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.
|
|
42
67
|
|
|
43
|
-
**Platform documentation:**
|
|
68
|
+
**Platform documentation:** ${docsLink({ atlasOrigin, label: 'Sequence Platform' })}
|
|
69
|
+
|
|
70
|
+
Documentation lives at \`/docs\` on the Atlas URL for your target environment. Find that URL with \`seq-studio envs list\` or ask your platform administrator; use it wherever \`<atlas-url>\` appears. The environment name is a CLI label, not a hostname. Keep the \`/docs/…\` path when switching environments.
|
|
44
71
|
|
|
45
72
|
## What this repository contains
|
|
46
73
|
|
|
@@ -144,15 +171,18 @@ seq-studio deploy -e <environment-name> --yes
|
|
|
144
171
|
- **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
172
|
- **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.
|
|
146
173
|
|
|
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
|
|
174
|
+
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' })}.
|
|
148
175
|
`;
|
|
149
176
|
}
|
|
150
|
-
export function renderEmptyRepoReadme({ repoName, namespaceSlug }) {
|
|
177
|
+
export function renderEmptyRepoReadme({ repoName, namespaceSlug, atlasOrigin }) {
|
|
151
178
|
const qualified = namespaceSlug ? `${namespaceSlug}/${repoName}` : repoName;
|
|
152
|
-
|
|
179
|
+
const origin = normalizeAtlasOrigin(atlasOrigin);
|
|
180
|
+
const originMarker = origin ? `<!-- seq-studio:atlas-origin=${origin} -->\n` : '';
|
|
181
|
+
return `${GIT_SERVICE_SEED_MARKER}\n${originMarker}${renderAppReadme({
|
|
153
182
|
appId: repoName,
|
|
154
183
|
description: `Sequence Platform git-service repository \`${qualified}\`. Scaffold an app in this clone, then validate and deploy with seq-studio.`,
|
|
155
184
|
primitives: ['orm', 'function', 'artifact'],
|
|
185
|
+
atlasOrigin: origin,
|
|
156
186
|
}).replace('## Implement this app', `## Scaffold the app
|
|
157
187
|
|
|
158
188
|
From this clone's root:
|
package/dist/app/scaffold.js
CHANGED
|
@@ -8,7 +8,7 @@ import { join, relative, resolve } from 'node:path';
|
|
|
8
8
|
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
|
-
import { renderAppReadme } from './readme.js';
|
|
11
|
+
import { readGitServiceSeedAtlasOrigin, renderAppReadme } from './readme.js';
|
|
12
12
|
import { writeScaffoldGuidance } from '../scaffold-guidance.js';
|
|
13
13
|
import { primitiveIdFor, relativePathFor, scaffoldKind } from './primitive-scaffold.js';
|
|
14
14
|
import { joinAppWorkspace, scaffoldAppWorkspace, scaffoldSharedPackage } from './workspace-scaffold.js';
|
|
@@ -77,6 +77,7 @@ export async function initAppMonorepo({ rootDir, appId, kinds, names = defaultSc
|
|
|
77
77
|
description: manifest.app.description,
|
|
78
78
|
primitives: kinds,
|
|
79
79
|
functionName: names.functionName,
|
|
80
|
+
atlasOrigin: readGitServiceSeedAtlasOrigin(snapshot.previousReadme),
|
|
80
81
|
}), 'utf8');
|
|
81
82
|
return manifest;
|
|
82
83
|
}
|
|
@@ -11,9 +11,8 @@
|
|
|
11
11
|
* `seq-studio` without exposing the bearer in argv or environment.
|
|
12
12
|
* 4. Forward all remaining argv to `runCli`.
|
|
13
13
|
*/
|
|
14
|
-
import { getAccessTokenWithMode,
|
|
15
|
-
import { readConfig,
|
|
16
|
-
import { fetchCatalog, readCachedCatalog } from '../env-catalog.js';
|
|
14
|
+
import { getAccessTokenWithMode, tryGetAccessTokenWithMode } from '../auth.js';
|
|
15
|
+
import { readConfig, resolveConfiguredEnv } from '../config.js';
|
|
17
16
|
import { normalizeShortEnvFlag, readEnvFromArgv } from '../env-flags.js';
|
|
18
17
|
import { PREVIEW_DOMAIN, PREVIEW_PROJECT, resolvePreviewByPr } from '../preview.js';
|
|
19
18
|
const ARTIFACT_USAGE = `usage:
|
|
@@ -96,7 +95,7 @@ export async function runArtifactCommand(sub, rest) {
|
|
|
96
95
|
await auth[sub]();
|
|
97
96
|
return 0;
|
|
98
97
|
}
|
|
99
|
-
// `artifact env list` renders the
|
|
98
|
+
// `artifact env list` renders the configured environments instead of
|
|
100
99
|
// artifact-studio's built-in (local-only) list.
|
|
101
100
|
if (sub === 'env' && rest[0] === 'list') {
|
|
102
101
|
const { runEnvsCommand } = await import('../envs/commands.js');
|
|
@@ -117,7 +116,6 @@ export async function runArtifactCommand(sub, rest) {
|
|
|
117
116
|
let resolved;
|
|
118
117
|
let argvForCli = forwardRest;
|
|
119
118
|
if (envUrl !== undefined) {
|
|
120
|
-
await requireSequenceTier('--env-url');
|
|
121
119
|
const validated = validatePreviewEnvUrl(envUrl);
|
|
122
120
|
// Explicit override wins over everything. Keep the user's --env name if
|
|
123
121
|
// they gave one, else label it `preview`.
|
|
@@ -125,13 +123,12 @@ export async function runArtifactCommand(sub, rest) {
|
|
|
125
123
|
argvForCli = ensureEnvFlag(forwardRest, resolved.name);
|
|
126
124
|
}
|
|
127
125
|
else if (prNumber !== undefined) {
|
|
128
|
-
await requireSequenceTier('--pr');
|
|
129
126
|
const preview = await resolvePreviewByPr({ pr: prNumber });
|
|
130
127
|
resolved = { name: `preview:${preview.slug}`, url: preview.url };
|
|
131
128
|
argvForCli = ensureEnvFlag(forwardRest, resolved.name);
|
|
132
129
|
}
|
|
133
130
|
else if (requested) {
|
|
134
|
-
resolved = await
|
|
131
|
+
resolved = await resolveConfiguredEnv({ requested });
|
|
135
132
|
// For `preview:<slug>` normalize the forwarded --env to the canonical name.
|
|
136
133
|
if (resolved.name !== requested)
|
|
137
134
|
argvForCli = ensureEnvFlag(forwardRest, resolved.name);
|
|
@@ -144,8 +141,8 @@ export async function runArtifactCommand(sub, rest) {
|
|
|
144
141
|
if (isPreviewUrl(resolved.url))
|
|
145
142
|
applyPreviewAccessHeader();
|
|
146
143
|
}
|
|
147
|
-
// Always hand artifact-studio the env map
|
|
148
|
-
//
|
|
144
|
+
// Always hand artifact-studio the configured env map (config.toml +
|
|
145
|
+
// registered deployments). Commands that resolve an env *name*
|
|
149
146
|
// without an explicit --env flag — the stored `.artifact-studio/config.json`
|
|
150
147
|
// defaultEnv, `artifact env set <name>` — would otherwise fall back to
|
|
151
148
|
// artifact-studio's built-in local-only map and fail on deployed envs.
|
|
@@ -167,31 +164,6 @@ export async function runArtifactCommand(sub, rest) {
|
|
|
167
164
|
}));
|
|
168
165
|
return runArtifactStudio([sub, ...argvForCli]);
|
|
169
166
|
}
|
|
170
|
-
/**
|
|
171
|
-
* Preview targeting (`preview:<slug>`, `--pr`, `--env-url`) is a
|
|
172
|
-
* Sequence-staff surface. The tier comes from the cached discovery catalog;
|
|
173
|
-
* refresh it lazily so a just-logged-in engineer isn't blocked on a stale
|
|
174
|
-
* anonymous cache.
|
|
175
|
-
*/
|
|
176
|
-
async function requireSequenceTier(flag) {
|
|
177
|
-
let { tier } = await readConfig();
|
|
178
|
-
if (tier !== 'sequence') {
|
|
179
|
-
try {
|
|
180
|
-
tier = (await fetchCatalog())?.tier ?? 'anonymous';
|
|
181
|
-
}
|
|
182
|
-
catch (err) {
|
|
183
|
-
// Broken CI credentials must surface as the Auth0 error, not as a
|
|
184
|
-
// misleading "Sequence-staff surface" rejection.
|
|
185
|
-
if (err instanceof M2mTokenError)
|
|
186
|
-
throw err;
|
|
187
|
-
tier = (await readCachedCatalog())?.tier ?? 'anonymous';
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (tier !== 'sequence') {
|
|
191
|
-
throw new Error(`${flag} targets per-PR preview environments, a Sequence-staff surface. ` +
|
|
192
|
-
'Authenticate with `seq-studio login` and run `seq-studio envs refresh`.');
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
167
|
/**
|
|
196
168
|
* Strip the seq-studio-only `--pr <number>` and `--env-url <url>` flags from
|
|
197
169
|
* argv and return the rest (forwarded to artifact-studio) plus the parsed
|
|
@@ -18,8 +18,8 @@ import { confirmYes } from '../prompt.js';
|
|
|
18
18
|
import { storeGitCredentials } from '../repos/git-clone.js';
|
|
19
19
|
import { formatPatSetupHint, settingsTokensUrl } from '../pat-hints.js';
|
|
20
20
|
/**
|
|
21
|
-
* Tokens-page URLs rendered from the environments
|
|
22
|
-
*
|
|
21
|
+
* Tokens-page URLs rendered from the configured environments (config.toml +
|
|
22
|
+
* registered deployments). With none configured, print a generic pointer
|
|
23
23
|
* instead of a hardcoded list of internal hosts.
|
|
24
24
|
*/
|
|
25
25
|
async function settingsTokensLines() {
|
package/dist/auth.d.ts
CHANGED
|
@@ -176,15 +176,6 @@ export declare function verifyTokenMatchesRealm({ accessToken, realm, requireOrg
|
|
|
176
176
|
realm: AuthRealm;
|
|
177
177
|
requireOrganization?: boolean;
|
|
178
178
|
}): void;
|
|
179
|
-
export declare function decodeJwtSub(token: string): string | null;
|
|
180
|
-
/**
|
|
181
|
-
* The Auth0 subject the CLI would authenticate as right now, without any
|
|
182
|
-
* network call. Matches token resolution precedence: a valid user session
|
|
183
|
-
* wins over an ambient M2M secret unless `SEQAPI_AUTH_MODE=m2m`.
|
|
184
|
-
*/
|
|
185
|
-
export declare function currentIdentitySubject(options?: {
|
|
186
|
-
env?: string;
|
|
187
|
-
}): Promise<string | null>;
|
|
188
179
|
export declare function loadCachedUserTokens(realmName?: string): Promise<SeqapiTokens | null>;
|
|
189
180
|
export declare function saveTokens(tokens: SeqapiTokens, realmName?: string): Promise<void>;
|
|
190
181
|
export declare function deleteRealmTokens(realmName: string): Promise<void>;
|
package/dist/auth.js
CHANGED
|
@@ -613,9 +613,8 @@ export async function inspectAuthPreflight(options) {
|
|
|
613
613
|
};
|
|
614
614
|
}
|
|
615
615
|
/**
|
|
616
|
-
* Decode
|
|
617
|
-
*
|
|
618
|
-
* bind the cached environment catalog to the identity that fetched it).
|
|
616
|
+
* Decode a JWT's claims without verification. Verification is the server's
|
|
617
|
+
* job — this is only used to inspect a token locally.
|
|
619
618
|
*/
|
|
620
619
|
function decodeJwtClaims(token) {
|
|
621
620
|
const payload = token.split('.')[1];
|
|
@@ -656,32 +655,6 @@ export function verifyTokenMatchesRealm({ accessToken, realm, requireOrganizatio
|
|
|
656
655
|
`expected '${realm.organization}' — refusing to store it.`);
|
|
657
656
|
}
|
|
658
657
|
}
|
|
659
|
-
export function decodeJwtSub(token) {
|
|
660
|
-
const claims = decodeJwtClaims(token);
|
|
661
|
-
const sub = claims ? Reflect.get(claims, 'sub') : null;
|
|
662
|
-
return typeof sub === 'string' && sub ? sub : null;
|
|
663
|
-
}
|
|
664
|
-
/**
|
|
665
|
-
* The Auth0 subject the CLI would authenticate as right now, without any
|
|
666
|
-
* network call. Matches token resolution precedence: a valid user session
|
|
667
|
-
* wins over an ambient M2M secret unless `SEQAPI_AUTH_MODE=m2m`.
|
|
668
|
-
*/
|
|
669
|
-
export async function currentIdentitySubject(options = {}) {
|
|
670
|
-
const realm = await realmForEnv(options.env);
|
|
671
|
-
const forceM2m = authModePrefersM2m();
|
|
672
|
-
if (!forceM2m) {
|
|
673
|
-
const tokens = await loadCachedUserTokens(realm.name);
|
|
674
|
-
const now = Date.now() / 1000;
|
|
675
|
-
if (tokens?.access_token && (tokens.expires_at ?? 0) > now + 60) {
|
|
676
|
-
verifyTokenMatchesRealm({ accessToken: tokens.access_token, realm });
|
|
677
|
-
return decodeJwtSub(tokens.access_token);
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
if (realm.m2mClientId && process.env[m2mSecretEnvName(realm)]?.trim()) {
|
|
681
|
-
return `${realm.m2mClientId}@clients`;
|
|
682
|
-
}
|
|
683
|
-
return null;
|
|
684
|
-
}
|
|
685
658
|
async function readTokenFile() {
|
|
686
659
|
const path = seqapiTokenPath();
|
|
687
660
|
let text;
|
package/dist/config.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { type EnvTier } from './env-catalog.js';
|
|
2
1
|
/**
|
|
3
2
|
* `--env preview:<branch-or-slug>` targets a per-PR Vercel preview deployment
|
|
4
3
|
* without a config.toml entry. The slug after the prefix is run through the
|
|
5
4
|
* canonical branch→slug transform (see `preview.ts`). PR-number resolution and
|
|
6
5
|
* the Cloudflare WAF bypass header live in `artifact/delegate.ts`.
|
|
7
|
-
* Preview targeting is a Sequence-staff surface — resolveEnv gates it on the
|
|
8
|
-
* discovered tier.
|
|
9
6
|
*/
|
|
10
7
|
export declare const PREVIEW_ENV_PREFIX = "preview:";
|
|
11
8
|
export declare const ENV_NAMES: string[];
|
|
@@ -14,8 +11,6 @@ export interface LatticeConfig {
|
|
|
14
11
|
url: string;
|
|
15
12
|
}>;
|
|
16
13
|
defaultEnv: string;
|
|
17
|
-
/** Discovered identity tier; `anonymous` when no catalog is cached. */
|
|
18
|
-
tier: EnvTier;
|
|
19
14
|
}
|
|
20
15
|
export declare function globalConfigDir(): string;
|
|
21
16
|
export declare function configPath(): string;
|
|
@@ -25,9 +20,8 @@ export declare function defaultConfig(): LatticeConfig;
|
|
|
25
20
|
*
|
|
26
21
|
* 1. built-in `local`
|
|
27
22
|
* 2. local worktrees discovered from `.wt.env`
|
|
28
|
-
* 3.
|
|
29
|
-
* 4.
|
|
30
|
-
* 5. OpCo registrations shared with seqapi (`~/.config/sequence-api/config.json`)
|
|
23
|
+
* 3. user entries in config.toml (an override for `local`, or net-new envs)
|
|
24
|
+
* 4. OpCo registrations shared with seqapi (`~/.config/sequence-api/config.json`)
|
|
31
25
|
*
|
|
32
26
|
* Registered OpCo routes are authoritative for their names so a lower-trust
|
|
33
27
|
* config.toml override cannot send a tenant token to another origin.
|
|
@@ -43,7 +37,7 @@ export interface ResolvedEnv {
|
|
|
43
37
|
url: string;
|
|
44
38
|
}
|
|
45
39
|
/**
|
|
46
|
-
* Copy-pasteable
|
|
40
|
+
* Copy-pasteable snippet for adding an environment by hand.
|
|
47
41
|
*
|
|
48
42
|
* The `[env.*]` table is safe to append to an existing config.toml. We
|
|
49
43
|
* intentionally omit `default_env` from the snippet — appending it after
|
|
@@ -54,21 +48,14 @@ export interface ResolvedEnv {
|
|
|
54
48
|
export declare function manualEnvConfigHint(): string;
|
|
55
49
|
/**
|
|
56
50
|
* Resolve `--env <name>` against the effective config. Falls back to the
|
|
57
|
-
* config's `defaultEnv` when no name is passed. Throws a clear error
|
|
58
|
-
* the
|
|
59
|
-
* that are actually visible.
|
|
51
|
+
* config's `defaultEnv` when no name is passed. Throws a clear error listing
|
|
52
|
+
* the configured envs when the name does not resolve.
|
|
60
53
|
*/
|
|
61
54
|
export declare function resolveEnv({ config, requested, }: {
|
|
62
55
|
config: LatticeConfig;
|
|
63
56
|
requested?: string;
|
|
64
57
|
}): ResolvedEnv;
|
|
65
|
-
/**
|
|
66
|
-
|
|
67
|
-
* resolve from the current config (built-ins + cached catalog + toml),
|
|
68
|
-
* refresh the catalog once — a logged-in identity that never ran
|
|
69
|
-
* `seq-studio envs refresh` (or fresh CI with AUTH0_M2M_CLIENT_SECRET)
|
|
70
|
-
* gets its environments on first use — then retry.
|
|
71
|
-
*/
|
|
72
|
-
export declare function resolveEnvWithDiscovery({ requested, }: {
|
|
58
|
+
/** Resolve `--env <name>` against the config on disk. */
|
|
59
|
+
export declare function resolveConfiguredEnv({ requested, }: {
|
|
73
60
|
requested?: string;
|
|
74
61
|
}): Promise<ResolvedEnv>;
|