@sequenceholdings/studio-cli 0.9.23 → 0.9.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/README.md +152 -144
  2. package/dist/access/commands.js +3 -5
  3. package/dist/access/principal.js +2 -2
  4. package/dist/access/tier-hosts.js +2 -2
  5. package/dist/agents/commands.d.ts +1 -1
  6. package/dist/agents/commands.js +9 -9
  7. package/dist/agents/scaffold.js +3 -3
  8. package/dist/agents/voice.d.ts +1 -1
  9. package/dist/agents/voice.js +1 -1
  10. package/dist/app/commands.d.ts +2 -2
  11. package/dist/app/commands.js +31 -21
  12. package/dist/app/deploy.d.ts +1 -1
  13. package/dist/app/deploy.js +1 -1
  14. package/dist/app/manifest.d.ts +9 -9
  15. package/dist/app/manifest.js +1 -1
  16. package/dist/app/prepare.js +1 -1
  17. package/dist/app/primitive-scaffold.js +1 -1
  18. package/dist/app/readme.js +6 -6
  19. package/dist/app/scaffold.js +1 -1
  20. package/dist/app/validate.d.ts +1 -1
  21. package/dist/app/workspace-scaffold.js +1 -1
  22. package/dist/artifact/delegate.d.ts +1 -1
  23. package/dist/artifact/delegate.js +43 -3
  24. package/dist/auth-cmds/commands.js +1 -2
  25. package/dist/bin.js +12 -2
  26. package/dist/cli-attribution.d.ts +4 -0
  27. package/dist/cli-attribution.js +25 -3
  28. package/dist/cli-errors.d.ts +9 -1
  29. package/dist/cli-errors.js +20 -9
  30. package/dist/command-contract.d.ts +7 -182
  31. package/dist/command-contract.js +9 -33
  32. package/dist/command-help.d.ts +4 -4
  33. package/dist/command-help.js +24 -24
  34. package/dist/command-telemetry.js +2 -2
  35. package/dist/config-dir.d.ts +8 -0
  36. package/dist/config-dir.js +35 -0
  37. package/dist/config.d.ts +6 -0
  38. package/dist/config.js +15 -3
  39. package/dist/docs/commands.js +9 -4
  40. package/dist/env-registry.d.ts +4 -0
  41. package/dist/env-registry.js +15 -6
  42. package/dist/envs/commands.d.ts +3 -0
  43. package/dist/envs/commands.js +11 -0
  44. package/dist/exit-codes.d.ts +16 -0
  45. package/dist/exit-codes.js +27 -0
  46. package/dist/functions/bundle.d.ts +1 -1
  47. package/dist/functions/commands.js +19 -18
  48. package/dist/functions/manifest.js +1 -1
  49. package/dist/functions/service-account-guidance.d.ts +1 -1
  50. package/dist/functions/service-account-guidance.js +2 -2
  51. package/dist/lifecycle/check.d.ts +13 -0
  52. package/dist/lifecycle/check.js +116 -0
  53. package/dist/lifecycle/commands.d.ts +14 -0
  54. package/dist/lifecycle/commands.js +121 -0
  55. package/dist/lifecycle/plan.d.ts +28 -0
  56. package/dist/lifecycle/plan.js +113 -0
  57. package/dist/lifecycle/rollback.d.ts +7 -0
  58. package/dist/lifecycle/rollback.js +89 -0
  59. package/dist/lifecycle/seq-ci-tools.d.ts +107 -0
  60. package/dist/lifecycle/seq-ci-tools.js +177 -0
  61. package/dist/lifecycle/upgrade.d.ts +3 -0
  62. package/dist/lifecycle/upgrade.js +38 -0
  63. package/dist/machine-output.d.ts +11 -2
  64. package/dist/machine-output.js +32 -10
  65. package/dist/main.d.ts +16 -6
  66. package/dist/main.js +187 -361
  67. package/dist/orgs.d.ts +45 -0
  68. package/dist/orgs.js +106 -0
  69. package/dist/orm/delegate.d.ts +1 -1
  70. package/dist/orm/delegate.js +32 -18
  71. package/dist/orm/deployment-policy.js +1 -2
  72. package/dist/orm/discover.js +6 -8
  73. package/dist/orm/execute.d.ts +1 -1
  74. package/dist/orm/execute.js +5 -6
  75. package/dist/orm/failures.js +2 -2
  76. package/dist/orm/help.d.ts +1 -1
  77. package/dist/orm/help.js +5 -5
  78. package/dist/orm/history.js +1 -2
  79. package/dist/orm/operation-show.js +1 -2
  80. package/dist/orm/version-guard.d.ts +7 -2
  81. package/dist/orm/version-guard.js +12 -7
  82. package/dist/pipeline/codegen.js +2 -2
  83. package/dist/pipeline/commands.js +9 -7
  84. package/dist/pipeline/discovery.d.ts +1 -1
  85. package/dist/pipeline/discovery.js +2 -3
  86. package/dist/pipeline/help.d.ts +1 -1
  87. package/dist/pipeline/help.js +1 -1
  88. package/dist/pipeline/lifecycle.js +1 -1
  89. package/dist/pipeline/stage-secrets.js +4 -4
  90. package/dist/pipeline/templates.js +2 -2
  91. package/dist/pnpm-auto-update.js +3 -3
  92. package/dist/preview.d.ts +1 -1
  93. package/dist/preview.js +1 -1
  94. package/dist/principals/commands.d.ts +1 -1
  95. package/dist/principals/commands.js +13 -14
  96. package/dist/process/commands.js +4 -1
  97. package/dist/process/run-steps.d.ts +2 -2
  98. package/dist/process/runs.js +1 -2
  99. package/dist/registry/commands.d.ts +4 -0
  100. package/dist/registry/commands.js +281 -0
  101. package/dist/registry/help.d.ts +8 -0
  102. package/dist/registry/help.js +64 -0
  103. package/dist/registry/lifecycle-commands.d.ts +3 -0
  104. package/dist/registry/lifecycle-commands.js +60 -0
  105. package/dist/registry/lookup.d.ts +6 -0
  106. package/dist/registry/lookup.js +18 -0
  107. package/dist/registry/runners.d.ts +14 -0
  108. package/dist/registry/runners.js +206 -0
  109. package/dist/registry/spec.d.ts +45 -0
  110. package/dist/registry/spec.js +8 -0
  111. package/dist/repos/commands.js +1 -2
  112. package/dist/repos/github-connect-command.d.ts +10 -1
  113. package/dist/repos/github-connect-command.js +52 -11
  114. package/dist/repos/github-init.d.ts +9 -2
  115. package/dist/repos/github-init.js +18 -2
  116. package/dist/repos/init-repo.js +1 -2
  117. package/dist/run-pinned.d.ts +48 -0
  118. package/dist/run-pinned.js +127 -0
  119. package/dist/sdk-source.d.ts +64 -0
  120. package/dist/sdk-source.js +199 -0
  121. package/dist/secrets/commands.d.ts +1 -1
  122. package/dist/secrets/commands.js +29 -24
  123. package/dist/service-accounts/commands.d.ts +1 -1
  124. package/dist/service-accounts/commands.js +4 -5
  125. package/dist/staged-env.d.ts +14 -0
  126. package/dist/staged-env.js +73 -0
  127. package/dist/storage/commands.js +21 -22
  128. package/dist/templates/catalog.d.ts +4 -4
  129. package/dist/update-check.js +3 -3
  130. package/dist/version-support.d.ts +39 -0
  131. package/dist/version-support.js +71 -0
  132. package/package.json +8 -7
  133. package/release-summary.json +2 -1
