@sequenceholdings/studio-cli 0.9.22 → 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 +11 -10
  133. package/release-summary.json +3 -1
@@ -0,0 +1,60 @@
1
+ /** Repository and app lifecycle commands: repo, apply, status, affected, check. Spread into COMMANDS. */
2
+ import { parse, present, subs } from './spec.js';
3
+ export const LIFECYCLE_COMMANDS = [
4
+ {
5
+ name: 'repo',
6
+ group: 'lifecycle', usage: 'repo init [--check] set up a GitHub checkout: workflows, Renovate, agent skill, branch rules',
7
+ description: 'Set up a GitHub repository and connect it to Atlas deploys',
8
+ lifecycle: 'preview', access: 'mixed', checkSubcommands: true, telemetry: 'subcommand',
9
+ subcommands: subs(['init', 'connect', 'bind', 'disconnect', 'status']),
10
+ run: async ({ sub, rest }) => {
11
+ if (sub === 'connect' || sub === 'disconnect' || sub === 'status' || sub === 'bind') {
12
+ return (await import('../repos/github-connect-command.js')).runRepoConnectCommand(sub, await parse(rest));
13
+ }
14
+ if (sub !== 'init') {
15
+ console.error('usage: seq-studio repo init|connect|bind|disconnect|status (see seq-studio repo <command> --help)');
16
+ return 2;
17
+ }
18
+ return (await import('../repos/github-init-command.js')).runRepoInitCommand(await parse(rest));
19
+ },
20
+ }, {
21
+ name: 'apply',
22
+ renamedFrom: ['deploy'],
23
+ group: 'lifecycle', usage: 'apply -e <env> [--only <ids>] deploy this app; refused for repositories that deploy from GitHub',
24
+ description: 'Deploy an app workspace',
25
+ lifecycle: 'preview', access: 'authenticated', subcommands: [], checkSubcommands: false, telemetry: 'command',
26
+ run: async ({ sub, rest }) => (await import('../lifecycle/commands.js')).runApplyCommand(await parse(present([sub, ...rest]))),
27
+ }, {
28
+ name: 'affected',
29
+ group: 'lifecycle', usage: 'affected [--base <rev>] which targets this change reaches, as seq-ci plans it',
30
+ description: "Show which targets a change reaches, using the repository's pinned seq-ci release",
31
+ lifecycle: 'preview', access: 'offline', subcommands: [], checkSubcommands: false, telemetry: 'command',
32
+ run: async ({ sub, rest }) => (await import('../lifecycle/check.js')).runAffectedCommand(await parse(present([sub, ...rest]))),
33
+ }, {
34
+ name: 'check',
35
+ group: 'lifecycle', usage: 'check [<target>...] run seq-ci checks locally, in CI\'s sandboxes',
36
+ description: "Run the repository's pinned seq-ci checks locally",
37
+ lifecycle: 'preview', access: 'offline', subcommands: [], checkSubcommands: false, telemetry: 'command',
38
+ run: async ({ sub, rest }) => (await import('../lifecycle/check.js')).runCheckCommand(await parse(present([sub, ...rest]))),
39
+ }, {
40
+ name: 'plan',
41
+ group: 'lifecycle', usage: 'plan -e <env> [--stage <s>] what merging or promoting this commit would do there',
42
+ description: 'Plan a committed change against an Atlas stage without deploying anything',
43
+ lifecycle: 'preview', access: 'staff', subcommands: [], checkSubcommands: false, telemetry: 'command',
44
+ run: async ({ sub, rest }) => (await import('../lifecycle/plan.js')).runPlanCommand(await parse(present([sub, ...rest]))),
45
+ },
46
+ {
47
+ name: 'rollback',
48
+ group: 'lifecycle', usage: 'rollback --to <rev> open a pull request that puts the dev branch back to <rev>',
49
+ description: "Open a pull request that restores the dev branch to an earlier commit's files",
50
+ lifecycle: 'preview', access: 'offline', subcommands: [], checkSubcommands: false, telemetry: 'command',
51
+ run: async ({ sub, rest }) => (await import('../lifecycle/rollback.js')).runRollbackCommand(await parse(present([sub, ...rest]))),
52
+ },
53
+ {
54
+ name: 'status',
55
+ group: 'lifecycle', usage: 'status [-e <env>] [--compare <a> <b>] this repository\'s releases and target states',
56
+ description: "Show this repository's releases on an Atlas",
57
+ lifecycle: 'preview', access: 'staff', subcommands: [], checkSubcommands: false, telemetry: 'command',
58
+ run: async ({ sub, rest }) => (await import('../lifecycle/commands.js')).runStatusCommand(await parse(present([sub, ...rest]))),
59
+ },
60
+ ];
@@ -0,0 +1,6 @@
1
+ import type { CommandSpec, Subcommand } from './spec.js';
2
+ export declare function findCommand(name: string): CommandSpec | undefined;
3
+ /** The subcommand a word names, by its current or an old spelling. */
4
+ export declare function findSubcommand(command: CommandSpec, word: string): Subcommand | undefined;
5
+ /** Whether `sub` is a known subcommand of `command`, or null when the command does not check. */
6
+ export declare function knowsSubcommand(command: CommandSpec, sub: string): boolean | null;
@@ -0,0 +1,18 @@
1
+ /** Finding commands and subcommands by their current or old spellings. */
2
+ import { COMMANDS } from './commands.js';
3
+ let byName;
4
+ export function findCommand(name) {
5
+ // Built on first use: commands.ts re-exports this module, so COMMANDS is not ready while it loads.
6
+ byName ??= new Map(COMMANDS.flatMap((command) => [command.name, ...(command.aliases ?? []), ...(command.renamedFrom ?? [])].map((name) => [name, command])));
7
+ return byName.get(name);
8
+ }
9
+ /** The subcommand a word names, by its current or an old spelling. */
10
+ export function findSubcommand(command, word) {
11
+ return command.subcommands.find(({ name, renamedFrom }) => name === word || (renamedFrom?.includes(word) ?? false));
12
+ }
13
+ /** Whether `sub` is a known subcommand of `command`, or null when the command does not check. */
14
+ export function knowsSubcommand(command, sub) {
15
+ if (!command.checkSubcommands)
16
+ return null;
17
+ return findSubcommand(command, sub) !== undefined;
18
+ }
@@ -0,0 +1,14 @@
1
+ export declare function hasHelpFlag(sub: string | undefined, rest: string[]): boolean;
2
+ export declare function runCapabilities(argv: string[]): Promise<number>;
3
+ export declare function runTelemetryCommand({ sub, rest }: {
4
+ sub: string | undefined;
5
+ rest: string[];
6
+ }): Promise<number>;
7
+ export declare function runSessionCommand({ args, command, }: {
8
+ args: string[];
9
+ command: 'login' | 'logout';
10
+ }): Promise<number>;
11
+ export declare function runProcessNamespace({ sub, rest }: {
12
+ sub: string | undefined;
13
+ rest: string[];
14
+ }): Promise<number>;
@@ -0,0 +1,206 @@
1
+ /** Commands whose routing lives in the CLI itself rather than in a command module. */
2
+ import { parseArgs } from '../argv.js';
3
+ import { ExitCode } from '../exit-codes.js';
4
+ const PROCESS_USAGE = `usage:
5
+ seq-studio process init <dir>
6
+ seq-studio process validate [--dir <path>] [--offline]
7
+ seq-studio process plan [--dir <path>] [-e <env>]
8
+ seq-studio process apply [--dir <path>] [-e <env>] [--only <id1,id2,...>] [--platform-managed]
9
+ seq-studio process apply --repo <namespace>/<name> [--ref <r>] -e <env> [--only <id1,id2,...>] [--platform-managed]
10
+ seq-studio process promote <processId> --version <v> [-e <env>]
11
+ seq-studio process pull <processId> [--version <v>] [-e <env>] [--out <dir>] [--no-children]
12
+ seq-studio process runs start|retry|list|show|cancel [args] -e <env> (see process runs --help)
13
+ seq-studio process test [-e <env>] [--offline]
14
+ seq-studio process simulate <process-id>
15
+ seq-studio process bundle build [-o file.json] [-e <env>] [--offline]
16
+ seq-studio process bundle pull <hash> [-o file.json] [-e <env>]
17
+ seq-studio process bundle archive <hash> [-e <env>]
18
+ seq-studio process bundle inspect <bundle.json>
19
+ seq-studio process bundle list [-e <env>] [--limit N] [--cursor <hash>]
20
+ seq-studio process bundle publish <hash|bundle.json> [-e <env>]
21
+ seq-studio process safety-baseline [--repo-root <dir>] [--write]
22
+ `;
23
+ const TELEMETRY_USAGE = 'usage: seq-studio telemetry enable|disable|status';
24
+ export function hasHelpFlag(sub, rest) {
25
+ return sub === 'help' || sub === '--help' || sub === '-h' || rest.some((arg) => arg === '--help' || arg === '-h');
26
+ }
27
+ export async function runCapabilities(argv) {
28
+ const args = parseArgs(argv);
29
+ const unknown = Object.keys(args.flags).find((flag) => flag !== 'json');
30
+ if (unknown || args.positional.length > 0 || (args.flags.json !== undefined && args.flags.json !== true)) {
31
+ console.error('usage: seq-studio capabilities [--json]');
32
+ return ExitCode.Usage;
33
+ }
34
+ const { renderCapabilities } = await import('../command-contract.js');
35
+ console.log(renderCapabilities({ json: args.flags.json === true }));
36
+ return 0;
37
+ }
38
+ export async function runTelemetryCommand({ sub, rest }) {
39
+ const { setTelemetryEnabled, telemetryEnabled } = await import('../command-telemetry.js');
40
+ if (sub === '--help' || sub === '-h' || sub === 'help') {
41
+ console.log(TELEMETRY_USAGE);
42
+ return 0;
43
+ }
44
+ if (rest.length > 0) {
45
+ console.error(TELEMETRY_USAGE);
46
+ return 1;
47
+ }
48
+ if (sub === 'enable' || sub === 'disable')
49
+ await setTelemetryEnabled(sub === 'enable');
50
+ else if (sub !== 'status') {
51
+ console.error(TELEMETRY_USAGE);
52
+ return 1;
53
+ }
54
+ console.log(`Command telemetry: ${await telemetryEnabled() ? 'on' : 'off'}`);
55
+ return 0;
56
+ }
57
+ const SESSION_USAGE = {
58
+ login: `usage: seq-studio login [<org> | <org>/<stage> | <deployment-url> | --env <name>]
59
+
60
+ login <deployment-url> add that deployment (and its org) once, then sign in
61
+ login <org> sign in to each known stage of the org
62
+ login <org>/<stage> sign in to one stage`,
63
+ logout: 'usage: seq-studio logout [--env <name>]',
64
+ };
65
+ export async function runSessionCommand({ args, command, }) {
66
+ const usage = SESSION_USAGE[command];
67
+ if (args[0] === 'help' || args[0] === '--help' || args[0] === '-h') {
68
+ console.log(usage);
69
+ return 0;
70
+ }
71
+ const parsed = parseArgs(args);
72
+ const flagEnv = (typeof parsed.flags.env === 'string' ? parsed.flags.env : undefined) ??
73
+ (typeof parsed.flags.e === 'string' ? parsed.flags.e : undefined);
74
+ const [target, ...extra] = parsed.positional;
75
+ if (extra.length > 0 || (args.length > 0 && !flagEnv && !target) || (command === 'logout' && target)) {
76
+ console.error(usage);
77
+ return 2;
78
+ }
79
+ const auth = await import('../login.js');
80
+ const envName = flagEnv ? await sessionEnvName(flagEnv) : undefined;
81
+ if (command === 'logout') {
82
+ await auth.logout(envName);
83
+ return 0;
84
+ }
85
+ const envNames = target ? await loginTargets(target) : [envName];
86
+ // An OpCo env name (registered via `seq-studio envs add` or `seqapi env add`)
87
+ // logs into that environment's Auth0 realm; omitted or a built-in name uses Sequence.
88
+ for (const envName of envNames)
89
+ await auth.login(envName);
90
+ return 0;
91
+ }
92
+ /**
93
+ * The configured environment an `-e` value names: `<org>/<stage>` and a bare
94
+ * stage inside a repository resolve to the environment serving them, because
95
+ * sessions are cached per configured environment.
96
+ */
97
+ async function sessionEnvName(requested) {
98
+ const [{ readConfig }, { resolveStagedEnv }] = await Promise.all([import('../config.js'), import('../staged-env.js')]);
99
+ return resolveStagedEnv({ config: await readConfig(), name: requested })?.name ?? requested;
100
+ }
101
+ /**
102
+ * The configured environment names a `login <target>` signs in to. A known org
103
+ * wins over a same-named environment, so `login <org>` reaches every stage;
104
+ * `-e <name>` still selects one environment.
105
+ */
106
+ async function loginTargets(target) {
107
+ const [{ readConfig, resolveEnv }, { UsageError }] = await Promise.all([import('../config.js'), import('../exit-codes.js')]);
108
+ if (/^https?:\/\//.test(target))
109
+ return [await addDeployment(target)];
110
+ const config = await readConfig();
111
+ const stages = target.includes('/') ? undefined : config.orgs?.[target];
112
+ if (stages)
113
+ return orgLoginTargets({ config, org: target, stages });
114
+ if (target.includes('/') || config.envs[target])
115
+ return [resolveEnv({ config, requested: target }).name];
116
+ throw new UsageError(`Unknown org or environment "${target}". Add a deployment once with: seq-studio login <deployment-url>`);
117
+ }
118
+ /** Each stage of `org` that is a configured environment; the others are reported, not fatal. */
119
+ async function orgLoginTargets({ config, org, stages }) {
120
+ const [{ resolveEnv }, { UsageError }] = await Promise.all([import('../config.js'), import('../exit-codes.js')]);
121
+ const { STAGES } = await import('../orgs.js');
122
+ const names = [];
123
+ const skipped = [];
124
+ for (const stage of STAGES.filter((known) => stages[known])) {
125
+ try {
126
+ names.push(resolveEnv({ config, requested: `${org}/${stage}` }).name);
127
+ }
128
+ catch (error) {
129
+ if (!(error instanceof UsageError))
130
+ throw error;
131
+ skipped.push(error.message);
132
+ }
133
+ }
134
+ for (const message of skipped)
135
+ console.error(`skipped ${message}`);
136
+ if (names.length === 0)
137
+ throw new UsageError(`No stage of org "${org}" is a configured environment yet.`);
138
+ return [...new Set(names)];
139
+ }
140
+ /** Register a deployment from its URL under the name it advertises, recording its org. */
141
+ async function addDeployment(baseUrl) {
142
+ const [{ fetchDeploymentLogin, registerEnvironment }, { addSharedLoginEnvironment }, { isSharedLoginDeploymentName, usesSharedSequenceLogin }, { rememberOrg }] = await Promise.all([import('../env-registry.js'), import('../config.js'), import('../auth.js'), import('../envs/commands.js')]);
143
+ const discovered = await fetchDeploymentLogin({ baseUrl });
144
+ const name = discovered.cliEnvironment;
145
+ if (!name || name === 'local') {
146
+ throw new Error(`${baseUrl} does not advertise a CLI environment name; add it with: seq-studio envs add <name> ${baseUrl}`);
147
+ }
148
+ if (usesSharedSequenceLogin(discovered) && isSharedLoginDeploymentName(name)) {
149
+ const added = await addSharedLoginEnvironment({ name, baseUrl });
150
+ await rememberOrg(added.cliOrg);
151
+ }
152
+ else {
153
+ const registration = await registerEnvironment({ name, baseUrl });
154
+ await rememberOrg(registration.cliOrg);
155
+ }
156
+ console.log(`Added environment '${name}' -> ${baseUrl}`);
157
+ return name;
158
+ }
159
+ export async function runProcessNamespace({ sub, rest }) {
160
+ if (sub === 'runs') {
161
+ const { processRunsCommand } = await import('../process/runs.js');
162
+ return processRunsCommand(parseArgs(rest));
163
+ }
164
+ if (hasHelpFlag(sub, rest)) {
165
+ console.log(PROCESS_USAGE);
166
+ return 0;
167
+ }
168
+ if (!sub) {
169
+ console.error(PROCESS_USAGE);
170
+ return 1;
171
+ }
172
+ const processCommands = await import('../process/commands.js');
173
+ const args = processCommands.parseArgs(sub === 'bundle' ? [sub, ...rest] : rest);
174
+ switch (sub) {
175
+ case 'init':
176
+ return processCommands.initCommand(args);
177
+ case 'lint':
178
+ return processCommands.lintCommand(args);
179
+ case 'plan':
180
+ return processCommands.planCommand(args);
181
+ case 'apply':
182
+ return processCommands.applyCommand(args);
183
+ case 'promote':
184
+ return processCommands.promoteCommand(args);
185
+ case 'pull':
186
+ return processCommands.pullCommand(args);
187
+ case 'test':
188
+ return processCommands.testCommand(args);
189
+ case 'simulate':
190
+ return processCommands.simulateCommand(args);
191
+ case 'bundle':
192
+ // bundleCommand reads its own verb (build/pull/inspect) from positional[0].
193
+ return processCommands.bundleCommand({
194
+ positional: args.positional.slice(1),
195
+ flags: args.flags,
196
+ });
197
+ case 'safety-baseline': {
198
+ const { safetyBaselineCommand } = await import('../process/safety-baseline.js');
199
+ return safetyBaselineCommand({ flags: args.flags });
200
+ }
201
+ default:
202
+ console.error(`unknown process command: ${sub}`);
203
+ console.error(PROCESS_USAGE);
204
+ return 1;
205
+ }
206
+ }
@@ -0,0 +1,45 @@
1
+ /** Types and helpers for the command registry in ./commands.ts. */
2
+ import type { ParsedArgs } from '../argv.js';
3
+ export type Lifecycle = 'stable' | 'preview' | 'internal' | 'blocked';
4
+ export type Access = 'offline' | 'public' | 'mixed' | 'authenticated' | 'staff';
5
+ export interface Subcommand {
6
+ name: string;
7
+ /** Old spellings that still work and print the new one. */
8
+ renamedFrom?: readonly string[];
9
+ /** The word the command's implementation reads, when it differs from `name`. */
10
+ implementation?: string;
11
+ /** False for routable subcommands that `capabilities` does not advertise. */
12
+ listed?: boolean;
13
+ /** Third-level words recorded in telemetry, e.g. `process runs start`. */
14
+ nested?: readonly string[];
15
+ }
16
+ export type CommandGroup = 'lifecycle' | 'primitive' | 'platform' | 'cli';
17
+ export interface CommandSpec {
18
+ name: string;
19
+ /** Old spellings that still work and print the new one. */
20
+ renamedFrom?: readonly string[];
21
+ group: CommandGroup;
22
+ /** One line for top-level help, without the `seq-studio ` prefix. */
23
+ usage: string;
24
+ /** Hidden from help unless SEQ_STUDIO_INTERNAL=1. */
25
+ internal?: boolean;
26
+ aliases?: readonly string[];
27
+ description: string;
28
+ lifecycle: Lifecycle;
29
+ access: Access;
30
+ subcommands: readonly Subcommand[];
31
+ /**
32
+ * Whether an unknown subcommand is rejected before offline help runs.
33
+ * Commands that parse their own first word (`repo`, `telemetry`) opt out.
34
+ */
35
+ checkSubcommands: boolean;
36
+ /** never: no telemetry; command: the command word only; subcommand: `<command> <sub>`. */
37
+ telemetry: 'never' | 'command' | 'subcommand';
38
+ run: (input: {
39
+ sub: string | undefined;
40
+ rest: string[];
41
+ }) => Promise<number>;
42
+ }
43
+ export declare const subs: (names: readonly string[], unlisted?: readonly string[]) => Subcommand[];
44
+ export declare const present: (values: Array<string | undefined>) => string[];
45
+ export declare function parse(argv: string[]): Promise<ParsedArgs>;
@@ -0,0 +1,8 @@
1
+ export const subs = (names, unlisted = []) => [
2
+ ...names.map((name) => ({ name })),
3
+ ...unlisted.map((name) => ({ name, listed: false })),
4
+ ];
5
+ export const present = (values) => values.filter((value) => Boolean(value));
6
+ export async function parse(argv) {
7
+ return (await import('../argv.js')).parseArgs(argv);
8
+ }
@@ -960,7 +960,6 @@ export async function runReposCommand(sub, args) {
960
960
  }
961
961
  }
