@sequenceholdings/studio-cli 0.2.2 → 0.4.1
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 +616 -78
- package/dist/access/commands.d.ts +3 -0
- package/dist/access/commands.js +91 -0
- package/dist/agents/commands.d.ts +1 -1
- package/dist/agents/commands.js +5 -0
- package/dist/agents/scaffold.js +5 -7
- package/dist/agents/voice-authoring.d.ts +5 -0
- package/dist/agents/voice-authoring.js +75 -0
- package/dist/agents/voice-publication.d.ts +5 -0
- package/dist/agents/voice-publication.js +63 -0
- package/dist/agents/voice-shared.d.ts +20 -0
- package/dist/agents/voice-shared.js +112 -0
- package/dist/agents/voice.d.ts +3 -0
- package/dist/agents/voice.js +57 -0
- package/dist/app/adapters.d.ts +6 -0
- package/dist/app/adapters.js +17 -2
- package/dist/app/agent-refs.d.ts +16 -0
- package/dist/app/agent-refs.js +36 -0
- package/dist/app/application-registration.d.ts +36 -6
- package/dist/app/application-registration.js +60 -15
- package/dist/app/commands.js +19 -2
- package/dist/app/deploy.d.ts +3 -0
- package/dist/app/deploy.js +22 -6
- package/dist/app/env-bindings.d.ts +21 -0
- package/dist/app/env-bindings.js +184 -0
- package/dist/app/manifest-validation.js +8 -0
- package/dist/app/manifest.d.ts +32 -14
- package/dist/app/manifest.js +16 -6
- package/dist/app/primitive-scaffold.d.ts +4 -1
- package/dist/app/primitive-scaffold.js +4 -4
- package/dist/app/readme.js +1 -0
- package/dist/app/scaffold-files.js +1 -1
- package/dist/app/scaffold.d.ts +6 -4
- package/dist/app/scaffold.js +7 -4
- package/dist/app/workspace-scaffold.js +12 -7
- package/dist/argv.d.ts +7 -0
- package/dist/argv.js +56 -0
- package/dist/artifact/delegate.js +8 -4
- package/dist/atlas-client.d.ts +6 -0
- package/dist/atlas-client.js +39 -2
- package/dist/auth-cmds/commands.d.ts +1 -1
- package/dist/auth-cmds/commands.js +16 -0
- package/dist/auth.d.ts +32 -0
- package/dist/auth.js +170 -33
- package/dist/bin.js +23 -4
- package/dist/command-contract.d.ts +137 -0
- package/dist/command-contract.js +43 -0
- package/dist/command-help.d.ts +8 -0
- package/dist/command-help.js +71 -0
- package/dist/command-input.d.ts +15 -0
- package/dist/command-input.js +33 -0
- package/dist/functions/commands.d.ts +2 -1
- package/dist/functions/commands.js +78 -33
- package/dist/functions/deploy-preflight.d.ts +21 -0
- package/dist/functions/deploy-preflight.js +58 -0
- package/dist/functions/egress-postgres.d.ts +7 -0
- package/dist/functions/egress-postgres.js +36 -0
- package/dist/functions/manifest.d.ts +15 -1
- package/dist/functions/manifest.js +49 -12
- package/dist/functions/secret-reconcile.d.ts +3 -3
- package/dist/functions/secret-reconcile.js +5 -7
- package/dist/functions/source-selection.js +4 -1
- package/dist/main.d.ts +2 -0
- package/dist/main.js +75 -25
- package/dist/manifest-roles-notice.d.ts +33 -0
- package/dist/manifest-roles-notice.js +75 -0
- package/dist/orm/delegate.d.ts +16 -0
- package/dist/orm/delegate.js +142 -7
- package/dist/pipeline/clone-deploy.d.ts +37 -0
- package/dist/pipeline/clone-deploy.js +125 -0
- package/dist/pipeline/codegen.js +6 -2
- package/dist/pipeline/commands.js +21 -5
- package/dist/pipeline/lifecycle.d.ts +1 -0
- package/dist/pipeline/lifecycle.js +95 -44
- package/dist/pipeline/repin-orm.js +6 -2
- package/dist/pipeline/stage-secrets.d.ts +4 -1
- package/dist/pipeline/stage-secrets.js +7 -3
- package/dist/process/build.js +17 -0
- package/dist/process/codegen.js +16 -0
- package/dist/process/commands.d.ts +15 -7
- package/dist/process/commands.js +294 -98
- package/dist/process/lint.js +35 -0
- package/dist/process/plan-diff.js +9 -0
- package/dist/process/simulate.js +8 -0
- package/dist/release-age.d.ts +12 -0
- package/dist/release-age.js +24 -0
- package/dist/repos/commands.d.ts +10 -1
- package/dist/repos/commands.js +42 -8
- package/dist/repos/pulls.d.ts +3 -0
- package/dist/repos/pulls.js +131 -0
- package/dist/scaffold-guidance.d.ts +4 -0
- package/dist/scaffold-guidance.js +15 -0
- package/dist/secrets/commands.d.ts +1 -1
- package/dist/secrets/commands.js +97 -16
- package/dist/service-accounts/commands.d.ts +3 -0
- package/dist/service-accounts/commands.js +50 -0
- package/dist/storage/commands.js +23 -1
- package/dist/storage/gcs-download.d.ts +13 -0
- package/dist/storage/gcs-download.js +41 -0
- package/dist/storage/import-cycle.d.ts +41 -0
- package/dist/storage/import-cycle.js +123 -0
- package/dist/storage/import-files.d.ts +30 -0
- package/dist/storage/import-files.js +133 -0
- package/dist/storage/import-gcloud.d.ts +12 -0
- package/dist/storage/import-gcloud.js +54 -0
- package/dist/storage/import-identity.d.ts +12 -0
- package/dist/storage/import-identity.js +15 -0
- package/dist/storage/import-plan.d.ts +120 -0
- package/dist/storage/import-plan.js +189 -0
- package/dist/storage/import-preflight.d.ts +36 -0
- package/dist/storage/import-preflight.js +62 -0
- package/dist/storage/import-progress-map.d.ts +5 -0
- package/dist/storage/import-progress-map.js +22 -0
- package/dist/storage/import-recover.d.ts +97 -0
- package/dist/storage/import-recover.js +186 -0
- package/dist/storage/import-run.d.ts +14 -0
- package/dist/storage/import-run.js +140 -0
- package/dist/templates/guidance/AGENTS.md +10 -0
- package/dist/templates/guidance/CLAUDE.md +1 -0
- package/dist/templates/process/package.json +2 -2
- package/dist/templates/process/pnpm-workspace.yaml +7 -4
- package/dist/validation-detail.d.ts +2 -0
- package/dist/validation-detail.js +20 -0
- package/package.json +9 -9
- package/templates/guidance/AGENTS.md +10 -0
- package/templates/guidance/CLAUDE.md +1 -0
- package/templates/process/package.json +2 -2
- package/templates/process/pnpm-workspace.yaml +7 -4
package/dist/repos/commands.d.ts
CHANGED
|
@@ -23,6 +23,15 @@ export declare function smartHttpCloneDepth({ ref, full, }: {
|
|
|
23
23
|
ref?: string;
|
|
24
24
|
full: boolean;
|
|
25
25
|
}): number | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* buildContext for repos commands: rejects a valueless -e/--env (which would
|
|
28
|
+
* silently fall back to the default environment — dangerous with `delete
|
|
29
|
+
* --yes`) and threads the Cloudflare preview WAF bypass header to
|
|
30
|
+
* artifact-studio's HTTP client, which resolveRepo/materializeRepo use
|
|
31
|
+
* (mirrors applyPreviewAccessHeader in ../artifact/delegate.ts — studio-cli's
|
|
32
|
+
* own atlas-client reads PREVIEW_ACCESS_HEADER directly).
|
|
33
|
+
*/
|
|
34
|
+
export declare function reposContext(args: ParsedArgs): Promise<CommandContext>;
|
|
26
35
|
/** Smart-HTTP clone base (aligned with PLA-83: `…/repos/<id>/git`). */
|
|
27
36
|
export declare function cloneUrl(ctx: CommandContext, repoId: string): string;
|
|
28
37
|
/**
|
|
@@ -106,6 +115,6 @@ export declare function reposCiRequireCommand(args: ParsedArgs): Promise<number>
|
|
|
106
115
|
export declare function reposCiImportCommand(args: ParsedArgs): Promise<number>;
|
|
107
116
|
export declare function reposCiCommand(args: ParsedArgs): Promise<number>;
|
|
108
117
|
export declare function reposDeleteCommand(args: ParsedArgs): Promise<number>;
|
|
109
|
-
export declare const REPOS_USAGE = "usage:\n seq-studio repos list -e <env> [--namespace <slug>] [--mine] repos visible on the environment\n seq-studio repos namespaces [create <slug>] -e <env> list or create namespaces\n seq-studio repos show <ns>/<name> -e <env> repo detail (branches, clone URL)\n seq-studio repos create <ns>/<name> -e <env> [--default-branch b] [--git-backend walgit]\n create a repo seeded with a README; --git-backend\n walgit creates it empty (for pushing existing\n history); needs namespace write\n seq-studio repos clone <ns>/<name> -e <env> [--ref r] [--output dir] [--force] [--full]\n seq-studio repos clone --url <https://\u2026/repos/<id>/git> -e <env> [--ref r] [--output dir] [--full]\n seq-studio repos clone --id <uuid> -e <env> [--ref r] [--output dir] [--full]\n smart-HTTP when ATLAS_GIT_PAT is set;\n otherwise JSON materialize (<ns>/<name>)\n seq-studio repos pull <ns>/<name> -e <env> [--ref r] [--out dir] [--force]\n materialize the tree at a ref (JSON API)\n seq-studio repos delete <ns>/<name> -e <env> [--yes] delete a repo (confirm prompt)\n seq-studio repos ci show <ns>/<name> -e <env> [--ref r] preview discovered CI checks\n seq-studio repos ci require <ns>/<name> --check <name> -e <env> reserved (refuses write until sandboxed runner)\n seq-studio repos ci import <ns>/<name> -e <env> [--ref r] reserved (refuses write until sandboxed runner)\n\n Flags: -e/--env <env> (required; see: seq-studio envs list)\n\n clone prefers real git clone (PAT via askpass \u2014 never written into the remote\n URL).
|
|
118
|
+
export declare const REPOS_USAGE = "usage:\n seq-studio repos list -e <env> [--namespace <slug>] [--mine] repos visible on the environment\n seq-studio repos namespaces [create <slug>] -e <env> list or create namespaces\n seq-studio repos show <ns>/<name> -e <env> repo detail (branches, clone URL)\n seq-studio repos create <ns>/<name> -e <env> [--default-branch b] [--git-backend walgit]\n create a repo seeded with a README; --git-backend\n walgit creates it empty (for pushing existing\n history); needs namespace write\n seq-studio repos clone <ns>/<name> -e <env> [--ref r] [--output dir] [--force] [--full] [--transport auto|git|json]\n seq-studio repos clone --url <https://\u2026/repos/<id>/git> -e <env> [--ref r] [--output dir] [--full]\n seq-studio repos clone --id <uuid> -e <env> [--ref r] [--output dir] [--full]\n smart-HTTP when ATLAS_GIT_PAT is set;\n otherwise JSON materialize (<ns>/<name>)\n seq-studio repos pull <ns>/<name> -e <env> [--ref r] [--out dir] [--force]\n materialize the tree at a ref (JSON API)\n seq-studio repos pulls <list|show|create|diff|merge> [args] review requests (see pulls --help)\n seq-studio repos delete <ns>/<name> -e <env> [--yes] delete a repo (confirm prompt)\n seq-studio repos ci show <ns>/<name> -e <env> [--ref r] preview discovered CI checks\n seq-studio repos ci require <ns>/<name> --check <name> -e <env> reserved (refuses write until sandboxed runner)\n seq-studio repos ci import <ns>/<name> -e <env> [--ref r] reserved (refuses write until sandboxed runner)\n\n Flags: -e/--env <env> (required; see: seq-studio envs list)\n\n clone prefers real git clone (PAT via askpass \u2014 never written into the remote\n URL). --transport auto (default) uses Git when ATLAS_GIT_PAT is set and JSON\n materialization otherwise; --transport git requires a repo:read PAT; --transport\n json ignores ATLAS_GIT_PAT and uses the signed-in Atlas identity (<ns>/<name>\n only; no .git directory). Authentication failures explain this retry path.\n JSON materialization requires repo read access and prints how to create a PAT.\n PAT without Auth0 login: use --id from Repositories \u2192 Clone\n (or --url with the environment's canonical HTTPS origin).\n --ref accepts a branch, tag, or commit SHA (SHA \u2192 full clone, then checkout).\n Branch and tag clones are shallow (--depth 1). Pass --full for history.\n --output selects the clone directory (--out remains an alias).\n\n Authenticate JSON API calls with: seq-studio login\n Authenticate git clone/push with: ATLAS_GIT_PAT (from Atlas Settings \u2192 Tokens)\n";
|
|
110
119
|
export declare function runReposCommand(sub: string | undefined, args: ParsedArgs): Promise<number>;
|
|
111
120
|
export {};
|
package/dist/repos/commands.js
CHANGED
|
@@ -73,7 +73,7 @@ export function smartHttpCloneDepth({ ref, full, }) {
|
|
|
73
73
|
* (mirrors applyPreviewAccessHeader in ../artifact/delegate.ts — studio-cli's
|
|
74
74
|
* own atlas-client reads PREVIEW_ACCESS_HEADER directly).
|
|
75
75
|
*/
|
|
76
|
-
async function reposContext(args) {
|
|
76
|
+
export async function reposContext(args) {
|
|
77
77
|
if (args.flags.env === true || args.flags.e === true) {
|
|
78
78
|
throw new Error('-e/--env requires a value — see: seq-studio envs list.');
|
|
79
79
|
}
|
|
@@ -366,6 +366,11 @@ export async function reposCloneCommand(args, deps = {}) {
|
|
|
366
366
|
}
|
|
367
367
|
const output = outputFlag ?? outFlag;
|
|
368
368
|
const pat = resolveGitPatFromEnv();
|
|
369
|
+
const transportFlag = stringFlag(args.flags, 'transport') ?? 'auto';
|
|
370
|
+
if (!['auto', 'git', 'json'].includes(transportFlag)) {
|
|
371
|
+
throw new Error('--transport must be one of: auto, git, json.');
|
|
372
|
+
}
|
|
373
|
+
const transport = transportFlag;
|
|
369
374
|
const urlFlag = stringFlag(args.flags, 'url');
|
|
370
375
|
const idFlag = stringFlag(args.flags, 'id');
|
|
371
376
|
const positional = args.positional[0];
|
|
@@ -376,14 +381,21 @@ export async function reposCloneCommand(args, deps = {}) {
|
|
|
376
381
|
throw new Error('Pass either <ns>/<name> or --url/--id, not both.');
|
|
377
382
|
}
|
|
378
383
|
// --url/--id are PAT-only (no JSON materialize for a bare UUID/URL).
|
|
379
|
-
if ((urlFlag || idFlag) && !pat) {
|
|
384
|
+
if ((urlFlag || idFlag) && (!pat || transport === 'json')) {
|
|
380
385
|
const env = await resolveEnvOnly(args);
|
|
381
386
|
const lines = [
|
|
382
|
-
`${LOG} --url/--id requires ATLAS_GIT_PAT (JSON materialize needs <ns>/<name>).`,
|
|
387
|
+
`${LOG} --url/--id requires ATLAS_GIT_PAT and Git transport (JSON materialize needs <ns>/<name>).`,
|
|
383
388
|
...formatPatSetupHint({ envUrl: env.url, envName: env.name }),
|
|
384
389
|
];
|
|
385
390
|
throw new Error(lines.join('\n'));
|
|
386
391
|
}
|
|
392
|
+
if (transport === 'git' && !pat) {
|
|
393
|
+
const env = await resolveEnvOnly(args);
|
|
394
|
+
throw new Error([
|
|
395
|
+
`${LOG} --transport git requires ATLAS_GIT_PAT with repo:read access for ${env.name}.`,
|
|
396
|
+
...formatPatSetupHint({ envUrl: env.url, envName: env.name }),
|
|
397
|
+
].join('\n'));
|
|
398
|
+
}
|
|
387
399
|
// PAT-only path: clone by URL or repo UUID without seqapi/Auth0.
|
|
388
400
|
if (pat && (urlFlag || idFlag)) {
|
|
389
401
|
const env = await resolveEnvOnly(args);
|
|
@@ -399,6 +411,8 @@ export async function reposCloneCommand(args, deps = {}) {
|
|
|
399
411
|
pat,
|
|
400
412
|
...(ref ? { ref } : {}),
|
|
401
413
|
...(depth != null ? { depth } : {}),
|
|
414
|
+
}).catch((error) => {
|
|
415
|
+
throw withGitAuthHint({ error, envName: env.name });
|
|
402
416
|
});
|
|
403
417
|
console.log(`${LOG} cloned ${targetUrl} → ${destDir}` +
|
|
404
418
|
(ref ? ` (ref ${ref})` : '') +
|
|
@@ -431,7 +445,7 @@ export async function reposCloneCommand(args, deps = {}) {
|
|
|
431
445
|
}
|
|
432
446
|
const ctx = await reposContext(args);
|
|
433
447
|
const destDir = resolve(output ?? name);
|
|
434
|
-
if (pat) {
|
|
448
|
+
if (pat && transport !== 'json') {
|
|
435
449
|
prepareCloneDest({ destDir, force });
|
|
436
450
|
const resolved = await resolveRepo({ ...clientOptions(ctx), namespace, name });
|
|
437
451
|
const targetUrl = cloneUrl(ctx, resolved.id);
|
|
@@ -442,6 +456,8 @@ export async function reposCloneCommand(args, deps = {}) {
|
|
|
442
456
|
pat,
|
|
443
457
|
...(ref ? { ref } : {}),
|
|
444
458
|
...(depth != null ? { depth } : {}),
|
|
459
|
+
}).catch((error) => {
|
|
460
|
+
throw withGitAuthHint({ error, envName: ctx.env.name });
|
|
445
461
|
});
|
|
446
462
|
console.log(`${LOG} cloned ${namespace}/${name} → ${destDir}` +
|
|
447
463
|
(ref ? ` (ref ${ref})` : '') +
|
|
@@ -449,7 +465,9 @@ export async function reposCloneCommand(args, deps = {}) {
|
|
|
449
465
|
return 0;
|
|
450
466
|
}
|
|
451
467
|
assertDestWritable({ destDir, force });
|
|
452
|
-
console.log(
|
|
468
|
+
console.log(transport === 'json'
|
|
469
|
+
? `${LOG} materializing via JSON API as the signed-in Atlas identity (no .git dir; ignoring ATLAS_GIT_PAT).`
|
|
470
|
+
: `${LOG} no ATLAS_GIT_PAT — materializing via JSON API (no .git dir).`);
|
|
453
471
|
for (const line of formatPatSetupHint({ envUrl: ctx.env.url, envName: ctx.env.name })) {
|
|
454
472
|
console.log(line);
|
|
455
473
|
}
|
|
@@ -462,6 +480,14 @@ export async function reposCloneCommand(args, deps = {}) {
|
|
|
462
480
|
verb: 'cloned',
|
|
463
481
|
});
|
|
464
482
|
}
|
|
483
|
+
function withGitAuthHint({ error, envName }) {
|
|
484
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
485
|
+
if (!/(authentication failed|could not read username|http\s*(401|403)|returned error:\s*(401|403))/i.test(message)) {
|
|
486
|
+
return error instanceof Error ? error : new Error(message);
|
|
487
|
+
}
|
|
488
|
+
return new Error(`${message}\n${LOG} Git-service rejected ATLAS_GIT_PAT for ${envName}. Check that it is current and has repo:read access for this environment. ` +
|
|
489
|
+
`If your signed-in Atlas account can read the repo, retry with --transport json to materialize without using the ambient PAT (this creates no .git directory).`, { cause: error });
|
|
490
|
+
}
|
|
465
491
|
/** Resolve -e/--env without requiring Auth0 (for PAT-only --url/--id clones). */
|
|
466
492
|
async function resolveEnvOnly(args) {
|
|
467
493
|
if (args.flags.env === true || args.flags.e === true) {
|
|
@@ -801,13 +827,14 @@ export const REPOS_USAGE = `usage:
|
|
|
801
827
|
create a repo seeded with a README; --git-backend
|
|
802
828
|
walgit creates it empty (for pushing existing
|
|
803
829
|
history); needs namespace write
|
|
804
|
-
seq-studio repos clone <ns>/<name> -e <env> [--ref r] [--output dir] [--force] [--full]
|
|
830
|
+
seq-studio repos clone <ns>/<name> -e <env> [--ref r] [--output dir] [--force] [--full] [--transport auto|git|json]
|
|
805
831
|
seq-studio repos clone --url <https://…/repos/<id>/git> -e <env> [--ref r] [--output dir] [--full]
|
|
806
832
|
seq-studio repos clone --id <uuid> -e <env> [--ref r] [--output dir] [--full]
|
|
807
833
|
smart-HTTP when ATLAS_GIT_PAT is set;
|
|
808
834
|
otherwise JSON materialize (<ns>/<name>)
|
|
809
835
|
seq-studio repos pull <ns>/<name> -e <env> [--ref r] [--out dir] [--force]
|
|
810
836
|
materialize the tree at a ref (JSON API)
|
|
837
|
+
seq-studio repos pulls <list|show|create|diff|merge> [args] review requests (see pulls --help)
|
|
811
838
|
seq-studio repos delete <ns>/<name> -e <env> [--yes] delete a repo (confirm prompt)
|
|
812
839
|
seq-studio repos ci show <ns>/<name> -e <env> [--ref r] preview discovered CI checks
|
|
813
840
|
seq-studio repos ci require <ns>/<name> --check <name> -e <env> reserved (refuses write until sandboxed runner)
|
|
@@ -816,8 +843,11 @@ export const REPOS_USAGE = `usage:
|
|
|
816
843
|
Flags: -e/--env <env> (required; see: seq-studio envs list)
|
|
817
844
|
|
|
818
845
|
clone prefers real git clone (PAT via askpass — never written into the remote
|
|
819
|
-
URL).
|
|
820
|
-
|
|
846
|
+
URL). --transport auto (default) uses Git when ATLAS_GIT_PAT is set and JSON
|
|
847
|
+
materialization otherwise; --transport git requires a repo:read PAT; --transport
|
|
848
|
+
json ignores ATLAS_GIT_PAT and uses the signed-in Atlas identity (<ns>/<name>
|
|
849
|
+
only; no .git directory). Authentication failures explain this retry path.
|
|
850
|
+
JSON materialization requires repo read access and prints how to create a PAT.
|
|
821
851
|
PAT without Auth0 login: use --id from Repositories → Clone
|
|
822
852
|
(or --url with the environment's canonical HTTPS origin).
|
|
823
853
|
--ref accepts a branch, tag, or commit SHA (SHA → full clone, then checkout).
|
|
@@ -844,6 +874,10 @@ export async function runReposCommand(sub, args) {
|
|
|
844
874
|
return await reposPullCommand(args);
|
|
845
875
|
case 'delete':
|
|
846
876
|
return await reposDeleteCommand(args);
|
|
877
|
+
case 'pulls': {
|
|
878
|
+
const { reposPullsCommand } = await import('./pulls.js');
|
|
879
|
+
return await reposPullsCommand(args);
|
|
880
|
+
}
|
|
847
881
|
case 'ci':
|
|
848
882
|
return await reposCiCommand(args);
|
|
849
883
|
case 'help':
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ParsedArgs } from '../process/commands.js';
|
|
2
|
+
export declare const PULLS_USAGE = "usage:\n seq-studio repos pulls list <ns>/<name> -e <env> [--state open|closed|merged] [--limit N] [--cursor <cursor>]\n seq-studio repos pulls show <ns>/<name> <number> -e <env>\n seq-studio repos pulls create <ns>/<name> --head <branch> --base <branch> --title <title> -e <env> [--body-file <path>]\n seq-studio repos pulls diff <ns>/<name> <number> -e <env> [--max-files N]\n seq-studio repos pulls merge <ns>/<name> <number> -e <env> [--method squash|merge|ff] [--message <text>] [--yes]\n\n All results are JSON (--json is accepted). Authenticate: seq-studio login --env <env>.\n create needs repository write; merge needs merge/admin authority and passing server\n review/check policy. There is no policy bypass. Review show and diff before merging.\n Merge operates on the current branch head under server policy; a displayed SHA is\n informational and is not a compare-and-swap guard. Default merge method: squash.\n list returns one page with nextCursor; pass --cursor to continue.\n diff compares live base/head branches for open Pulls, recorded SHAs for terminal\n Pulls, and reports truncated when its file\n limit is reached (default 100, maximum 500).\n repos pull (singular) materializes files; repos pulls manages review requests.\n";
|
|
3
|
+
export declare function reposPullsCommand(input: ParsedArgs): Promise<number>;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { resolveRepo } from '@sequenceholdings/artifact-studio/git-service-client';
|
|
3
|
+
import { getJson, postJson } from '../atlas-client.js';
|
|
4
|
+
import { requiredStringFlag, validateCommandInput, wantsHelp } from '../command-input.js';
|
|
5
|
+
import { clientOptions } from '../functions/commands.js';
|
|
6
|
+
import { confirmYes } from '../prompt.js';
|
|
7
|
+
import { parseRepoPath, reposContext } from './commands.js';
|
|
8
|
+
export const PULLS_USAGE = `usage:
|
|
9
|
+
seq-studio repos pulls list <ns>/<name> -e <env> [--state open|closed|merged] [--limit N] [--cursor <cursor>]
|
|
10
|
+
seq-studio repos pulls show <ns>/<name> <number> -e <env>
|
|
11
|
+
seq-studio repos pulls create <ns>/<name> --head <branch> --base <branch> --title <title> -e <env> [--body-file <path>]
|
|
12
|
+
seq-studio repos pulls diff <ns>/<name> <number> -e <env> [--max-files N]
|
|
13
|
+
seq-studio repos pulls merge <ns>/<name> <number> -e <env> [--method squash|merge|ff] [--message <text>] [--yes]
|
|
14
|
+
|
|
15
|
+
All results are JSON (--json is accepted). Authenticate: seq-studio login --env <env>.
|
|
16
|
+
create needs repository write; merge needs merge/admin authority and passing server
|
|
17
|
+
review/check policy. There is no policy bypass. Review show and diff before merging.
|
|
18
|
+
Merge operates on the current branch head under server policy; a displayed SHA is
|
|
19
|
+
informational and is not a compare-and-swap guard. Default merge method: squash.
|
|
20
|
+
list returns one page with nextCursor; pass --cursor to continue.
|
|
21
|
+
diff compares live base/head branches for open Pulls, recorded SHAs for terminal
|
|
22
|
+
Pulls, and reports truncated when its file
|
|
23
|
+
limit is reached (default 100, maximum 500).
|
|
24
|
+
repos pull (singular) materializes files; repos pulls manages review requests.
|
|
25
|
+
`;
|
|
26
|
+
function integerFlag({ args, key, max }) {
|
|
27
|
+
const value = args.flags[key];
|
|
28
|
+
if (value === undefined)
|
|
29
|
+
return undefined;
|
|
30
|
+
if (typeof value !== 'string' || !/^\d+$/.test(value) || Number(value) < 1 || Number(value) > max) {
|
|
31
|
+
throw new Error(`--${key} must be an integer between 1 and ${max}.`);
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
function actionFlags(action) {
|
|
36
|
+
switch (action) {
|
|
37
|
+
case 'list': return { state: 'string', limit: 'string', cursor: 'string' };
|
|
38
|
+
case 'show': return {};
|
|
39
|
+
case 'create': return { head: 'string', base: 'string', title: 'string', 'body-file': 'string' };
|
|
40
|
+
case 'diff': return { 'max-files': 'string' };
|
|
41
|
+
case 'merge': return { method: 'string', message: 'string', yes: 'boolean' };
|
|
42
|
+
default: throw new Error(`Unknown pulls command: ${action}. See: seq-studio repos pulls --help`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async function createBody(args) {
|
|
46
|
+
const headRef = requiredStringFlag({ args, key: 'head' });
|
|
47
|
+
const baseRef = requiredStringFlag({ args, key: 'base' });
|
|
48
|
+
const title = requiredStringFlag({ args, key: 'title' });
|
|
49
|
+
const bodyFile = args.flags['body-file'];
|
|
50
|
+
const body = typeof bodyFile === 'string' ? await readFile(bodyFile, 'utf8') : undefined;
|
|
51
|
+
if (body !== undefined && body.length > 65_536)
|
|
52
|
+
throw new Error('--body-file exceeds 65,536 characters.');
|
|
53
|
+
return { headRef, baseRef, title, ...(body === undefined ? {} : { body }) };
|
|
54
|
+
}
|
|
55
|
+
async function mergePull({ args, ctx, path, repoPath }) {
|
|
56
|
+
const detail = await getJson({ ...clientOptions(ctx), path });
|
|
57
|
+
if (!detail.viewerCanMerge)
|
|
58
|
+
throw new Error('The authenticated identity does not have merge authority on this repository.');
|
|
59
|
+
const preview = [
|
|
60
|
+
`Merge ${repoPath} Pull #${args.positional[1]} on ${ctx.env.name}: ${detail.pullRequest.title}`,
|
|
61
|
+
`${detail.pullRequest.headRef} → ${detail.pullRequest.baseRef}; recorded head: ${detail.pullRequest.headSha}`,
|
|
62
|
+
'The server merges the current branch head, subject to its review and check policy.',
|
|
63
|
+
];
|
|
64
|
+
for (const line of preview)
|
|
65
|
+
console.error(line);
|
|
66
|
+
const confirmed = await confirmYes({ confirmed: args.flags.yes === true, preview: [] });
|
|
67
|
+
if (!confirmed)
|
|
68
|
+
return 1;
|
|
69
|
+
const result = await postJson({ ...clientOptions(ctx), path: `${path}/merge`, body: {
|
|
70
|
+
method: args.flags.method ?? 'squash',
|
|
71
|
+
...(args.flags.message === undefined ? {} : { message: args.flags.message }),
|
|
72
|
+
} });
|
|
73
|
+
console.log(JSON.stringify(result, null, 2));
|
|
74
|
+
return 0;
|
|
75
|
+
}
|
|
76
|
+
function parsePullOptions(args) {
|
|
77
|
+
if (args.positional[1] !== undefined && (!/^[1-9]\d*$/.test(args.positional[1]) || !Number.isSafeInteger(Number(args.positional[1])))) {
|
|
78
|
+
throw new Error('Pull number must be a positive integer.');
|
|
79
|
+
}
|
|
80
|
+
const state = args.flags.state;
|
|
81
|
+
if (state !== undefined && !['open', 'closed', 'merged'].includes(String(state)))
|
|
82
|
+
throw new Error('--state must be open, closed, or merged.');
|
|
83
|
+
const method = args.flags.method;
|
|
84
|
+
if (method !== undefined && !['squash', 'merge', 'ff'].includes(String(method)))
|
|
85
|
+
throw new Error('--method must be squash, merge, or ff.');
|
|
86
|
+
const limit = integerFlag({ args, key: 'limit', max: 200 });
|
|
87
|
+
const maxFiles = integerFlag({ args, key: 'max-files', max: 500 });
|
|
88
|
+
return { state: typeof state === 'string' ? state : undefined, limit, maxFiles };
|
|
89
|
+
}
|
|
90
|
+
export async function reposPullsCommand(input) {
|
|
91
|
+
const [action, ...positional] = input.positional;
|
|
92
|
+
if (!action || wantsHelp({ sub: action, args: input })) {
|
|
93
|
+
console.log(PULLS_USAGE);
|
|
94
|
+
return action || input.flags.help ? 0 : 1;
|
|
95
|
+
}
|
|
96
|
+
const args = { ...input, positional };
|
|
97
|
+
validateCommandInput({ args, flags: actionFlags(action), positional: ['list', 'create'].includes(action) ? 1 : 2 });
|
|
98
|
+
const repoPath = positional[0];
|
|
99
|
+
const repo = parseRepoPath(repoPath);
|
|
100
|
+
const { state, limit, maxFiles } = parsePullOptions(args);
|
|
101
|
+
const body = action === 'create' ? await createBody(args) : undefined;
|
|
102
|
+
const ctx = await reposContext(args);
|
|
103
|
+
const resolved = await resolveRepo({ ...clientOptions(ctx), ...repo });
|
|
104
|
+
const repoBase = `/api/git-service/repos/${encodeURIComponent(resolved.id)}`;
|
|
105
|
+
const path = `${repoBase}/pulls${positional[1] ? `/${positional[1]}` : ''}`;
|
|
106
|
+
if (action === 'merge')
|
|
107
|
+
return mergePull({ args, ctx, path, repoPath });
|
|
108
|
+
let result;
|
|
109
|
+
if (action === 'create') {
|
|
110
|
+
result = await postJson({ ...clientOptions(ctx), path, body });
|
|
111
|
+
}
|
|
112
|
+
else if (action === 'diff') {
|
|
113
|
+
const { pullRequest } = await getJson({ ...clientOptions(ctx), path: `${path}?include_mergeability=0` });
|
|
114
|
+
const base = pullRequest.state === 'open' ? pullRequest.baseRef : pullRequest.baseSha;
|
|
115
|
+
const head = pullRequest.state === 'open' ? pullRequest.headRef : pullRequest.headSha;
|
|
116
|
+
const range = `${encodeURIComponent(base)}...${encodeURIComponent(head)}`;
|
|
117
|
+
result = await getJson({ ...clientOptions(ctx), path: `${repoBase}/compare/${range}${maxFiles ? `?max_files=${maxFiles}` : ''}` });
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
const query = new URLSearchParams();
|
|
121
|
+
if (typeof state === 'string')
|
|
122
|
+
query.set('state', state);
|
|
123
|
+
if (limit)
|
|
124
|
+
query.set('limit', limit);
|
|
125
|
+
if (typeof args.flags.cursor === 'string')
|
|
126
|
+
query.set('cursor', args.flags.cursor);
|
|
127
|
+
result = await getJson({ ...clientOptions(ctx), path: `${path}${query.size ? `?${query}` : ''}` });
|
|
128
|
+
}
|
|
129
|
+
console.log(JSON.stringify(result, null, 2));
|
|
130
|
+
return 0;
|
|
131
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
/** Add documentation pointers without replacing project-specific instructions. */
|
|
4
|
+
export async function writeScaffoldGuidance({ directory }) {
|
|
5
|
+
for (const name of ['AGENTS.md', 'CLAUDE.md']) {
|
|
6
|
+
const body = await readFile(new URL(`../templates/guidance/${name}`, import.meta.url), 'utf8');
|
|
7
|
+
try {
|
|
8
|
+
await writeFile(join(directory, name), body, { flag: 'wx' });
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
if (!(error instanceof Error && 'code' in error && error.code === 'EEXIST'))
|
|
12
|
+
throw error;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -22,5 +22,5 @@ export declare function secretsSetDefaultCommand(args: ParsedArgs): Promise<numb
|
|
|
22
22
|
* UI: pin + redeploy the function's active version / pin only / cancel.
|
|
23
23
|
*/
|
|
24
24
|
export declare function secretsPinCommand(args: ParsedArgs): Promise<number>;
|
|
25
|
-
export declare const SECRETS_USAGE = "usage:\n seq-studio secrets create <NAME> -e <env> [--org <slug>] [--description text]\n register an org-owned secret\n seq-studio secrets set <NAME> -e <env> [--org <slug>] [--from-file <path>]\n set the shared default value (write-only)\n seq-studio secrets list -e <env> secrets you can see (never values)\n seq-studio secrets attach <NAME> --fn <slug> -e <env> [--org <slug>]\n mount default on a function env var\n seq-studio secrets detach <NAME> --fn <slug> -e <env> [--org <slug>]\n remove attachment\n seq-studio secrets attach <NAME> --stage <slug> -e <env> [--target <id>] [--credential <name>]\n attach to a pipeline stage's credential for one deploy target\n seq-studio secrets detach <NAME> --stage <slug> -e <env> [--target <id>] [--credential <name>]\n remove it (the stage's copy is deleted now)\n seq-studio secrets apply --from-env-file .env -e <env> push defaults + attach (keys default from manifest)\n seq-studio secrets versions <NAME> -e <env> [--org <slug>] value version history (never values)\n seq-studio secrets set-default <NAME> [version] -e <env> [--org <slug>]\n point the default at a prior version (editor)\n seq-studio secrets pin <NAME> --fn <slug> [version] -e <env> [--org <slug>]\n pin one function to a version (sticky; --unpin clears)\n\n Note: for the common deploy loop, secrets declared in managed-function.yml are\n reconciled automatically by `seq-studio functions deploy` using a local .env.\n Use `secrets` commands for CI (no .env), bulk/multi-function ops, or write-only\n value changes without a redeploy.\n\n Pipelines: managed secrets are the preferred way to give a stage a credential.\n Declare source.credential in the stage spec and read it in code with\n pipeline_runtime.get_credential(\"<name>\"). `seq-studio pipeline plan|deploy`\n attaches the secret named by convention (abrigo_oauth -> ABRIGO_OAUTH) when\n you can edit it (stages already deployed the legacy way are left alone); use\n `secrets attach --stage` for any other name.\n\n Flags: -e/--env <env> (required; see: seq-studio envs list)\n --org <slug> (target/select managed-scope org; required when a name exists in multiple orgs)\n set: --from-file <path>
|
|
25
|
+
export declare const SECRETS_USAGE = "usage:\n seq-studio secrets create <NAME> -e <env> [--type key-value|single] [--org <slug>] [--description text]\n register an org-owned secret\n seq-studio secrets set <NAME> -e <env> [--org <slug>] [--from-file <path>|--from-json <path>] [--merge]\n set the shared default value (write-only)\n seq-studio secrets list -e <env> secrets you can see (never values)\n seq-studio secrets attach <NAME> --fn <slug> -e <env> [--org <slug>] [--map KEY=ENV,KEY=ENV]\n mount default on a function env var\n seq-studio secrets detach <NAME> --fn <slug> -e <env> [--org <slug>]\n remove attachment\n seq-studio secrets attach <NAME> --stage <slug> -e <env> [--target <id>] [--credential <name>] [--entry KEY]\n attach to a pipeline stage's credential for one deploy target\n seq-studio secrets detach <NAME> --stage <slug> -e <env> [--target <id>] [--credential <name>]\n remove it (the stage's copy is deleted now)\n seq-studio secrets apply --from-env-file .env -e <env> push defaults + attach (keys default from manifest)\n seq-studio secrets versions <NAME> -e <env> [--org <slug>] value version history (never values)\n seq-studio secrets set-default <NAME> [version] -e <env> [--org <slug>]\n point the default at a prior version (editor)\n seq-studio secrets pin <NAME> --fn <slug> [version] -e <env> [--org <slug>]\n pin one function to a version (sticky; --unpin clears)\n\n Note: for the common deploy loop, secrets declared in managed-function.yml are\n reconciled automatically by `seq-studio functions deploy` using a local .env.\n Explicit function attachments require the same secret source and mapping in the active manifest.\n Use `secrets` commands for CI (no .env), bulk/multi-function ops, or write-only\n value changes without a redeploy.\n\n Pipelines: managed secrets are the preferred way to give a stage a credential.\n Declare source.credential in the stage spec and read it in code with\n pipeline_runtime.get_credential(\"<name>\"). `seq-studio pipeline plan|deploy`\n attaches the secret named by convention (abrigo_oauth -> ABRIGO_OAUTH) when\n you can edit it (stages already deployed the legacy way are left alone); use\n `secrets attach --stage` for any other name.\n\n Flags: -e/--env <env> (required; see: seq-studio envs list)\n --org <slug> (target/select managed-scope org; required when a name exists in multiple orgs)\n set: --from-file <path> for single values; --from-json <path> for key/value sets; --merge changes only listed entries (null removes one)\n --fn <slug> \u00B7 --env-var <NAME> \u00B7 --yes\n --stage <slug> \u00B7 --target <id> (deploy target; default from -e) \u00B7 --credential <name> \u00B7 --entry <KEY> (key/value sets)\n (the spec's source.credential; default: NAME lowercased) \u00B7 --repo <ns>/<name> (disambiguate)\n --functions <f1,f2> \u00B7 --keys <K1,K2> \u00B7 --all (override key selection)\n set-default: [version|version-row-id] (defaults to the most recent non-default) \u00B7 --yes\n pin: [version|version-row-id] (defaults to the current default) \u00B7 --unpin \u00B7 --yes (redeploy) \u00B7 --yes --no-redeploy\n";
|
|
26
26
|
export declare function runSecretsCommand(sub: string | undefined, args: ParsedArgs): Promise<number>;
|
package/dist/secrets/commands.js
CHANGED
|
@@ -162,12 +162,17 @@ async function functionExistsBySlugEventually({ ctx, slug, attempts = 3, retryDe
|
|
|
162
162
|
export async function secretsCreateCommand(args) {
|
|
163
163
|
const name = args.positional[0];
|
|
164
164
|
if (!name) {
|
|
165
|
-
console.error('usage: seq-studio secrets create <NAME> -e <env> [--org <slug>] [--description text]');
|
|
165
|
+
console.error('usage: seq-studio secrets create <NAME> -e <env> [--type key-value|single] [--org <slug>] [--description text]');
|
|
166
166
|
return 1;
|
|
167
167
|
}
|
|
168
168
|
const ctx = await buildContext(args);
|
|
169
169
|
const description = typeof args.flags.description === 'string' ? args.flags.description : undefined;
|
|
170
170
|
const org = orgFlag(args);
|
|
171
|
+
const typeFlag = args.flags.type;
|
|
172
|
+
if (typeFlag !== undefined && typeFlag !== 'single' && typeFlag !== 'key-value') {
|
|
173
|
+
console.error(`${LOG} --type must be key-value or single`);
|
|
174
|
+
return 1;
|
|
175
|
+
}
|
|
171
176
|
if (org) {
|
|
172
177
|
const mismatch = orgDeploymentError(org, ctx.env.name);
|
|
173
178
|
if (mismatch) {
|
|
@@ -180,6 +185,7 @@ export async function secretsCreateCommand(args) {
|
|
|
180
185
|
path: '/api/managed-secrets',
|
|
181
186
|
body: {
|
|
182
187
|
name,
|
|
188
|
+
...(typeFlag === 'key-value' ? { valueType: 'key_value' } : {}),
|
|
183
189
|
description: description ?? null,
|
|
184
190
|
...(org ? { orgId: org } : {}),
|
|
185
191
|
},
|
|
@@ -193,12 +199,55 @@ export async function secretsCreateCommand(args) {
|
|
|
193
199
|
export async function secretsSetCommand(args) {
|
|
194
200
|
const name = args.positional[0];
|
|
195
201
|
if (!name) {
|
|
196
|
-
console.error('usage: seq-studio secrets set <NAME> -e <env> [--org <slug>] [--from-file <path>]');
|
|
202
|
+
console.error('usage: seq-studio secrets set <NAME> -e <env> [--org <slug>] [--from-file <path>] [--from-json <path>]');
|
|
197
203
|
return 1;
|
|
198
204
|
}
|
|
199
205
|
const ctx = await buildContext(args);
|
|
200
206
|
const secret = await resolveSecretByName({ ctx, name, org: orgFlag(args) });
|
|
201
207
|
const fromFile = typeof args.flags['from-file'] === 'string' ? args.flags['from-file'] : undefined;
|
|
208
|
+
const fromJson = typeof args.flags['from-json'] === 'string' ? args.flags['from-json'] : undefined;
|
|
209
|
+
if (secret.valueType === 'key_value') {
|
|
210
|
+
if (!fromJson || fromFile) {
|
|
211
|
+
console.error(`${LOG} key/value sets require --from-json <path> containing an object of entry names and string values`);
|
|
212
|
+
return 1;
|
|
213
|
+
}
|
|
214
|
+
const filePath = isAbsolute(fromJson) ? fromJson : resolve(workDir(args), fromJson);
|
|
215
|
+
if (!existsSync(filePath)) {
|
|
216
|
+
console.error(`${LOG} --from-json not found: ${filePath}`);
|
|
217
|
+
return 1;
|
|
218
|
+
}
|
|
219
|
+
let entries;
|
|
220
|
+
try {
|
|
221
|
+
entries = JSON.parse(await readFile(filePath, 'utf8'));
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
console.error(`${LOG} --from-json must contain valid JSON`);
|
|
225
|
+
return 1;
|
|
226
|
+
}
|
|
227
|
+
const merge = flagBool(args.flags, 'merge');
|
|
228
|
+
if (!entries || typeof entries !== 'object' || Array.isArray(entries) || Object.keys(entries).length === 0 || Object.values(entries).some((value) => merge ? value !== null && (typeof value !== 'string' || !value) : typeof value !== 'string' || !value)) {
|
|
229
|
+
console.error(`${LOG} --from-json must contain a nonempty object of ${merge ? 'nonempty string values or null removals' : 'nonempty string values'}`);
|
|
230
|
+
return 1;
|
|
231
|
+
}
|
|
232
|
+
if (merge) {
|
|
233
|
+
const detail = await getJson({ ...clientOptions(ctx), path: `/api/managed-secrets/${secret.id}` });
|
|
234
|
+
if (!detail.currentGcpVersion) {
|
|
235
|
+
console.error(`${LOG} the set has no active version; use secrets set --from-json without --merge first`);
|
|
236
|
+
return 1;
|
|
237
|
+
}
|
|
238
|
+
await patchJson({ ...clientOptions(ctx), path: `/api/managed-secrets/${secret.id}/value`, body: { expectedVersion: detail.currentGcpVersion, changes: entries } });
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
await putJson({ ...clientOptions(ctx), path: `/api/managed-secrets/${secret.id}/value`, body: { entries } });
|
|
242
|
+
}
|
|
243
|
+
console.log(`${LOG} ${merge ? 'updated' : 'set'} default key/value version for "${name}" (${Object.keys(entries).length} ${merge ? 'changes' : 'entries'})`);
|
|
244
|
+
console.log(`${LOG} functions tracking this secret need a redeploy to pick up the new version`);
|
|
245
|
+
return 0;
|
|
246
|
+
}
|
|
247
|
+
if (fromJson) {
|
|
248
|
+
console.error(`${LOG} --from-json is only for key/value sets`);
|
|
249
|
+
return 1;
|
|
250
|
+
}
|
|
202
251
|
let value;
|
|
203
252
|
if (fromFile) {
|
|
204
253
|
const filePath = isAbsolute(fromFile) ? fromFile : resolve(workDir(args), fromFile);
|
|
@@ -238,7 +287,7 @@ export async function secretsListCommand(args) {
|
|
|
238
287
|
for (const secret of secrets) {
|
|
239
288
|
const defaultState = secret.hasDefaultValue ? 'default set' : 'no default';
|
|
240
289
|
const access = secret.currentUserAccess ?? 'none';
|
|
241
|
-
console.log(` ${secret.name} org=${secret.orgId} [${defaultState}] access=${access} attachments=${secret.attachmentCount}`);
|
|
290
|
+
console.log(` ${secret.name} type=${secret.valueType ?? 'single'} org=${secret.orgId} [${defaultState}] access=${access} attachments=${secret.attachmentCount}`);
|
|
242
291
|
}
|
|
243
292
|
return 0;
|
|
244
293
|
}
|
|
@@ -259,10 +308,20 @@ async function resolveStageAttachment({ args, ctx, name }) {
|
|
|
259
308
|
async function secretsAttachToStage(args, name) {
|
|
260
309
|
const ctx = await buildContext(args);
|
|
261
310
|
const secret = await resolveSecretByName({ ctx, name, org: orgFlag(args) });
|
|
311
|
+
const entryKey = typeof args.flags.entry === 'string' ? args.flags.entry : undefined;
|
|
312
|
+
if (secret.valueType === 'key_value' && !entryKey) {
|
|
313
|
+
console.error(`${LOG} key/value set ${name} requires --entry KEY for a pipeline credential`);
|
|
314
|
+
return 1;
|
|
315
|
+
}
|
|
316
|
+
if (secret.valueType !== 'key_value' && entryKey) {
|
|
317
|
+
console.error(`${LOG} --entry is only for key/value sets`);
|
|
318
|
+
return 1;
|
|
319
|
+
}
|
|
262
320
|
const { stage, symbolic, deployTarget } = await resolveStageAttachment({ args, ctx, name });
|
|
263
321
|
const preview = [
|
|
264
322
|
`${LOG} attach preview:`,
|
|
265
323
|
`${LOG} secret: ${name}`,
|
|
324
|
+
...(entryKey ? [`${LOG} entry: ${entryKey}`] : []),
|
|
266
325
|
`${LOG} stage: ${stage.slug} (${stage.repo})`,
|
|
267
326
|
`${LOG} credential: ${symbolic}`,
|
|
268
327
|
`${LOG} target: ${deployTarget}`,
|
|
@@ -270,7 +329,7 @@ async function secretsAttachToStage(args, name) {
|
|
|
270
329
|
];
|
|
271
330
|
if (!(await confirmYes({ preview, confirmed: flagBool(args.flags, 'yes') })))
|
|
272
331
|
return 1;
|
|
273
|
-
await attachSecretToStage({ client: clientOptions(ctx), stageId: stage.id, deployTarget, symbolic, secretId: secret.id });
|
|
332
|
+
await attachSecretToStage({ client: clientOptions(ctx), stageId: stage.id, deployTarget, symbolic, secretId: secret.id, entryKey });
|
|
274
333
|
console.log(`${LOG} attached "${name}" to ${stage.slug} as ${symbolic} for ${deployTarget}`);
|
|
275
334
|
console.log(`${LOG} plan and deploy the stage to copy it; read it with pipeline_runtime.get_credential("${symbolic}")`);
|
|
276
335
|
return 0;
|
|
@@ -300,20 +359,38 @@ export async function secretsAttachCommand(args) {
|
|
|
300
359
|
return secretsAttachToStage(args, name);
|
|
301
360
|
const fnSlug = typeof args.flags.fn === 'string' ? args.flags.fn : args.positional[1];
|
|
302
361
|
if (!name || !fnSlug) {
|
|
303
|
-
console.error('usage: seq-studio secrets attach <NAME> --fn <slug> -e <env> [--org <slug>] [--env-var NAME]\n' +
|
|
304
|
-
' seq-studio secrets attach <NAME> --stage <slug> -e <env> [--target <id>] [--credential <name>] [--repo <ns>/<name>] [--org <slug>]');
|
|
362
|
+
console.error('usage: seq-studio secrets attach <NAME> --fn <slug> -e <env> [--org <slug>] [--env-var NAME] [--map KEY=ENV,KEY=ENV]\n' +
|
|
363
|
+
' seq-studio secrets attach <NAME> --stage <slug> -e <env> [--target <id>] [--credential <name>] [--entry KEY] [--repo <ns>/<name>] [--org <slug>]');
|
|
305
364
|
return 1;
|
|
306
365
|
}
|
|
307
366
|
const ctx = await buildContext(args);
|
|
308
367
|
const secret = await resolveSecretByName({ ctx, name, org: orgFlag(args) });
|
|
309
368
|
const fn = await resolveFunctionBySlug({ ctx, slug: fnSlug });
|
|
310
369
|
const envVarName = (typeof args.flags['env-var'] === 'string' ? args.flags['env-var'] : undefined) ?? name;
|
|
370
|
+
let entryMappings;
|
|
371
|
+
if (secret.valueType === 'key_value') {
|
|
372
|
+
const mapFlag = args.flags.map;
|
|
373
|
+
if (typeof mapFlag !== 'string' || !mapFlag.trim()) {
|
|
374
|
+
console.error(`${LOG} key/value sets require --map KEY=ENV,KEY=ENV matching the function manifest's secret and entry mappings`);
|
|
375
|
+
return 1;
|
|
376
|
+
}
|
|
377
|
+
const pairs = mapFlag.split(',').map((part) => part.trim().split('='));
|
|
378
|
+
if (pairs.some((parts) => parts.length !== 2 || !parts[0] || !parts[1]) || new Set(pairs.map((parts) => parts[0])).size !== pairs.length) {
|
|
379
|
+
console.error(`${LOG} --map must contain distinct KEY=ENV pairs`);
|
|
380
|
+
return 1;
|
|
381
|
+
}
|
|
382
|
+
entryMappings = Object.fromEntries(pairs.map(([key, env]) => [key, env]));
|
|
383
|
+
}
|
|
384
|
+
else if (args.flags.map !== undefined) {
|
|
385
|
+
console.error(`${LOG} --map is only for key/value sets`);
|
|
386
|
+
return 1;
|
|
387
|
+
}
|
|
311
388
|
if (secret.hasDefaultValue) {
|
|
312
389
|
const preview = [
|
|
313
390
|
`${LOG} attach preview:`,
|
|
314
391
|
`${LOG} secret: ${name}`,
|
|
315
392
|
`${LOG} function: ${fnSlug}`,
|
|
316
|
-
`${LOG} env var: ${envVarName}
|
|
393
|
+
...(entryMappings ? Object.entries(entryMappings).map(([key, env]) => `${LOG} ${key} → ${env}`) : [`${LOG} env var: ${envVarName}`]),
|
|
317
394
|
`${LOG} note: shared default — anyone who can invoke "${fnSlug}" receives it at runtime`,
|
|
318
395
|
];
|
|
319
396
|
const ok = await confirmYes({ preview, confirmed: flagBool(args.flags, 'yes') });
|
|
@@ -326,10 +403,11 @@ export async function secretsAttachCommand(args) {
|
|
|
326
403
|
body: {
|
|
327
404
|
functionId: fn.id,
|
|
328
405
|
envVarName,
|
|
406
|
+
...(entryMappings ? { entryMappings } : {}),
|
|
329
407
|
},
|
|
330
408
|
});
|
|
331
|
-
console.log(`${LOG} attached "${name}" to ${fnSlug} as env var ${envVarName}`);
|
|
332
|
-
console.log(`${LOG} redeploy ${fnSlug} to mount the secret`);
|
|
409
|
+
console.log(`${LOG} attached "${name}" to ${fnSlug}${entryMappings ? ` with ${Object.keys(entryMappings).length} entry mappings` : ` as env var ${envVarName}`}`);
|
|
410
|
+
console.log(`${LOG} the function manifest must bind ${name} with this exact mapping; redeploy ${fnSlug} to mount the secret`);
|
|
333
411
|
return 0;
|
|
334
412
|
}
|
|
335
413
|
export async function secretsDetachCommand(args) {
|
|
@@ -383,7 +461,9 @@ function resolveApplyKeys({ parsed, manifest, explicitKeys, applyAll, }) {
|
|
|
383
461
|
};
|
|
384
462
|
}
|
|
385
463
|
if (manifest) {
|
|
386
|
-
const keys = manifest.secrets
|
|
464
|
+
const keys = manifest.secrets
|
|
465
|
+
.filter((entry) => typeof entry === 'string')
|
|
466
|
+
.filter((key) => parsed[key] && parsed[key].length > 0);
|
|
387
467
|
return {
|
|
388
468
|
keys,
|
|
389
469
|
mode: manifest.secrets.length > 0 ? 'manifest secrets ∩ .env' : 'manifest secrets (none declared)',
|
|
@@ -753,16 +833,16 @@ export async function secretsPinCommand(args) {
|
|
|
753
833
|
// dispatcher
|
|
754
834
|
// ---------------------------------------------------------------------------
|
|
755
835
|
export const SECRETS_USAGE = `usage:
|
|
756
|
-
seq-studio secrets create <NAME> -e <env> [--org <slug>] [--description text]
|
|
836
|
+
seq-studio secrets create <NAME> -e <env> [--type key-value|single] [--org <slug>] [--description text]
|
|
757
837
|
register an org-owned secret
|
|
758
|
-
seq-studio secrets set <NAME> -e <env> [--org <slug>] [--from-file <path>]
|
|
838
|
+
seq-studio secrets set <NAME> -e <env> [--org <slug>] [--from-file <path>|--from-json <path>] [--merge]
|
|
759
839
|
set the shared default value (write-only)
|
|
760
840
|
seq-studio secrets list -e <env> secrets you can see (never values)
|
|
761
|
-
seq-studio secrets attach <NAME> --fn <slug> -e <env> [--org <slug>]
|
|
841
|
+
seq-studio secrets attach <NAME> --fn <slug> -e <env> [--org <slug>] [--map KEY=ENV,KEY=ENV]
|
|
762
842
|
mount default on a function env var
|
|
763
843
|
seq-studio secrets detach <NAME> --fn <slug> -e <env> [--org <slug>]
|
|
764
844
|
remove attachment
|
|
765
|
-
seq-studio secrets attach <NAME> --stage <slug> -e <env> [--target <id>] [--credential <name>]
|
|
845
|
+
seq-studio secrets attach <NAME> --stage <slug> -e <env> [--target <id>] [--credential <name>] [--entry KEY]
|
|
766
846
|
attach to a pipeline stage's credential for one deploy target
|
|
767
847
|
seq-studio secrets detach <NAME> --stage <slug> -e <env> [--target <id>] [--credential <name>]
|
|
768
848
|
remove it (the stage's copy is deleted now)
|
|
@@ -775,6 +855,7 @@ export const SECRETS_USAGE = `usage:
|
|
|
775
855
|
|
|
776
856
|
Note: for the common deploy loop, secrets declared in managed-function.yml are
|
|
777
857
|
reconciled automatically by \`seq-studio functions deploy\` using a local .env.
|
|
858
|
+
Explicit function attachments require the same secret source and mapping in the active manifest.
|
|
778
859
|
Use \`secrets\` commands for CI (no .env), bulk/multi-function ops, or write-only
|
|
779
860
|
value changes without a redeploy.
|
|
780
861
|
|
|
@@ -787,9 +868,9 @@ export const SECRETS_USAGE = `usage:
|
|
|
787
868
|
|
|
788
869
|
Flags: -e/--env <env> (required; see: seq-studio envs list)
|
|
789
870
|
--org <slug> (target/select managed-scope org; required when a name exists in multiple orgs)
|
|
790
|
-
set: --from-file <path>
|
|
871
|
+
set: --from-file <path> for single values; --from-json <path> for key/value sets; --merge changes only listed entries (null removes one)
|
|
791
872
|
--fn <slug> · --env-var <NAME> · --yes
|
|
792
|
-
--stage <slug> · --target <id> (deploy target; default from -e) · --credential <name>
|
|
873
|
+
--stage <slug> · --target <id> (deploy target; default from -e) · --credential <name> · --entry <KEY> (key/value sets)
|
|
793
874
|
(the spec's source.credential; default: NAME lowercased) · --repo <ns>/<name> (disambiguate)
|
|
794
875
|
--functions <f1,f2> · --keys <K1,K2> · --all (override key selection)
|
|
795
876
|
set-default: [version|version-row-id] (defaults to the most recent non-default) · --yes
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ParsedArgs } from '../process/commands.js';
|
|
2
|
+
export declare const SERVICE_ACCOUNTS_USAGE = "usage:\n seq-studio service-accounts list -e <env> [--json]\n seq-studio service-accounts show <account-id> -e <env> [--json]\n seq-studio service-accounts create <slug> --display-name <name> -e <env> [--description <text>] [--json]\n\n All results are JSON. Authenticate: seq-studio login --env <env>.\n Administrator provisioning: listing needs Service Accounts surface access;\n create needs its editor grant; show needs admin on that account.\n A normal builder should use the account ID/slug supplied by their administrator.\n Creation does not grant the account access to data or functions. Grant required\n runtime access with seq-studio access using principal user: service-account|<id>.\n The server checks creator, actor, and resource authority on every operation.\n No credential is issued or printed by these commands.\n";
|
|
3
|
+
export declare function runServiceAccountsCommand(sub: string | undefined, args: ParsedArgs): Promise<number>;
|