@sequenceholdings/studio-cli 0.7.1 → 0.9.0
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 +390 -54
- package/dist/access/commands.d.ts +1 -1
- package/dist/access/commands.js +102 -55
- package/dist/access/custom-role-hosts.d.ts +3 -0
- package/dist/access/custom-role-hosts.js +88 -0
- package/dist/access/group-rosters.d.ts +6 -0
- package/dist/access/group-rosters.js +33 -0
- package/dist/access/host-contract.d.ts +55 -0
- package/dist/access/host-contract.js +33 -0
- package/dist/access/hosts.d.ts +4 -0
- package/dist/access/hosts.js +60 -0
- package/dist/access/principal.d.ts +16 -0
- package/dist/access/principal.js +36 -0
- package/dist/access/roles.d.ts +18 -0
- package/dist/access/roles.js +89 -0
- package/dist/access/tier-hosts.d.ts +12 -0
- package/dist/access/tier-hosts.js +206 -0
- package/dist/agents/commands.d.ts +1 -1
- package/dist/agents/commands.js +76 -16
- package/dist/agents/scaffold.js +8 -3
- package/dist/app/commands.d.ts +3 -1
- package/dist/app/commands.js +88 -12
- package/dist/app/manifest.d.ts +2 -2
- package/dist/app/official-source.d.ts +4 -2
- package/dist/app/official-source.js +6 -4
- package/dist/app/readme.js +2 -2
- package/dist/app/validate.d.ts +16 -0
- package/dist/app/validate.js +40 -0
- package/dist/app/workspace-model.js +4 -0
- package/dist/app/workspace-scaffold.js +5 -3
- package/dist/app/workspace.d.ts +2 -0
- package/dist/app/workspace.js +1 -1
- package/dist/artifact/delegate.js +26 -3
- package/dist/artifact/sandbox.js +2 -1
- package/dist/atlas-client.d.ts +17 -8
- package/dist/atlas-client.js +146 -62
- package/dist/bin.js +10 -1
- package/dist/cli-errors.js +12 -3
- package/dist/command-contract.d.ts +14 -2
- package/dist/command-contract.js +4 -2
- package/dist/command-help.d.ts +9 -7
- package/dist/command-help.js +56 -12
- package/dist/env-flags.d.ts +7 -0
- package/dist/env-flags.js +23 -0
- package/dist/functions/commands.d.ts +4 -0
- package/dist/functions/commands.js +127 -11
- package/dist/functions/manifest.d.ts +5 -0
- package/dist/functions/manifest.js +44 -23
- package/dist/functions/service-account-guidance.d.ts +21 -0
- package/dist/functions/service-account-guidance.js +62 -0
- package/dist/functions/workspace.d.ts +11 -0
- package/dist/functions/workspace.js +52 -0
- package/dist/main.d.ts +2 -1
- package/dist/main.js +17 -3
- package/dist/orm/delegate.d.ts +1 -0
- package/dist/orm/delegate.js +65 -12
- package/dist/orm/discover-schema.d.ts +26 -0
- package/dist/orm/discover-schema.js +5 -0
- package/dist/orm/execute.js +11 -5
- package/dist/orm/failures.d.ts +32 -0
- package/dist/orm/failures.js +75 -0
- package/dist/orm/operation-show.d.ts +2 -0
- package/dist/orm/operation-show.js +35 -0
- package/dist/orm/read.js +3 -3
- package/dist/orm/version-guard.d.ts +3 -0
- package/dist/orm/version-guard.js +63 -0
- package/dist/pipeline/commands.js +4 -1
- package/dist/principals/commands.d.ts +3 -0
- package/dist/principals/commands.js +124 -0
- package/dist/process/runs.d.ts +4 -3
- package/dist/process/runs.js +52 -10
- package/dist/release-age.d.ts +1 -1
- package/dist/release-age.js +1 -0
- package/dist/repos/commands.d.ts +44 -0
- package/dist/repos/commands.js +55 -15
- package/dist/repos/init-repo.d.ts +45 -0
- package/dist/repos/init-repo.js +257 -0
- package/dist/sandbox-unpushed-warning.d.ts +23 -0
- package/dist/sandbox-unpushed-warning.js +86 -0
- package/dist/service-accounts/commands.js +15 -3
- package/dist/templates/commands.d.ts +14 -2
- package/dist/templates/commands.js +70 -16
- package/dist/templates/process/pnpm-workspace.yaml +1 -0
- package/dist/transient-503.d.ts +4 -0
- package/dist/transient-503.js +25 -0
- package/package.json +14 -10
- package/templates/process/pnpm-workspace.yaml +1 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { join, resolve } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { satisfies, validRange } from 'semver';
|
|
5
|
+
const SCHEMA_SUBCOMMANDS = new Set(['generate', 'validate', 'plan', 'apply', 'diff']);
|
|
6
|
+
export function requiresSchemaVersionCheck(sub) {
|
|
7
|
+
return SCHEMA_SUBCOMMANDS.has(sub);
|
|
8
|
+
}
|
|
9
|
+
function missingFile(error) {
|
|
10
|
+
return error instanceof Error && 'code' in error && error.code === 'ENOENT';
|
|
11
|
+
}
|
|
12
|
+
function dependencyRange(manifest) {
|
|
13
|
+
if (typeof manifest !== 'object' || manifest === null)
|
|
14
|
+
return undefined;
|
|
15
|
+
for (const field of ['dependencies', 'devDependencies']) {
|
|
16
|
+
const section = Reflect.get(manifest, field);
|
|
17
|
+
if (typeof section === 'object' && section !== null) {
|
|
18
|
+
const range = Reflect.get(section, '@sequenceholdings/orm');
|
|
19
|
+
if (range !== undefined)
|
|
20
|
+
return range;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
/** Fail before compiling a v2 schema with an ORM outside its declared range. */
|
|
26
|
+
export async function ormVersionMismatch(dir) {
|
|
27
|
+
const configPath = join(resolve(dir), 'sequence.config.ts');
|
|
28
|
+
try {
|
|
29
|
+
await readFile(configPath);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
if (missingFile(error))
|
|
33
|
+
return null; // v1 namespace
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
const manifestPath = join(resolve(dir), 'package.json');
|
|
37
|
+
let manifest;
|
|
38
|
+
try {
|
|
39
|
+
manifest = JSON.parse(await readFile(manifestPath, 'utf8'));
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (missingFile(error))
|
|
43
|
+
return null; // unversioned source
|
|
44
|
+
throw new Error(`could not read ${manifestPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
45
|
+
}
|
|
46
|
+
const range = dependencyRange(manifest);
|
|
47
|
+
if (range === undefined || (typeof range === 'string' && range.startsWith('workspace:')))
|
|
48
|
+
return null;
|
|
49
|
+
if (typeof range !== 'string' || !validRange(range)) {
|
|
50
|
+
return `invalid @sequenceholdings/orm range "${String(range)}" in ${manifestPath}`;
|
|
51
|
+
}
|
|
52
|
+
// Resolve beside this CLI, matching the delegated ORM import in every installation layout.
|
|
53
|
+
const ormPackagePath = fileURLToPath(new URL('../package.json', import.meta.resolve('@sequenceholdings/orm/cli')));
|
|
54
|
+
const ormManifest = JSON.parse(await readFile(ormPackagePath, 'utf8'));
|
|
55
|
+
const version = typeof ormManifest === 'object' && ormManifest !== null
|
|
56
|
+
? Reflect.get(ormManifest, 'version') : undefined;
|
|
57
|
+
if (typeof version !== 'string' || !satisfies(version, range)) {
|
|
58
|
+
return `this seq-studio loads @sequenceholdings/orm ${typeof version === 'string' ? version : '(unknown version)'}, ` +
|
|
59
|
+
`but ${manifestPath} requires ${range}. Run the namespace-local CLI after installing its dependencies, ` +
|
|
60
|
+
'or upgrade seq-studio and @sequenceholdings/orm together.';
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
@@ -58,7 +58,10 @@ ${PIPELINE_DISCOVERY_USAGE}
|
|
|
58
58
|
For an existing target release unit, --source-env reads a repository
|
|
59
59
|
from a separately authenticated registered
|
|
60
60
|
environment; -e still selects the target. The target verifies and snapshots
|
|
61
|
-
source bytes before queuing.
|
|
61
|
+
source bytes before queuing. Reviewed pipeline.config.yml source_paths
|
|
62
|
+
can select runtime files/directories while preserving pipeline metadata
|
|
63
|
+
and the release identity. Snapshot and Git-fetch size limits still apply.
|
|
64
|
+
Not available with --dir or migrations.
|
|
62
65
|
enqueue a durable plan, poll progress, then print the completed
|
|
63
66
|
materialize + SDK/graph + compile + live-diff + provision findings
|
|
64
67
|
(no Databricks CLI / DAB validate on Atlas); exit 1 on destructive findings
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ParsedArgs } from '../process/commands.js';
|
|
2
|
+
export declare const PRINCIPALS_USAGE = "usage:\n seq-studio principals search <query> -e <env> [--types user,group,service-account,organization] [--limit <n>]\n seq-studio principals users search <query> -e <env> [--limit <n>]\n seq-studio principals groups list -e <env> [--search <query>] [--limit <n>] [--page <n>]\n seq-studio principals groups show <group-id> -e <env> [--limit <n>] [--offset <n>]\n\n Find the people, groups, service accounts and organizations YOU may grant\n access to, with the exact ids seq-studio access grant takes. Results are JSON;\n each principal carries \"grant\": { \"principalType\", \"principalId\" }.\n Queries need at least 2 characters. search defaults to user,group,service-account.\n\n You see exactly what the Atlas pickers show you, never more:\n people: active users in your organization (Sequence operators: everyone);\n groups: groups you belong to (platform admins: every group), never deleted ones;\n service accounts: accounts you hold actor on; organizations: your own tenant.\n groups show lists a visible group's active members, paged (default 50 per\n page); a group you can't see is reported as not found.\n Authenticate: seq-studio login --env <env> (agent sandbox tokens work too).\n";
|
|
3
|
+
export declare function runPrincipalsCommand(sub: string | undefined, args: ParsedArgs): Promise<number>;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { getJson } from '../atlas-client.js';
|
|
2
|
+
import { printCliError } from '../cli-errors.js';
|
|
3
|
+
import { validateCommandInput, wantsHelp } from '../command-input.js';
|
|
4
|
+
import { buildContext, clientOptions } from '../functions/commands.js';
|
|
5
|
+
const SEARCH_TYPES = ['user', 'group', 'service-account', 'organization'];
|
|
6
|
+
export const PRINCIPALS_USAGE = `usage:
|
|
7
|
+
seq-studio principals search <query> -e <env> [--types user,group,service-account,organization] [--limit <n>]
|
|
8
|
+
seq-studio principals users search <query> -e <env> [--limit <n>]
|
|
9
|
+
seq-studio principals groups list -e <env> [--search <query>] [--limit <n>] [--page <n>]
|
|
10
|
+
seq-studio principals groups show <group-id> -e <env> [--limit <n>] [--offset <n>]
|
|
11
|
+
|
|
12
|
+
Find the people, groups, service accounts and organizations YOU may grant
|
|
13
|
+
access to, with the exact ids seq-studio access grant takes. Results are JSON;
|
|
14
|
+
each principal carries "grant": { "principalType", "principalId" }.
|
|
15
|
+
Queries need at least 2 characters. search defaults to user,group,service-account.
|
|
16
|
+
|
|
17
|
+
You see exactly what the Atlas pickers show you, never more:
|
|
18
|
+
people: active users in your organization (Sequence operators: everyone);
|
|
19
|
+
groups: groups you belong to (platform admins: every group), never deleted ones;
|
|
20
|
+
service accounts: accounts you hold actor on; organizations: your own tenant.
|
|
21
|
+
groups show lists a visible group's active members, paged (default 50 per
|
|
22
|
+
page); a group you can't see is reported as not found.
|
|
23
|
+
Authenticate: seq-studio login --env <env> (agent sandbox tokens work too).
|
|
24
|
+
`;
|
|
25
|
+
function withGrant(principal) {
|
|
26
|
+
const principalType = principal.type === 'service_account' ? 'service-account' : principal.type;
|
|
27
|
+
return { ...principal, grant: { principalType, principalId: principal.id } };
|
|
28
|
+
}
|
|
29
|
+
function numberFlag(args, key) {
|
|
30
|
+
const value = args.flags[key];
|
|
31
|
+
if (value === undefined)
|
|
32
|
+
return undefined;
|
|
33
|
+
if (typeof value !== 'string' || !/^\d+$/.test(value))
|
|
34
|
+
throw new Error(`--${key} must be a non-negative integer.`);
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
function query(params) {
|
|
38
|
+
const search = new URLSearchParams();
|
|
39
|
+
for (const [key, value] of Object.entries(params))
|
|
40
|
+
if (value !== undefined)
|
|
41
|
+
search.set(key, value);
|
|
42
|
+
const text = search.toString();
|
|
43
|
+
return text ? `?${text}` : '';
|
|
44
|
+
}
|
|
45
|
+
function searchQuery(args, index) {
|
|
46
|
+
const text = args.positional[index]?.trim() ?? '';
|
|
47
|
+
if (text.length < 2)
|
|
48
|
+
throw new Error('A search query of at least 2 characters is required.');
|
|
49
|
+
return text;
|
|
50
|
+
}
|
|
51
|
+
const DEFAULT_SEARCH_TYPES = 'user,group,service_account';
|
|
52
|
+
function parseTypes(raw) {
|
|
53
|
+
// Always explicit: the server's own default omits service accounts.
|
|
54
|
+
if (raw === undefined)
|
|
55
|
+
return DEFAULT_SEARCH_TYPES;
|
|
56
|
+
if (typeof raw !== 'string')
|
|
57
|
+
throw new Error(`--types takes a comma-separated list of ${SEARCH_TYPES.join(', ')}.`);
|
|
58
|
+
const types = raw.split(',').map((type) => type.trim()).filter(Boolean);
|
|
59
|
+
const unknown = types.find((type) => !SEARCH_TYPES.includes(type));
|
|
60
|
+
if (unknown || types.length === 0)
|
|
61
|
+
throw new Error(`--types takes a comma-separated list of ${SEARCH_TYPES.join(', ')}.`);
|
|
62
|
+
return types.map((type) => (type === 'service-account' ? 'service_account' : type)).join(',');
|
|
63
|
+
}
|
|
64
|
+
/** Resolve the request path for a subcommand; everything here runs before auth. */
|
|
65
|
+
function requestPath(sub, args) {
|
|
66
|
+
if (sub === 'search') {
|
|
67
|
+
validateCommandInput({ args, flags: { types: 'string', limit: 'string' }, positional: 1 });
|
|
68
|
+
const path = `/api/authz/principals/search${query({ q: searchQuery(args, 0), types: parseTypes(args.flags.types), limit: numberFlag(args, 'limit') })}`;
|
|
69
|
+
return { path, shape: 'principals' };
|
|
70
|
+
}
|
|
71
|
+
const [action, target] = [args.positional[0], args.positional[1]];
|
|
72
|
+
if (sub === 'users') {
|
|
73
|
+
if (action !== 'search')
|
|
74
|
+
throw new Error('Usage: seq-studio principals users search <query> -e <env>');
|
|
75
|
+
validateCommandInput({ args, flags: { limit: 'string' }, positional: 2 });
|
|
76
|
+
return { path: `/api/authz/principals/search${query({ q: searchQuery(args, 1), types: 'user', limit: numberFlag(args, 'limit') })}`, shape: 'principals' };
|
|
77
|
+
}
|
|
78
|
+
if (sub === 'groups' && action === 'list') {
|
|
79
|
+
validateCommandInput({ args, flags: { search: 'string', limit: 'string', page: 'string' }, positional: 1 });
|
|
80
|
+
const search = typeof args.flags.search === 'string' ? args.flags.search : undefined;
|
|
81
|
+
return { path: `/api/authz/principals/groups${query({ q: search, limit: numberFlag(args, 'limit'), page: numberFlag(args, 'page') })}`, shape: 'groups' };
|
|
82
|
+
}
|
|
83
|
+
if (sub === 'groups' && action === 'show') {
|
|
84
|
+
validateCommandInput({ args, flags: { limit: 'string', offset: 'string' }, positional: 2 });
|
|
85
|
+
if (!target?.trim())
|
|
86
|
+
throw new Error('A group id is required. Find it with seq-studio principals groups list.');
|
|
87
|
+
return { path: `/api/authz/principals/groups/${encodeURIComponent(target.trim())}${query({ limit: numberFlag(args, 'limit'), offset: numberFlag(args, 'offset') })}`, shape: 'group' };
|
|
88
|
+
}
|
|
89
|
+
if (sub === 'groups')
|
|
90
|
+
throw new Error('Usage: seq-studio principals groups list|show -e <env>');
|
|
91
|
+
throw new Error(`Unknown principals command: ${sub}. See: seq-studio principals --help`);
|
|
92
|
+
}
|
|
93
|
+
function present(shape, body) {
|
|
94
|
+
const record = body;
|
|
95
|
+
if (shape === 'principals') {
|
|
96
|
+
return { principals: (record.principals ?? []).map(withGrant) };
|
|
97
|
+
}
|
|
98
|
+
if (shape === 'groups') {
|
|
99
|
+
return { ...record, groups: (record.groups ?? []).map((group) => withGrant({ ...group, type: 'group' })) };
|
|
100
|
+
}
|
|
101
|
+
const group = record.group;
|
|
102
|
+
return {
|
|
103
|
+
...record,
|
|
104
|
+
...(group ? { group: withGrant({ ...group, type: 'group' }) } : {}),
|
|
105
|
+
members: (record.members ?? []).map(withGrant),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export async function runPrincipalsCommand(sub, args) {
|
|
109
|
+
if (!sub || wantsHelp({ sub, args })) {
|
|
110
|
+
console.log(PRINCIPALS_USAGE);
|
|
111
|
+
return sub ? 0 : 1;
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
const { path, shape } = requestPath(sub, args);
|
|
115
|
+
const ctx = await buildContext(args);
|
|
116
|
+
const body = await getJson({ ...clientOptions(ctx), path });
|
|
117
|
+
console.log(JSON.stringify(present(shape, body), null, 2));
|
|
118
|
+
return 0;
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
printCliError(error);
|
|
122
|
+
return 1;
|
|
123
|
+
}
|
|
124
|
+
}
|
package/dist/process/runs.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `seq-studio process runs <start|list|show|cancel>` — start and
|
|
3
|
-
* Lattice runs through the programmatic run API, as the caller.
|
|
4
|
-
* `invoker` on the process; reading a run needs
|
|
2
|
+
* `seq-studio process runs <start|retry|list|show|cancel>` — start, retry and
|
|
3
|
+
* observe Lattice runs through the programmatic run API, as the caller.
|
|
4
|
+
* Starting or retrying needs `invoker` on the process; reading a run needs
|
|
5
|
+
* `viewer` on it.
|
|
5
6
|
*/
|
|
6
7
|
import type { ParsedArgs } from './commands.js';
|
|
7
8
|
type Sleep = (ms: number) => Promise<void>;
|
package/dist/process/runs.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `seq-studio process runs <start|list|show|cancel>` — start and
|
|
3
|
-
* Lattice runs through the programmatic run API, as the caller.
|
|
4
|
-
* `invoker` on the process; reading a run needs
|
|
2
|
+
* `seq-studio process runs <start|retry|list|show|cancel>` — start, retry and
|
|
3
|
+
* observe Lattice runs through the programmatic run API, as the caller.
|
|
4
|
+
* Starting or retrying needs `invoker` on the process; reading a run needs
|
|
5
|
+
* `viewer` on it.
|
|
5
6
|
*/
|
|
7
|
+
import { randomUUID } from 'node:crypto';
|
|
6
8
|
import { readFile } from 'node:fs/promises';
|
|
7
9
|
import { getJson, postJson } from '../atlas-client.js';
|
|
8
10
|
import { printCliError } from '../cli-errors.js';
|
|
@@ -12,10 +14,15 @@ import { buildContext, clientOptions } from '../functions/commands.js';
|
|
|
12
14
|
import { table } from '../text-table.js';
|
|
13
15
|
const RUN_STATUSES = ['pending', 'running', 'completed', 'failed', 'cancelled', 'timed_out'];
|
|
14
16
|
const TERMINAL_STATUSES = new Set(['completed', 'failed', 'cancelled', 'timed_out']);
|
|
17
|
+
const RETRYABLE_STATUSES = new Set(['failed', 'cancelled', 'timed_out']);
|
|
15
18
|
const RUN_ID = /^[A-Za-z0-9._-]{2,128}$/;
|
|
16
19
|
const MAX_LIST_LIMIT = 500;
|
|
17
20
|
const DEFAULT_WAIT_SECONDS = 600;
|
|
18
21
|
const WAIT_POLL_MS = 2_000;
|
|
22
|
+
/** Atlas holds a new run `pending` when its process is at `max_concurrent_runs`. */
|
|
23
|
+
function queuedNote(outcome) {
|
|
24
|
+
return outcome === 'queued' ? ' (queued: the process is at its concurrent-run limit; it starts when a slot frees)' : '';
|
|
25
|
+
}
|
|
19
26
|
function stringFlag({ args, key }) {
|
|
20
27
|
const value = args.flags[key];
|
|
21
28
|
return typeof value === 'string' ? value : undefined;
|
|
@@ -26,6 +33,18 @@ function runIdArg({ args, label }) {
|
|
|
26
33
|
throw new Error(`Invalid ${label} '${value}': 2-128 letters, digits, '.', '_' or '-'.`);
|
|
27
34
|
return value;
|
|
28
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* The new run's id: `--run-id` when given, else a fresh UUID. Minting it here
|
|
38
|
+
* rather than leaving it to Atlas keeps the client's own 503 retries of the
|
|
39
|
+
* POST from ever starting a second run.
|
|
40
|
+
*/
|
|
41
|
+
function newRunId(args) {
|
|
42
|
+
const runId = stringFlag({ args, key: 'run-id' });
|
|
43
|
+
if (runId !== undefined && !RUN_ID.test(runId)) {
|
|
44
|
+
throw new Error(`Invalid --run-id '${runId}': 2-128 letters, digits, '.', '_' or '-'.`);
|
|
45
|
+
}
|
|
46
|
+
return runId ?? randomUUID();
|
|
47
|
+
}
|
|
29
48
|
function errorText(error) {
|
|
30
49
|
if (error === null || error === undefined)
|
|
31
50
|
return undefined;
|
|
@@ -55,10 +74,7 @@ export async function startRunBody(args) {
|
|
|
55
74
|
flags: { version: 'string', 'run-id': 'string', 'metadata-file': 'string', title: 'string', entity: 'string' },
|
|
56
75
|
positional: 2,
|
|
57
76
|
});
|
|
58
|
-
const runId =
|
|
59
|
-
if (runId !== undefined && !RUN_ID.test(runId)) {
|
|
60
|
-
throw new Error(`Invalid --run-id '${runId}': 2-128 letters, digits, '.', '_' or '-'.`);
|
|
61
|
-
}
|
|
77
|
+
const runId = newRunId(args);
|
|
62
78
|
const entity = stringFlag({ args, key: 'entity' });
|
|
63
79
|
const separator = entity?.indexOf(':') ?? -1;
|
|
64
80
|
if (entity !== undefined && (separator < 1 || separator === entity.length - 1)) {
|
|
@@ -70,7 +86,7 @@ export async function startRunBody(args) {
|
|
|
70
86
|
return {
|
|
71
87
|
process_id: args.positional[1],
|
|
72
88
|
...(version !== undefined ? { version } : {}),
|
|
73
|
-
|
|
89
|
+
run_id: runId,
|
|
74
90
|
...(title !== undefined ? { title } : {}),
|
|
75
91
|
...(entity !== undefined ? { entity: { type: entity.slice(0, separator), id: entity.slice(separator + 1) } } : {}),
|
|
76
92
|
...(metadataFile !== undefined ? { metadata: await metadataFromFile(metadataFile) } : {}),
|
|
@@ -148,8 +164,33 @@ async function startRun({ args, json }) {
|
|
|
148
164
|
console.log(JSON.stringify(result, null, 2));
|
|
149
165
|
return 0;
|
|
150
166
|
}
|
|
151
|
-
const
|
|
152
|
-
|
|
167
|
+
const status = result.existing_status ?? result.status;
|
|
168
|
+
const replay = result.idempotent_replay ? ' (existing run; a run id names one run and never starts another)' : '';
|
|
169
|
+
console.log(`Run: ${result.run_id} | Process: ${result.process_id}@${result.process_version ?? '—'} | Status: ${status}${replay}${queuedNote(result.outcome)}`);
|
|
170
|
+
if (result.idempotent_replay && RETRYABLE_STATUSES.has(status)) {
|
|
171
|
+
console.log(`Retry it with: seq-studio process runs retry ${result.run_id}`);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
console.log(`Follow it with: seq-studio process runs show ${result.run_id} --wait`);
|
|
175
|
+
}
|
|
176
|
+
return 0;
|
|
177
|
+
}
|
|
178
|
+
async function retryRun({ args, json }) {
|
|
179
|
+
validateCommandInput({ args, flags: { 'run-id': 'string' }, positional: 2 });
|
|
180
|
+
const sourceRunId = runIdArg({ args, label: 'run id' });
|
|
181
|
+
const runId = newRunId(args);
|
|
182
|
+
const ctx = await buildContext(args);
|
|
183
|
+
const result = await postJson({
|
|
184
|
+
...clientOptions(ctx),
|
|
185
|
+
path: `/api/lattice/runs/${encodeURIComponent(sourceRunId)}/retry`,
|
|
186
|
+
body: { run_id: runId },
|
|
187
|
+
});
|
|
188
|
+
if (json) {
|
|
189
|
+
console.log(JSON.stringify(result, null, 2));
|
|
190
|
+
return 0;
|
|
191
|
+
}
|
|
192
|
+
const replay = result.idempotent_replay ? ' (existing retry; this run id was already used)' : '';
|
|
193
|
+
console.log(`Run: ${result.run_id} | Retry of: ${result.retry_of} | Process: ${result.process_id}@${result.process_version ?? '—'} | Status: ${result.status}${replay}${queuedNote(result.outcome)}`);
|
|
153
194
|
console.log(`Follow it with: seq-studio process runs show ${result.run_id} --wait`);
|
|
154
195
|
return 0;
|
|
155
196
|
}
|
|
@@ -208,6 +249,7 @@ async function cancelRun({ args, json }) {
|
|
|
208
249
|
}
|
|
209
250
|
const RUN_ACTIONS = {
|
|
210
251
|
start: startRun,
|
|
252
|
+
retry: retryRun,
|
|
211
253
|
list: listRuns,
|
|
212
254
|
show: showRun,
|
|
213
255
|
cancel: cancelRun,
|
package/dist/release-age.d.ts
CHANGED
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
* The YAML templates under templates/ carry the same list; a test keeps them
|
|
10
10
|
* in sync with this one.
|
|
11
11
|
*/
|
|
12
|
-
export declare const FIRST_PARTY_RELEASE_AGE_EXCLUDE: readonly ["@sequenceholdings/agent-spec", "@sequenceholdings/artifact-studio", "@sequenceholdings/atlas-ui", "@sequenceholdings/custom-roles-manifest", "@sequenceholdings/lattice", "@sequenceholdings/lattice-form-renderer", "@sequenceholdings/managed-functions", "@sequenceholdings/orm", "@sequenceholdings/pipeline-spec", "@sequenceholdings/storage", "@sequenceholdings/studio-cli"];
|
|
12
|
+
export declare const FIRST_PARTY_RELEASE_AGE_EXCLUDE: readonly ["@sequenceholdings/agent-spec", "@sequenceholdings/artifact-studio", "@sequenceholdings/atlas-ui", "@sequenceholdings/custom-roles-manifest", "@sequenceholdings/lattice", "@sequenceholdings/lattice-form-renderer", "@sequenceholdings/managed-functions", "@sequenceholdings/orm", "@sequenceholdings/pipeline-spec", "@sequenceholdings/platform", "@sequenceholdings/storage", "@sequenceholdings/studio-cli"];
|
package/dist/release-age.js
CHANGED
|
@@ -19,6 +19,7 @@ export const FIRST_PARTY_RELEASE_AGE_EXCLUDE = [
|
|
|
19
19
|
'@sequenceholdings/managed-functions',
|
|
20
20
|
'@sequenceholdings/orm',
|
|
21
21
|
'@sequenceholdings/pipeline-spec',
|
|
22
|
+
'@sequenceholdings/platform',
|
|
22
23
|
'@sequenceholdings/storage',
|
|
23
24
|
'@sequenceholdings/studio-cli',
|
|
24
25
|
];
|
package/dist/repos/commands.d.ts
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
import type { ParsedArgs } from '../process/commands.js';
|
|
2
2
|
import { type CommandContext } from '../functions/commands.js';
|
|
3
3
|
import { type RunGitClone } from './git-clone.js';
|
|
4
|
+
import type { RepositoryIdentity } from '@sequenceholdings/artifact-studio/repository-identity';
|
|
4
5
|
import { type ResolvedEnv } from '../config.js';
|
|
6
|
+
interface ReviewPolicyDTO {
|
|
7
|
+
codexReview?: boolean;
|
|
8
|
+
claudeReview?: boolean;
|
|
9
|
+
requiredReviews?: boolean;
|
|
10
|
+
requiredReviewMode?: string;
|
|
11
|
+
requiredChecks?: string[];
|
|
12
|
+
}
|
|
13
|
+
export interface RepoDTO {
|
|
14
|
+
id: string;
|
|
15
|
+
namespaceId: string;
|
|
16
|
+
name: string;
|
|
17
|
+
defaultBranch: string;
|
|
18
|
+
reviewPolicy?: ReviewPolicyDTO | null;
|
|
19
|
+
gitBackend?: string;
|
|
20
|
+
repositoryIdentity?: RepositoryIdentity | null;
|
|
21
|
+
createdBy: string;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
updatedAt: string;
|
|
24
|
+
}
|
|
5
25
|
export declare function parseRepoPath(input: string | undefined): {
|
|
6
26
|
namespace: string;
|
|
7
27
|
name: string;
|
|
@@ -43,8 +63,32 @@ export declare function assertSafeForceDest(destDir: string): void;
|
|
|
43
63
|
export declare function reposNamespacesCommand(args: ParsedArgs): Promise<number>;
|
|
44
64
|
export declare function reposListCommand(args: ParsedArgs): Promise<number>;
|
|
45
65
|
export declare function reposShowCommand(args: ParsedArgs): Promise<number>;
|
|
66
|
+
/**
|
|
67
|
+
* Create a git-service repo. Without `gitBackend` Atlas seeds it with a README
|
|
68
|
+
* and the `.seq/identity.json` receipt; `gitBackend: 'walgit'` creates it empty
|
|
69
|
+
* for pushing existing history. 409 when the name is taken.
|
|
70
|
+
*/
|
|
71
|
+
export declare function createRepo({ ctx, namespace, name, defaultBranch, gitBackend, }: {
|
|
72
|
+
ctx: CommandContext;
|
|
73
|
+
namespace: string;
|
|
74
|
+
name: string;
|
|
75
|
+
defaultBranch?: string;
|
|
76
|
+
gitBackend?: 'walgit';
|
|
77
|
+
}): Promise<RepoDTO>;
|
|
46
78
|
export declare function reposCreateCommand(args: ParsedArgs): Promise<number>;
|
|
47
79
|
export declare function reposPullCommand(args: ParsedArgs): Promise<number>;
|
|
80
|
+
/** A real Git checkout needs a user login or a sandbox credential, never an M2M identity. */
|
|
81
|
+
export declare function assertGitCheckoutAuth(ctx: CommandContext): void;
|
|
82
|
+
/**
|
|
83
|
+
* Clone a resolved repository's default branch (shallow, like `repos clone`)
|
|
84
|
+
* into an absent or empty `destDir`. Returns the origin URL it configured.
|
|
85
|
+
*/
|
|
86
|
+
export declare function cloneRepoById({ ctx, repoId, destDir, gitClone, }: {
|
|
87
|
+
ctx: CommandContext;
|
|
88
|
+
repoId: string;
|
|
89
|
+
destDir: string;
|
|
90
|
+
gitClone?: RunGitClone;
|
|
91
|
+
}): Promise<string>;
|
|
48
92
|
/** Git clone always uses the selected human login, never an ambient PAT. */
|
|
49
93
|
export declare function reposCloneCommand(args: ParsedArgs, deps?: {
|
|
50
94
|
gitClone?: RunGitClone;
|
package/dist/repos/commands.js
CHANGED
|
@@ -297,15 +297,13 @@ function parseGitBackendFlag(args) {
|
|
|
297
297
|
}
|
|
298
298
|
return gitBackend;
|
|
299
299
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
const repo = await postJson({
|
|
300
|
+
/**
|
|
301
|
+
* Create a git-service repo. Without `gitBackend` Atlas seeds it with a README
|
|
302
|
+
* and the `.seq/identity.json` receipt; `gitBackend: 'walgit'` creates it empty
|
|
303
|
+
* for pushing existing history. 409 when the name is taken.
|
|
304
|
+
*/
|
|
305
|
+
export async function createRepo({ ctx, namespace, name, defaultBranch, gitBackend, }) {
|
|
306
|
+
return postJson({
|
|
309
307
|
...clientOptions(ctx),
|
|
310
308
|
path: '/api/git-service/repos',
|
|
311
309
|
body: {
|
|
@@ -315,6 +313,22 @@ export async function reposCreateCommand(args) {
|
|
|
315
313
|
...(gitBackend ? { gitBackend } : {}),
|
|
316
314
|
},
|
|
317
315
|
});
|
|
316
|
+
}
|
|
317
|
+
export async function reposCreateCommand(args) {
|
|
318
|
+
const { namespace, name } = parseRepoPath(args.positional[0]);
|
|
319
|
+
const ctx = await reposContext(args);
|
|
320
|
+
const defaultBranch = stringFlag(args.flags, 'default-branch');
|
|
321
|
+
const gitBackend = parseGitBackendFlag(args);
|
|
322
|
+
if (gitBackend === 'walgit' && defaultBranch !== undefined && defaultBranch !== 'main') {
|
|
323
|
+
throw new Error('walgit create does not set HEAD from --default-branch; omit it or use main.');
|
|
324
|
+
}
|
|
325
|
+
const repo = await createRepo({
|
|
326
|
+
ctx,
|
|
327
|
+
namespace,
|
|
328
|
+
name,
|
|
329
|
+
...(defaultBranch ? { defaultBranch } : {}),
|
|
330
|
+
...(gitBackend ? { gitBackend } : {}),
|
|
331
|
+
});
|
|
318
332
|
const backend = repo.gitBackend ?? gitBackend;
|
|
319
333
|
console.log(`${LOG} created ${namespace}/${name} (id=${repo.id}, default branch ${repo.defaultBranch}${backend ? `, gitBackend=${backend}` : ''}) on ${ctx.env.name}`);
|
|
320
334
|
return 0;
|
|
@@ -373,13 +387,40 @@ function parseCloneOptions(args) {
|
|
|
373
387
|
throw new Error('--transport json requires <namespace>/<name>.');
|
|
374
388
|
return { force, ref, depth, output, urlFlag, idFlag, positional, transport };
|
|
375
389
|
}
|
|
376
|
-
|
|
377
|
-
|
|
390
|
+
/** A real Git checkout needs a user login or a sandbox credential, never an M2M identity. */
|
|
391
|
+
export function assertGitCheckoutAuth(ctx) {
|
|
378
392
|
if (ctx.authMode === 'm2m') {
|
|
379
393
|
throw new Error(`Git clone requires a user login: seq-studio login --env ${ctx.env.name}. Use repos pull for M2M JSON materialization.`);
|
|
380
394
|
}
|
|
395
|
+
}
|
|
396
|
+
async function gitCloneContext(args) {
|
|
397
|
+
const ctx = await reposContext(args);
|
|
398
|
+
assertGitCheckoutAuth(ctx);
|
|
381
399
|
return ctx;
|
|
382
400
|
}
|
|
401
|
+
/**
|
|
402
|
+
* Clone over smart-HTTP into `destDir` (absent or empty unless `force`) and
|
|
403
|
+
* bind the checkout's credential helper to this environment and repository.
|
|
404
|
+
*/
|
|
405
|
+
async function cloneCheckout({ ctx, targetUrl, destDir, force, ref, depth, gitClone, }) {
|
|
406
|
+
prepareCloneDest({ destDir, force });
|
|
407
|
+
await (gitClone ?? runGitClone)({
|
|
408
|
+
cloneUrl: targetUrl, destDir, pat: ctx.token,
|
|
409
|
+
...(ref ? { ref } : {}),
|
|
410
|
+
...(depth != null ? { depth } : {}),
|
|
411
|
+
});
|
|
412
|
+
await configureGitLogin({ destDir, envName: ctx.env.name, cloneUrl: targetUrl });
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Clone a resolved repository's default branch (shallow, like `repos clone`)
|
|
416
|
+
* into an absent or empty `destDir`. Returns the origin URL it configured.
|
|
417
|
+
*/
|
|
418
|
+
export async function cloneRepoById({ ctx, repoId, destDir, gitClone, }) {
|
|
419
|
+
assertGitCheckoutAuth(ctx);
|
|
420
|
+
const targetUrl = normalizeCloneUrl(cloneUrl(ctx, repoId), ctx.env);
|
|
421
|
+
await cloneCheckout({ ctx, targetUrl, destDir, force: false, depth: smartHttpCloneDepth({ full: false }), ...(gitClone ? { gitClone } : {}) });
|
|
422
|
+
return targetUrl;
|
|
423
|
+
}
|
|
383
424
|
/** Git clone always uses the selected human login, never an ambient PAT. */
|
|
384
425
|
export async function reposCloneCommand(args, deps = {}) {
|
|
385
426
|
const { force, ref, depth, output, urlFlag, idFlag, positional, transport } = parseCloneOptions(args);
|
|
@@ -411,13 +452,12 @@ export async function reposCloneCommand(args, deps = {}) {
|
|
|
411
452
|
}
|
|
412
453
|
targetUrl = normalizeCloneUrl(targetUrl, env);
|
|
413
454
|
const destDir = resolve(output ?? defaultOut);
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
cloneUrl: targetUrl, destDir, pat: ctx.token,
|
|
455
|
+
await cloneCheckout({
|
|
456
|
+
ctx, targetUrl, destDir, force,
|
|
417
457
|
...(ref ? { ref } : {}),
|
|
418
458
|
...(depth != null ? { depth } : {}),
|
|
459
|
+
...(deps.gitClone ? { gitClone: deps.gitClone } : {}),
|
|
419
460
|
});
|
|
420
|
-
await configureGitLogin({ destDir, envName: env.name, cloneUrl: targetUrl });
|
|
421
461
|
console.log(`${LOG} cloned ${positional ?? targetUrl} → ${destDir}` +
|
|
422
462
|
(ref ? ` (ref ${ref})` : '') +
|
|
423
463
|
` via smart-HTTP${depth != null ? ` (depth ${depth})` : ''}`);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ParsedArgs } from '../process/commands.js';
|
|
2
|
+
import type { RunGitClone } from './git-clone.js';
|
|
3
|
+
type LocalCheckout = {
|
|
4
|
+
mode: 'clone';
|
|
5
|
+
targetDir: string;
|
|
6
|
+
} | {
|
|
7
|
+
mode: 'origin';
|
|
8
|
+
root: string;
|
|
9
|
+
origin: string | null;
|
|
10
|
+
};
|
|
11
|
+
export declare function inspectLocalCheckout(targetDir: string): Promise<LocalCheckout>;
|
|
12
|
+
/** How the checkout came to point at the repository; it decides the push steps. */
|
|
13
|
+
export type RepoSetup = 'cloned' | 'origin-created' | 'origin-added' | 'origin-kept';
|
|
14
|
+
export declare function persistNextSteps({ root, repoPath, envName, defaultBranch, setup }: {
|
|
15
|
+
root: string;
|
|
16
|
+
repoPath: string;
|
|
17
|
+
envName: string;
|
|
18
|
+
defaultBranch: string;
|
|
19
|
+
setup: RepoSetup;
|
|
20
|
+
}): string[];
|
|
21
|
+
/**
|
|
22
|
+
* Prepare the repository checkout for `target`, run `scaffold` in it, then
|
|
23
|
+
* print how to commit and push. Returns the scaffold's exit code (1 when the
|
|
24
|
+
* repository could not be prepared).
|
|
25
|
+
*/
|
|
26
|
+
export declare function runInitWithRepo({ args, target, scaffold, deps }: {
|
|
27
|
+
args: ParsedArgs;
|
|
28
|
+
target: string;
|
|
29
|
+
scaffold: () => Promise<number>;
|
|
30
|
+
deps?: {
|
|
31
|
+
gitClone?: RunGitClone;
|
|
32
|
+
};
|
|
33
|
+
}): Promise<number>;
|
|
34
|
+
/** The same parsed arguments with `--repo` removed, for the scaffold itself. */
|
|
35
|
+
export declare function withoutRepoFlag(args: ParsedArgs): ParsedArgs;
|
|
36
|
+
/**
|
|
37
|
+
* For delegated init commands that forward raw argv: split `--repo <v>` /
|
|
38
|
+
* `--repo=<v>` off. `repo` is undefined when absent and `true` when given
|
|
39
|
+
* without a value (so the caller can report it like any other flag).
|
|
40
|
+
*/
|
|
41
|
+
export declare function extractRepoFlag(argv: readonly string[]): {
|
|
42
|
+
repo: string | true | undefined;
|
|
43
|
+
rest: string[];
|
|
44
|
+
};
|
|
45
|
+
export {};
|