@sequenceholdings/studio-cli 0.9.10 → 0.9.13

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.
@@ -3,21 +3,37 @@ import { getJson, putJson } from '../atlas-client.js';
3
3
  import { printCliError } from '../cli-errors.js';
4
4
  import { requiredStringFlag, validateCommandInput } from '../command-input.js';
5
5
  import { buildContext, clientOptions } from '../functions/commands.js';
6
+ function repository(args) {
7
+ const repo = requiredStringFlag({ args, key: 'repo' }).split('/');
8
+ if (repo.length !== 2 || !repo[0] || !repo[1])
9
+ throw new Error('--repo must be <namespace>/<name>.');
10
+ return { repositoryNamespace: repo[0], repositoryName: repo[1], branch: requiredStringFlag({ args, key: 'branch' }) };
11
+ }
6
12
  function selection(args) {
7
- validateCommandInput({ args, flags: { mode: 'string', repo: 'string', branch: 'string', target: 'string' }, positional: 1 });
13
+ validateCommandInput({ args, flags: { mode: 'string', repo: 'string', branch: 'string', target: 'string', path: 'string' }, positional: 1 });
8
14
  const mode = args.flags.mode;
9
- if (mode !== undefined && mode !== 'manual' && mode !== 'ci')
10
- throw new Error('--mode must be manual or ci.');
11
- if (mode !== 'ci') {
12
- if (['repo', 'branch', 'target'].some(key => args.flags[key] !== undefined))
13
- throw new Error('--repo, --branch and --target require --mode ci.');
15
+ if (mode !== undefined && mode !== 'manual' && mode !== 'ci' && mode !== 'source')
16
+ throw new Error('--mode must be manual, ci or source.');
17
+ if (mode === undefined || mode === 'manual') {
18
+ if (['repo', 'branch', 'target', 'path'].some(key => args.flags[key] !== undefined))
19
+ throw new Error('--repo, --branch, --target and --path require --mode ci or source.');
14
20
  return { mode };
15
21
  }
16
- const repo = requiredStringFlag({ args, key: 'repo' }).split('/');
17
- if (repo.length !== 2 || !repo[0] || !repo[1])
18
- throw new Error('--repo must be <namespace>/<name>.');
19
- return { mode, repositoryNamespace: repo[0], repositoryName: repo[1],
20
- branch: requiredStringFlag({ args, key: 'branch' }), target: requiredStringFlag({ args, key: 'target' }) };
22
+ if (mode === 'ci') {
23
+ if (args.flags.path !== undefined)
24
+ throw new Error('--path applies only to --mode source.');
25
+ return { mode, ...repository(args), target: requiredStringFlag({ args, key: 'target' }) };
26
+ }
27
+ if (args.flags.target !== undefined)
28
+ throw new Error('--target applies only to --mode ci.');
29
+ return { mode, ...repository(args), path: requiredStringFlag({ args, key: 'path' }) };
30
+ }
31
+ function describe(policy) {
32
+ if (policy.mode === 'manual')
33
+ return 'manual deployment';
34
+ if (policy.mode === 'ci')
35
+ return `CI-managed (${policy.repository_id}, ${policy.branch}, ${policy.target_key})`;
36
+ return `direct applies only from ${policy.branch}:${policy.path === '' ? '.' : policy.path} in ${policy.repository_id}, verified by Atlas`;
21
37
  }
22
38
  export async function ormDeploymentPolicyCommand(args) {
23
39
  try {
@@ -27,19 +43,19 @@ export async function ormDeploymentPolicyCommand(args) {
27
43
  let result;
28
44
  if (selected.mode === undefined)
29
45
  result = await getJson({ ...options, path });
46
+ else if (!('repositoryNamespace' in selected))
47
+ result = await putJson({ ...options, path, body: { mode: 'manual' } });
30
48
  else {
49
+ const repositoryId = (await resolveRepo({ ...options, namespace: selected.repositoryNamespace, name: selected.repositoryName })).id;
31
50
  const body = selected.mode === 'ci'
32
- ? { mode: 'ci', repository_id: (await resolveRepo({ ...options, namespace: selected.repositoryNamespace, name: selected.repositoryName })).id,
33
- branch: selected.branch, target_key: selected.target }
34
- : { mode: 'manual' };
51
+ ? { mode: 'ci', repository_id: repositoryId, branch: selected.branch, target_key: selected.target }
52
+ : { mode: 'source', repository_id: repositoryId, branch: selected.branch, path: selected.path };
35
53
  result = await putJson({ ...options, path, body });
36
54
  }
37
55
  if (args.flags.json === true)
38
56
  console.log(JSON.stringify(result, null, 2));
39
- else {
40
- const policy = result.deployment_policy;
41
- console.log(`${result.namespace}: ${policy.mode === 'manual' ? 'manual deployment' : `CI-managed (${policy.repository_id}, ${policy.branch}, ${policy.target_key})`}`);
42
- }
57
+ else
58
+ console.log(`${result.namespace}: ${describe(result.deployment_policy)}`);
43
59
  return 0;
44
60
  }
45
61
  catch (error) {
@@ -1 +1 @@
1
- export declare const ORM_USAGE = "usage:\n seq-studio orm init <dir> [--repo <ns>/<name>]\n scaffold a namespace package (v2: TypeScript schema + GraphQL documents);\n --repo scaffolds into a git-service repo (see Init into a repo below)\n seq-studio orm generate [dir] write schema.graphql + operations.manifest.json + typePolicies.gen.ts (offline; runs consumer codegen when codegen.ts is present)\n seq-studio orm generate [dir] --migration-export [--check]\n export reviewed ORM inputs for a coordinated pipeline migration; --check verifies without writing\n seq-studio orm validate [dir] parse + validate definitions and verify committed migrations are in sync\n seq-studio orm plan [dir] -e <env> compile definitions and diff against the registry\n seq-studio orm apply [dir] -e <env> [--timeout <duration>] [--no-wait]\n author the migration, register, apply, and refresh the generated outputs (the everyday command);\n waits until the new version is live (default up to 20m; e.g. --timeout 90s), --no-wait returns once queued\n seq-studio orm plan|apply --repo <ns>/<name> [--path <dir>] [--ref <ref>] -e <env>\n plan/apply a namespace committed to a platform git-service repo (CI deploy-from-git);\n --path selects the namespace directory (default: repo root). A remote apply never\n authors migrations: the committed ledger must already match the definitions.\n seq-studio orm execute <namespace> <operation> -e <env> [--variables-file <file>] [--var <name>=<value>]...\n run the deployed version's persisted operation by name as the caller (no checkout)\n seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>\n execute from the checkout manifest through the installed ORM package\n both execute forms accept --variables-file - (or /dev/stdin) for JSON stdin until EOF\n seq-studio orm read <namespace> <table> -e <env> [--where c=op.v]... [--select c,...] [--order c.desc] [--limit N] [--offset N] [--json|--jsonl]\n read rows of a deployed v2 namespace as the caller (row-level security applies)\n seq-studio orm sql <namespace> --query <sql> | --file <path> -e <env> [--param name[:type]=v]... | [--params <json-object>] [--json|--jsonl]\n run read-only SQL against a deployed v2 namespace as the caller\n seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]\n list the namespaces you can read\n seq-studio orm deployment-policy <namespace> -e <env> [--mode manual|ci] [--repo <ns>/<name> --branch <branch> --target <target-key>] [--json]\n inspect or explicitly change the namespace's deployment controller\n seq-studio orm describe <namespace> [<table> | --operations] -e <env> [--json]\n show a namespace's tables, views, and persisted operations (with variables), or one table's columns and actions\n seq-studio orm diff [dir] write/verify the committed migration standalone (--check is the offline CI gate; --allow-destructive consents; --rebase records a v1 -> v2 conversion)\n seq-studio orm migrate-from-yaml <dir> convert a v1 YAML namespace to the v2 TypeScript format (offline; migrations/ preserved)\n seq-studio orm import [dir] --spec <file> | --table <t> --from <schema.table> --map <target=source,...>\n plan a batched copy from an existing Postgres relation into an owned table (writes a SQL script; no database connection)\n\n Environments: see `seq-studio envs list` (built-in: local; more are\n discovered after you authenticate).\n Authenticate with: seq-studio login\n\n Init into a repo: --repo <ns>/<name> on an init command creates that platform\n git-service repo if missing (same name rules as repos create), then clones it\n into <dir> and scaffolds there, or, when <dir> is inside a Git checkout, sets\n it as that checkout's origin (a different existing origin is refused). It\n needs -e <env>, or an agent sandbox. Nothing is committed or pushed; the\n command prints the git add, commit, and push to run.\n In a git-service checkout (with or without --repo), orm init, functions init\n and artifact init also declare the scaffold under resources in\n .seq/repository.yml, so repository CI checks and deploys it. A scaffold inside\n a declared application is not declared; add it to that app with seq-studio add.\n";
1
+ export declare const ORM_USAGE = "usage:\n seq-studio orm init <dir> [--repo <ns>/<name>]\n scaffold a namespace package (v2: TypeScript schema + GraphQL documents);\n --repo scaffolds into a git-service repo (see Init into a repo below)\n seq-studio orm generate [dir] write schema.graphql + operations.manifest.json + typePolicies.gen.ts (offline; runs consumer codegen when codegen.ts is present)\n seq-studio orm generate [dir] --migration-export [--check]\n export reviewed ORM inputs for a coordinated pipeline migration; --check verifies without writing\n seq-studio orm validate [dir] parse + validate definitions and verify committed migrations are in sync\n seq-studio orm plan [dir] -e <env> compile definitions and diff against the registry\n seq-studio orm apply [dir] -e <env> [--timeout <duration>] [--no-wait] [--unverified-source \"<reason>\"]\n author the migration, register, apply, and refresh the generated outputs (the everyday command);\n waits until the new version is live (default up to 20m; e.g. --timeout 90s), --no-wait returns once queued\n seq-studio orm plan|apply --repo <ns>/<name> [--path <dir>] [--ref <ref>] -e <env>\n plan/apply a namespace committed to a platform git-service repo (CI deploy-from-git);\n --path selects the namespace directory (default: repo root). A remote apply never\n authors migrations: the committed ledger must already match the definitions.\n seq-studio orm execute <namespace> <operation> -e <env> [--variables-file <file>] [--var <name>=<value>]...\n run the deployed version's persisted operation by name as the caller (no checkout)\n seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>\n execute from the checkout manifest through the installed ORM package\n both execute forms accept --variables-file - (or /dev/stdin) for JSON stdin until EOF\n seq-studio orm read <namespace> <table> -e <env> [--where c=op.v]... [--select c,...] [--order c.desc] [--limit N] [--offset N] [--json|--jsonl]\n read rows of a deployed v2 namespace as the caller (row-level security applies)\n seq-studio orm sql <namespace> --query <sql> | --file <path> -e <env> [--param name[:type]=v]... | [--params <json-object>] [--json|--jsonl]\n run read-only SQL against a deployed v2 namespace as the caller\n qualify tables and double-quote mixed-case columns (e.g. SELECT \"loanNumber\" FROM lending.loans)\n seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]\n list the namespaces you can read\n seq-studio orm history <namespace> -e <env> [--limit N] [--json]\n seq-studio orm deployment-policy <namespace> -e <env> [--mode manual|ci|source] [--repo <ns>/<name> --branch <branch> (--target <target-key> | --path <dir>)] [--json]\n inspect or explicitly change the namespace's deployment controller\n seq-studio orm describe <namespace> [<table> | --operations] -e <env> [--json]\n show a namespace's tables, views, and persisted operations (with variables), or one table's columns and actions\n seq-studio orm diff [dir] write/verify the committed migration standalone (--check is the offline CI gate; --allow-destructive consents; --rebase records a v1 -> v2 conversion)\n seq-studio orm migrate-from-yaml <dir> convert a v1 YAML namespace to the v2 TypeScript format (offline; migrations/ preserved)\n seq-studio orm import [dir] --spec <file> | --table <t> --from <schema.table> --map <target=source,...>\n plan a batched copy from an existing Postgres relation into an owned table (writes a SQL script; no database connection)\n\n Environments: see `seq-studio envs list` (built-in: local; more are\n discovered after you authenticate).\n Authenticate with: seq-studio login\n\n Init into a repo: --repo <ns>/<name> on an init command creates that platform\n git-service repo if missing (same name rules as repos create), then clones it\n into <dir> and scaffolds there, or, when <dir> is inside a Git checkout, sets\n it as that checkout's origin (a different existing origin is refused). It\n needs -e <env>, or an agent sandbox. Nothing is committed or pushed; the\n command prints the git add, commit, and push to run.\n In a git-service checkout (with or without --repo), orm init, functions init\n and artifact init also declare the scaffold under resources in\n .seq/repository.yml, so repository CI checks and deploys it. A scaffold inside\n a declared application is not declared; add it to that app with seq-studio add.\n";
package/dist/orm/help.js CHANGED
@@ -8,7 +8,7 @@ export const ORM_USAGE = `usage:
8
8
  export reviewed ORM inputs for a coordinated pipeline migration; --check verifies without writing
9
9
  seq-studio orm validate [dir] parse + validate definitions and verify committed migrations are in sync
10
10
  seq-studio orm plan [dir] -e <env> compile definitions and diff against the registry
11
- seq-studio orm apply [dir] -e <env> [--timeout <duration>] [--no-wait]
11
+ seq-studio orm apply [dir] -e <env> [--timeout <duration>] [--no-wait] [--unverified-source "<reason>"]
12
12
  author the migration, register, apply, and refresh the generated outputs (the everyday command);
13
13
  waits until the new version is live (default up to 20m; e.g. --timeout 90s), --no-wait returns once queued
14
14
  seq-studio orm plan|apply --repo <ns>/<name> [--path <dir>] [--ref <ref>] -e <env>
@@ -24,9 +24,11 @@ export const ORM_USAGE = `usage:
24
24
  read rows of a deployed v2 namespace as the caller (row-level security applies)
25
25
  seq-studio orm sql <namespace> --query <sql> | --file <path> -e <env> [--param name[:type]=v]... | [--params <json-object>] [--json|--jsonl]
26
26
  run read-only SQL against a deployed v2 namespace as the caller
27
+ qualify tables and double-quote mixed-case columns (e.g. SELECT "loanNumber" FROM lending.loans)
27
28
  seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]
28
29
  list the namespaces you can read
29
- seq-studio orm deployment-policy <namespace> -e <env> [--mode manual|ci] [--repo <ns>/<name> --branch <branch> --target <target-key>] [--json]
30
+ seq-studio orm history <namespace> -e <env> [--limit N] [--json]
31
+ seq-studio orm deployment-policy <namespace> -e <env> [--mode manual|ci|source] [--repo <ns>/<name> --branch <branch> (--target <target-key> | --path <dir>)] [--json]
30
32
  inspect or explicitly change the namespace's deployment controller
31
33
  seq-studio orm describe <namespace> [<table> | --operations] -e <env> [--json]
32
34
  show a namespace's tables, views, and persisted operations (with variables), or one table's columns and actions
@@ -0,0 +1,23 @@
1
+ import type { ParsedArgs } from '../argv.js';
2
+ export interface ActivationRow {
3
+ id: string;
4
+ kind: 'schema' | 'operations' | 'attest';
5
+ version_id: string;
6
+ operation_set_id: string | null;
7
+ provenance_class: 'repository_verified' | 'ci_intent' | 'reported';
8
+ source_repository_id: string | null;
9
+ source_commit: string | null;
10
+ source_branch: string | null;
11
+ source_path: string | null;
12
+ intent_id: string | null;
13
+ ledger_ordinal: number | null;
14
+ reported_source: Record<string, unknown> | null;
15
+ actor_sub: string;
16
+ activated_at: string;
17
+ }
18
+ /** One line per activation: when, who, what moved, and where it came from. */
19
+ export declare function formatActivation({ row, active }: {
20
+ row: ActivationRow;
21
+ active: boolean;
22
+ }): string;
23
+ export declare function ormHistoryCommand(args: ParsedArgs): Promise<number>;
@@ -0,0 +1,58 @@
1
+ import { getJson } from '../atlas-client.js';
2
+ import { printCliError } from '../cli-errors.js';
3
+ import { validateCommandInput } from '../command-input.js';
4
+ import { buildContext, clientOptions } from '../functions/commands.js';
5
+ const DEFAULT_LIMIT = 20;
6
+ function limitFlag(args) {
7
+ const raw = args.flags.limit;
8
+ if (raw === undefined)
9
+ return DEFAULT_LIMIT;
10
+ const limit = Number(raw);
11
+ if (!Number.isInteger(limit) || limit < 1 || limit > 500)
12
+ throw new Error('--limit must be an integer from 1 to 500.');
13
+ return limit;
14
+ }
15
+ /** One line per activation: when, who, what moved, and where it came from. */
16
+ export function formatActivation({ row, active }) {
17
+ const actor = row.actor_sub.replace(/^google-apps\|/, '');
18
+ const what = row.kind === 'schema' ? `schema ${row.version_id.slice(0, 8)}${row.ledger_ordinal === null ? '' : ` (ledger ${row.ledger_ordinal})`}`
19
+ : row.kind === 'operations' ? `operations ${row.operation_set_id?.slice(0, 8) ?? '-'}`
20
+ : `attest ${row.version_id.slice(0, 8)}`;
21
+ const claimed = row.reported_source;
22
+ const where = row.provenance_class === 'reported'
23
+ ? `reported${typeof claimed?.commit === 'string' ? ` ${claimed.commit.slice(0, 12)}` : ''}${typeof claimed?.verification_failure === 'string' ? ` (${claimed.verification_failure})` : ''}`
24
+ : `${row.provenance_class === 'ci_intent' ? 'ci' : 'verified'} ${row.source_commit?.slice(0, 12)} on ${row.source_branch} at ${row.source_path === '' ? '.' : row.source_path}`;
25
+ return `${active ? '*' : ' '} ${row.activated_at.slice(0, 19).replace('T', ' ')}Z ${what.padEnd(28)} ${actor.padEnd(32)} ${where}`;
26
+ }
27
+ export async function ormHistoryCommand(args) {
28
+ try {
29
+ validateCommandInput({ args, flags: { limit: 'string' }, positional: 1 });
30
+ const namespace = args.positional[0];
31
+ if (!namespace)
32
+ throw new Error('usage: seq-studio orm history <namespace> -e <env> [--limit N] [--json]');
33
+ const limit = limitFlag(args);
34
+ const options = clientOptions(await buildContext(args));
35
+ const result = await getJson({
36
+ ...options,
37
+ path: `/api/orm/namespaces/${encodeURIComponent(namespace)}?versions_limit=1&ledger_limit=1&activations_limit=${limit}`,
38
+ });
39
+ if (result.activations === undefined)
40
+ throw new Error('This Atlas does not record activation history yet.');
41
+ if (args.flags.json === true) {
42
+ console.log(JSON.stringify({ namespace, activations: result.activations, activations_total: result.activations_total }, null, 2));
43
+ return 0;
44
+ }
45
+ if (result.activations.length === 0) {
46
+ console.log(`${namespace}: no activations recorded yet (history starts with the first apply after it shipped)`);
47
+ return 0;
48
+ }
49
+ console.log(`${namespace}: ${result.activations_total ?? result.activations.length} activation(s), newest first; * = live`);
50
+ for (const row of result.activations)
51
+ console.log(formatActivation({ row, active: row.id === result.namespace.active_activation_id }));
52
+ return 0;
53
+ }
54
+ catch (error) {
55
+ printCliError(error);
56
+ return 1;
57
+ }
58
+ }
@@ -12,7 +12,7 @@
12
12
  */
13
13
  import type { SqlQueryParameter, SqlQueryVariables } from '@sequenceholdings/orm/client';
14
14
  import type { ParsedArgs } from '../process/commands.js';
15
- export declare const ORM_READ_USAGE = "usage:\n seq-studio orm read <namespace> <table> -e <env> [--where <column>=<op>.<value>]...\n [--select <col,...>] [--order <column>[.asc|.desc]]... [--limit N] [--offset N] [--json | --jsonl]\n seq-studio orm sql <namespace> (--query <sql> | --file <path>) -e <env>\n [--param <name>[:<type>]=<value>]... | [--params <json-object>] [--json | --jsonl]\n\n Reads run as you against an ORM v2 namespace: its grants, row-level security,\n and a read-only SQL grammar apply on the server, which returns at most 1,000 rows.\n\n --where operators: eq, ne, gt, gte, lt, lte, in, is\n --where status=eq.open --where balance=gte.1000 --where id=in.(a,b,c) --where closed_at=is.null\n sql binds :name placeholders. --param types: text (default), uuid, date, timestamptz,\n numeric, bigint, integer, double, boolean. --params takes the wire shape, e.g.\n '{\"limit\": {\"type\": \"integer\", \"value\": 5}}', and allows null values.\n sql must reference every table as <namespace>.<table> (SELECT id FROM lending.loans, not\n FROM loans); unqualified names and queries without a table (SELECT 1) are rejected.\n The grammar is read-only SELECT with joins, CTEs, UNION, aggregates, and comparison\n operators (no LIKE or IN).\n --json prints a JSON array of row objects; --jsonl prints one row object per line.\n Without either, rows print as a table. Counts, truncation, and paging hints go to stderr.\n";
15
+ export declare const ORM_READ_USAGE = "usage:\n seq-studio orm read <namespace> <table> -e <env> [--where <column>=<op>.<value>]...\n [--select <col,...>] [--order <column>[.asc|.desc]]... [--limit N] [--offset N] [--json | --jsonl]\n seq-studio orm sql <namespace> (--query <sql> | --file <path>) -e <env>\n [--param <name>[:<type>]=<value>]... | [--params <json-object>] [--json | --jsonl]\n\n Reads run as you against an ORM v2 namespace: its grants, row-level security,\n and a read-only SQL grammar apply on the server, which returns at most 1,000 rows.\n\n --where operators: eq, ne, gt, gte, lt, lte, in, is\n --where status=eq.open --where balance=gte.1000 --where id=in.(a,b,c) --where closed_at=is.null\n sql binds :name placeholders. --param types: text (default), uuid, date, timestamptz,\n numeric, bigint, integer, double, boolean. --params takes the wire shape, e.g.\n '{\"limit\": {\"type\": \"integer\", \"value\": 5}}', and allows null values.\n sql must reference every table as <namespace>.<table> (SELECT id FROM lending.loans, not\n FROM loans); unqualified names and queries without a table (SELECT 1) are rejected.\n Quote mixed-case column names: SELECT \"loanNumber\" FROM lending.loans.\n The grammar is read-only SELECT with joins, CTEs, UNION, aggregates, and comparison\n operators (no LIKE or IN).\n --json prints a JSON array of row objects; --jsonl prints one row object per line.\n Without either, rows print as a table. Counts, truncation, and paging hints go to stderr.\n";
16
16
  export interface ReadFilter {
17
17
  column: string;
18
18
  op: string;
package/dist/orm/read.js CHANGED
@@ -32,6 +32,7 @@ export const ORM_READ_USAGE = `usage:
32
32
  '{"limit": {"type": "integer", "value": 5}}', and allows null values.
33
33
  sql must reference every table as <namespace>.<table> (SELECT id FROM lending.loans, not
34
34
  FROM loans); unqualified names and queries without a table (SELECT 1) are rejected.
35
+ Quote mixed-case column names: SELECT "loanNumber" FROM lending.loans.
35
36
  The grammar is read-only SELECT with joins, CTEs, UNION, aggregates, and comparison
36
37
  operators (no LIKE or IN).
37
38
  --json prints a JSON array of row objects; --jsonl prints one row object per line.
@@ -301,8 +302,9 @@ function isRejectedSql(error) {
301
302
  return error instanceof Error && error.name === 'OrmOperationError' && Reflect.get(error, 'code') === 'BAD_USER_INPUT';
302
303
  }
303
304
  export function sqlGrammarHint(namespace) {
304
- return `[seq-studio] hint: reference every table as <namespace>.<table> (e.g. SELECT count(*) FROM ${namespace}.<table>); `
305
- + 'unqualified names and queries without a table are rejected. The grammar is read-only SELECT with joins, '
305
+ return `[seq-studio] hint: check table qualification (e.g. SELECT count(*) FROM ${namespace}.<table>) `
306
+ + 'and double-quote mixed-case columns (e.g. SELECT "loanNumber" FROM '
307
+ + `${namespace}.<table>). Unqualified tables and queries without a table are rejected. The grammar is read-only SELECT with joins, `
306
308
  + 'CTEs, UNION, aggregates (count, sum, avg, min, max), lower/upper/length, and comparison operators; '
307
309
  + 'it has no LIKE or IN. See: seq-studio orm sql --help.';
308
310
  }
@@ -11,6 +11,7 @@
11
11
  * The SDK is lazy-imported like `@sequenceholdings/orm` so public installs of
12
12
  * the CLI without the package get a clear install hint instead of a crash.
13
13
  */
14
+ import { cliAttributionHeaders } from '../cli-attribution.js';
14
15
  import { pipelineSourceError } from './source.js';
15
16
  import { mkdir, readFile, writeFile } from 'node:fs/promises';
16
17
  import { existsSync } from 'node:fs';
@@ -277,7 +278,7 @@ export function buildExternalAssetsRequest({ source, knownOrigins, token, }) {
277
278
  return {
278
279
  url,
279
280
  init: {
280
- headers: { authorization: `Bearer ${token}` },
281
+ headers: { authorization: `Bearer ${token}`, ...cliAttributionHeaders() },
281
282
  redirect: 'manual',
282
283
  },
283
284
  };
@@ -30,6 +30,9 @@ const INGESTION_BODY = `
30
30
  # Where the ingestion code runs: databricks (API pulls) | edge-worker (on-prem VM).
31
31
  # ('upload' is reserved — not yet supported.)
32
32
  runtime: databricks
33
+ # Optional source schema for both raw files and materialized source tables.
34
+ # Omitted preserves legacy bronze paths; changing an existing stage needs migration.
35
+ # source_schema: raw
33
36
  # databricks runtime pulls from an external system (symbolic refs, never secrets).
34
37
  # Secure-by-default: declare a credential for authenticated APIs. Attach a
35
38
  # managed secret to it per deploy target (seq-studio secrets attach <NAME>
@@ -48,8 +51,8 @@ source:
48
51
  feeds:
49
52
  # One feed = one stream of raw files into the volume landing zone.
50
53
  # The platform derives (per-source catalog, never the deployment catalog):
51
- # /Volumes/src_<source>/bronze/<feed>/batch_id=<ts>/, the bronze table
52
- # src_<source>.bronze.<feed>, envelope columns (batch_id, ingested_at,
54
+ # /Volumes/src_<source>/<source_schema>/<feed>/batch_id=<ts>/, the source table
55
+ # src_<source>.<source_schema>.<feed>, envelope columns (batch_id, ingested_at,
53
56
  # source_system, content_hash), and a presence manifest for full_snapshot.
54
57
  my_feed:
55
58
  # full_snapshot | incremental | event_stream
@@ -1,3 +1,3 @@
1
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";
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 seq-studio principals groups create <name> -e <env> [--description <text>] [--request-id <uuid>]\n seq-studio principals groups members add <group-id> -e <env> --principal-id <user-sub> [--principal-id <user-sub> ...]\n seq-studio principals groups members remove <group-id> -e <env> --principal-id <user-sub>\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 Create makes a local group with you as admin. It prints its request UUID\n before sending; reuse --request-id <uuid> to safely retry an uncertain result.\n Member IDs are the authenticated subjects returned by users search, not\n emails or directory row IDs. Add accepts 1\u201350 IDs, leaves existing roles\n unchanged, and rejects disabled or out-of-tenant users. Managing members\n requires permission to administer a CLI-created group in your tenant.\n Remove revokes one member and refuses to\n remove the last group admin. Members may always leave their own group.\n Mutation receipts are JSON.\n Authenticate: seq-studio login --env <env> (agent sandbox tokens work too).\n";
3
3
  export declare function runPrincipalsCommand(sub: string | undefined, args: ParsedArgs): Promise<number>;
@@ -1,6 +1,7 @@
1
- import { getJson } from '../atlas-client.js';
1
+ import { randomUUID } from 'node:crypto';
2
+ import { getJson, requestJsonOnce } from '../atlas-client.js';
2
3
  import { printCliError } from '../cli-errors.js';
3
- import { validateCommandInput, wantsHelp } from '../command-input.js';
4
+ import { requiredStringFlag, validateCommandInput, wantsHelp } from '../command-input.js';
4
5
  import { buildContext, clientOptions } from '../functions/commands.js';
5
6
  const SEARCH_TYPES = ['user', 'group', 'service-account', 'organization'];
6
7
  export const PRINCIPALS_USAGE = `usage:
@@ -8,6 +9,9 @@ export const PRINCIPALS_USAGE = `usage:
8
9
  seq-studio principals users search <query> -e <env> [--limit <n>]
9
10
  seq-studio principals groups list -e <env> [--search <query>] [--limit <n>] [--page <n>]
10
11
  seq-studio principals groups show <group-id> -e <env> [--limit <n>] [--offset <n>]
12
+ seq-studio principals groups create <name> -e <env> [--description <text>] [--request-id <uuid>]
13
+ seq-studio principals groups members add <group-id> -e <env> --principal-id <user-sub> [--principal-id <user-sub> ...]
14
+ seq-studio principals groups members remove <group-id> -e <env> --principal-id <user-sub>
11
15
 
12
16
  Find the people, groups, service accounts and organizations YOU may grant
13
17
  access to, with the exact ids seq-studio access grant takes. Results are JSON;
@@ -20,6 +24,15 @@ export const PRINCIPALS_USAGE = `usage:
20
24
  service accounts: accounts you hold actor on; organizations: your own tenant.
21
25
  groups show lists a visible group's active members, paged (default 50 per
22
26
  page); a group you can't see is reported as not found.
27
+ Create makes a local group with you as admin. It prints its request UUID
28
+ before sending; reuse --request-id <uuid> to safely retry an uncertain result.
29
+ Member IDs are the authenticated subjects returned by users search, not
30
+ emails or directory row IDs. Add accepts 1–50 IDs, leaves existing roles
31
+ unchanged, and rejects disabled or out-of-tenant users. Managing members
32
+ requires permission to administer a CLI-created group in your tenant.
33
+ Remove revokes one member and refuses to
34
+ remove the last group admin. Members may always leave their own group.
35
+ Mutation receipts are JSON.
23
36
  Authenticate: seq-studio login --env <env> (agent sandbox tokens work too).
24
37
  `;
25
38
  function withGrant(principal) {
@@ -105,12 +118,47 @@ function present(shape, body) {
105
118
  members: (record.members ?? []).map(withGrant),
106
119
  };
107
120
  }
121
+ async function mutateGroup(args) {
122
+ const [action, target, verb] = args.positional;
123
+ if (action === 'create') {
124
+ validateCommandInput({ args, flags: { description: 'string', 'request-id': 'string' }, positional: 2 });
125
+ if (!target?.trim() || target.trim().length > 200)
126
+ throw new Error('Group name must be 1–200 characters.');
127
+ const id = typeof args.flags['request-id'] === 'string' ? args.flags['request-id'] : randomUUID();
128
+ if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(id))
129
+ throw new Error('--request-id must be a UUID.');
130
+ const description = args.flags.description;
131
+ const body = { id, name: target.trim(), ...(typeof description === 'string' ? { description: description.trim() } : {}) };
132
+ const ctx = await buildContext(args);
133
+ console.error(`Group request ID: ${id} (reuse with --request-id to retry)`);
134
+ return requestJsonOnce({ ...clientOptions(ctx), path: '/api/authz/principals/groups', method: 'POST', body });
135
+ }
136
+ if (action === 'members' && (target === 'add' || target === 'remove')) {
137
+ validateCommandInput({ args, flags: { 'principal-id': 'string' }, positional: 3 });
138
+ if (!verb?.trim())
139
+ throw new Error('A group ID is required.');
140
+ const ids = args.repeatedFlags?.['principal-id'] ?? [requiredStringFlag({ args, key: 'principal-id' })];
141
+ if (ids.length < 1 || ids.length > (target === 'add' ? 50 : 1) || new Set(ids).size !== ids.length || ids.some((id) => !id.includes('|') || /[#*\s]/.test(id))) {
142
+ throw new Error('Pass distinct authenticated user subjects with --principal-id (1–50 for add, one for remove).');
143
+ }
144
+ const ctx = await buildContext(args);
145
+ const path = `/api/authz/principals/groups/${encodeURIComponent(verb)}/members`;
146
+ return target === 'add'
147
+ ? requestJsonOnce({ ...clientOptions(ctx), path, method: 'POST', body: { principalIds: ids } })
148
+ : requestJsonOnce({ ...clientOptions(ctx), path: `${path}/${encodeURIComponent(ids[0])}`, method: 'DELETE' });
149
+ }
150
+ throw new Error('Usage: seq-studio principals groups create|members add|members remove. See: seq-studio principals --help');
151
+ }
108
152
  export async function runPrincipalsCommand(sub, args) {
109
153
  if (!sub || wantsHelp({ sub, args })) {
110
154
  console.log(PRINCIPALS_USAGE);
111
155
  return sub ? 0 : 1;
112
156
  }
113
157
  try {
158
+ if (sub === 'groups' && (args.positional[0] === 'create' || args.positional[0] === 'members')) {
159
+ console.log(JSON.stringify(await mutateGroup(args), null, 2));
160
+ return 0;
161
+ }
114
162
  const { path, shape } = requestPath(sub, args);
115
163
  const ctx = await buildContext(args);
116
164
  const body = await getJson({ ...clientOptions(ctx), path });
@@ -225,9 +225,12 @@ async function tryBuildAgentLoader(args) {
225
225
  return undefined;
226
226
  // Agent loader is only meaningful when we have a target env + token.
227
227
  // If either fails to resolve, skip the check; lint will emit a warning
228
- // for multi-edge agent nodes instead of failing.
228
+ // for multi-edge agent nodes instead of failing. The check is optional, so
229
+ // it never opens a browser login (CI sandboxes would wait out the timeout).
229
230
  try {
230
- const { env, token } = await getEnvAndToken(args);
231
+ const requested = typeof args.flags.env === 'string' ? args.flags.env : undefined;
232
+ const env = await resolveConfiguredEnv({ requested });
233
+ const token = await getAccessToken({ env: env.name, targetUrl: env.url, allowInteractiveLogin: false });
231
234
  return buildAgentSchemaLoader({ baseUrl: env.url, token });
232
235
  }
233
236
  catch {
@@ -7,10 +7,17 @@ export declare function gitCredentialResponse({ input, operation, envName, clone
7
7
  envName?: string;
8
8
  cloneUrl?: string;
9
9
  }): Promise<string>;
10
+ /** Select the stable launcher that invoked this CLI, not the first one on a later Git PATH. */
11
+ export declare function resolveGitHelperLauncher({ scriptPath, launcherHint, searchPath, }?: {
12
+ scriptPath?: string;
13
+ launcherHint?: string;
14
+ searchPath?: string;
15
+ }): Promise<string>;
10
16
  /** Store only a helper command, bound to this environment and repository URL. */
11
- export declare function configureGitLogin({ destDir, envName, cloneUrl, }: {
17
+ export declare function configureGitLogin({ destDir, envName, cloneUrl, launcherPath, }: {
12
18
  destDir: string;
13
19
  envName: string;
14
20
  cloneUrl: string;
21
+ launcherPath?: string;
15
22
  }): Promise<void>;
16
23
  export declare function gitCredentialCommand(args: ParsedArgs): Promise<number>;
@@ -1,4 +1,6 @@
1
1
  import { execFile } from 'node:child_process';
2
+ import { readFile, realpath } from 'node:fs/promises';
3
+ import { basename, delimiter, dirname, isAbsolute, join, resolve } from 'node:path';
2
4
  import { promisify } from 'node:util';
3
5
  import { getAccessTokenWithMode } from '../auth.js';
4
6
  import { resolveConfiguredEnv } from '../config.js';
@@ -100,11 +102,55 @@ export async function gitCredentialResponse({ input, operation, envName, cloneUr
100
102
  function shellQuote(value) {
101
103
  return `'${value.replace(/'/g, "'\\''")}'`;
102
104
  }
105
+ async function shimRunsScript(candidate, script, target) {
106
+ const shim = await readFile(candidate, 'utf8');
107
+ if (shim.includes(`exec node "${script}" "$@"`))
108
+ return true;
109
+ // pnpm's local and global POSIX shims use $basedir to invoke the package
110
+ // bin. Resolve that literal target without executing a PATH candidate.
111
+ for (const match of shim.matchAll(/^\s*exec (?:node|"\$basedir\/node")\s+"\$basedir\/([^"]+\/dist\/bin\.js)" "\$@"\s*$/gm)) {
112
+ if (await realpath(join(dirname(candidate), match[1])) === target)
113
+ return true;
114
+ }
115
+ return false;
116
+ }
117
+ /** Select the stable launcher that invoked this CLI, not the first one on a later Git PATH. */
118
+ export async function resolveGitHelperLauncher({ scriptPath = process.argv[1], launcherHint = process.env.SEQ_STUDIO_LAUNCHER, searchPath = process.env.PATH, } = {}) {
119
+ if (!scriptPath || !isAbsolute(scriptPath))
120
+ throw new Error('Cannot identify the seq-studio launcher. Run repos clone through an installed seq-studio command.');
121
+ const script = resolve(scriptPath);
122
+ if (launcherHint && isAbsolute(launcherHint) && basename(launcherHint) === 'seq-studio') {
123
+ try {
124
+ // Our installed shell shim exports its own path before execing this build.
125
+ // Require the shim to target this exact script, so an inherited hint from
126
+ // another installation cannot make Git run a different CLI.
127
+ if ((await readFile(launcherHint, 'utf8')).includes(`exec node "${script}" "$@"`))
128
+ return resolve(launcherHint);
129
+ }
130
+ catch { /* Stale or unrelated launcher; look for a matching executable. */ }
131
+ }
132
+ if (basename(script) === 'seq-studio')
133
+ return script; // Node preserves the symlink invocation path.
134
+ const target = await realpath(script);
135
+ for (const directory of (searchPath ?? '').split(delimiter).filter(Boolean)) {
136
+ const candidate = join(directory, 'seq-studio');
137
+ try {
138
+ if (await realpath(candidate) === target)
139
+ return resolve(candidate);
140
+ }
141
+ catch { /* Not an installed launcher in this PATH entry. */ }
142
+ try {
143
+ if (await shimRunsScript(candidate, script, target))
144
+ return resolve(candidate);
145
+ }
146
+ catch { /* Not a matching generated shim. */ }
147
+ }
148
+ throw new Error('Cannot identify a stable seq-studio launcher for Git. Install this CLI with install-cli.sh or invoke its installed executable, then clone again.');
149
+ }
103
150
  /** Store only a helper command, bound to this environment and repository URL. */
104
- export async function configureGitLogin({ destDir, envName, cloneUrl, }) {
105
- // Resolve the installed CLI via PATH so package/Node upgrades do not leave
106
- // existing repositories pinned to a deleted version-specific executable.
107
- const helper = `!seq-studio auth git-credential --env ${shellQuote(envName)} --url ${shellQuote(cloneUrl)}`;
151
+ export async function configureGitLogin({ destDir, envName, cloneUrl, launcherPath, }) {
152
+ const launcher = launcherPath ?? await resolveGitHelperLauncher();
153
+ const helper = `!${shellQuote(launcher)} auth git-credential --env ${shellQuote(envName)} --url ${shellQuote(cloneUrl)}`;
108
154
  const config = async (...args) => { await exec('git', ['-C', destDir, 'config', '--local', ...args]); };
109
155
  // An empty helper resets inherited credential stores for this URL. That keeps
110
156
  // an Auth0 access token out of the user's global store/keychain on approval.
@@ -8,3 +8,8 @@ Start with that site's `/docs/llms.txt` index and follow the relevant pages as
8
8
  needed. The hosted docs are the single source of truth for platform usage;
9
9
  do not duplicate their instructions in this file. If docs access is blocked,
10
10
  open the same URL in the signed-in browser.
11
+
12
+ After concrete CLI friction costs time or retries, finish the task, then follow
13
+ the live `/seq-studio/feedback` guide and run `seq-studio feedback submit`
14
+ before the final response. Include the confirmed receipt ID and ticket URL, or
15
+ the sanitized draft and submission evidence if no receipt is confirmed.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sequenceholdings/studio-cli",
3
- "version": "0.9.10",
3
+ "version": "0.9.13",
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": {
@@ -45,15 +45,15 @@
45
45
  "yaml": "^2.8.4",
46
46
  "zod": "4.6.6",
47
47
  "@sequenceholdings/agent-spec": "0.1.5",
48
- "@sequenceholdings/artifact-studio": "0.11.10",
49
- "@sequenceholdings/managed-functions": "0.5.8",
50
- "@sequenceholdings/storage": "0.1.6",
48
+ "@sequenceholdings/artifact-studio": "0.11.12",
51
49
  "@sequenceholdings/lattice": "0.1.8",
52
- "@sequenceholdings/platform": "0.1.3"
50
+ "@sequenceholdings/managed-functions": "0.5.9",
51
+ "@sequenceholdings/storage": "0.1.7",
52
+ "@sequenceholdings/platform": "0.1.4"
53
53
  },
54
54
  "peerDependencies": {
55
- "@sequenceholdings/pipeline-spec": "0.3.6",
56
- "@sequenceholdings/orm": "2.8.5"
55
+ "@sequenceholdings/orm": "2.8.5",
56
+ "@sequenceholdings/pipeline-spec": "0.3.8"
57
57
  },
58
58
  "peerDependenciesMeta": {
59
59
  "@sequenceholdings/orm": {
@@ -69,8 +69,8 @@
69
69
  "@types/semver": "^7.8.0",
70
70
  "typescript": "^5.6.0",
71
71
  "vitest": "^4.1.11",
72
- "@sequenceholdings/pipeline-spec": "0.3.6",
73
- "@sequenceholdings/orm": "2.8.5"
72
+ "@sequenceholdings/orm": "2.8.5",
73
+ "@sequenceholdings/pipeline-spec": "0.3.8"
74
74
  },
75
75
  "engines": {
76
76
  "node": ">=20"
@@ -8,3 +8,8 @@ Start with that site's `/docs/llms.txt` index and follow the relevant pages as
8
8
  needed. The hosted docs are the single source of truth for platform usage;
9
9
  do not duplicate their instructions in this file. If docs access is blocked,
10
10
  open the same URL in the signed-in browser.
11
+
12
+ After concrete CLI friction costs time or retries, finish the task, then follow
13
+ the live `/seq-studio/feedback` guide and run `seq-studio feedback submit`
14
+ before the final response. Include the confirmed receipt ID and ticket URL, or
15
+ the sanitized draft and submission evidence if no receipt is confirmed.