962
962
  catch (error) {
963
- printCliError(error);
964
- return 1;
963
+ return printCliError(error);
965
964
  }
966
965
  }
@@ -1,5 +1,13 @@
1
1
  import type { ParsedArgs } from '../argv.js';
2
- export declare const REPO_CONNECT_USAGE = "usage:\n seq-studio repo connect -e <env> --stage staging|prod [--adopt <namespace/repo>:<branch>] [--dir <checkout>] [--json]\n seq-studio repo disconnect -e <env> [--dir <checkout>] [--yes]\n seq-studio repo status -e <env> [--stage staging|prod] [--limit <n>] [--dir <checkout>] [--json]\n seq-studio repo bind -e <env> --stage staging|prod [--dry-run] [--dir <checkout>] [--json]\n\n connect: let this GitHub repository deploy to one stage of an Atlas. The dev branch deploys to staging and the\n release branch to prod (from .seq/github.yml); the Atlas's branch policy pins the images of the repository's\n seq-ci release. --adopt moves a git-service branch's deployments here: its bindings and the resources it controls,\n and it drops to checks-only. release group (Sequence Staff) only; --adopt also needs merge rights on the git-service repository.\n\n disconnect: stop all GitHub deploys of this repository to the Atlas, including queued and retried ones.\n\n status: this repository's releases on the Atlas, newest first, with each target's deployment state.\n\n bind: for a repository whose resources were deployed by hand before it deployed from CI, bind each target to the\n one existing, ready resource of exactly its name that you may deploy, and make the branch its controller. Run it\n after connect and before the first deploy, or every existing resource plans as a new create. Only targets the\n stage's plan deploys are bound: one scoped to other stages (its own or its Application's stages in\n .seq/repository.yml) is skipped and reported. --dry-run previews.\n\n Managed Pipelines are released under the name in .seq/github.yml's release_repository (seq-studio repo init\n --release-repository apps/platform-billing). If a git-service repository of that name exists on the Atlas, they\n keep releasing under it (you need its identity receipt and merge rights); otherwise connect claims the name for\n this repository, and no other repository can use it there.\n\n Uses gh (authenticated) to read the repository id and seq-ci's pinned images.";
2
+ export declare const REPO_CONNECT_USAGE = "usage:\n seq-studio repo connect -e <env> --stage staging|prod [--laptop-deploys warn|refuse] [--adopt <namespace/repo>:<branch>] [--dir <checkout>] [--json]\n seq-studio repo disconnect -e <env> [--release] [--dir <checkout>] [--yes]\n seq-studio repo status -e <env> [--stage staging|prod] [--limit <n>] [--dir <checkout>] [--json]\n seq-studio repo bind -e <env> --stage staging|prod [--dry-run] [--dir <checkout>] [--json]\n\n connect: let this GitHub repository deploy to one stage of an Atlas. The dev branch deploys to staging and the\n release branch to prod (from .seq/github.yml); the Atlas's branch policy pins the images of the repository's\n seq-ci release. --adopt moves a git-service branch's deployments here: its bindings and the resources it controls,\n and it drops to checks-only. release group (Sequence Staff) only; --adopt also needs merge rights on the git-service repository.\n --laptop-deploys says what a deploy from a laptop (seq-studio deploy, apply, promote) of a resource the branch\n deploys gets: warn (the default) lets it through with a notice and an audit event; refuse turns it away unless it\n carries --break-glass \"<reason>\". Reconnecting without it keeps the current setting.\n\n disconnect: stop all GitHub deploys of this repository to the Atlas, including queued and retried ones.\n Its branches stay the controllers of the resources they deploy, so reconnecting resumes them and no other\n repository can bind them. --release also gives those resources up, with their bindings and the repository's\n Managed Pipelines release name: the step before another repository takes them over with repo connect and repo bind\n (moving an app to another repository, or retiring this one).\n\n status: this repository's releases on the Atlas, newest first, with each target's deployment state.\n\n bind: for a repository whose resources were deployed by hand before it deployed from CI, bind each target to the\n one existing, ready resource of exactly its name that you may deploy, and make the branch its controller. Run it\n after connect and before the first deploy, or every existing resource plans as a new create. Only targets the\n stage's plan deploys are bound: one scoped to other stages (its own or its Application's stages in\n .seq/repository.yml) is skipped and reported. A target already bound whose resource lost its controller (for\n example, removed from .seq/repository.yml and added back) is reclaimed: the branch becomes its controller again.\n One another branch controls is left alone. --dry-run previews.\n\n Managed Pipelines are released under the name in .seq/github.yml's release_repository (seq-studio repo init\n --release-repository apps/platform-billing). If a git-service repository of that name exists on the Atlas, they\n keep releasing under it (you need its identity receipt and merge rights); otherwise connect claims the name for\n this repository, and no other repository can use it there.\n\n Uses gh (authenticated) to read the repository id and seq-ci's pinned images.";
3
+ export declare function gh(args: string[]): string;
4
+ /** The GitHub repository a checkout's origin names, and its numeric id (stable across renames). */
5
+ export declare function githubRepository({ directory }: {
6
+ directory: string;
7
+ }): {
8
+ repository: string;
9
+ id: string;
10
+ };
3
11
  /** The candidate and Next.js images a seq-ci release pins, read from its pipeline workflow. */
