@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.
- package/README.md +152 -144
- package/dist/access/commands.js +3 -5
- package/dist/access/principal.js +2 -2
- package/dist/access/tier-hosts.js +2 -2
- package/dist/agents/commands.d.ts +1 -1
- package/dist/agents/commands.js +9 -9
- package/dist/agents/scaffold.js +3 -3
- package/dist/agents/voice.d.ts +1 -1
- package/dist/agents/voice.js +1 -1
- package/dist/app/commands.d.ts +2 -2
- package/dist/app/commands.js +31 -21
- package/dist/app/deploy.d.ts +1 -1
- package/dist/app/deploy.js +1 -1
- package/dist/app/manifest.d.ts +9 -9
- package/dist/app/manifest.js +1 -1
- package/dist/app/prepare.js +1 -1
- package/dist/app/primitive-scaffold.js +1 -1
- package/dist/app/readme.js +6 -6
- package/dist/app/scaffold.js +1 -1
- package/dist/app/validate.d.ts +1 -1
- package/dist/app/workspace-scaffold.js +1 -1
- package/dist/artifact/delegate.d.ts +1 -1
- package/dist/artifact/delegate.js +43 -3
- package/dist/auth-cmds/commands.js +1 -2
- package/dist/bin.js +12 -2
- package/dist/cli-attribution.d.ts +4 -0
- package/dist/cli-attribution.js +25 -3
- package/dist/cli-errors.d.ts +9 -1
- package/dist/cli-errors.js +20 -9
- package/dist/command-contract.d.ts +7 -182
- package/dist/command-contract.js +9 -33
- package/dist/command-help.d.ts +4 -4
- package/dist/command-help.js +24 -24
- package/dist/command-telemetry.js +2 -2
- package/dist/config-dir.d.ts +8 -0
- package/dist/config-dir.js +35 -0
- package/dist/config.d.ts +6 -0
- package/dist/config.js +15 -3
- package/dist/docs/commands.js +9 -4
- package/dist/env-registry.d.ts +4 -0
- package/dist/env-registry.js +15 -6
- package/dist/envs/commands.d.ts +3 -0
- package/dist/envs/commands.js +11 -0
- package/dist/exit-codes.d.ts +16 -0
- package/dist/exit-codes.js +27 -0
- package/dist/functions/bundle.d.ts +1 -1
- package/dist/functions/commands.js +19 -18
- package/dist/functions/manifest.js +1 -1
- package/dist/functions/service-account-guidance.d.ts +1 -1
- package/dist/functions/service-account-guidance.js +2 -2
- package/dist/lifecycle/check.d.ts +13 -0
- package/dist/lifecycle/check.js +116 -0
- package/dist/lifecycle/commands.d.ts +14 -0
- package/dist/lifecycle/commands.js +121 -0
- package/dist/lifecycle/plan.d.ts +28 -0
- package/dist/lifecycle/plan.js +113 -0
- package/dist/lifecycle/rollback.d.ts +7 -0
- package/dist/lifecycle/rollback.js +89 -0
- package/dist/lifecycle/seq-ci-tools.d.ts +107 -0
- package/dist/lifecycle/seq-ci-tools.js +177 -0
- package/dist/lifecycle/upgrade.d.ts +3 -0
- package/dist/lifecycle/upgrade.js +38 -0
- package/dist/machine-output.d.ts +11 -2
- package/dist/machine-output.js +32 -10
- package/dist/main.d.ts +16 -6
- package/dist/main.js +187 -361
- package/dist/orgs.d.ts +45 -0
- package/dist/orgs.js +106 -0
- package/dist/orm/delegate.d.ts +1 -1
- package/dist/orm/delegate.js +32 -18
- package/dist/orm/deployment-policy.js +1 -2
- package/dist/orm/discover.js +6 -8
- package/dist/orm/execute.d.ts +1 -1
- package/dist/orm/execute.js +5 -6
- package/dist/orm/failures.js +2 -2
- package/dist/orm/help.d.ts +1 -1
- package/dist/orm/help.js +5 -5
- package/dist/orm/history.js +1 -2
- package/dist/orm/operation-show.js +1 -2
- package/dist/orm/version-guard.d.ts +7 -2
- package/dist/orm/version-guard.js +12 -7
- package/dist/pipeline/codegen.js +2 -2
- package/dist/pipeline/commands.js +9 -7
- package/dist/pipeline/discovery.d.ts +1 -1
- package/dist/pipeline/discovery.js +2 -3
- package/dist/pipeline/help.d.ts +1 -1
- package/dist/pipeline/help.js +1 -1
- package/dist/pipeline/lifecycle.js +1 -1
- package/dist/pipeline/stage-secrets.js +4 -4
- package/dist/pipeline/templates.js +2 -2
- package/dist/pnpm-auto-update.js +3 -3
- package/dist/preview.d.ts +1 -1
- package/dist/preview.js +1 -1
- package/dist/principals/commands.d.ts +1 -1
- package/dist/principals/commands.js +13 -14
- package/dist/process/commands.js +4 -1
- package/dist/process/run-steps.d.ts +2 -2
- package/dist/process/runs.js +1 -2
- package/dist/registry/commands.d.ts +4 -0
- package/dist/registry/commands.js +281 -0
- package/dist/registry/help.d.ts +8 -0
- package/dist/registry/help.js +64 -0
- package/dist/registry/lifecycle-commands.d.ts +3 -0
- package/dist/registry/lifecycle-commands.js +60 -0
- package/dist/registry/lookup.d.ts +6 -0
- package/dist/registry/lookup.js +18 -0
- package/dist/registry/runners.d.ts +14 -0
- package/dist/registry/runners.js +206 -0
- package/dist/registry/spec.d.ts +45 -0
- package/dist/registry/spec.js +8 -0
- package/dist/repos/commands.js +1 -2
- package/dist/repos/github-connect-command.d.ts +10 -1
- package/dist/repos/github-connect-command.js +52 -11
- package/dist/repos/github-init.d.ts +9 -2
- package/dist/repos/github-init.js +18 -2
- package/dist/repos/init-repo.js +1 -2
- package/dist/run-pinned.d.ts +48 -0
- package/dist/run-pinned.js +127 -0
- package/dist/sdk-source.d.ts +64 -0
- package/dist/sdk-source.js +199 -0
- package/dist/secrets/commands.d.ts +1 -1
- package/dist/secrets/commands.js +29 -24
- package/dist/service-accounts/commands.d.ts +1 -1
- package/dist/service-accounts/commands.js +4 -5
- package/dist/staged-env.d.ts +14 -0
- package/dist/staged-env.js +73 -0
- package/dist/storage/commands.js +21 -22
- package/dist/templates/catalog.d.ts +4 -4
- package/dist/update-check.js +3 -3
- package/dist/version-support.d.ts +39 -0
- package/dist/version-support.js +71 -0
- package/package.json +11 -10
- package/release-summary.json +3 -1
package/dist/main.js
CHANGED
|
@@ -7,150 +7,58 @@
|
|
|
7
7
|
* seq-studio deploy deploy all primitives from sequence.app.yml
|
|
8
8
|
* seq-studio process <sub> manage Lattice processes
|
|
9
9
|
* seq-studio artifact <sub> manage Artifact Studio apps
|
|
10
|
-
* seq-studio
|
|
11
|
-
* seq-studio
|
|
12
|
-
* seq-studio
|
|
10
|
+
* seq-studio function <sub> manage Managed Functions
|
|
11
|
+
* seq-studio agent <sub> manage typed agent definitions
|
|
12
|
+
* seq-studio secret <sub> manage org-owned Managed Secrets
|
|
13
13
|
* seq-studio repos <sub> manage platform git-service repos
|
|
14
14
|
* seq-studio templates <sub> publish and synchronize Git-backed templates
|
|
15
15
|
* seq-studio pipeline <sub> discover, query, author and operate Data Pipelines
|
|
16
16
|
* seq-studio auth <sub> manage Git authentication
|
|
17
17
|
* seq-studio docs <sub> search and read the environment's developer docs
|
|
18
18
|
* seq-studio feedback submit submit agent feedback
|
|
19
|
-
* seq-studio service-
|
|
19
|
+
* seq-studio service-account <sub> provision runtime identities
|
|
20
20
|
* seq-studio access <sub> manage resource access on every primitive
|
|
21
|
-
* seq-studio
|
|
21
|
+
* seq-studio principal <sub> find users, groups and service accounts to grant
|
|
22
22
|
* seq-studio envs <sub> add/list environments
|
|
23
23
|
* seq-studio login authenticate interactively with Auth0
|
|
24
24
|
* seq-studio logout remove cached user tokens
|
|
25
25
|
* seq-studio doctor check token + env + writer gate
|
|
26
26
|
* seq-studio help show usage
|
|
27
27
|
*/
|
|
28
|
-
import {
|
|
29
|
-
import { renderCapabilities } from './command-contract.js';
|
|
28
|
+
import { SDK_ENV, takeSdkFlag } from './sdk-source.js';
|
|
30
29
|
import { staticHelp } from './command-help.js';
|
|
31
30
|
import { ignoredSandboxEnvNotice } from './env-flags.js';
|
|
32
31
|
import { guardMachineOutput, requestsMachineOutput } from './machine-output.js';
|
|
32
|
+
import { findCommand, findSubcommand, knowsSubcommand } from './registry/commands.js';
|
|
33
|
+
import { renderTopLevelHelp, suggest, topLevelNames } from './registry/help.js';
|
|
34
|
+
import { ExitCode } from './exit-codes.js';
|
|
35
|
+
import { hasHelpFlag } from './registry/runners.js';
|
|
33
36
|
import { sandboxUsageFooter } from './sandbox-auth.js';
|
|
34
|
-
|
|
35
|
-
// still auto-runs runCli() at module load; importing it here breaks doctor/process.
|
|
36
|
-
const TOP_LEVEL_USAGE = `usage:
|
|
37
|
-
seq-studio init <dir> [options] scaffold an app or use a published template
|
|
38
|
-
seq-studio add <kind> <name> [internal] add a primitive to the current app monorepo
|
|
39
|
-
seq-studio validate [--dir <path>] validate an app manifest offline
|
|
40
|
-
seq-studio deploy -e <env> [internal] deploy primitives from sequence.app.yml
|
|
41
|
-
seq-studio process <sub> [args] lint | plan | apply | runs | test | simulate | bundle | init
|
|
42
|
-
seq-studio artifact <sub> [args] init | whoami | link | env | status | list | show | validate | build | plan | deploy | dev | promote | pull | rollback
|
|
43
|
-
seq-studio functions <sub> [args] init | build | deploy | list | show | limits | invoke | logs | promote | rollback | delete
|
|
44
|
-
seq-studio storage <sub> [args] init | validate | apply | list | show | mkdir | upload | download | access | trash | restore | purge | operations | abort | delete
|
|
45
|
-
seq-studio agents <sub> [args] init | validate | bundle | plan | apply | list | show | voice (internal)
|
|
46
|
-
seq-studio secrets <sub> [args] create | set | list | attach | detach | apply
|
|
47
|
-
seq-studio repo init [--check] set up a GitHub checkout: workflows, Renovate, agent skill, branch rules
|
|
48
|
-
seq-studio repos <sub> [args] list | namespaces | show | identity | create | clone | pull | pulls | delete | ci
|
|
49
|
-
seq-studio templates <sub> [args] publish | sync | list
|
|
50
|
-
seq-studio pipeline <sub> [args] list | assets | search | describe | schema | sample | query | init | validate | repin-orm | codegen | plan | adopt | unbind | retire | deploy | status | migrate | promote | rollback | run-now
|
|
51
|
-
seq-studio auth <sub> [args] whoami | git-credential
|
|
52
|
-
seq-studio docs <sub> -e <env> search <query> | read <slug> | list (read before guessing commands)
|
|
53
|
-
seq-studio feedback submit --file report.json [-e <env>] [--json]
|
|
54
|
-
seq-studio orm <sub> [args] init | generate | validate | plan | apply | deployment-policy | execute | read | sql | diff | migrate-from-yaml | import
|
|
55
|
-
seq-studio service-accounts <sub> list | show | create (requires provisioning authority)
|
|
56
|
-
seq-studio access <sub> definitions | list | grant | revoke | resolve
|
|
57
|
-
seq-studio principals <sub> search | users search | groups list/show/create/members
|
|
58
|
-
seq-studio envs <sub> add | list environments
|
|
59
|
-
seq-studio login [--env <name>] authenticate in the browser
|
|
60
|
-
seq-studio logout [--env <name>] remove one realm's cached user tokens
|
|
61
|
-
seq-studio doctor [-e <env>] [--json] [--offline] diagnose config, auth, toolchain, and writer gate
|
|
62
|
-
seq-studio telemetry enable|disable|status control authenticated command metrics
|
|
63
|
-
seq-studio updater status | track latest|next control global pnpm auto-updates
|
|
64
|
-
seq-studio version print the installed version
|
|
65
|
-
seq-studio capabilities [--json] describe command availability and access
|
|
66
|
-
seq-studio help show this message
|
|
67
|
-
|
|
68
|
-
Authenticate with: seq-studio login
|
|
69
|
-
init, orm init, functions init, artifact init, and agents init take
|
|
70
|
-
--repo <ns>/<name> to scaffold straight into a git-service repo; commit and push from there.
|
|
71
|
-
In an agent sandbox, SEQ_STUDIO_BASE_URL + SEQ_STUDIO_TOKEN_FILE select the
|
|
72
|
-
deployment and token instead (no login; -e optional).
|
|
73
|
-
Where supported, --json writes only JSON to stdout (status lines go to stderr);
|
|
74
|
-
check exit status and pagination.
|
|
75
|
-
Built-in env: local. Add your organization's deployment with
|
|
76
|
-
\`seq-studio envs add <name> <url>\`; custom entries live in ~/.config/lattice/config.toml.
|
|
77
|
-
If this CLI cannot complete a documented step, read that environment's docs
|
|
78
|
-
before trying another tool. \`seq-studio envs list\` prints each environment URL.
|
|
79
|
-
Docs: seq-studio docs search <query> -e <env>, or <url>/docs. Feedback guide: <url>/docs/raw/seq-studio/feedback.md.
|
|
80
|
-
`;
|
|
81
|
-
const PROCESS_USAGE = `usage:
|
|
82
|
-
seq-studio process init <dir>
|
|
83
|
-
seq-studio process lint [--dir <path>] [--offline]
|
|
84
|
-
seq-studio process plan [--dir <path>] [-e <env>]
|
|
85
|
-
seq-studio process apply [--dir <path>] [-e <env>] [--only <id1,id2,...>] [--platform-managed]
|
|
86
|
-
seq-studio process apply --repo <namespace>/<name> [--ref <r>] -e <env> [--only <id1,id2,...>] [--platform-managed]
|
|
87
|
-
seq-studio process promote <processId> --version <v> [-e <env>]
|
|
88
|
-
seq-studio process pull <processId> [--version <v>] [-e <env>] [--out <dir>] [--no-children]
|
|
89
|
-
seq-studio process runs start|retry|list|show|cancel [args] -e <env> (see process runs --help)
|
|
90
|
-
seq-studio process test [-e <env>] [--offline]
|
|
91
|
-
seq-studio process simulate <process-id>
|
|
92
|
-
seq-studio process bundle build [-o file.json] [-e <env>] [--offline]
|
|
93
|
-
seq-studio process bundle pull <hash> [-o file.json] [-e <env>]
|
|
94
|
-
seq-studio process bundle archive <hash> [-e <env>]
|
|
95
|
-
seq-studio process bundle inspect <bundle.json>
|
|
96
|
-
seq-studio process bundle list [-e <env>] [--limit N] [--cursor <hash>]
|
|
97
|
-
seq-studio process bundle publish <hash|bundle.json> [-e <env>]
|
|
98
|
-
seq-studio process safety-baseline [--repo-root <dir>] [--write]
|
|
99
|
-
`;
|
|
100
|
-
// Validate command names before the offline help shortcut. Otherwise a typo such
|
|
101
|
-
// as `repos creat --help` appears successful without ever reaching the router.
|
|
102
|
-
const SUBCOMMANDS = {
|
|
103
|
-
process: new Set(['init', 'lint', 'plan', 'apply', 'promote', 'pull', 'runs', 'test', 'simulate', 'bundle', 'safety-baseline']),
|
|
104
|
-
artifact: new Set(['init', 'whoami', 'link', 'env', 'status', 'list', 'show', 'validate', 'build', 'plan', 'deploy', 'dev', 'promote', 'pull', 'rollback', 'login', 'logout']),
|
|
105
|
-
functions: new Set(['init', 'dev', 'build', 'register', 'deploy', 'list', 'show', 'limits', 'invoke', 'logs', 'promote', 'rollback', 'delete']),
|
|
106
|
-
storage: new Set(['init', 'validate', 'apply', 'list', 'show', 'mkdir', 'upload', 'import', 'uploads', 'reconcile', 'download', 'access', 'trash', 'restore', 'purge', 'operations', 'abort', 'delete']),
|
|
107
|
-
agents: new Set(['init', 'validate', 'bundle', 'plan', 'apply', 'list', 'show', 'voice']),
|
|
108
|
-
secrets: new Set(['create', 'set', 'list', 'attach', 'detach', 'apply', 'versions', 'set-default', 'pin']),
|
|
109
|
-
repos: new Set(['list', 'namespaces', 'show', 'identity', 'create', 'clone', 'attach-login', 'pull', 'pulls', 'delete', 'ci']),
|
|
110
|
-
templates: new Set(['publish', 'sync', 'list']),
|
|
111
|
-
'service-accounts': new Set(['list', 'show', 'create']),
|
|
112
|
-
access: new Set(['definitions', 'resolve', 'list', 'grant', 'revoke', 'roles']),
|
|
113
|
-
principals: new Set(['search', 'users', 'groups']),
|
|
114
|
-
auth: new Set(['whoami', 'git-credential', 'pat']),
|
|
115
|
-
feedback: new Set(['submit']),
|
|
116
|
-
docs: new Set(['search', 'read', 'list']),
|
|
117
|
-
orm: new Set(['init', 'generate', 'validate', 'plan', 'apply', 'history', 'deployment-policy', 'execute', 'namespaces', 'describe', 'read', 'sql', 'diff', 'migrate-from-yaml', 'import']),
|
|
118
|
-
pipeline: new Set(['list', 'assets', 'search', 'describe', 'schema', 'sample', 'query', 'init', 'validate', 'repin-orm', 'codegen', 'adopt', 'unbind', 'retire', 'plan', 'deploy', 'status', 'migrate', 'promote', 'rollback', 'run-now']),
|
|
119
|
-
envs: new Set(['add', 'list']),
|
|
120
|
-
updater: new Set(['status', 'track']),
|
|
121
|
-
};
|
|
122
|
-
const TELEMETRY_EXCLUDED = new Set(['validate', 'telemetry', 'updater', 'version', 'capabilities', 'help', 'login', 'logout', 'envs']);
|
|
123
|
-
const TELEMETRY_TOP_LEVEL = new Set(['init', 'add', 'deploy', 'doctor']);
|
|
124
|
-
const TELEMETRY_NESTED = {
|
|
125
|
-
'repos pulls': new Set(['list', 'show', 'create', 'diff', 'merge', 'edit', 'close', 'comment', 'comments', 'resolve', 'unresolve', 'review', 'reviews', 'checks']),
|
|
126
|
-
'process runs': new Set(['start', 'retry', 'list', 'show', 'cancel']),
|
|
127
|
-
'process bundle': new Set(['build', 'pull', 'archive', 'inspect', 'list', 'publish']),
|
|
128
|
-
};
|
|
129
|
-
/** Only command words from the router; never operands, flags, paths, or arguments. */
|
|
37
|
+
/** Only command words from the router; never operands, flags, paths, or arguments. Always the current spelling. */
|
|
130
38
|
export function commandTelemetryName(argv) {
|
|
131
39
|
if (argv.some((arg) => arg === '--help' || arg === '-h'))
|
|
132
40
|
return null;
|
|
133
41
|
const [namespace, sub] = argv;
|
|
134
|
-
|
|
42
|
+
const command = namespace ? findCommand(namespace) : undefined;
|
|
43
|
+
if (!command || command.telemetry === 'never' || command.aliases?.includes(namespace ?? ''))
|
|
135
44
|
return null;
|
|
136
|
-
if (
|
|
45
|
+
if (command.name === 'doctor' && (argv.includes('--offline') || argv.includes('--offline=true')))
|
|
137
46
|
return null;
|
|
138
|
-
if (
|
|
47
|
+
if (command.name === 'auth' && sub === 'git-credential')
|
|
139
48
|
return null;
|
|
140
|
-
if (
|
|
141
|
-
return
|
|
142
|
-
|
|
49
|
+
if (command.telemetry === 'command')
|
|
50
|
+
return command.name;
|
|
51
|
+
const subcommand = sub && command.checkSubcommands ? findSubcommand(command, sub) : undefined;
|
|
52
|
+
if (!subcommand)
|
|
143
53
|
return null;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return command;
|
|
148
|
-
return argv[2] && nested.has(argv[2]) ? `${command} ${argv[2]}` : null;
|
|
54
|
+
if (!subcommand.nested)
|
|
55
|
+
return `${command.name} ${subcommand.name}`;
|
|
56
|
+
return argv[2] && subcommand.nested.includes(argv[2]) ? `${command.name} ${subcommand.name} ${argv[2]}` : null;
|
|
149
57
|
}
|
|
150
58
|
export async function run(argv = process.argv.slice(2)) {
|
|
151
59
|
if (!requestsMachineOutput(argv))
|
|
152
60
|
return dispatch(argv);
|
|
153
|
-
const restore = guardMachineOutput();
|
|
61
|
+
const restore = guardMachineOutput({ schema: schemaName(argv), argv });
|
|
154
62
|
try {
|
|
155
63
|
return await dispatch(argv);
|
|
156
64
|
}
|
|
@@ -158,27 +66,49 @@ export async function run(argv = process.argv.slice(2)) {
|
|
|
158
66
|
restore();
|
|
159
67
|
}
|
|
160
68
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
if (
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Flags any command takes, removed before routing and handed on through the environment: `--sdk` (read by
|
|
71
|
+
* sdk-source.ts wherever a command loads an SDK) and `--break-glass` (sent on every Atlas request, cli-attribution.ts).
|
|
72
|
+
*/
|
|
73
|
+
function takeGlobalFlags(rawArgv) {
|
|
74
|
+
const { argv: withoutSdk, sdk } = takeSdkFlag(rawArgv);
|
|
75
|
+
if (sdk instanceof Error)
|
|
76
|
+
return sdk;
|
|
77
|
+
const { argv, breakGlass } = takeBreakGlass(withoutSdk);
|
|
78
|
+
if (breakGlass instanceof Error)
|
|
79
|
+
return breakGlass;
|
|
80
|
+
if (sdk !== undefined)
|
|
81
|
+
process.env[SDK_ENV] = sdk;
|
|
82
|
+
if (breakGlass !== undefined)
|
|
83
|
+
process.env.SEQ_STUDIO_BREAK_GLASS = breakGlass;
|
|
84
|
+
return argv;
|
|
85
|
+
}
|
|
86
|
+
async function dispatch(rawArgv) {
|
|
87
|
+
const argv = takeGlobalFlags(rawArgv);
|
|
88
|
+
if (argv instanceof Error) {
|
|
89
|
+
console.error(`error ${argv.message}`);
|
|
90
|
+
return ExitCode.Usage;
|
|
174
91
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
92
|
+
const [namespace, sub, ...rest] = argv;
|
|
93
|
+
const early = answeredBeforeRouting({ namespace, sub, rest });
|
|
94
|
+
if (early !== null)
|
|
95
|
+
return early;
|
|
96
|
+
if (!namespace)
|
|
178
97
|
return 1;
|
|
179
|
-
|
|
98
|
+
const command = findCommand(namespace);
|
|
99
|
+
if (!command)
|
|
100
|
+
return unknownCommand(namespace);
|
|
101
|
+
// Reject an unknown subcommand before offline help or the command's router runs.
|
|
102
|
+
// Otherwise a typo such as `repos creat --help` appears successful.
|
|
103
|
+
if (sub && !sub.startsWith('-') && sub !== 'help' && knowsSubcommand(command, sub) === false) {
|
|
104
|
+
return unknownSubcommand(command, sub);
|
|
105
|
+
}
|
|
106
|
+
const subcommand = sub && command.checkSubcommands ? findSubcommand(command, sub) : undefined;
|
|
107
|
+
noteRenamed({ command, namespace, subcommand, sub });
|
|
108
|
+
// Implementations still read their original words; the registry maps current spellings to them.
|
|
109
|
+
const implementationSub = subcommand?.implementation ?? sub;
|
|
180
110
|
if (hasHelpFlag(sub, rest)) {
|
|
181
|
-
const help = staticHelp({ namespace, sub });
|
|
111
|
+
const help = staticHelp({ namespace: command.name, sub: implementationSub });
|
|
182
112
|
if (help) {
|
|
183
113
|
console.log(help);
|
|
184
114
|
return 0;
|
|
@@ -187,241 +117,137 @@ async function dispatch(argv) {
|
|
|
187
117
|
const ignoredEnv = ignoredSandboxEnvNotice([sub, ...rest].filter((a) => Boolean(a)));
|
|
188
118
|
if (ignoredEnv)
|
|
189
119
|
console.error(ignoredEnv);
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
args: parseArgs(rest),
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
case 'deploy': {
|
|
203
|
-
const { runAppDeployCommand } = await import('./app/commands.js');
|
|
204
|
-
return runAppDeployCommand(parseArgs([sub, ...rest].filter((a) => Boolean(a))));
|
|
205
|
-
}
|
|
206
|
-
case 'validate': {
|
|
207
|
-
const { runAppValidateCommand } = await import('./app/commands.js');
|
|
208
|
-
return runAppValidateCommand(parseArgs([sub, ...rest].filter((a) => Boolean(a))));
|
|
209
|
-
}
|
|
210
|
-
case 'process':
|
|
211
|
-
return runProcessNamespace(sub, rest);
|
|
212
|
-
case 'artifact': {
|
|
213
|
-
const { runArtifactCommand } = await import('./artifact/delegate.js');
|
|
214
|
-
if (sub === 'init')
|
|
215
|
-
return (await import('./repos/primitive-declaration.js')).runStandaloneInit({ kind: 'artifact', argv: rest, defaultDir: '.', run: () => runArtifactCommand(sub, rest) });
|
|
216
|
-
return runArtifactCommand(sub, rest);
|
|
217
|
-
}
|
|
218
|
-
case 'functions': {
|
|
219
|
-
const { runFunctionsCommand } = await import('./functions/commands.js');
|
|
220
|
-
if (sub === 'init')
|
|
221
|
-
return (await import('./repos/primitive-declaration.js')).runStandaloneInit({ kind: 'function', argv: rest, run: () => runFunctionsCommand(sub, parseArgs(rest)) });
|
|
222
|
-
return runFunctionsCommand(sub, parseArgs(rest));
|
|
223
|
-
}
|
|
224
|
-
case 'storage': {
|
|
225
|
-
const { runStorageCommand } = await import('./storage/commands.js');
|
|
226
|
-
return runStorageCommand(sub, parseArgs(rest));
|
|
227
|
-
}
|
|
228
|
-
case 'agents': {
|
|
229
|
-
const { runAgentsCommand } = await import('./agents/commands.js');
|
|
230
|
-
return runAgentsCommand(sub, parseArgs(rest));
|
|
231
|
-
}
|
|
232
|
-
case 'secrets': {
|
|
233
|
-
const { runSecretsCommand } = await import('./secrets/commands.js');
|
|
234
|
-
return runSecretsCommand(sub, parseArgs(rest));
|
|
235
|
-
}
|
|
236
|
-
case 'repo': {
|
|
237
|
-
if (sub === 'connect' || sub === 'disconnect' || sub === 'status' || sub === 'bind') {
|
|
238
|
-
const { runRepoConnectCommand } = await import('./repos/github-connect-command.js');
|
|
239
|
-
return runRepoConnectCommand(sub, parseArgs(rest));
|
|
240
|
-
}
|
|
241
|
-
if (sub !== 'init') {
|
|
242
|
-
console.error('usage: seq-studio repo init|connect|bind|disconnect|status (see seq-studio repo <command> --help)');
|
|
243
|
-
return 2;
|
|
244
|
-
}
|
|
245
|
-
const { runRepoInitCommand } = await import('./repos/github-init-command.js');
|
|
246
|
-
return runRepoInitCommand(parseArgs(rest));
|
|
247
|
-
}
|
|
248
|
-
case 'repos': {
|
|
249
|
-
const { runReposCommand } = await import('./repos/commands.js');
|
|
250
|
-
return runReposCommand(sub, parseArgs(rest));
|
|
251
|
-
}
|
|
252
|
-
case 'templates': {
|
|
253
|
-
const { runTemplatesCommand } = await import('./templates/commands.js');
|
|
254
|
-
return runTemplatesCommand(sub, parseArgs(rest));
|
|
255
|
-
}
|
|
256
|
-
case 'service-accounts': {
|
|
257
|
-
const { runServiceAccountsCommand } = await import('./service-accounts/commands.js');
|
|
258
|
-
return runServiceAccountsCommand(sub, parseArgs(rest));
|
|
259
|
-
}
|
|
260
|
-
case 'access': {
|
|
261
|
-
const { runAccessCommand } = await import('./access/commands.js');
|
|
262
|
-
return runAccessCommand(sub, parseArgs(rest));
|
|
263
|
-
}
|
|
264
|
-
case 'principals': {
|
|
265
|
-
const { runPrincipalsCommand } = await import('./principals/commands.js');
|
|
266
|
-
return runPrincipalsCommand(sub, parseArgs(rest));
|
|
267
|
-
}
|
|
268
|
-
case 'feedback':
|
|
269
|
-
return (await import('./feedback/commands.js')).runFeedbackCommand(sub, parseArgs(rest));
|
|
270
|
-
case 'docs':
|
|
271
|
-
return (await import('./docs/commands.js')).runDocsCommand(sub, parseArgs(rest));
|
|
272
|
-
case 'auth': {
|
|
273
|
-
const { runAuthCommand } = await import('./auth-cmds/commands.js');
|
|
274
|
-
return runAuthCommand(sub, parseArgs(rest));
|
|
275
|
-
}
|
|
276
|
-
case 'orm': {
|
|
277
|
-
const { runOrmCommand } = await import('./orm/delegate.js');
|
|
278
|
-
if (sub === 'init')
|
|
279
|
-
return (await import('./repos/primitive-declaration.js')).runStandaloneInit({ kind: 'orm', argv: rest, run: () => runOrmCommand(sub, rest) });
|
|
280
|
-
return runOrmCommand(sub, rest);
|
|
281
|
-
}
|
|
282
|
-
case 'pipeline': {
|
|
283
|
-
// Lazy import keeps doctor/process from pulling in @sequenceholdings/pipeline-spec
|
|
284
|
-
// (an optional peer, same posture as @sequenceholdings/orm).
|
|
285
|
-
const { runPipelineCommand } = await import('./pipeline/commands.js');
|
|
286
|
-
return runPipelineCommand(sub, parseArgs(rest));
|
|
287
|
-
}
|
|
288
|
-
case 'envs': {
|
|
289
|
-
const { runEnvsCommand } = await import('./envs/commands.js');
|
|
290
|
-
return runEnvsCommand(sub, rest);
|
|
291
|
-
}
|
|
292
|
-
case 'login':
|
|
293
|
-
case 'logout':
|
|
294
|
-
return runSessionCommand({ args: [sub, ...rest].filter((a) => Boolean(a)), command: namespace });
|
|
295
|
-
case 'version':
|
|
296
|
-
case '--version':
|
|
297
|
-
case '-v': {
|
|
298
|
-
const { currentVersion } = await import('./update-check.js');
|
|
299
|
-
console.log(currentVersion());
|
|
300
|
-
return 0;
|
|
301
|
-
}
|
|
302
|
-
case 'updater':
|
|
303
|
-
return (await import('./pnpm-auto-update.js')).updaterCommand([sub, ...rest].filter((arg) => Boolean(arg)));
|
|
304
|
-
case 'capabilities':
|
|
305
|
-
return runCapabilities([sub, ...rest].filter((value) => Boolean(value)));
|
|
306
|
-
case 'doctor':
|
|
307
|
-
return (await import('./process/commands.js')).doctorCommand(parseArgs([sub, ...rest].filter(Boolean)));
|
|
308
|
-
case 'telemetry': {
|
|
309
|
-
const { setTelemetryEnabled, telemetryEnabled } = await import('./command-telemetry.js');
|
|
310
|
-
if (sub === '--help' || sub === '-h' || sub === 'help') {
|
|
311
|
-
console.log('usage: seq-studio telemetry enable|disable|status');
|
|
312
|
-
return 0;
|
|
313
|
-
}
|
|
314
|
-
if (rest.length > 0) {
|
|
315
|
-
console.error('usage: seq-studio telemetry enable|disable|status');
|
|
316
|
-
return 1;
|
|
317
|
-
}
|
|
318
|
-
if (sub === 'enable' || sub === 'disable')
|
|
319
|
-
await setTelemetryEnabled(sub === 'enable');
|
|
320
|
-
else if (sub !== 'status') {
|
|
321
|
-
console.error('usage: seq-studio telemetry enable|disable|status');
|
|
322
|
-
return 1;
|
|
323
|
-
}
|
|
324
|
-
console.log(`Command telemetry: ${await telemetryEnabled() ? 'on' : 'off'}`);
|
|
325
|
-
return 0;
|
|
326
|
-
}
|
|
327
|
-
default:
|
|
328
|
-
console.error(`unknown command: ${namespace}`);
|
|
329
|
-
console.error(TOP_LEVEL_USAGE);
|
|
330
|
-
return 1;
|
|
331
|
-
}
|
|
120
|
+
const envError = await checkStagedEnv([sub, ...rest]);
|
|
121
|
+
if (envError !== null)
|
|
122
|
+
return envError;
|
|
123
|
+
if (!PIN_EXEMPT.has(command.name)) {
|
|
124
|
+
const pinnedExit = await honorPin({ argv, offline: command.access === 'offline' || argv.includes('--offline') });
|
|
125
|
+
if (pinnedExit !== null)
|
|
126
|
+
return pinnedExit;
|
|
127
|
+
}
|
|
128
|
+
return command.run({ sub: implementationSub, rest });
|
|
332
129
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
const
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
if (args[0] === 'help' || args[0] === '--help' || args[0] === '-h') {
|
|
346
|
-
console.log(usage);
|
|
347
|
-
return 0;
|
|
348
|
-
}
|
|
349
|
-
let envName;
|
|
350
|
-
if (args.length > 0) {
|
|
351
|
-
const flags = parseArgs(args).flags;
|
|
352
|
-
envName =
|
|
353
|
-
(typeof flags.env === 'string' ? flags.env : undefined) ??
|
|
354
|
-
(typeof flags.e === 'string' ? flags.e : undefined);
|
|
355
|
-
if (!envName) {
|
|
356
|
-
console.error(usage);
|
|
357
|
-
return 1;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
const auth = await import('./login.js');
|
|
361
|
-
if (command === 'logout') {
|
|
362
|
-
await auth.logout(envName);
|
|
363
|
-
}
|
|
364
|
-
else {
|
|
365
|
-
// An OpCo env name (registered via `seq-studio envs add` or `seqapi env add`)
|
|
366
|
-
// logs into that environment's Auth0 realm; omitted or a built-in name uses Sequence.
|
|
367
|
-
await auth.login(envName);
|
|
368
|
-
}
|
|
369
|
-
return 0;
|
|
130
|
+
/** Run the repository's pinned CLI when opted in (run-pinned.ts); otherwise note a mismatch. Null: run it here. */
|
|
131
|
+
async function honorPin({ argv, offline }) {
|
|
132
|
+
const [{ pinNote }, { repositoryCliPin }, { runPinned, wantsPinnedRun }, { currentVersion }] = await Promise.all([
|
|
133
|
+
import('./version-support.js'), import('./orgs.js'), import('./run-pinned.js'), import('./update-check.js')
|
|
134
|
+
]);
|
|
135
|
+
const pin = await repositoryCliPin();
|
|
136
|
+
if (wantsPinnedRun())
|
|
137
|
+
return runPinned({ pin, installed: currentVersion(), argv, offline });
|
|
138
|
+
const note = pinNote({ pin });
|
|
139
|
+
if (note)
|
|
140
|
+
console.error(note);
|
|
141
|
+
return null;
|
|
370
142
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
143
|
+
/** Top-level help and flag checks that never reach a command's router. */
|
|
144
|
+
function answeredBeforeRouting({ namespace, sub, rest }) {
|
|
145
|
+
if (!namespace || namespace === 'help' || namespace === '--help' || namespace === '-h') {
|
|
146
|
+
console.log(`${renderTopLevelHelp()}${sandboxUsageFooter()}`);
|
|
147
|
+
return namespace ? 0 : 1;
|
|
375
148
|
}
|
|
376
|
-
if (hasHelpFlag(sub, rest)) {
|
|
377
|
-
console.log(
|
|
149
|
+
if (namespace === 'capabilities' && hasHelpFlag(sub, rest)) {
|
|
150
|
+
console.log('usage: seq-studio capabilities [--json]');
|
|
378
151
|
return 0;
|
|
379
152
|
}
|
|
380
|
-
if (
|
|
381
|
-
console.error(
|
|
153
|
+
if (namespace === 'artifact' && [sub, ...rest].some((arg) => arg === '--token' || arg?.startsWith('--token='))) {
|
|
154
|
+
console.error('Artifact Studio does not accept --token bearer injection. Authenticate with seq-studio login.');
|
|
382
155
|
return 1;
|
|
383
156
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
/** Commands that work the same on any version, or that move the pin itself. */
|
|
160
|
+
const PIN_EXEMPT = new Set(['help', 'version', 'capabilities', 'telemetry', 'updater', 'upgrade', 'login', 'logout']);
|
|
161
|
+
function noteRenamed({ command, namespace, subcommand, sub }) {
|
|
162
|
+
const nounRenamed = command.renamedFrom?.includes(namespace) ?? false;
|
|
163
|
+
const verbRenamed = subcommand !== undefined && sub !== undefined && sub !== subcommand.name;
|
|
164
|
+
if (!nounRenamed && !verbRenamed)
|
|
165
|
+
return;
|
|
166
|
+
// Only command words: a flag or operand in the second position is not part of the name.
|
|
167
|
+
const before = [namespace, subcommand ? sub : undefined].filter(Boolean).join(' ');
|
|
168
|
+
const after = [command.name, subcommand?.name].filter(Boolean).join(' ');
|
|
169
|
+
console.error(`note: seq-studio ${before} is now seq-studio ${after}`);
|
|
170
|
+
}
|
|
171
|
+
function unknownCommand(word) {
|
|
172
|
+
console.error(`error unknown command: ${word}`);
|
|
173
|
+
const match = suggest(word, topLevelNames());
|
|
174
|
+
if (match)
|
|
175
|
+
console.error(` did you mean: seq-studio ${match}`);
|
|
176
|
+
console.error(' see: seq-studio help');
|
|
177
|
+
return ExitCode.Usage;
|
|
178
|
+
}
|
|
179
|
+
function unknownSubcommand(command, sub) {
|
|
180
|
+
console.error(`error unknown ${command.name} command: ${sub}`);
|
|
181
|
+
// A typo of an old spelling (`describ`) suggests its current name (`show`).
|
|
182
|
+
const spellings = new Map(command.subcommands.filter(({ listed }) => listed !== false)
|
|
183
|
+
.flatMap(({ name, renamedFrom }) => [name, ...(renamedFrom ?? [])].map((word) => [word, name])));
|
|
184
|
+
const match = suggest(sub, [...spellings.keys()]);
|
|
185
|
+
if (match)
|
|
186
|
+
console.error(` did you mean: seq-studio ${command.name} ${spellings.get(match)}`);
|
|
187
|
+
console.error(` see: seq-studio ${command.name} --help`);
|
|
188
|
+
return ExitCode.Usage;
|
|
189
|
+
}
|
|
190
|
+
/** The command words that name a JSON document's schema, e.g. `repo status`. Always the current spelling. */
|
|
191
|
+
export function schemaName(argv) {
|
|
192
|
+
const [namespace, sub, third] = argv;
|
|
193
|
+
const command = namespace ? findCommand(namespace) : undefined;
|
|
194
|
+
if (!command)
|
|
195
|
+
return undefined;
|
|
196
|
+
const subcommand = sub ? findSubcommand(command, sub) : undefined;
|
|
197
|
+
if (!subcommand)
|
|
198
|
+
return command.name;
|
|
199
|
+
return third && subcommand.nested?.includes(third) ? `${command.name} ${subcommand.name} ${third}` : `${command.name} ${subcommand.name}`;
|
|
200
|
+
}
|
|
201
|
+
function requestedEnv(args) {
|
|
202
|
+
for (let index = 0; index < args.length; index++) {
|
|
203
|
+
const arg = args[index];
|
|
204
|
+
if (arg === '--')
|
|
205
|
+
return undefined;
|
|
206
|
+
if (arg === '-e' || arg === '--env')
|
|
207
|
+
return args[index + 1];
|
|
208
|
+
if (arg?.startsWith('--env='))
|
|
209
|
+
return arg.slice('--env='.length);
|
|
210
|
+
}
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Resolve an `-e <org>/<stage>` or bare-stage value before the command runs, so
|
|
215
|
+
* its usage errors exit 2 the same way for every command, delegated ones included.
|
|
216
|
+
* Other values are left to the command, unchanged.
|
|
217
|
+
*/
|
|
218
|
+
async function checkStagedEnv(args) {
|
|
219
|
+
const requested = requestedEnv(args);
|
|
220
|
+
if (!requested || !(requested.includes('/') || requested === 'staging' || requested === 'prod'))
|
|
221
|
+
return null;
|
|
222
|
+
if (requested.startsWith('preview:') || requested.startsWith('local:'))
|
|
223
|
+
return null;
|
|
224
|
+
const [{ resolveConfiguredEnv }, { UsageError }, { printCliError }] = await Promise.all([
|
|
225
|
+
import('./config.js'), import('./exit-codes.js'), import('./cli-errors.js'),
|
|
226
|
+
]);
|
|
227
|
+
try {
|
|
228
|
+
await resolveConfiguredEnv({ requested });
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
// Anything but a usage error is the command's to report, as before.
|
|
233
|
+
return error instanceof UsageError ? printCliError(error) : null;
|
|
423
234
|
}
|
|
424
235
|
}
|
|
425
|
-
|
|
426
|
-
|
|
236
|
+
/**
|
|
237
|
+
* `--break-glass "<reason>"` on any command: removed from argv so no command's own parser sees it. An empty or
|
|
238
|
+
* missing reason is a usage error.
|
|
239
|
+
*/
|
|
240
|
+
export function takeBreakGlass(argv) {
|
|
241
|
+
const index = argv.findIndex((arg) => arg === '--break-glass' || arg.startsWith('--break-glass='));
|
|
242
|
+
if (index < 0)
|
|
243
|
+
return { argv };
|
|
244
|
+
const arg = argv[index];
|
|
245
|
+
const inline = arg.startsWith('--break-glass=') ? arg.slice('--break-glass='.length) : undefined;
|
|
246
|
+
const value = inline ?? argv[index + 1];
|
|
247
|
+
const consumed = inline === undefined && value !== undefined && !value.startsWith('-') ? 2 : 1;
|
|
248
|
+
const reason = consumed === 2 || inline !== undefined ? value?.trim() : undefined;
|
|
249
|
+
const rest = [...argv.slice(0, index), ...argv.slice(index + consumed)];
|
|
250
|
+
if (!reason)
|
|
251
|
+
return { argv: rest, breakGlass: new Error('--break-glass needs a reason: --break-glass "<why CI cannot deploy this>"') };
|
|
252
|
+
return { argv: rest, breakGlass: reason };
|
|
427
253
|
}
|