@sequenceholdings/studio-cli 0.5.1 → 0.5.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.
- package/README.md +86 -36
- package/dist/agents/commands.js +7 -0
- package/dist/app/adapters.d.ts +2 -2
- package/dist/app/adapters.js +15 -14
- package/dist/app/commands.d.ts +1 -1
- package/dist/app/commands.js +57 -19
- package/dist/app/deploy.d.ts +2 -0
- package/dist/app/deploy.js +25 -13
- package/dist/app/kinds.d.ts +6 -0
- package/dist/app/kinds.js +6 -0
- package/dist/app/manifest.js +1 -1
- package/dist/app/official-source.d.ts +10 -0
- package/dist/app/official-source.js +23 -0
- package/dist/app/prepare.d.ts +27 -0
- package/dist/app/prepare.js +58 -0
- package/dist/app/primitive-ids.d.ts +6 -0
- package/dist/app/primitive-ids.js +16 -0
- package/dist/app/primitive-scaffold.d.ts +0 -4
- package/dist/app/primitive-scaffold.js +7 -18
- package/dist/app/readme.js +17 -14
- package/dist/app/repository-index.d.ts +19 -0
- package/dist/app/repository-index.js +86 -0
- package/dist/app/scaffold.d.ts +12 -1
- package/dist/app/scaffold.js +31 -18
- package/dist/app/workspace-compile.d.ts +9 -0
- package/dist/app/workspace-compile.js +13 -1
- package/dist/app/workspace-scaffold.js +5 -1
- package/dist/auth.d.ts +17 -0
- package/dist/auth.js +29 -0
- package/dist/config.d.ts +16 -0
- package/dist/config.js +38 -5
- package/dist/env-registry.d.ts +8 -0
- package/dist/env-registry.js +9 -1
- package/dist/envs/commands.js +14 -1
- package/dist/functions/manifest.d.ts +4 -1
- package/dist/functions/manifest.js +8 -2
- package/dist/main.js +1 -1
- package/dist/orm/delegate.js +5 -2
- package/dist/pipeline/clone-deploy.d.ts +1 -1
- package/dist/pipeline/clone-deploy.js +3 -2
- package/dist/pipeline/commands.js +3 -2
- package/dist/process/commands.d.ts +6 -3
- package/dist/process/commands.js +26 -10
- package/dist/repos/commands.js +1 -1
- package/dist/repos/pulls.d.ts +19 -1
- package/dist/repos/pulls.js +15 -2
- package/dist/templates/process/example-process/process.ts +2 -0
- package/dist/templates/process/package.json +1 -1
- package/package.json +8 -7
- package/templates/process/example-process/process.ts +2 -0
- package/templates/process/package.json +1 -1
package/dist/config.d.ts
CHANGED
|
@@ -55,6 +55,22 @@ export declare function resolveEnv({ config, requested, }: {
|
|
|
55
55
|
config: LatticeConfig;
|
|
56
56
|
requested?: string;
|
|
57
57
|
}): ResolvedEnv;
|
|
58
|
+
/**
|
|
59
|
+
* Save a first-party deployment under its reserved name (`staging`,
|
|
60
|
+
* `production`, `banksouth`) in config.toml. Those names sign in through the
|
|
61
|
+
* shared Sequence login, so the deployment must advertise exactly that login
|
|
62
|
+
* at its public `/api/auth/cli-config`; anything else is refused. The entry is
|
|
63
|
+
* appended, leaving the rest of the file as written.
|
|
64
|
+
*/
|
|
65
|
+
export declare function addSharedLoginEnvironment({ name, baseUrl: rawBaseUrl, fetchImpl, }: {
|
|
66
|
+
name: string;
|
|
67
|
+
baseUrl: string;
|
|
68
|
+
fetchImpl?: typeof fetch;
|
|
69
|
+
}): Promise<{
|
|
70
|
+
name: string;
|
|
71
|
+
baseUrl: string;
|
|
72
|
+
changed: boolean;
|
|
73
|
+
}>;
|
|
58
74
|
/** Resolve `--env <name>` against the config on disk. */
|
|
59
75
|
export declare function resolveConfiguredEnv({ requested, }: {
|
|
60
76
|
requested?: string;
|
package/dist/config.js
CHANGED
|
@@ -5,8 +5,9 @@ import { homedir } from 'node:os';
|
|
|
5
5
|
import { basename, dirname, join } from 'node:path';
|
|
6
6
|
import { promisify } from 'node:util';
|
|
7
7
|
import { parse as parseToml, stringify as stringifyToml } from 'smol-toml';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { validateDeploymentBaseUrl } from '@sequenceholdings/artifact-studio/deployment-validation';
|
|
9
|
+
import { isSequenceAuthEnvName, isSharedLoginDeploymentName, usesSharedSequenceLogin } from './auth.js';
|
|
10
|
+
import { fetchDeploymentLogin, readRegisteredEnvironmentUrls } from './env-registry.js';
|
|
10
11
|
import { resolvePreviewFromSlug } from './preview.js';
|
|
11
12
|
/**
|
|
12
13
|
* `--env preview:<branch-or-slug>` targets a per-PR Vercel preview deployment
|
|
@@ -194,9 +195,7 @@ export function resolveEnv({ config, requested, }) {
|
|
|
194
195
|
const env = config.envs[name];
|
|
195
196
|
if (!env) {
|
|
196
197
|
const known = Object.keys(config.envs).join(', ');
|
|
197
|
-
|
|
198
|
-
// them; point those at config.toml instead.
|
|
199
|
-
const addHint = isSequenceAuthEnvName(name)
|
|
198
|
+
const addHint = isSequenceAuthEnvName(name) && !isSharedLoginDeploymentName(name)
|
|
200
199
|
? `add an [env.${name}] entry to ${configPath()}`
|
|
201
200
|
: `register the deployment with: seq-studio envs add ${name} <url>`;
|
|
202
201
|
throw new Error(`Unknown env "${name}". Known envs: ${known}. ` +
|
|
@@ -204,6 +203,40 @@ export function resolveEnv({ config, requested, }) {
|
|
|
204
203
|
}
|
|
205
204
|
return { name, url: env.url };
|
|
206
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* Save a first-party deployment under its reserved name (`staging`,
|
|
208
|
+
* `production`, `banksouth`) in config.toml. Those names sign in through the
|
|
209
|
+
* shared Sequence login, so the deployment must advertise exactly that login
|
|
210
|
+
* at its public `/api/auth/cli-config`; anything else is refused. The entry is
|
|
211
|
+
* appended, leaving the rest of the file as written.
|
|
212
|
+
*/
|
|
213
|
+
export async function addSharedLoginEnvironment({ name, baseUrl: rawBaseUrl, fetchImpl = fetch, }) {
|
|
214
|
+
if (!isSharedLoginDeploymentName(name)) {
|
|
215
|
+
throw new Error(`'${name}' is not a reserved first-party deployment name.`);
|
|
216
|
+
}
|
|
217
|
+
const baseUrl = validateDeploymentBaseUrl(rawBaseUrl).replace(/\/$/, '');
|
|
218
|
+
if (!baseUrl.startsWith('https://')) {
|
|
219
|
+
throw new Error(`'${name}' must be an HTTPS deployment under *.seqholdings.com, not ${baseUrl}.`);
|
|
220
|
+
}
|
|
221
|
+
const login = await fetchDeploymentLogin({ baseUrl, fetchImpl });
|
|
222
|
+
if (!usesSharedSequenceLogin(login)) {
|
|
223
|
+
throw new Error(`'${name}' is reserved for a deployment on the shared Sequence login, and ${baseUrl} uses its own ` +
|
|
224
|
+
`login. Register it under another name: seq-studio envs add <name> ${baseUrl}`);
|
|
225
|
+
}
|
|
226
|
+
const path = configPath();
|
|
227
|
+
const existing = existsSync(path) ? await readFile(path, 'utf8') : '';
|
|
228
|
+
const current = parseToml(existing).env?.[name]?.url;
|
|
229
|
+
if (current === baseUrl)
|
|
230
|
+
return { name, baseUrl, changed: false };
|
|
231
|
+
if (current !== undefined) {
|
|
232
|
+
throw new Error(`[env.${name}] in ${path} already points at ${current}; edit it there to change it.`);
|
|
233
|
+
}
|
|
234
|
+
await mkdir(dirname(path), { recursive: true });
|
|
235
|
+
const separator = existing === '' || existing.endsWith('\n\n') ? '' : existing.endsWith('\n') ? '\n' : '\n\n';
|
|
236
|
+
const table = `[env.${name}]\nurl = ${stringifyToml({ url: baseUrl }).trim().replace(/^url = /, '')}\n`;
|
|
237
|
+
await writeFile(path, existing + separator + table, { encoding: 'utf8', mode: 0o600 });
|
|
238
|
+
return { name, baseUrl, changed: true };
|
|
239
|
+
}
|
|
207
240
|
/** Resolve `--env <name>` against the config on disk. */
|
|
208
241
|
export async function resolveConfiguredEnv({ requested, }) {
|
|
209
242
|
return resolveEnv({ config: await readConfig(), requested });
|
package/dist/env-registry.d.ts
CHANGED
|
@@ -12,6 +12,14 @@ interface RegistrationResult {
|
|
|
12
12
|
realm: DiscoveredRealm;
|
|
13
13
|
}
|
|
14
14
|
export declare function seqapiConfigPath(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Read a deployment's public CLI login config (`/api/auth/cli-config`) without
|
|
17
|
+
* judging its audience; callers decide which login they will trust.
|
|
18
|
+
*/
|
|
19
|
+
export declare function fetchDeploymentLogin({ baseUrl, fetchImpl, }: {
|
|
20
|
+
baseUrl: string;
|
|
21
|
+
fetchImpl?: typeof fetch;
|
|
22
|
+
}): Promise<DiscoveredRealm>;
|
|
15
23
|
export declare function readRegisteredEnvironmentUrls({ configFile, }?: {
|
|
16
24
|
configFile?: string;
|
|
17
25
|
}): Promise<Record<string, {
|
package/dist/env-registry.js
CHANGED
|
@@ -30,6 +30,14 @@ function validateEnvironmentName(input) {
|
|
|
30
30
|
return name;
|
|
31
31
|
}
|
|
32
32
|
async function discoverRealm({ baseUrl, fetchImpl, }) {
|
|
33
|
+
const login = await fetchDeploymentLogin({ baseUrl, fetchImpl });
|
|
34
|
+
return { ...login, audience: validateDeploymentAudience({ audience: login.audience, baseUrl }) };
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Read a deployment's public CLI login config (`/api/auth/cli-config`) without
|
|
38
|
+
* judging its audience; callers decide which login they will trust.
|
|
39
|
+
*/
|
|
40
|
+
export async function fetchDeploymentLogin({ baseUrl, fetchImpl = fetch, }) {
|
|
33
41
|
const url = `${baseUrl}${DISCOVERY_PATH}`;
|
|
34
42
|
let response;
|
|
35
43
|
try {
|
|
@@ -78,7 +86,7 @@ async function discoverRealm({ baseUrl, fetchImpl, }) {
|
|
|
78
86
|
return {
|
|
79
87
|
domain: validateAuth0Domain(domain),
|
|
80
88
|
clientId,
|
|
81
|
-
audience
|
|
89
|
+
audience,
|
|
82
90
|
organization: optionalString(Reflect.get(auth0, 'organization')),
|
|
83
91
|
m2mClientId: optionalString(Reflect.get(auth0, 'm2mClientId')),
|
|
84
92
|
};
|
package/dist/envs/commands.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { readConfig, configPath, manualEnvConfigHint } from '../config.js';
|
|
1
|
+
import { addSharedLoginEnvironment, readConfig, configPath, manualEnvConfigHint } from '../config.js';
|
|
2
|
+
import { isSharedLoginDeploymentName } from '../auth.js';
|
|
2
3
|
import { readRegisteredEnvironmentUrls, registerEnvironment, } from '../env-registry.js';
|
|
3
4
|
const ENVS_USAGE = `usage:
|
|
4
5
|
seq-studio envs list show the configured environments
|
|
@@ -9,6 +10,11 @@ const ENVS_USAGE = `usage:
|
|
|
9
10
|
deployment with "envs add"; it reads the deployment's public sign-in
|
|
10
11
|
settings, then "seq-studio login --env <name>" signs you in to it.
|
|
11
12
|
|
|
13
|
+
The reserved names staging, production and banksouth are for deployments
|
|
14
|
+
on the shared Sequence login. "envs add" saves one of them to config.toml
|
|
15
|
+
only after the deployment's sign-in settings confirm that login; then
|
|
16
|
+
"seq-studio login" signs you in.
|
|
17
|
+
|
|
12
18
|
Local worktrees are discovered from their .wt.env files. Entries in
|
|
13
19
|
${configPath()} are also honored.
|
|
14
20
|
`;
|
|
@@ -37,6 +43,13 @@ async function addCommand(rest) {
|
|
|
37
43
|
return 1;
|
|
38
44
|
}
|
|
39
45
|
try {
|
|
46
|
+
if (isSharedLoginDeploymentName(name.toLowerCase())) {
|
|
47
|
+
const added = await addSharedLoginEnvironment({ name: name.toLowerCase(), baseUrl });
|
|
48
|
+
console.log(`${added.changed ? 'Added' : 'Already configured:'} environment '${added.name}' -> ${added.baseUrl} ` +
|
|
49
|
+
`(shared Sequence login, saved in ${configPath()})`);
|
|
50
|
+
console.log('Next: seq-studio login');
|
|
51
|
+
return 0;
|
|
52
|
+
}
|
|
40
53
|
const registration = await registerEnvironment({ name, baseUrl });
|
|
41
54
|
const verb = registration.replacing ? 'Updated' : 'Registered';
|
|
42
55
|
console.log(`${verb} environment '${registration.name}' -> ${registration.baseUrl}`);
|
|
@@ -136,6 +136,9 @@ export declare const managedFunctionManifestSchema: z.ZodObject<{
|
|
|
136
136
|
processes: z.ZodOptional<z.ZodObject<{
|
|
137
137
|
read: z.ZodArray<z.ZodString>;
|
|
138
138
|
}, z.core.$strict>>;
|
|
139
|
+
directory: z.ZodOptional<z.ZodObject<{
|
|
140
|
+
groups: z.ZodArray<z.ZodString>;
|
|
141
|
+
}, z.core.$strict>>;
|
|
139
142
|
roles: z.ZodOptional<z.ZodObject<{
|
|
140
143
|
definitions: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
141
144
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -156,7 +159,7 @@ export declare const managedFunctionManifestSchema: z.ZodObject<{
|
|
|
156
159
|
}, z.core.$strip>>;
|
|
157
160
|
}, z.core.$strip>>>;
|
|
158
161
|
data: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
159
|
-
tables: z.ZodDefault<z.ZodArray<z.ZodString
|
|
162
|
+
tables: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"platformUsers">, z.ZodString]>>>;
|
|
160
163
|
actions: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
161
164
|
operations: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
162
165
|
query: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { storageScopesSchema, readStorageScopes } from '@sequenceholdings/storage';
|
|
2
2
|
import { postgresEgressError } from './egress-postgres.js';
|
|
3
|
-
import { cacheManifestSchema, managedFunctionWorkloadLimitsSchema } from '@sequenceholdings/managed-functions/config';
|
|
3
|
+
import { cacheManifestSchema, directoryScopesSchema, managedFunctionWorkloadLimitsSchema } from '@sequenceholdings/managed-functions/config';
|
|
4
4
|
import { functionProcessReadScopesSchema } from '@sequenceholdings/managed-functions/config';
|
|
5
5
|
import { isIP } from 'node:net';
|
|
6
6
|
import { z } from 'zod';
|
|
@@ -692,6 +692,7 @@ export const managedFunctionManifestSchema = z.object({
|
|
|
692
692
|
capabilities: z.object({
|
|
693
693
|
storage: storageScopesSchema.optional(),
|
|
694
694
|
processes: functionProcessReadScopesSchema.optional(),
|
|
695
|
+
directory: directoryScopesSchema.optional(),
|
|
695
696
|
roles: customRolesBlockSchema.optional(),
|
|
696
697
|
uses: capabilityPinsSchema,
|
|
697
698
|
gates: capabilityGatesSchema,
|
|
@@ -710,7 +711,12 @@ export const managedFunctionManifestSchema = z.object({
|
|
|
710
711
|
*/
|
|
711
712
|
data: z
|
|
712
713
|
.record(z.string().regex(/^[a-z][a-z0-9_]{0,40}$/, 'capabilities.data keys are ORM namespace names'), z.object({
|
|
713
|
-
|
|
714
|
+
// ORM emits this exact logical key for toPlatformUser joins; it is
|
|
715
|
+
// not a physical SQL table name or a general camelCase exception.
|
|
716
|
+
tables: z.array(z.union([
|
|
717
|
+
z.literal('platformUsers'),
|
|
718
|
+
z.string().regex(/^[a-z_][a-z0-9_]*$/, 'table names'),
|
|
719
|
+
])).max(64).default([]),
|
|
714
720
|
actions: z.array(z.string().regex(/^[a-z_][a-z0-9_]*$/, 'action names')).max(64).default([]),
|
|
715
721
|
/**
|
|
716
722
|
* ORM v2 persisted operations (GraphQL mutations/actions by name)
|
package/dist/main.js
CHANGED
|
@@ -62,7 +62,7 @@ const PROCESS_USAGE = `usage:
|
|
|
62
62
|
seq-studio process lint [--dir <path>] [--offline]
|
|
63
63
|
seq-studio process plan [--dir <path>] [-e <env>]
|
|
64
64
|
seq-studio process apply [--dir <path>] [-e <env>] [--only <id1,id2,...>] [--platform-managed]
|
|
65
|
-
seq-studio process apply --repo
|
|
65
|
+
seq-studio process apply --repo <namespace>/<name> [--ref <r>] -e <env> [--only <id1,id2,...>] [--platform-managed]
|
|
66
66
|
seq-studio process promote <processId> --version <v> [-e <env>]
|
|
67
67
|
seq-studio process pull <processId> [--version <v>] [-e <env>] [--out <dir>] [--no-children]
|
|
68
68
|
seq-studio process test [-e <env>] [--offline]
|
package/dist/orm/delegate.js
CHANGED
|
@@ -172,11 +172,14 @@ async function loadOrmCli() {
|
|
|
172
172
|
throw err;
|
|
173
173
|
const message = err instanceof Error ? err.message : String(err);
|
|
174
174
|
if (isOrmPackageMissing(message)) {
|
|
175
|
-
console.error('seq-studio orm needs the @sequenceholdings/orm package.
|
|
176
|
-
'
|
|
175
|
+
console.error('seq-studio orm needs the @sequenceholdings/orm package. Add it to your app, then run the app\'s CLI:\n' +
|
|
176
|
+
' pnpm add -D @sequenceholdings/orm\n' +
|
|
177
|
+
' pnpm exec seq-studio orm …');
|
|
177
178
|
}
|
|
178
179
|
else {
|
|
179
180
|
console.error('@sequenceholdings/orm is installed but a dependency failed to load. Reinstall dependencies, then retry.\n' +
|
|
181
|
+
'A CLI installed globally with pnpm 11 cannot load drizzle-kit, which imports drizzle-orm without declaring it; ' +
|
|
182
|
+
'run the app\'s own CLI instead (`pnpm exec seq-studio orm …`).\n' +
|
|
180
183
|
` ${message}`);
|
|
181
184
|
}
|
|
182
185
|
return null;
|
|
@@ -4,7 +4,7 @@ export interface CloneDeployTarget {
|
|
|
4
4
|
}
|
|
5
5
|
export declare function assertCloneDeployAllowed(target: CloneDeployTarget): void;
|
|
6
6
|
export declare function parseCloneDeployRepo(repo: string): {
|
|
7
|
-
namespace:
|
|
7
|
+
namespace: string;
|
|
8
8
|
name: string;
|
|
9
9
|
};
|
|
10
10
|
export declare function readCloneHead(dir: string): Promise<{
|
|
@@ -21,11 +21,12 @@ export function assertCloneDeployAllowed(target) {
|
|
|
21
21
|
throw new Error(`pipeline deploy from a local clone is only supported on targets that do not require approval (got '${target.id}'). ` +
|
|
22
22
|
'Push the commit to that environment\'s git service, then deploy with --repo and --ref.');
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
/** `<namespace>/<repo>`; the server decides which namespaces may hold pipelines. */
|
|
25
|
+
const RELEASE_REPO = /^([a-z][a-z0-9-]*)\/([a-z][a-z0-9-]*)$/;
|
|
25
26
|
export function parseCloneDeployRepo(repo) {
|
|
26
27
|
const match = RELEASE_REPO.exec(repo);
|
|
27
28
|
if (!match) {
|
|
28
|
-
throw new Error(`--repo must be pipelines/<name> or
|
|
29
|
+
throw new Error(`--repo must be <namespace>/<name>, such as pipelines/<name> or your app's namespace (got '${repo}')`);
|
|
29
30
|
}
|
|
30
31
|
return { namespace: match[1], name: match[2] };
|
|
31
32
|
}
|
|
@@ -147,8 +147,9 @@ async function importPipelineSpec() {
|
|
|
147
147
|
if (err.code === 'ERR_MODULE_NOT_FOUND') {
|
|
148
148
|
const message = err instanceof Error ? err.message : String(err);
|
|
149
149
|
if (isPipelineSpecMissing(message)) {
|
|
150
|
-
console.error('seq-studio pipeline needs the @sequenceholdings/pipeline-spec package.
|
|
151
|
-
'
|
|
150
|
+
console.error('seq-studio pipeline needs the @sequenceholdings/pipeline-spec package. Add it to your app, then run the app\'s CLI:\n' +
|
|
151
|
+
' pnpm add -D @sequenceholdings/pipeline-spec\n' +
|
|
152
|
+
' pnpm exec seq-studio pipeline …');
|
|
152
153
|
}
|
|
153
154
|
else {
|
|
154
155
|
console.error('@sequenceholdings/pipeline-spec is installed but a dependency failed to load. Reinstall dependencies, then retry.\n' +
|
|
@@ -16,16 +16,19 @@ export type ProcessSourceSpec = {
|
|
|
16
16
|
ref?: string;
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
|
-
* Parse the process-apply source flags. `--repo
|
|
19
|
+
* Parse the process-apply source flags. `--repo <namespace>/<name>` materializes
|
|
20
20
|
* from the platform git service; absent means local (cwd / LATTICE_PROCESSES_ROOT).
|
|
21
21
|
* `--git-url` is passed through to the underlying `resolveArtifactSource` when
|
|
22
22
|
* the repo flag is a full ns/name pair (future); today only git-service is
|
|
23
23
|
* supported.
|
|
24
24
|
*
|
|
25
|
-
* Process repos live
|
|
26
|
-
*
|
|
25
|
+
* Process repos live in `processes`, an `apps` monorepo, or a builder's own
|
|
26
|
+
* namespace. Platform namespaces that hold another kind are rejected to avoid
|
|
27
|
+
* cross-kind accidents.
|
|
27
28
|
*/
|
|
28
29
|
export declare function parseProcessSourceSpec(flags: Record<string, string | true>): ProcessSourceSpec;
|
|
30
|
+
/** The last segment of a directory path, whichever separator the platform uses. */
|
|
31
|
+
export declare function scaffoldName(dir: string): string;
|
|
29
32
|
export declare function initCommand(args: ParsedArgs): Promise<number>;
|
|
30
33
|
export declare function lintCommand(args: ParsedArgs): Promise<number>;
|
|
31
34
|
export declare function planCommand(args: ParsedArgs): Promise<number>;
|
package/dist/process/commands.js
CHANGED
|
@@ -14,6 +14,7 @@ import { getJson, getJsonOr404, postJson, AtlasApiError } from '../atlas-client.
|
|
|
14
14
|
import { generateProcessFiles } from './codegen.js';
|
|
15
15
|
import { getAccessToken, getAccessTokenWithMode, inspectAuthPreflight, AuthTokenStoreError, NotLoggedInError, } from '../auth.js';
|
|
16
16
|
import { readConfig, resolveEnv, resolveConfiguredEnv } from '../config.js';
|
|
17
|
+
import { currentVersion } from '../update-check.js';
|
|
17
18
|
import { writeScaffoldGuidance } from '../scaffold-guidance.js';
|
|
18
19
|
import { finalizeCompiledBundle, summarizeBundle } from './build.js';
|
|
19
20
|
import { buildResolveProcessPinFromEnv } from './resolve-process-pin.js';
|
|
@@ -48,21 +49,31 @@ async function getEnvAndAuth(args) {
|
|
|
48
49
|
const auth = await getAccessTokenWithMode({ env: env.name, targetUrl: env.url });
|
|
49
50
|
return { authMode: auth.authMode, env, token: auth.token };
|
|
50
51
|
}
|
|
52
|
+
/** Platform namespaces reserved for primitives other than processes. */
|
|
53
|
+
const OTHER_KIND_NAMESPACES = new Set([
|
|
54
|
+
'agents',
|
|
55
|
+
'artifacts',
|
|
56
|
+
'external-systems',
|
|
57
|
+
'managed-functions',
|
|
58
|
+
'pipelines',
|
|
59
|
+
'templates',
|
|
60
|
+
]);
|
|
51
61
|
/**
|
|
52
|
-
* Parse the process-apply source flags. `--repo
|
|
62
|
+
* Parse the process-apply source flags. `--repo <namespace>/<name>` materializes
|
|
53
63
|
* from the platform git service; absent means local (cwd / LATTICE_PROCESSES_ROOT).
|
|
54
64
|
* `--git-url` is passed through to the underlying `resolveArtifactSource` when
|
|
55
65
|
* the repo flag is a full ns/name pair (future); today only git-service is
|
|
56
66
|
* supported.
|
|
57
67
|
*
|
|
58
|
-
* Process repos live
|
|
59
|
-
*
|
|
68
|
+
* Process repos live in `processes`, an `apps` monorepo, or a builder's own
|
|
69
|
+
* namespace. Platform namespaces that hold another kind are rejected to avoid
|
|
70
|
+
* cross-kind accidents.
|
|
60
71
|
*/
|
|
61
72
|
export function parseProcessSourceSpec(flags) {
|
|
62
73
|
const repo = typeof flags.repo === 'string' ? flags.repo : undefined;
|
|
63
74
|
const ref = typeof flags.ref === 'string' ? flags.ref : undefined;
|
|
64
75
|
if (flags.repo === true)
|
|
65
|
-
throw new Error('--repo requires a value: --repo
|
|
76
|
+
throw new Error('--repo requires a value: --repo <namespace>/<name>');
|
|
66
77
|
if (flags.ref === true)
|
|
67
78
|
throw new Error('--ref requires a value.');
|
|
68
79
|
if (flags.dir === true)
|
|
@@ -77,17 +88,21 @@ export function parseProcessSourceSpec(flags) {
|
|
|
77
88
|
return { kind: 'local' };
|
|
78
89
|
const parts = repo.split('/');
|
|
79
90
|
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
80
|
-
throw new Error(`--repo must be "processes/<name>
|
|
91
|
+
throw new Error(`--repo must be "<namespace>/<name>", such as processes/<name> or your app's namespace (got "${repo}").`);
|
|
81
92
|
}
|
|
82
|
-
if (parts[0]
|
|
83
|
-
throw new Error(`
|
|
84
|
-
`Use --repo processes/<name
|
|
93
|
+
if (OTHER_KIND_NAMESPACES.has(parts[0])) {
|
|
94
|
+
throw new Error(`The "${parts[0]}" namespace holds another kind of primitive, not processes. ` +
|
|
95
|
+
`Use --repo processes/<name> or your app's namespace.`);
|
|
85
96
|
}
|
|
86
97
|
return { kind: 'git-service', namespace: parts[0], name: parts[1], ref };
|
|
87
98
|
}
|
|
88
99
|
// ---------------------------------------------------------------------------
|
|
89
100
|
// init
|
|
90
101
|
// ---------------------------------------------------------------------------
|
|
102
|
+
/** The last segment of a directory path, whichever separator the platform uses. */
|
|
103
|
+
export function scaffoldName(dir) {
|
|
104
|
+
return dir.split(/[\\/]/).filter(Boolean).at(-1) ?? 'my-process';
|
|
105
|
+
}
|
|
91
106
|
export async function initCommand(args) {
|
|
92
107
|
const target = args.positional[0];
|
|
93
108
|
if (!target) {
|
|
@@ -95,7 +110,7 @@ export async function initCommand(args) {
|
|
|
95
110
|
return 1;
|
|
96
111
|
}
|
|
97
112
|
const dir = resolve(target);
|
|
98
|
-
const name = dir
|
|
113
|
+
const name = scaffoldName(dir);
|
|
99
114
|
if (existsSync(dir)) {
|
|
100
115
|
console.error(`${dir} already exists`);
|
|
101
116
|
return 1;
|
|
@@ -129,7 +144,8 @@ export async function initCommand(args) {
|
|
|
129
144
|
if (existsSync(path)) {
|
|
130
145
|
const body = (await readFile(path, 'utf8'))
|
|
131
146
|
.replace(/\{\{name\}\}/g, name)
|
|
132
|
-
.replace(/\{\{slug\}\}/g, slug)
|
|
147
|
+
.replace(/\{\{slug\}\}/g, slug)
|
|
148
|
+
.replace(/\{\{cliVersion\}\}/g, currentVersion());
|
|
133
149
|
await writeFile(path, body, 'utf8');
|
|
134
150
|
}
|
|
135
151
|
}
|
package/dist/repos/commands.js
CHANGED
|
@@ -173,7 +173,7 @@ export async function reposNamespacesCommand(args) {
|
|
|
173
173
|
const ctx = await reposContext(args);
|
|
174
174
|
if (action === 'create') {
|
|
175
175
|
if (!slug) {
|
|
176
|
-
console.error('usage: seq-studio repos namespaces create <slug> -e <env>');
|
|
176
|
+
console.error('usage: seq-studio repos namespaces create <slug> -e <env> (needs Can create on Repositories)');
|
|
177
177
|
return 1;
|
|
178
178
|
}
|
|
179
179
|
const created = await postJson({
|
package/dist/repos/pulls.d.ts
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
1
|
import type { ParsedArgs } from '../process/commands.js';
|
|
2
|
-
export declare const PULLS_USAGE = "usage:\n seq-studio repos pulls list <ns>/<name> -e <env> [--state open|closed|merged] [--limit N] [--cursor <cursor>]\n seq-studio repos pulls show <ns>/<name> <number> -e <env>\n seq-studio repos pulls create <ns>/<name> --head <branch> --base <branch> --title <title> -e <env> [--body-file <path>]\n seq-studio repos pulls diff <ns>/<name> <number> -e <env> [--max-files N]\n seq-studio repos pulls merge <ns>/<name> <number> -e <env> [--method squash|merge|ff] [--message <text>] [--yes]\n\n All results are JSON (--json is accepted). Authenticate: seq-studio login --env <env>.\n create needs repository write; merge needs merge/admin authority and passing server\n review/check policy. There is no policy bypass. Review show and diff before merging.\n Merge operates on the current branch head under server policy
|
|
2
|
+
export declare const PULLS_USAGE = "usage:\n seq-studio repos pulls list <ns>/<name> -e <env> [--state open|closed|merged] [--limit N] [--cursor <cursor>]\n seq-studio repos pulls show <ns>/<name> <number> -e <env>\n seq-studio repos pulls create <ns>/<name> --head <branch> --base <branch> --title <title> -e <env> [--body-file <path>]\n seq-studio repos pulls diff <ns>/<name> <number> -e <env> [--max-files N]\n seq-studio repos pulls merge <ns>/<name> <number> -e <env> [--method squash|merge|ff] [--message <text>] [--yes]\n\n All results are JSON (--json is accepted). Authenticate: seq-studio login --env <env>.\n create needs repository write; merge needs merge/admin authority and passing server\n review/check policy. There is no policy bypass. Review show and diff before merging.\n Merge operates on the current branch head under server policy. When repository CI\n checks the branch, merge sends the checked head and base revisions; a newer push\n makes the server refuse until checks rerun. Default merge method: squash.\n list returns one page with nextCursor; pass --cursor to continue.\n diff compares live base/head branches for open Pulls, recorded SHAs for terminal\n Pulls, and reports truncated when its file\n limit is reached (default 100, maximum 500).\n repos pull (singular) materializes files; repos pulls manages review requests.\n";
|
|
3
|
+
/** Only the revisions this command needs from GET .../pulls/<n>/ci. */
|
|
4
|
+
interface PullCiStatus {
|
|
5
|
+
plan?: {
|
|
6
|
+
headSha?: string;
|
|
7
|
+
baseSha?: string;
|
|
8
|
+
} | null;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A branch under repository CI only merges the exact revisions its checks
|
|
12
|
+
* planned (the server returns 409 without them). Unchecked branches need none.
|
|
13
|
+
*/
|
|
14
|
+
export declare function checkedMergeRevision({ fetchStatus }: {
|
|
15
|
+
fetchStatus: () => Promise<PullCiStatus>;
|
|
16
|
+
}): Promise<{
|
|
17
|
+
expectedHeadSha: string;
|
|
18
|
+
expectedBaseSha: string;
|
|
19
|
+
} | Record<string, never>>;
|
|
3
20
|
export declare function reposPullsCommand(input: ParsedArgs): Promise<number>;
|
|
21
|
+
export {};
|
package/dist/repos/pulls.js
CHANGED
|
@@ -15,14 +15,25 @@ export const PULLS_USAGE = `usage:
|
|
|
15
15
|
All results are JSON (--json is accepted). Authenticate: seq-studio login --env <env>.
|
|
16
16
|
create needs repository write; merge needs merge/admin authority and passing server
|
|
17
17
|
review/check policy. There is no policy bypass. Review show and diff before merging.
|
|
18
|
-
Merge operates on the current branch head under server policy
|
|
19
|
-
|
|
18
|
+
Merge operates on the current branch head under server policy. When repository CI
|
|
19
|
+
checks the branch, merge sends the checked head and base revisions; a newer push
|
|
20
|
+
makes the server refuse until checks rerun. Default merge method: squash.
|
|
20
21
|
list returns one page with nextCursor; pass --cursor to continue.
|
|
21
22
|
diff compares live base/head branches for open Pulls, recorded SHAs for terminal
|
|
22
23
|
Pulls, and reports truncated when its file
|
|
23
24
|
limit is reached (default 100, maximum 500).
|
|
24
25
|
repos pull (singular) materializes files; repos pulls manages review requests.
|
|
25
26
|
`;
|
|
27
|
+
/**
|
|
28
|
+
* A branch under repository CI only merges the exact revisions its checks
|
|
29
|
+
* planned (the server returns 409 without them). Unchecked branches need none.
|
|
30
|
+
*/
|
|
31
|
+
export async function checkedMergeRevision({ fetchStatus }) {
|
|
32
|
+
const status = await fetchStatus();
|
|
33
|
+
const headSha = status.plan?.headSha;
|
|
34
|
+
const baseSha = status.plan?.baseSha;
|
|
35
|
+
return headSha && baseSha ? { expectedHeadSha: headSha, expectedBaseSha: baseSha } : {};
|
|
36
|
+
}
|
|
26
37
|
function integerFlag({ args, key, max }) {
|
|
27
38
|
const value = args.flags[key];
|
|
28
39
|
if (value === undefined)
|
|
@@ -66,9 +77,11 @@ async function mergePull({ args, ctx, path, repoPath }) {
|
|
|
66
77
|
const confirmed = await confirmYes({ confirmed: args.flags.yes === true, preview: [] });
|
|
67
78
|
if (!confirmed)
|
|
68
79
|
return 1;
|
|
80
|
+
const revision = await checkedMergeRevision({ fetchStatus: () => getJson({ ...clientOptions(ctx), path: `${path}/ci` }) });
|
|
69
81
|
const result = await postJson({ ...clientOptions(ctx), path: `${path}/merge`, body: {
|
|
70
82
|
method: args.flags.method ?? 'squash',
|
|
71
83
|
...(args.flags.message === undefined ? {} : { message: args.flags.message }),
|
|
84
|
+
...revision,
|
|
72
85
|
} });
|
|
73
86
|
console.log(JSON.stringify(result, null, 2));
|
|
74
87
|
return 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sequenceholdings/studio-cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Unified Sequence Studio CLI — `seq-studio init` / `add` / `deploy` (app monorepos), `seq-studio agents`, `seq-studio process` (Lattice), `seq-studio artifact`, `seq-studio functions` / `secrets`, `seq-studio repos`, and `seq-studio auth whoami`. Includes Auth0 browser login shared with seqapi.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -41,15 +41,16 @@
|
|
|
41
41
|
"smol-toml": "^1.9.0",
|
|
42
42
|
"tsx": "^4.20.3",
|
|
43
43
|
"zod": "^4.1.13",
|
|
44
|
-
"
|
|
44
|
+
"yaml": "^2.8.4",
|
|
45
45
|
"@sequenceholdings/agent-spec": "0.1.3",
|
|
46
|
+
"@sequenceholdings/artifact-studio": "0.7.1",
|
|
46
47
|
"@sequenceholdings/lattice": "0.1.5",
|
|
47
|
-
"@sequenceholdings/managed-functions": "0.4.
|
|
48
|
+
"@sequenceholdings/managed-functions": "0.4.1",
|
|
48
49
|
"@sequenceholdings/storage": "0.1.1"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
51
|
-
"@sequenceholdings/pipeline-spec": "0.2.
|
|
52
|
-
"@sequenceholdings/orm": "2.6.
|
|
52
|
+
"@sequenceholdings/pipeline-spec": "0.2.5",
|
|
53
|
+
"@sequenceholdings/orm": "2.6.1"
|
|
53
54
|
},
|
|
54
55
|
"peerDependenciesMeta": {
|
|
55
56
|
"@sequenceholdings/orm": {
|
|
@@ -64,8 +65,8 @@
|
|
|
64
65
|
"@types/node": "^22.0.0",
|
|
65
66
|
"typescript": "^5.6.0",
|
|
66
67
|
"vitest": "^4.1.11",
|
|
67
|
-
"@sequenceholdings/orm": "2.6.
|
|
68
|
-
"@sequenceholdings/pipeline-spec": "0.2.
|
|
68
|
+
"@sequenceholdings/orm": "2.6.1",
|
|
69
|
+
"@sequenceholdings/pipeline-spec": "0.2.5"
|
|
69
70
|
},
|
|
70
71
|
"engines": {
|
|
71
72
|
"node": ">=20"
|