4
12
  export declare function seqCiImages({ workflowText, release }: {
5
13
  workflowText: string;
@@ -22,6 +30,7 @@ export declare function parseAdopt(value: string): {
22
30
  name: string;
23
31
  branch: string;
24
32
  };
33
+ export declare function laptopDeploysOf(args: ParsedArgs): 'warn' | 'refuse' | undefined;
25
34
  /** A preflight refusal arrives as JSON naming each denied operation; anything else is already prose. */
26
35
  export declare function readableReason(reason: string): string;
27
36
  interface TreeEntry {
@@ -1,14 +1,15 @@
1
1
  import { spawnSync } from 'node:child_process';
2
2
  import { resolveRepo } from '@sequenceholdings/artifact-studio/git-service-client';
3
3
  import { load as yamlLoad } from 'js-yaml';
4
- import { deleteJson, getJson, postJson } from '../atlas-client.js';
4
+ import { AtlasApiError, deleteJson, getJson, postJson } from '../atlas-client.js';
5
5
  import { confirmYes } from '../prompt.js';
6
+ import { UsageError } from '../exit-codes.js';
6
7
  import { buildContext, clientOptions } from '../functions/commands.js';
7
8
  import { githubRepositoryFromRemote } from './github-init-command.js';
8
9
  import { resolveSettings, SEQ_CI_REPOSITORY } from './github-init.js';
9
10
  export const REPO_CONNECT_USAGE = `usage:
10
- seq-studio repo connect -e <env> --stage staging|prod [--adopt <namespace/repo>:<branch>] [--dir <checkout>] [--json]
11
- seq-studio repo disconnect -e <env> [--dir <checkout>] [--yes]
11
+ seq-studio repo connect -e <env> --stage staging|prod [--laptop-deploys warn|refuse] [--adopt <namespace/repo>:<branch>] [--dir <checkout>] [--json]
12
+ seq-studio repo disconnect -e <env> [--release] [--dir <checkout>] [--yes]
12
13
  seq-studio repo status -e <env> [--stage staging|prod] [--limit <n>] [--dir <checkout>] [--json]
13
14
  seq-studio repo bind -e <env> --stage staging|prod [--dry-run] [--dir <checkout>] [--json]
14
15
 
@@ -16,8 +17,15 @@ export const REPO_CONNECT_USAGE = `usage:
16
17
  release branch to prod (from .seq/github.yml); the Atlas's branch policy pins the images of the repository's
17
18
  seq-ci release. --adopt moves a git-service branch's deployments here: its bindings and the resources it controls,
18
19
  and it drops to checks-only. release group (Sequence Staff) only; --adopt also needs merge rights on the git-service repository.
20
+ --laptop-deploys says what a deploy from a laptop (seq-studio deploy, apply, promote) of a resource the branch
21
+ deploys gets: warn (the default) lets it through with a notice and an audit event; refuse turns it away unless it
22
+ carries --break-glass "<reason>". Reconnecting without it keeps the current setting.
19
23
 
20
24
  disconnect: stop all GitHub deploys of this repository to the Atlas, including queued and retried ones.
25
+ Its branches stay the controllers of the resources they deploy, so reconnecting resumes them and no other
26
+ repository can bind them. --release also gives those resources up, with their bindings and the repository's
27
+ Managed Pipelines release name: the step before another repository takes them over with repo connect and repo bind
28
+ (moving an app to another repository, or retiring this one).
21
29
 
22
30
  status: this repository's releases on the Atlas, newest first, with each target's deployment state.
23
31
 
@@ -25,7 +33,9 @@ export const REPO_CONNECT_USAGE = `usage:
25
33
  one existing, ready resource of exactly its name that you may deploy, and make the branch its controller. Run it
26
34
  after connect and before the first deploy, or every existing resource plans as a new create. Only targets the
27
35
  stage's plan deploys are bound: one scoped to other stages (its own or its Application's stages in
28
- .seq/repository.yml) is skipped and reported. --dry-run previews.
36
+ .seq/repository.yml) is skipped and reported. A target already bound whose resource lost its controller (for
37
+ example, removed from .seq/repository.yml and added back) is reclaimed: the branch becomes its controller again.
38
+ One another branch controls is left alone. --dry-run previews.
29
39
 
30
40
  Managed Pipelines are released under the name in .seq/github.yml's release_repository (seq-studio repo init
31
41
  --release-repository apps/platform-billing). If a git-service repository of that name exists on the Atlas, they
@@ -38,14 +48,14 @@ function flag(args, name) {
38
48
  const value = args.flags[name];
39
49
  return typeof value === 'string' ? value : undefined;
40
50
  }
41
- function gh(args) {
51
+ export function gh(args) {
42
52
  const result = spawnSync('gh', args, { encoding: 'utf8' });
43
53
  if (result.error || result.status !== 0)
44
54
  throw new Error(`gh ${args.slice(0, 2).join(' ')} failed: ${(result.stderr || result.error?.message || '').trim() || 'is gh installed and logged in?'}`);
45
55
  return result.stdout.trim();
46
56
  }
47
57
  /** The GitHub repository a checkout's origin names, and its numeric id (stable across renames). */
48
- function githubRepository({ directory }) {
58
+ export function githubRepository({ directory }) {
49
59
  const remote = spawnSync('git', ['remote', 'get-url', 'origin'], { cwd: directory, encoding: 'utf8' });
50
60
  const repository = remote.status === 0 ? githubRepositoryFromRemote(remote.stdout) : null;
51
61
  if (!repository)
@@ -107,9 +117,16 @@ function stageOf(args) {
107
117
  throw new Error('--stage must be staging or prod: the stage this Atlas serves');
108
118
  return stage;
109
119
  }
120
+ export function laptopDeploysOf(args) {
121
+ const value = flag(args, 'laptop-deploys');
122
+ if (value === undefined || value === 'warn' || value === 'refuse')
123
+ return value;
124
+ throw new UsageError('--laptop-deploys must be warn or refuse');
125
+ }
110
126
  async function connect(args) {
111
127
  const directory = flag(args, 'dir') ?? '.';
112
128
  const stage = stageOf(args);
129
+ const laptopDeploys = laptopDeploysOf(args);
113
130
  const settings = await resolveSettings({ directory });
114
131
  const branch = stage === 'staging' ? settings.branches.dev : settings.branches.release;
115
132
  const { repository, id } = githubRepository({ directory });
@@ -127,7 +144,7 @@ async function connect(args) {
127
144
  ...(settings.release_repository ? { releaseRepository: settings.release_repository } : {}),
128
145
  // Only the dev branch's deploys reuse pull-request builds; Atlas ignores it for prod.
129
146
  ...(stage === 'staging' ? { pullRequestBuilds: settings.pull_request_builds ?? 'reuse' } : {}),
130
- ...(promotedBuildsFrom ? { promotedBuildsFrom } : {})
147
+ ...(promotedBuildsFrom ? { promotedBuildsFrom } : {}), ...(laptopDeploys ? { laptopDeploys } : {})
131
148
  } });
132
149
  if (args.flags.json === true) {
133
150
  process.stdout.write(`${JSON.stringify({ repository, githubRepositoryId: id, connections, ...images }, null, 2)}\n`);
@@ -140,6 +157,10 @@ async function connect(args) {
140
157
  if (stage === 'prod')
141
158
  process.stdout.write(promotedBuildsFrom ? `Promoted deploys reuse what ${promotedBuildsFrom} built and runs for the same commit; Next.js apps, managed functions and environment-specific builds still build.\n`
142
159
  : 'Every promoted deploy builds and checks each target it deploys (promoted_builds: reuse in .seq/github.yml reuses staging\'s builds).\n');
160
+ const laptop = connections.find((connection) => connection.branch === branch)?.laptopDeploys;
161
+ if (laptop)
162
+ process.stdout.write(laptop === 'refuse' ? `Laptop deploys of what ${branch} deploys are refused without --break-glass "<reason>".\n`
163
+ : `Laptop deploys of what ${branch} deploys go through with a warning (--laptop-deploys refuse turns them away).\n`);
143
164
  if (adopt)
144
165
  process.stdout.write(`Adopted ${adopt.namespace}/${adopt.name}:${adopt.branch}: its bindings and resources are ${branch}'s now, and it runs checks only.\n`);
145
166
  return 0;
@@ -147,10 +168,27 @@ async function connect(args) {
147
168
  async function disconnect(args) {
148
169
  const { repository, id } = githubRepository({ directory: flag(args, 'dir') ?? '.' });
149
170
  const ctx = await buildContext(args);
150
- if (!await confirmYes({ preview: [`Stop every GitHub deploy of ${repository} to ${ctx.env.name}, including queued and retried ones.`], confirmed: args.flags.yes === true }))
171
+ const release = args.flags.release === true;
172
+ const preview = [`Stop every GitHub deploy of ${repository} to ${ctx.env.name}, including queued and retried ones.`,
173
+ ...(release ? [`Release every resource its branches control on ${ctx.env.name}, their bindings and its Managed Pipelines release name. Another repository can then bind them; reconnecting ${repository} will not bring them back.`] : [])];
174
+ if (!await confirmYes({ preview, confirmed: args.flags.yes === true }))
151
175
  return 1;
152
- const { revoked } = await deleteJson({ ...clientOptions(ctx), path: `/api/ci/github/connections?githubRepositoryId=${id}` });
153
- process.stdout.write(`Disconnected ${repository} from ${ctx.env.name} (${revoked} connection${revoked === 1 ? '' : 's'}).\n`);
176
+ if (!release) {
177
+ const { revoked } = await deleteJson({ ...clientOptions(ctx), path: `/api/ci/github/connections?githubRepositoryId=${id}` });
178
+ process.stdout.write(`Disconnected ${repository} from ${ctx.env.name} (${revoked} connection${revoked === 1 ? '' : 's'}).\n`);
179
+ return 0;
180
+ }
181
+ let result;
182
+ try {
183
+ result = await deleteJson({ ...clientOptions(ctx), path: `/api/ci/github/bindings?githubRepositoryId=${id}` });
184
+ }
185
+ catch (error) {
186
+ // An Atlas from before --release has no DELETE on this route, and changed nothing.
187
+ if (error instanceof AtlasApiError && (error.status === 404 || error.status === 405))
188
+ throw new Error(`${ctx.env.name} cannot release a repository's resources yet; nothing was changed. Upgrade that Atlas, or disconnect without --release to only stop its deploys.`);
189
+ throw error;
190
+ }
191
+ process.stdout.write(`Disconnected ${repository} from ${ctx.env.name} (${result.revoked} connection${result.revoked === 1 ? '' : 's'}) and released ${result.released} resource${result.released === 1 ? '' : 's'} it controlled.\n`);
154
192
  return 0;
155
193
  }
156
194
  /** A preflight refusal arrives as JSON naming each denied operation; anything else is already prose. */
@@ -225,8 +263,11 @@ async function bind(args) {
225
263
  const verb = result.saved ? 'Bound' : 'Would bind';
226
264
  for (const entry of result.bound)
227
265
  process.stdout.write(`${verb.padEnd(11)} ${entry.key} -> ${entry.name}\n`);
228
- for (const key of result.alreadyBound)
266
+ const reclaimed = new Set(result.reclaimed ?? []);
267
+ for (const key of result.alreadyBound.filter((entry) => !reclaimed.has(entry)))
229
268
  process.stdout.write(`${'Bound'.padEnd(11)} ${key} (already)\n`);
269
+ for (const key of reclaimed)
270
+ process.stdout.write(result.saved ? `${'Reclaimed'.padEnd(11)} ${key} (controller restored)\n` : `${'Would reclaim'.padEnd(11)} ${key} (no controller; binding restores it)\n`);
230
271
  for (const entry of result.ambiguous)
231
272
  process.stdout.write(`${'Ambiguous'.padEnd(11)} ${entry.key}: ${entry.names.join(', ')}; bind it in Atlas Settings\n`);
232
273
  for (const key of result.notFound)
@@ -4,6 +4,8 @@ import { z } from 'zod';
4
4
  * managed header, and only what's missing or stale; `check` reports the same without writing.
5
5
  */
6
6
  export declare const TEMPLATE_VERSION = 1;
7
+ /** `<major>.<minor>` of the running CLI. */
8
+ export declare function installedMajorMinor(): string;
7
9
  export declare const MANAGED_MARKER = "Managed by seq-studio";
8
10
  export declare const SEQ_CI_REPOSITORY = "sequenceholdings/seq-ci";
9
11
  export declare const githubSettingsSchema: z.ZodObject<{
@@ -23,6 +25,11 @@ export declare const githubSettingsSchema: z.ZodObject<{
23
25
  reuse: "reuse";
24
26
  rebuild: "rebuild";
25
27
  }>>;
28
+ cli: z.ZodOptional<z.ZodString>;
29
+ sdk: z.ZodOptional<z.ZodEnum<{
30
+ bundled: "bundled";
31
+ project: "project";
32
+ }>>;
26
33
  }, z.core.$strict>;
27
34
  export type GitHubSettings = z.infer<typeof githubSettingsSchema>;
28
35
  export declare const GITHUB_SETTINGS_PATH = ".seq/github.yml";
@@ -61,8 +68,7 @@ export interface FileReport {
61
68
  path: string;
62
69
  status: FileStatus;
63
70
  }
64
- /** Existing settings win over defaults, so rerunning never changes a repository's org or branches. */
65
- export declare function resolveSettings({ directory, org, dev, release, seqCi, releaseRepository, pullRequestBuilds }: {
71
+ export declare function resolveSettings({ directory, org, dev, release, seqCi, releaseRepository, pullRequestBuilds, cli }: {
66
72
  directory: string;
67
73
  org?: string;
68
74
  dev?: string;
@@ -70,6 +76,7 @@ export declare function resolveSettings({ directory, org, dev, release, seqCi, r
70
76
  seqCi?: string;
71
77
  releaseRepository?: string;
72
78
  pullRequestBuilds?: string;
79
+ cli?: string;
73
80
  }): Promise<GitHubSettings>;
74
81
  /**
75
82
  * Report, or with `write`, create every managed file that's missing or stale. Never overwrites a file it doesn't own:
@@ -1,4 +1,5 @@
1
1
  import { readFileSync } from 'node:fs';
2
+ import { currentVersion } from '../update-check.js';
2
3
  import { lstat, mkdir, readFile, writeFile } from 'node:fs/promises';
3
4
  import { dirname, join, resolve } from 'node:path';
4
5
  import { dump as yamlDump, load as yamlLoad } from 'js-yaml';
@@ -8,6 +9,10 @@ import { z } from 'zod';
8
9
  * managed header, and only what's missing or stale; `check` reports the same without writing.
9
10
  */
10
11
  export const TEMPLATE_VERSION = 1;
12
+ /** `<major>.<minor>` of the running CLI. */
13
+ export function installedMajorMinor() {
14
+ return currentVersion().split('.').slice(0, 2).join('.');
15
+ }
11
16
  export const MANAGED_MARKER = 'Managed by seq-studio';
12
17
  export const SEQ_CI_REPOSITORY = 'sequenceholdings/seq-ci';
13
18
  export const githubSettingsSchema = z.object({
@@ -31,6 +36,10 @@ export const githubSettingsSchema = z.object({
31
36
  * `repo connect --stage prod` records it on the prod Atlas.
32
37
  */
33
38
  promoted_builds: z.enum(['reuse', 'rebuild']).optional(),
39
+ /** The seq-studio `<major>.<minor>` this repository runs; `seq-studio upgrade` moves it. */
40
+ cli: z.string().regex(/^[0-9]+\.[0-9]+$/).optional(),
41
+ /** `project` runs the SDKs this repository's lockfile installed instead of the CLI's bundled copies (sdk-source.ts). */
42
+ sdk: z.enum(['bundled', 'project']).optional(),
34
43
  }).strict();
35
44
  export const GITHUB_SETTINGS_PATH = '.seq/github.yml';
36
45
  const header = (path) => `# ${MANAGED_MARKER} (template ${TEMPLATE_VERSION}). Change it with \`seq-studio repo init\`; check it with \`seq-studio repo init --check\`.\n# ${path}\n`;
@@ -205,7 +214,12 @@ function statusOf({ existing, content }) {
205
214
  return existing.includes(MANAGED_MARKER) ? 'stale' : 'unmanaged';
206
215
  }
207
216
  /** Existing settings win over defaults, so rerunning never changes a repository's org or branches. */
208
- export async function resolveSettings({ directory, org, dev, release, seqCi, releaseRepository, pullRequestBuilds }) {
217
+ /** A new repository pins the CLI that created it; an existing one keeps what it has until `seq-studio upgrade`. */
218
+ function pinnedCli({ cli, current }) {
219
+ const pin = cli ?? (current ? current.cli : installedMajorMinor());
220
+ return pin ? { cli: pin } : {};
221
+ }
222
+ export async function resolveSettings({ directory, org, dev, release, seqCi, releaseRepository, pullRequestBuilds, cli }) {
209
223
  const existing = await readOptional(join(resolve(directory), GITHUB_SETTINGS_PATH));
210
224
  const current = existing === null ? undefined : githubSettingsSchema.parse(yamlLoad(existing));
211
225
  const settings = { schema_version: 1, org: org ?? current?.org, branches: { dev: dev ?? current?.branches.dev ?? 'staging', release: release ?? current?.branches.release ?? 'main' },
@@ -213,7 +227,9 @@ export async function resolveSettings({ directory, org, dev, release, seqCi, rel
213
227
  // On by default: the dev branch ruleset below requires no approvals.
214
228
  pull_request_builds: pullRequestBuilds ?? current?.pull_request_builds ?? 'reuse',
215
229
  ...((releaseRepository ?? current?.release_repository) ? { release_repository: releaseRepository ?? current?.release_repository } : {}),
216
- ...(current?.promoted_builds ? { promoted_builds: current.promoted_builds } : {}) };
230
+ ...(current?.promoted_builds ? { promoted_builds: current.promoted_builds } : {}),
231
+ ...(current?.sdk ? { sdk: current.sdk } : {}),
232
+ ...pinnedCli({ cli, current }) };
217
233
  if (!settings.org)
218
234
  throw new Error('repo init needs --org the first time (for example --org banksouth)');
219
235
  if (settings.branches.dev === settings.branches.release)