@@ -35,7 +35,7 @@ ${ACCESS_HOSTS.map((host) => ` ${host.name.padEnd(16)}${host.summary}`).join(
35
35
  On single-tier types (process, agent, pipeline, service-account, secret, repo,
36
36
  namespace, workspace) a principal holds one tier: grant refuses to change an
37
37
  existing different tier unless you pass --replace.
38
- Find principal ids with seq-studio principals search <query>. Users are
38
+ Find principal ids with seq-studio principal search <query>. Users are
39
39
  authenticated subjects, groups are directory group ids, organizations are
40
40
  tenant slugs, and service accounts are <account-id> or service-account|<id>.
41
41
  Never pass an email or display name in place of an id.
@@ -115,8 +115,7 @@ export async function runAccessCommand(sub, args) {
115
115
  return await runAccessRolesCommand(args);
116
116
  }
117
117
  catch (error) {
118
- printCliError(error);
119
- return 1;
118
+ return printCliError(error);
120
119
  }
121
120
  }
122
121
  if (!sub || wantsHelp({ sub, args })) {
@@ -132,7 +131,6 @@ export async function runAccessCommand(sub, args) {
132
131
  return 0;
133
132
  }
134
133
  catch (error) {
135
- printCliError(error);
136
- return 1;
134
+ return printCliError(error);
137
135
  }
138
136
  }
@@ -18,7 +18,7 @@ export function parsePrincipal(args) {
18
18
  throw new Error(`--principal-type must be one of ${PRINCIPAL_KINDS.join(', ')}.`);
19
19
  }
20
20
  if (!rawId || /[#*\s]/.test(rawId)) {
21
- throw new Error('--principal-id must be an exact id (no spaces, wildcards, or #). Find ids with seq-studio principals search.');
21
+ throw new Error('--principal-id must be an exact id (no spaces, wildcards, or #). Find ids with seq-studio principal search.');
22
22
  }
23
23
  if (type === 'service-account' || rawId.startsWith(SERVICE_ACCOUNT_PREFIX)) {
24
24
  if (type !== 'service-account' && type !== 'user') {
@@ -30,7 +30,7 @@ export function parsePrincipal(args) {
30
30
  return { kind: 'service-account', id: accountId };
31
31
  }
32
32
  if (type === 'user' && !rawId.includes('|') && !rawId.endsWith('@clients')) {
33
- throw new Error('User principal ids are authenticated subjects (e.g. auth0|abc), not emails or names. Find them with seq-studio principals users search <query>.');
33
+ throw new Error('User principal ids are authenticated subjects (e.g. auth0|abc), not emails or names. Find them with seq-studio principal users search <query>.');
34
34
  }
35
35
  return { kind: type, id: rawId };
36
36
  }
@@ -131,7 +131,7 @@ function principalRowsHost({ name, summary, keys, floor, basePath, toAccess, fro
131
131
  const identity = (value) => value;
132
132
  export const secretHost = principalRowsHost({
133
133
  name: 'secret',
134
- summary: 'Managed secret (id from seq-studio secrets list); user = runtime read via attachment',
134
+ summary: 'Managed secret (id from seq-studio secret list); user = runtime read via attachment',
135
135
  keys: ['user', 'editor', 'admin'],
136
136
  floor: 'user',
137
137
  basePath: async ({ id }) => `/api/managed-secrets/${encodeURIComponent(id)}/principals`,
@@ -168,7 +168,7 @@ function storagePrincipal(principal) {
168
168
  }
169
169
  export const workspaceHost = {
170
170
  name: 'workspace',
171
- summary: 'Workspaces V2 storage workspace (use seq-studio storage access for folders/files)',
171
+ summary: 'Workspaces V2 storage workspace (use seq-studio workspace access for folders/files)',
172
172
  keys: ['viewer', 'editor', 'admin'],
173
173
  singleTier: true,
174
174
  principals: ['user', 'group', 'organization', 'service-account'],
@@ -20,5 +20,5 @@ export declare function agentsApplyCommand(args: ParsedArgs, { mode }?: {
20
20
  }): Promise<number>;
21
21
  export declare function agentsListCommand(args: ParsedArgs): Promise<number>;
22
22
  export declare function agentsShowCommand(args: ParsedArgs): Promise<number>;
23
- export declare const AGENTS_USAGE = "usage:\n seq-studio agents init <dir> [--repo <ns>/<name>] scaffold a typed agent (--repo: into a git-service repo)\n seq-studio agents validate [--dir d] [--target app] [--only ids] offline compile + validation\n seq-studio agents bundle --out <file> [--dir d] [--target app] [--only ids] offline deploy body { definitions, bundleHash }\n seq-studio agents plan [--dir d] [-e <env>] [--only ids] [--managed] [--check-execution] offline bundle plan or live diff\n seq-studio agents apply [--dir d] -e <env> [--only ids] [--yes] [--managed] [--check-execution] apply creates/updates; never deletes\n seq-studio agents list -e <env> list visible agents\n seq-studio agents show <id> -e <env> show one agent\n seq-studio agents voice help internal Voice authoring/publication\n\n plan and apply deploy configuration only, as you: a new agent needs Can\n create on Agent Builder, an existing one needs editor, and access stays\n whatever Agent Builder or the API set. --managed is Sequence's code-managed\n path, where the definition also owns access; it is limited to Sequence staff.\n\n --check-execution requires -e, CONFIG mode and at most 20 existing agents in\n one whole bundle. It checks proposed pinned-execution eligibility before\n apply writes; it is point-in-time and grants no access or future identity.\n Unknown checked routes or missing acknowledgement fail without fallback.\n\n Source: local --dir (default .), --repo agents/<name>, or --git-url <url>.\n Use --ref for remote sources. --target selects the deployment APP_ENV when it\n differs from the CLI environment alias (notably OpCo registrations). --only\n accepts a comma-separated list of agent IDs after environment selection.\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";
23
+ export declare const AGENTS_USAGE = "usage:\n seq-studio agent init <dir> [--repo <ns>/<name>] scaffold a typed agent (--repo: into a git-service repo)\n seq-studio agent validate [--dir d] [--target app] [--only ids] offline compile + validation\n seq-studio agent bundle --out <file> [--dir d] [--target app] [--only ids] offline deploy body { definitions, bundleHash }\n seq-studio agent plan [--dir d] [-e <env>] [--only ids] [--managed] [--check-execution] offline bundle plan or live diff\n seq-studio agent apply [--dir d] -e <env> [--only ids] [--yes] [--managed] [--check-execution] apply creates/updates; never deletes\n seq-studio agent list -e <env> list visible agents\n seq-studio agent show <id> -e <env> show one agent\n seq-studio agent voice help internal Voice authoring/publication\n\n plan and apply deploy configuration only, as you: a new agent needs Can\n create on Agent Builder, an existing one needs editor, and access stays\n whatever Agent Builder or the API set. --managed is Sequence's code-managed\n path, where the definition also owns access; it is limited to Sequence staff.\n\n --check-execution requires -e, CONFIG mode and at most 20 existing agents in\n one whole bundle. It checks proposed pinned-execution eligibility before\n apply writes; it is point-in-time and grants no access or future identity.\n Unknown checked routes or missing acknowledgement fail without fallback.\n\n Source: local --dir (default .), --repo agents/<name>, or --git-url <url>.\n Use --ref for remote sources. --target selects the deployment APP_ENV when it\n differs from the CLI environment alias (notably OpCo registrations). --only\n accepts a comma-separated list of agent IDs after environment selection.\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";
24
24
  export declare function runAgentsCommand(sub: string | undefined, args: ParsedArgs): Promise<number>;
@@ -234,7 +234,7 @@ export async function agentsListCommand(args) {
234
234
  export async function agentsShowCommand(args) {
235
235
  const id = args.positional[0];
236
236
  if (!id) {
237
- console.error('usage: seq-studio agents show <id> -e <env>');
237
+ console.error('usage: seq-studio agent show <id> -e <env>');
238
238
  return 1;
239
239
  }
240
240
  const context = await buildContext(args);
@@ -246,14 +246,14 @@ export async function agentsShowCommand(args) {
246
246
  return 0;
247
247
  }
248
248
  export const AGENTS_USAGE = `usage:
249
- seq-studio agents init <dir> [--repo <ns>/<name>] scaffold a typed agent (--repo: into a git-service repo)
250
- seq-studio agents validate [--dir d] [--target app] [--only ids] offline compile + validation
251
- seq-studio agents bundle --out <file> [--dir d] [--target app] [--only ids] offline deploy body { definitions, bundleHash }
252
- seq-studio agents plan [--dir d] [-e <env>] [--only ids] [--managed] [--check-execution] offline bundle plan or live diff
253
- seq-studio agents apply [--dir d] -e <env> [--only ids] [--yes] [--managed] [--check-execution] apply creates/updates; never deletes
254
- seq-studio agents list -e <env> list visible agents
255
- seq-studio agents show <id> -e <env> show one agent
256
- seq-studio agents voice help internal Voice authoring/publication
249
+ seq-studio agent init <dir> [--repo <ns>/<name>] scaffold a typed agent (--repo: into a git-service repo)
250
+ seq-studio agent validate [--dir d] [--target app] [--only ids] offline compile + validation
251
+ seq-studio agent bundle --out <file> [--dir d] [--target app] [--only ids] offline deploy body { definitions, bundleHash }
252
+ seq-studio agent plan [--dir d] [-e <env>] [--only ids] [--managed] [--check-execution] offline bundle plan or live diff
253
+ seq-studio agent apply [--dir d] -e <env> [--only ids] [--yes] [--managed] [--check-execution] apply creates/updates; never deletes
254
+ seq-studio agent list -e <env> list visible agents
255
+ seq-studio agent show <id> -e <env> show one agent
256
+ seq-studio agent voice help internal Voice authoring/publication
257
257
 
258
258
  plan and apply deploy configuration only, as you: a new agent needs Can
259
259
  create on Agent Builder, an existing one needs editor, and access stays
@@ -22,7 +22,7 @@ export const agent = defineAgent({
22
22
  export async function agentsInitCommand(args) {
23
23
  const target = args.positional[0];
24
24
  if (!target) {
25
- console.error('usage: seq-studio agents init <dir> [--repo <ns>/<name> -e <env>]');
25
+ console.error('usage: seq-studio agent init <dir> [--repo <ns>/<name> -e <env>]');
26
26
  return 1;
27
27
  }
28
28
  if (args.flags.repo !== undefined) {
@@ -47,7 +47,7 @@ export async function agentsInitCommand(args) {
47
47
  version: '0.0.1',
48
48
  private: true,
49
49
  type: 'module',
50
- scripts: { validate: 'seq-studio agents validate' },
50
+ scripts: { validate: 'seq-studio agent validate' },
51
51
  dependencies: { '@sequenceholdings/agent-spec': '^0.1.3' },
52
52
  devDependencies: {
53
53
  '@sequenceholdings/studio-cli': `^${currentVersion()}`,
@@ -75,6 +75,6 @@ allowBuilds:
75
75
  `);
76
76
  await writeScaffoldGuidance({ directory });
77
77
  console.log(`${LOG} scaffolded typed agent in ${directory}`);
78
- console.log('Next: pnpm install && seq-studio agents validate');
78
+ console.log('Next: pnpm install && seq-studio agent validate');
79
79
  return 0;
80
80
  }
@@ -1,3 +1,3 @@
1
1
  import type { ParsedArgs } from '../process/commands.js';
2
- export declare const VOICE_USAGE = "usage: seq-studio agents voice <command> <agent-id> -e <env>\n inspect read captured draft, source drift and supported options\n export [--out agent.ts] export the exact captured authored definition\n save --expected-revision <N|new> [--dir d|--repo agents/name|--git-url url]\n [--ref ref] [--target APP_ENV] [--yes] compile one ID and save its draft\n capture --request-file capture.json [--yes] explicitly attach/refresh a native Skill\n validate --expected-revision N [--out review.json] review current publication bindings\n publish --request-file publication.json [--yes] publish an explicit durable request\n status --key UUID | --operation UUID inspect without replaying a mutation\n retry --operation UUID [--yes] resume only the recorded publication\n\nInternal synthetic staging demo only. Requires seq-studio login as a current human\nparticipant/editor; publication requires an operator. Machine auth is rejected.\nGeneric agents apply never activates Voice. Import/export does not refresh Skills.\nRequest-file schemas and examples are in the CLI README. --yes confirms the shown\naction; it never supplies missing tool reviews. Keep publication files and keys for\nrecovery; no automatic mutation retry. Output files are created, never overwritten.\nStatus exits 2 when no operation is recorded (an in-flight request may still arrive).\n";
2
+ export declare const VOICE_USAGE = "usage: seq-studio agent voice <command> <agent-id> -e <env>\n inspect read captured draft, source drift and supported options\n export [--out agent.ts] export the exact captured authored definition\n save --expected-revision <N|new> [--dir d|--repo agents/name|--git-url url]\n [--ref ref] [--target APP_ENV] [--yes] compile one ID and save its draft\n capture --request-file capture.json [--yes] explicitly attach/refresh a native Skill\n validate --expected-revision N [--out review.json] review current publication bindings\n publish --request-file publication.json [--yes] publish an explicit durable request\n status --key UUID | --operation UUID inspect without replaying a mutation\n retry --operation UUID [--yes] resume only the recorded publication\n\nInternal synthetic staging demo only. Requires seq-studio login as a current human\nparticipant/editor; publication requires an operator. Machine auth is rejected.\nGeneric agents apply never activates Voice. Import/export does not refresh Skills.\nRequest-file schemas and examples are in the CLI README. --yes confirms the shown\naction; it never supplies missing tool reviews. Keep publication files and keys for\nrecovery; no automatic mutation retry. Output files are created, never overwritten.\nStatus exits 2 when no operation is recorded (an in-flight request may still arrive).\n";
3
3
  export declare function runVoiceCommand(args: ParsedArgs): Promise<number>;
@@ -1,7 +1,7 @@
1
1
  import { voiceCapture, voiceExport, voiceInspect, voiceSave } from './voice-authoring.js';
2
2
  import { voicePublish, voiceRetry, voiceStatus, voiceValidate } from './voice-publication.js';
3
3
  import { VoiceCliError } from './voice-shared.js';
4
- export const VOICE_USAGE = `usage: seq-studio agents voice <command> <agent-id> -e <env>
4
+ export const VOICE_USAGE = `usage: seq-studio agent voice <command> <agent-id> -e <env>
5
5
  inspect read captured draft, source drift and supported options
6
6
  export [--out agent.ts] export the exact captured authored definition
7
7
  save --expected-revision <N|new> [--dir d|--repo agents/name|--git-url url]
@@ -2,12 +2,12 @@
2
2
  * Top-level app monorepo commands:
3
3
  * seq-studio init <dir> --with orm,function,artifact
4
4
  * seq-studio add <kind> <name>
5
- * seq-studio deploy -e <env>
5
+ * seq-studio apply -e <env>
6
6
  */
7
7
  import type { ParsedArgs } from '../process/commands.js';
8
8
  export declare const APP_INIT_USAGE: string;
9
9
  export declare const APP_ADD_USAGE: string;
10
- export declare const APP_DEPLOY_USAGE = "usage:\n seq-studio deploy -e <env> [options]\n\n Requires a platform repository clone with an adopted identity and a matching\n .seq/identity.json committed on the selected server. Checked before any\n primitive runs, including --dry-run; there is no legacy bypass.\n\n Deploy the app declared in sequence.app.yml. Versions 2 and 3 use\n depends_on prerequisites; deploy.order optionally orders ready primitives.\n Runs each kind's existing command:\n orm \u2192 seq-studio orm apply <path> -e <env>\n function \u2192 seq-studio functions deploy --dir <path> -e <env> [--yes]\n agent \u2192 seq-studio agents apply --dir <path> -e <env> [--yes], config-only (access stays in Atlas)\n process \u2192 seq-studio process apply --dir <path> -e <env>\n pipeline \u2192 seq-studio pipeline deploy --repo <repo> --ref <ref> -e <env>\n artifact \u2192 seq-studio artifact deploy <path> -e <env>\n\n Options:\n -e, --env <name> target environment (required)\n --dir <path> app root (default: cwd; must contain sequence.app.yml)\n --only <id1,id2> deploy these ids and their prerequisites (v2)\n --yes non-interactive (forwarded to primitive commands)\n --dry-run validate/compile selected sources without deploying (v2)\n --approved-by <sub> recorded caller approval for protected pipeline targets\n --wait-timeout <d> pipeline polling timeout, e.g. 10m or 2h\n\n Examples:\n seq-studio deploy -e staging --yes\n seq-studio deploy -e local --only get-pokemon --yes\n seq-studio deploy --dir ./pokedex -e staging --dry-run\n\n Run from the app root (directory with sequence.app.yml), or pass --dir.\n Version 1 manifests keep their existing ordering and exact --only behavior.\n Pipelines require repo and ref in their manifest entry.\n ORM namespaces require generated code and a reviewed migration ledger:\n seq-studio orm generate <path> && seq-studio orm diff <path>\n Commit generated migrations before the first deployment and schema changes.\n Repository admission reads the remote receipt at HEAD; all dry-runs need\n network/auth. Version 1 dry-run only lists after that check.\n For offline manifest, graph, path, and member checks before adoption, use\n `seq-studio validate`.\n A dry-run never opens a browser login: sign in beforehand. It warns,\n rather than fails, when the\n artifact source is not committed and clean on main.\n Version 2 writes the result to .sequence/deployments/<environment>.json.\n";
10
+ export declare const APP_DEPLOY_USAGE = "usage:\n seq-studio apply -e <env> [options]\n\n Requires a platform repository clone with an adopted identity and a matching\n .seq/identity.json committed on the selected server. Checked before any\n primitive runs, including --dry-run; there is no legacy bypass.\n\n Deploy the app declared in sequence.app.yml. Versions 2 and 3 use\n depends_on prerequisites; deploy.order optionally orders ready primitives.\n Runs each kind's existing command:\n orm \u2192 seq-studio orm apply <path> -e <env>\n function \u2192 seq-studio function deploy --dir <path> -e <env> [--yes]\n agent \u2192 seq-studio agent apply --dir <path> -e <env> [--yes], config-only (access stays in Atlas)\n process \u2192 seq-studio process apply --dir <path> -e <env>\n pipeline \u2192 seq-studio pipeline deploy --repo <repo> --ref <ref> -e <env>\n artifact \u2192 seq-studio artifact deploy <path> -e <env>\n\n Options:\n -e, --env <name> target environment (required)\n --dir <path> app root (default: cwd; must contain sequence.app.yml)\n --only <id1,id2> deploy these ids and their prerequisites (v2)\n --yes non-interactive (forwarded to primitive commands)\n --dry-run validate/compile selected sources without deploying (v2)\n --approved-by <sub> recorded caller approval for protected pipeline targets\n --wait-timeout <d> pipeline polling timeout, e.g. 10m or 2h\n\n Examples:\n seq-studio apply -e staging --yes\n seq-studio apply -e local --only get-pokemon --yes\n seq-studio apply --dir ./pokedex -e staging --dry-run\n\n Run from the app root (directory with sequence.app.yml), or pass --dir.\n Version 1 manifests keep their existing ordering and exact --only behavior.\n Pipelines require repo and ref in their manifest entry.\n ORM namespaces require generated code and a reviewed migration ledger:\n seq-studio orm build <path> && seq-studio orm diff <path>\n Commit generated migrations before the first deployment and schema changes.\n Repository admission reads the remote receipt at HEAD; all dry-runs need\n network/auth. Version 1 dry-run only lists after that check.\n For offline manifest, graph, path, and member checks before adoption, use\n `seq-studio validate`.\n A dry-run never opens a browser login: sign in beforehand. It warns,\n rather than fails, when the\n artifact source is not committed and clean on main.\n Version 2 writes the result to .sequence/deployments/<environment>.json.\n";
11
11
  export declare const APP_VALIDATE_USAGE = "usage:\n seq-studio validate [--dir <path>] [--json]\n\n Validate sequence.app.yml, its dependency graph, and primitive directories\n locally. List resolved Application members, including existing process refs.\n No environment, login, repository adoption, or network access is required.\n This checks local structure only; it does not validate remote member existence,\n primitive-specific source, or authorize deployment. Deploy still requires a\n matching repository identity receipt.\n\n Options:\n --dir <path> app root (default: cwd)\n --json print structured validation result\n";
12
12
  export declare function runAppValidateCommand(args: ParsedArgs): Promise<number>;
13
13
  /**
@@ -2,11 +2,13 @@
2
2
  * Top-level app monorepo commands:
3
3
  * seq-studio init <dir> --with orm,function,artifact
4
4
  * seq-studio add <kind> <name>
5
- * seq-studio deploy -e <env>
5
+ * seq-studio apply -e <env>
6
6
  */
7
7
  import { basename, resolve } from 'node:path';
8
8
  import { parseDurationMs } from '@sequenceholdings/lattice';
9
9
  import { REQUIRE_EXPLICIT_ENV_MESSAGE, explicitOrSandboxEnv } from '../env-flags.js';
10
+ import { formatCliError } from '../cli-errors.js';
11
+ import { ExitCode, UsageError } from '../exit-codes.js';
10
12
  import { deployApp } from './deploy.js';
11
13
  import { validateAppLocal } from './validate.js';
12
14
  import { DEFAULT_APP_KINDS, resolveRequestedKinds } from './kinds.js';
@@ -100,7 +102,7 @@ export const APP_ADD_USAGE = `usage:
100
102
  Run from the app root (directory with ${APP_MANIFEST_FILENAME}).
101
103
  `;
102
104
  export const APP_DEPLOY_USAGE = `usage:
103
- seq-studio deploy -e <env> [options]
105
+ seq-studio apply -e <env> [options]
104
106
 
105
107
  Requires a platform repository clone with an adopted identity and a matching
106
108
  .seq/identity.json committed on the selected server. Checked before any
@@ -110,8 +112,8 @@ export const APP_DEPLOY_USAGE = `usage:
110
112
  depends_on prerequisites; deploy.order optionally orders ready primitives.
111
113
  Runs each kind's existing command:
112
114
  orm → seq-studio orm apply <path> -e <env>
113
- function → seq-studio functions deploy --dir <path> -e <env> [--yes]
114
- agent → seq-studio agents apply --dir <path> -e <env> [--yes], config-only (access stays in Atlas)
115
+ function → seq-studio function deploy --dir <path> -e <env> [--yes]
116
+ agent → seq-studio agent apply --dir <path> -e <env> [--yes], config-only (access stays in Atlas)
115
117
  process → seq-studio process apply --dir <path> -e <env>
116
118
  pipeline → seq-studio pipeline deploy --repo <repo> --ref <ref> -e <env>
117
119
  artifact → seq-studio artifact deploy <path> -e <env>
@@ -126,15 +128,15 @@ export const APP_DEPLOY_USAGE = `usage:
126
128
  --wait-timeout <d> pipeline polling timeout, e.g. 10m or 2h
127
129
 
128
130
  Examples:
129
- seq-studio deploy -e staging --yes
130
- seq-studio deploy -e local --only get-pokemon --yes
131
- seq-studio deploy --dir ./pokedex -e staging --dry-run
131
+ seq-studio apply -e staging --yes
132
+ seq-studio apply -e local --only get-pokemon --yes
133
+ seq-studio apply --dir ./pokedex -e staging --dry-run
132
134
 
133
135
  Run from the app root (directory with ${APP_MANIFEST_FILENAME}), or pass --dir.
134
136
  Version 1 manifests keep their existing ordering and exact --only behavior.
135
137
  Pipelines require repo and ref in their manifest entry.
136
138
  ORM namespaces require generated code and a reviewed migration ledger:
137
- seq-studio orm generate <path> && seq-studio orm diff <path>
139
+ seq-studio orm build <path> && seq-studio orm diff <path>
138
140
  Commit generated migrations before the first deployment and schema changes.
139
141
  Repository admission reads the remote receipt at HEAD; all dry-runs need
140
142
  network/auth. Version 1 dry-run only lists after that check.
@@ -164,16 +166,12 @@ export async function runAppValidateCommand(args) {
164
166
  console.log(APP_VALIDATE_USAGE);
165
167
  return 0;
166
168
  }
169
+ const usageProblem = appValidateUsageProblem(args);
170
+ if (usageProblem) {
171
+ printError(new UsageError(usageProblem));
172
+ return ExitCode.Usage;
173
+ }
167
174
  try {
168
- if (args.positional.length > 0)
169
- throw new Error('unexpected arguments; use --dir for the app root');
170
- for (const [flag, value] of Object.entries(args.flags)) {
171
- if (flag === 'dir' && typeof value === 'string' && value.trim())
172
- continue;
173
- if (flag === 'json' && value === true)
174
- continue;
175
- throw new Error(flag === 'dir' ? '--dir requires a value' : `unknown option --${flag}`);
176
- }
177
175
  const result = await validateAppLocal({ rootDir: resolve(flagString(args.flags, 'dir') ?? process.cwd()) });
178
176
  if (args.flags.json === true) {
179
177
  console.log(JSON.stringify(result, null, 2));
@@ -190,9 +188,21 @@ export async function runAppValidateCommand(args) {
190
188
  }
191
189
  catch (error) {
192
190
  printError(error);
193
- return 1;
191
+ return ExitCode.Blocked;
194
192
  }
195
193
  }
194
+ function appValidateUsageProblem(args) {
195
+ if (args.positional.length > 0)
196
+ return 'unexpected arguments; use --dir for the app root';
197
+ for (const [flag, value] of Object.entries(args.flags)) {
198
+ if (flag === 'dir' && typeof value === 'string' && value.trim())
199
+ continue;
200
+ if (flag === 'json' && value === true)
201
+ continue;
202
+ return flag === 'dir' ? '--dir requires a value' : `unknown option --${flag}`;
203
+ }
204
+ return undefined;
205
+ }
196
206
  function pipelineTypeFlag(flags) {
197
207
  const value = flags['pipeline-type'];
198
208
  if (value === undefined)
@@ -221,8 +231,8 @@ function artifactTemplateFlag({ flags, kinds }) {
221
231
  export const NEXTJS_RUNTIME_NOTE = `${LOG} note: a Next.js app deploys only to a deployment with the Next.js runtime turned on. ` +
222
232
  'Check with your administrator before you build on it; react-vite (the default) deploys everywhere.';
223
233
  function printError(error) {
224
- const message = error instanceof Error ? error.message : String(error);
225
- console.error(`${LOG} ${message}`);
234
+ for (const line of formatCliError(error))
235
+ console.error(line);
226
236
  }
227
237
  /**
228
238
  * A published-template request (`--template <name>@<version>`), validated so
@@ -415,7 +425,7 @@ export async function runAppAddCommand({ kindArg, args, }) {
415
425
  console.log(`${LOG} updated ${APP_MANIFEST_FILENAME}`);
416
426
  console.log(`${LOG} next: pnpm install`);
417
427
  printOrmPreparation({ primitives: [entry] });
418
- console.log(` seq-studio deploy --only ${entry.id} -e <env>`);
428
+ console.log(` seq-studio apply --only ${entry.id} -e <env>`);
419
429
  return 0;
420
430
  }
421
431
  catch (error) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Top-level `seq-studio deploy` — fan out from sequence.app.yml in deploy order.
2
+ * Top-level `seq-studio apply` — fan out from sequence.app.yml in deploy order.
3
3
  *
4
4
  * Child primitives keep their own deploy/apply verbs; this command only
5
5
  * orchestrates them. Injectable runners keep unit tests offline.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Top-level `seq-studio deploy` — fan out from sequence.app.yml in deploy order.
2
+ * Top-level `seq-studio apply` — fan out from sequence.app.yml in deploy order.
3
3
  *
4
4
  * Child primitives keep their own deploy/apply verbs; this command only
5
5
  * orchestrates them. Injectable runners keep unit tests offline.
@@ -19,10 +19,10 @@ declare const primitiveEntrySchema: z.ZodObject<{
19
19
  id: z.ZodString;
20
20
  kind: z.ZodEnum<{
21
21
  function: "function";
22
- process: "process";
23
22
  artifact: "artifact";
24
- pipeline: "pipeline";
25
23
  orm: "orm";
24
+ pipeline: "pipeline";
25
+ process: "process";
26
26
  agent: "agent";
27
27
  workspace: "workspace";
28
28
  }>;
@@ -107,7 +107,7 @@ export declare const applicationCollaboratorsSchema: z.ZodObject<{
107
107
  }, z.core.$strict>;
108
108
  /**
109
109
  * Managed secrets the app's functions and pipelines read (schema_version 3).
110
- * Not deployed from here — create and set them with `seq-studio secrets` —
110
+ * Not deployed from here — create and set them with `seq-studio secret` —
111
111
  * but named so collaborator roles can bundle their editor tier and `uses`
112
112
  * can point at them. `name` is the secret's name in each environment.
113
113
  */
@@ -139,10 +139,10 @@ declare const appExistingSchema: z.ZodObject<{
139
139
  id: z.ZodString;
140
140
  kind: z.ZodEnum<{
141
141
  function: "function";
142
- process: "process";
143
142
  artifact: "artifact";
144
- pipeline: "pipeline";
145
143
  orm: "orm";
144
+ pipeline: "pipeline";
145
+ process: "process";
146
146
  agent: "agent";
147
147
  }>;
148
148
  ref: z.ZodString;
@@ -163,10 +163,10 @@ export declare const appManifestSchema: z.ZodObject<{
163
163
  id: z.ZodString;
164
164
  kind: z.ZodEnum<{
165
165
  function: "function";
166
- process: "process";
167
166
  artifact: "artifact";
168
- pipeline: "pipeline";
169
167
  orm: "orm";
168
+ pipeline: "pipeline";
169
+ process: "process";
170
170
  agent: "agent";
171
171
  workspace: "workspace";
172
172
  }>;
@@ -208,10 +208,10 @@ export declare const appManifestSchema: z.ZodObject<{
208
208
  id: z.ZodString;
209
209
  kind: z.ZodEnum<{
210
210
  function: "function";
211
- process: "process";
212
211
  artifact: "artifact";
213
- pipeline: "pipeline";
214
212
  orm: "orm";
213
+ pipeline: "pipeline";
214
+ process: "process";
215
215
  agent: "agent";
216
216
  }>;
217
217
  ref: z.ZodString;
@@ -154,7 +154,7 @@ export const applicationCollaboratorsSchema = z
154
154
  .strict();
155
155
  /**
156
156
  * Managed secrets the app's functions and pipelines read (schema_version 3).
157
- * Not deployed from here — create and set them with `seq-studio secrets` —
157
+ * Not deployed from here — create and set them with `seq-studio secret` —
158
158
  * but named so collaborator roles can bundle their editor tier and `uses`
159
159
  * can point at them. `name` is the secret's name in each environment.
160
160
  */
@@ -40,7 +40,7 @@ export async function prepareScaffoldedApp({ appRoot, manifest, run = runCommand
40
40
  const steps = [
41
41
  ...roots.map((cwd) => ({ label: `pnpm install (in ${cwd})`, perform: () => run({ command: 'pnpm', args: ['install'], cwd }) })),
42
42
  ...namespaces.flatMap((directory) => [
43
- { label: `seq-studio orm generate ${directory}`, perform: () => orm('generate', [directory]) },
43
+ { label: `seq-studio orm build ${directory}`, perform: () => orm('generate', [directory]) },
44
44
  { label: `seq-studio orm diff ${directory}`, perform: () => orm('diff', [directory]) },
45
45
  ]),
46
46
  ];
@@ -134,7 +134,7 @@ export async function scaffoldKind({ kind, appRoot, appId, name, pipelineType =
134
134
  break;
135
135
  case 'workspace':
136
136
  await mkdir(absPath, { recursive: true });
137
- // Same file `seq-studio storage init` writes.
137
+ // Same file `seq-studio workspace init` writes.
138
138
  await writeFile(join(absPath, 'workspace.yml'), `workspace:\n name: ${name}\n description: ""\n`, { flag: 'wx' });
139
139
  break;
140
140
  }
@@ -169,8 +169,8 @@ Versions 2 and 3 validate and compile the selected sources before deployment. Pi
169
169
  Review and deploy from this directory:
170
170
 
171
171
  \`\`\`bash
172
- seq-studio deploy -e <environment-name> --dry-run
173
- seq-studio deploy -e <environment-name> --yes
172
+ seq-studio apply -e <environment-name> --dry-run
173
+ seq-studio apply -e <environment-name> --yes
174
174
  \`\`\`
175
175
 
176
176
  ## Runtime boundaries
@@ -182,7 +182,7 @@ seq-studio deploy -e <environment-name> --yes
182
182
  - **Official artifact deployments** require the full app checkout to be clean on \`main\`, including shared packages and the root manifest. Use \`seq-studio artifact dev artifact -e <environment-name>\` to preview uncommitted UI.
183
183
  - **Environment bindings** are resolved at deploy time. \`-e\` selects the environment. Explicit \`artifact.bundle.yml\` target URLs and storage capability workspace IDs are validated, as are named workspace dependencies declared with \`uses\`. Source text and arbitrary config values are not scanned for URLs or UUIDs. Repository identity and runtime access checks still apply.
184
184
 
185
- The per-primitive commands remain available for validation and operation; \`seq-studio deploy\` is the app-level deployment entry point. See \`seq-studio deploy --help\` and the CLI command reference at ${docsLink({ atlasOrigin, label: 'CLI command reference', slug: 'seq-studio/commands' })}.
185
+ The per-primitive commands remain available for validation and operation; \`seq-studio apply\` is the app-level deployment entry point. See \`seq-studio apply --help\` and the CLI command reference at ${docsLink({ atlasOrigin, label: 'CLI command reference', slug: 'seq-studio/commands' })}.
186
186
  `;
187
187
  }
188
188
  export function renderEmptyRepoReadme({ repoName, namespaceSlug, atlasOrigin }) {
@@ -213,11 +213,11 @@ function renderImplementSection({ kinds, functionName, appId }) {
213
213
  if (kinds.has('function'))
214
214
  steps.push(`- **Function:** implement \`functions/${functionName}/index.ts\`; declare egress and secret names in \`managed-function.yml\`.`);
215
215
  if (kinds.has('orm'))
216
- steps.push(`- **ORM:** author tables and operations under \`orm/${appId.replace(/-/g, '_')}/\`, then run \`seq-studio orm generate orm/${appId.replace(/-/g, '_')}\` and \`seq-studio orm diff orm/${appId.replace(/-/g, '_')}\`. Review and commit the generated \`migrations/\` ledger before the first deployment and after schema changes. Init creates namespace source; it does not create the migration baseline automatically.`);
216
+ steps.push(`- **ORM:** author tables and operations under \`orm/${appId.replace(/-/g, '_')}/\`, then run \`seq-studio orm build orm/${appId.replace(/-/g, '_')}\` and \`seq-studio orm diff orm/${appId.replace(/-/g, '_')}\`. Review and commit the generated \`migrations/\` ledger before the first deployment and after schema changes. Init creates namespace source; it does not create the migration baseline automatically.`);
217
217
  if (kinds.has('agent'))
218
- steps.push(`- **Agent:** edit \`agents/${appId}/agent.ts\`; run \`seq-studio agents validate --dir agents/${appId}\`.`);
218
+ steps.push(`- **Agent:** edit \`agents/${appId}/agent.ts\`; run \`seq-studio agent validate --dir agents/${appId}\`.`);
219
219
  if (kinds.has('process'))
220
- steps.push(`- **Lattice:** edit \`processes/${appId}/${appId}/process.ts\`; run \`seq-studio process lint --dir processes/${appId} --offline\`.`);
220
+ steps.push(`- **Lattice:** edit \`processes/${appId}/${appId}/process.ts\`; run \`seq-studio process validate --dir processes/${appId} --offline\`.`);
221
221
  if (kinds.has('pipeline'))
222
222
  steps.push(`- **Pipeline:** complete \`pipelines/${appId}/${appId}.stage.yml\` and its source; run \`seq-studio pipeline validate pipelines/${appId}\`. The template is a transformation stage by default; \`--pipeline-type\` selects ingestion or serving. Pipeline deployment uses a platform git-service release unit: set this primitive's \`repo\` (this app's repository, \`<namespace>/<repository>\`) and \`ref\` in \`sequence.app.yml\`, and commit/push its source to that repository before deployment. A serving template also requires a real producing stage.`);
223
223
  if (kinds.has('artifact'))
@@ -184,7 +184,7 @@ export function firstMissingDirectory({ appRoot, absPath }) {
184
184
  }
185
185
  export function printOrmPreparation({ primitives }) {
186
186
  for (const entry of primitives.filter((item) => item.kind === 'orm')) {
187
- console.log(` seq-studio orm generate ${entry.path}`);
187
+ console.log(` seq-studio orm build ${entry.path}`);
188
188
  console.log(` seq-studio orm diff ${entry.path}`);
189
189
  console.log(` # review and commit ${entry.path}/migrations/ before deploying`);
190
190
  }
@@ -5,7 +5,7 @@ export declare function validateAppLocal({ rootDir }: {
5
5
  schemaVersion: 1 | 2 | 3;
6
6
  primitives: {
7
7
  id: string;
8
- kind: "function" | "process" | "artifact" | "pipeline" | "orm" | "agent" | "workspace";
8
+ kind: "function" | "artifact" | "orm" | "pipeline" | "process" | "agent" | "workspace";
9
9
  path: string;
10
10
  }[];
11
11
  members: {
@@ -99,7 +99,7 @@ export async function scaffoldAppWorkspace({ rootDir, manifest, }) {
99
99
  private: true,
100
100
  type: 'module',
101
101
  packageManager: 'pnpm@10.28.2',
102
- scripts: { deploy: 'seq-studio deploy', 'deploy:plan': 'seq-studio deploy --dry-run' },
102
+ scripts: { deploy: 'seq-studio apply', 'deploy:plan': 'seq-studio apply --dry-run' },
103
103
  devDependencies: { '@sequenceholdings/studio-cli': `^${currentVersion()}` },
104
104
  }, null, 2)}\n`);
105
105
  await writeFile(join(rootDir, 'pnpm-workspace.yaml'), yamlDump({
@@ -4,7 +4,7 @@
4
4
  * Delegates to `runCli` from the `@sequenceholdings/artifact-studio/cli`
5
5
  * library export, so the command implementations live in one place. We:
6
6
  *
7
- * 1. Resolve `--env` from `~/.config/lattice/config.toml`.
7
+ * 1. Resolve `--env` from `~/.config/seq-studio/config.toml`.
8
8
  * 2. Set `ARTIFACT_STUDIO_BASE_URL` so artifact-studio's API client
9
9
  * uses the resolved URL (instead of its own built-in env map).
10
10
  * 3. Install an internal token provider so auth is shared with the rest of
@@ -4,7 +4,7 @@
4
4
  * Delegates to `runCli` from the `@sequenceholdings/artifact-studio/cli`
5
5
  * library export, so the command implementations live in one place. We:
6
6
  *
7
- * 1. Resolve `--env` from `~/.config/lattice/config.toml`.
7
+ * 1. Resolve `--env` from `~/.config/seq-studio/config.toml`.
8
8
  * 2. Set `ARTIFACT_STUDIO_BASE_URL` so artifact-studio's API client
9
9
  * uses the resolved URL (instead of its own built-in env map).
10
10
  * 3. Install an internal token provider so auth is shared with the rest of
@@ -15,6 +15,9 @@
15
15
  * from Atlas instead, and only commands that need neither a local login nor a
16
16
  * package registry run: an agent sandbox reaches its Atlas origin and nothing else.
17
17
  */
18
+ import { resolve as resolvePath } from 'node:path';
19
+ import { BREAK_GLASS_HEADER, cliAttributionHeaders } from '../cli-attribution.js';
20
+ import { ExitCode } from '../exit-codes.js';
18
21
  import { getAccessTokenWithMode, tryGetAccessTokenWithMode } from '../auth.js';
19
22
  import { ARTIFACT_SANDBOX_HELP, INIT_INTO_REPO_HELP } from '../command-help.js';
20
23
  import { readConfig, resolveConfiguredEnv } from '../config.js';
@@ -198,13 +201,15 @@ export async function runArtifactCommand(sub, rest) {
198
201
  process.env['ARTIFACT_STUDIO_ENV_URLS'] = JSON.stringify(Object.fromEntries(Object.entries(routingConfig.envs).map(([name, { url }]) => [name, url])));
199
202
  // Lazy import so `process` / `doctor` commands don't pull in
200
203
  // artifact-studio's vite/react/tailwind dependency graph.
201
- const { getConfiguredDefaultEnv, runCli: runArtifactStudio, setTokenProvider } = await import('@sequenceholdings/artifact-studio/cli');
204
+ const { getConfiguredDefaultEnv, runCli: runArtifactStudio, setTokenProvider } = await (await import('../sdk-source.js')).importSdk({ name: '@sequenceholdings/artifact-studio', subpath: './cli',
205
+ bundled: () => import('@sequenceholdings/artifact-studio/cli'), cwd: await localAppDirectory({ sub, argv: argvForCli }) });
202
206
  const authEnvName = resolved?.name ?? (await getConfiguredDefaultEnv());
203
207
  const targetUrl = resolved?.url ??
204
208
  process.env['ARTIFACT_STUDIO_BASE_URL']?.trim() ??
205
209
  (authEnvName ? routingConfig.envs[authEnvName]?.url : undefined);
206
210
  if (targetUrl)
207
211
  process.env['ARTIFACT_STUDIO_BASE_URL'] = targetUrl;
212
+ applyBreakGlassHeader();
208
213
  setTokenProvider(async ({ allowInteractiveLogin, sourceEnvironment }) => {
209
214
  const source = sourceEnvironment
210
215
  ? await resolveConfiguredEnv({ requested: sourceEnvironment })
@@ -214,7 +219,7 @@ export async function runArtifactCommand(sub, rest) {
214
219
  ? await getAccessTokenWithMode(selected)
215
220
  : await tryGetAccessTokenWithMode({ failClosedForM2m: true, ...selected }));
216
221
  });
217
- return runArtifactStudio([sub, ...argvForCli]);
222
+ return runArtifactStudio([sub, ...argvForCli], { usageExitCode: ExitCode.Usage });
218
223
  }
219
224
  /**
220
225
  * Artifact Studio uses only credentials the CLI obtained itself, never a bearer
@@ -342,6 +347,41 @@ function isPreviewUrl(url) {
342
347
  return false;
343
348
  }
344
349
  }
350
+ /** Subcommands whose first positional is the local application directory (artifact-studio's `[dir]`). */
351
+ const DIRECTORY_SUBCOMMANDS = new Set(['validate', 'build', 'plan', 'deploy', 'dev']);
352
+ /**
353
+ * The local application a directory-based command names, so its SDK and .seq/github.yml select the SDK copy.
354
+ * Undefined (the current directory) for other commands and for remote sources (--repo, --git-url).
355
+ */
356
+ async function localAppDirectory({ sub, argv }) {
357
+ if (!DIRECTORY_SUBCOMMANDS.has(sub))
358
+ return undefined;
359
+ const { parseArgs } = await import('../argv.js');
360
+ const args = parseArgs(argv);
361
+ if (args.flags.repo !== undefined || args.flags['git-url'] !== undefined)
362
+ return undefined;
363
+ return resolvePath(args.positional[0] ?? '.');
364
+ }
365
+ /**
366
+ * Carry `--break-glass` through artifact-studio's own transport, which does not
367
+ * use the CLI's (cli-attribution.ts). Added to ARTIFACT_STUDIO_EXTRA_HEADERS,
368
+ * which artifact-studio sends only to ARTIFACT_STUDIO_BASE_URL's origin.
369
+ */
370
+ function applyBreakGlassHeader() {
371
+ const reason = cliAttributionHeaders()[BREAK_GLASS_HEADER];
372
+ if (!reason)
373
+ return;
374
+ let existing = {};
375
+ try {
376
+ const parsed = JSON.parse(process.env['ARTIFACT_STUDIO_EXTRA_HEADERS'] ?? '{}');
377
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed))
378
+ existing = parsed;
379
+ }
380
+ catch {
381
+ // artifact-studio ignores malformed extra headers; replace them with ours.
382
+ }
383
+ process.env['ARTIFACT_STUDIO_EXTRA_HEADERS'] = JSON.stringify({ ...existing, [BREAK_GLASS_HEADER]: reason });
384
+ }
345
385
  /**
346
386
  * Thread the Cloudflare WAF bypass header through artifact-studio's HTTP client
347
387
  * via ARTIFACT_STUDIO_EXTRA_HEADERS (read in artifact-studio/src/api.ts). Reads
@@ -49,7 +49,6 @@ export async function runAuthCommand(sub, args) {
49
49
  }
50
50
  }
51
51
  catch (error) {
52
- printCliError(error);
53
- return 1;
52
+ return printCliError(error);
54
53
  }
55
54
  }
package/dist/bin.js CHANGED
@@ -2,6 +2,16 @@
2
2
  import { commandTelemetryName, run } from './main.js';
3
3
  import { parseArgs } from './argv.js';
4
4
  import { beginCommandTelemetry, finishCommandTelemetry } from './command-telemetry.js';
5
+ import { migrateLegacyConfigDir } from './config-dir.js';
6
+ import { exitCodeFor } from './exit-codes.js';
7
+ import { setDefaultAutoSelectFamilyAttemptTimeout } from 'node:net';
8
+ // Node's 250ms default gives up on IPv6/IPv4 happy-eyeballs too early on slow
9
+ // networks and fails with `fetch failed`; set it here so nobody needs NODE_OPTIONS.
10
+ setDefaultAutoSelectFamilyAttemptTimeout(2500);
11
+ // Once per machine: ~/.config/lattice becomes ~/.config/seq-studio (old path symlinked).
12
+ const migrationError = migrateLegacyConfigDir();
13
+ if (migrationError)
14
+ console.error(`note: could not move ~/.config/lattice to ~/.config/seq-studio: ${migrationError.message}`);
5
15
  // A consumer may close stdout while a remote operation continues. Stop local
6
16
  // output quietly; never cancel or retry the remote operation.
7
17
  process.stdout.on('error', (error) => {
@@ -22,8 +32,8 @@ let commandError;
22
32
  run(argv)
23
33
  .catch((error) => {
24
34
  commandError = error;
25
- console.error(error instanceof Error ? error.message : error);
26
- return 1;
35
+ console.error(`error ${error instanceof Error ? error.message : String(error)}`);
36
+ return exitCodeFor(error);
27
37
  })
28
38
  // The update notice runs after the command so it never delays real output,
29
39
  // and it is best-effort (never throws, never changes the exit code).