@sequenceholdings/studio-cli 1.0.1 → 1.0.2

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 (51) hide show
  1. package/README.md +3 -2
  2. package/dist/access/custom-role-hosts.js +8 -6
  3. package/dist/app/manifest-validation.js +4 -2
  4. package/dist/app/manifest.d.ts +2 -0
  5. package/dist/app/manifest.js +2 -0
  6. package/dist/app/paths.js +3 -0
  7. package/dist/app-preview/bundle-dependencies.d.ts +52 -0
  8. package/dist/app-preview/bundle-dependencies.js +121 -0
  9. package/dist/app-preview/commands.d.ts +2 -5
  10. package/dist/app-preview/commands.js +57 -62
  11. package/dist/app-preview/fork-setup.d.ts +66 -0
  12. package/dist/app-preview/fork-setup.js +123 -0
  13. package/dist/app-preview/fork.d.ts +171 -0
  14. package/dist/app-preview/fork.js +279 -0
  15. package/dist/app-preview/install.d.ts +23 -2
  16. package/dist/app-preview/install.js +67 -6
  17. package/dist/app-preview/orm-sdk.d.ts +31 -0
  18. package/dist/app-preview/orm-sdk.js +16 -0
  19. package/dist/app-preview/plan.d.ts +2 -0
  20. package/dist/app-preview/plan.js +2 -2
  21. package/dist/app-preview/report.d.ts +30 -0
  22. package/dist/app-preview/report.js +80 -0
  23. package/dist/app-preview/repository-manifest.d.ts +83 -0
  24. package/dist/app-preview/repository-manifest.js +179 -0
  25. package/dist/app-preview/runners.d.ts +14 -0
  26. package/dist/app-preview/runners.js +83 -23
  27. package/dist/app-preview/session-output.d.ts +5 -0
  28. package/dist/app-preview/session-output.js +28 -0
  29. package/dist/app-preview/source-includes.d.ts +12 -0
  30. package/dist/app-preview/source-includes.js +74 -0
  31. package/dist/app-preview/target.d.ts +8 -0
  32. package/dist/app-preview/target.js +4 -1
  33. package/dist/app-preview/usage.d.ts +7 -0
  34. package/dist/app-preview/usage.js +57 -0
  35. package/dist/envs/commands.js +2 -1
  36. package/dist/login.js +1 -1
  37. package/dist/orm/break-glass.d.ts +15 -0
  38. package/dist/orm/break-glass.js +22 -0
  39. package/dist/orm/delegate.js +10 -8
  40. package/dist/orm/version-guard.d.ts +6 -2
  41. package/dist/orm/version-guard.js +27 -7
  42. package/dist/registry/help.js +5 -6
  43. package/dist/repos/github-init.js +4 -1
  44. package/dist/repos/primitive-declaration.d.ts +27 -0
  45. package/dist/repos/primitive-declaration.js +22 -6
  46. package/dist/repos/seq-ci-release.d.ts +10 -0
  47. package/dist/repos/seq-ci-release.js +27 -0
  48. package/dist/sdk-source.d.ts +15 -0
  49. package/dist/sdk-source.js +30 -11
  50. package/package.json +3 -3
  51. package/release-summary.json +2 -1
@@ -4,6 +4,7 @@ import { lstat, mkdir, readFile, writeFile } from 'node:fs/promises';
4
4
  import { dirname, join, resolve } from 'node:path';
5
5
  import { dump as yamlDump, load as yamlLoad } from 'js-yaml';
6
6
  import { z } from 'zod';
7
+ import { newestRelease, workflowSeqCiReleases } from './seq-ci-release.js';
7
8
  /**
8
9
  * `seq-studio repo init`: make a GitHub checkout a Sequence repository. Writes only files it owns, marked with a
9
10
  * managed header, and only what's missing or stale; `check` reports the same without writing.
@@ -222,8 +223,10 @@ function pinnedCli({ cli, current }) {
222
223
  export async function resolveSettings({ directory, org, dev, release, seqCi, releaseRepository, pullRequestBuilds, cli }) {
223
224
  const existing = await readOptional(join(resolve(directory), GITHUB_SETTINGS_PATH));
224
225
  const current = existing === null ? undefined : githubSettingsSchema.parse(yamlLoad(existing));
226
+ // An explicit --seq-ci wins, older or not; otherwise never step back from what the workflows already call.
227
+ const inUse = newestRelease([...(current ? [current.seq_ci] : []), ...await workflowSeqCiReleases({ root: resolve(directory), read: readOptional })]);
225
228
  const settings = { schema_version: 1, org: org ?? current?.org, branches: { dev: dev ?? current?.branches.dev ?? 'staging', release: release ?? current?.branches.release ?? 'main' },
226
- seq_ci: seqCi ?? current?.seq_ci ?? 'v1.0.5',
229
+ seq_ci: seqCi ?? inUse ?? 'v1.0.5',
227
230
  // On by default: the dev branch ruleset below requires no approvals.
228
231
  pull_request_builds: pullRequestBuilds ?? current?.pull_request_builds ?? 'reuse',
229
232
  ...((releaseRepository ?? current?.release_repository) ? { release_repository: releaseRepository ?? current?.release_repository } : {}),
@@ -1,3 +1,4 @@
1
+ import { z } from 'zod';
1
2
  export type StandalonePrimitiveKind = 'orm' | 'function' | 'artifact';
2
3
  export interface ResourceEntry {
3
4
  id: string;
@@ -17,6 +18,31 @@ export type ResourceDeclarationPlan = {
17
18
  action: 'skip';
18
19
  reason?: string;
19
20
  };
21
+ declare const indexSchema: z.ZodObject<{
22
+ schema_version: z.ZodLiteral<1>;
23
+ applications: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
24
+ path: z.ZodString;
25
+ }, z.core.$loose>>>>;
26
+ resources: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
27
+ id: z.ZodString;
28
+ path: z.ZodString;
29
+ kind: z.ZodOptional<z.ZodString>;
30
+ namespace: z.ZodOptional<z.ZodString>;
31
+ slug: z.ZodOptional<z.ZodString>;
32
+ project_id: z.ZodOptional<z.ZodString>;
33
+ name: z.ZodOptional<z.ZodString>;
34
+ }, z.core.$loose>>>>;
35
+ ignore: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
36
+ }, z.core.$loose>;
37
+ export type IndexedResource = NonNullable<RepositoryIndex['resources']>[number];
38
+ type RepositoryIndex = z.infer<typeof indexSchema>;
39
+ /**
40
+ * The resources a repository's index declares, as written (unknown fields kept), for a reader that only looks.
41
+ * Null when the repository has no index; throws when the file is there and cannot be read as one.
42
+ */
43
+ export declare function readRepositoryResources({ gitRoot }: {
44
+ gitRoot: string;
45
+ }): Promise<IndexedResource[] | null>;
20
46
  /** Plan the index change for a primitive just scaffolded at `dir`. */
21
47
  export declare function planResourceDeclaration({ kind, dir }: {
22
48
  kind: StandalonePrimitiveKind;
@@ -41,3 +67,4 @@ export declare function runStandaloneInit({ kind, argv, defaultDir, run }: {
41
67
  defaultDir?: string;
42
68
  run: () => Promise<number>;
43
69
  }): Promise<number>;
70
+ export {};
@@ -99,19 +99,35 @@ function uniqueId(id, taken) {
99
99
  if (!taken.has(`${id}-${n}`))
100
100
  return `${id}-${n}`;
101
101
  }
102
- /** The existing index (with its document, to edit in place), none, or why it cannot be edited. */
103
- async function readIndex({ indexPath, path }) {
102
+ /** The existing index (with its document), none, or what is wrong with the file. */
103
+ async function parseIndex(indexPath) {
104
104
  if (!existsSync(indexPath))
105
105
  return null;
106
106
  const document = parseDocument(await readFile(indexPath, 'utf8'));
107
107
  if (document.errors.length > 0)
108
- return { reason: `${REPOSITORY_INDEX_PATH} is not valid YAML; declare ${path} under resources by hand` };
108
+ return { problem: `${REPOSITORY_INDEX_PATH} is not valid YAML` };
109
109
  const parsed = indexSchema.safeParse(document.toJS());
110
- if (!parsed.success) {
111
- return { reason: `${REPOSITORY_INDEX_PATH} is not a schema_version 1 repository index; declare ${path} under resources by hand` };
112
- }
110
+ if (!parsed.success)
111
+ return { problem: `${REPOSITORY_INDEX_PATH} is not a schema_version 1 repository index` };
113
112
  return { document, index: parsed.data };
114
113
  }
114
+ /** The existing index (with its document, to edit in place), none, or why it cannot be edited. */
115
+ async function readIndex({ indexPath, path }) {
116
+ const existing = await parseIndex(indexPath);
117
+ return existing && 'problem' in existing ? { reason: `${existing.problem}; declare ${path} under resources by hand` } : existing;
118
+ }
119
+ /**
120
+ * The resources a repository's index declares, as written (unknown fields kept), for a reader that only looks.
121
+ * Null when the repository has no index; throws when the file is there and cannot be read as one.
122
+ */
123
+ export async function readRepositoryResources({ gitRoot }) {
124
+ const existing = await parseIndex(join(gitRoot, REPOSITORY_INDEX_PATH));
125
+ if (existing === null)
126
+ return null;
127
+ if ('problem' in existing)
128
+ throw new Error(existing.problem);
129
+ return existing.index.resources ?? [];
130
+ }
115
131
  /** Why `path` must not become a resource, or null when it can. */
116
132
  function conflict({ path, gitRoot, index }) {
117
133
  const applications = index
@@ -0,0 +1,10 @@
1
+ /** The newest of these `vX.Y.Z` releases. */
2
+ export declare function newestRelease(releases: readonly string[]): string | undefined;
3
+ /**
4
+ * The seq-ci releases the checked-in seq and seq promote workflows call. A hand edit can move these ahead of
5
+ * `.seq/github.yml`, so settings never render the workflows older than they already are.
6
+ */
7
+ export declare function workflowSeqCiReleases({ root, read }: {
8
+ root: string;
9
+ read: (path: string) => Promise<string | null>;
10
+ }): Promise<string[]>;
@@ -0,0 +1,27 @@
1
+ /** Which seq-ci release a repository's checked-in workflows already call. */
2
+ import { join } from 'node:path';
3
+ const SEQ_CI_WORKFLOW_REF = new RegExp(`sequenceholdings\\/seq-ci\\/\\.github\\/workflows\\/[\\w.-]+@(v\\d+\\.\\d+\\.\\d+)\\b`, 'g');
4
+ const SEQ_CI_WORKFLOW_PATHS = ['.github/workflows/seq.yml', '.github/workflows/seq-promote.yml'];
5
+ function releaseParts(release) {
6
+ return release.slice(1).split('.').map(Number);
7
+ }
8
+ /** The newest of these `vX.Y.Z` releases. */
9
+ export function newestRelease(releases) {
10
+ return [...releases].sort((a, b) => {
11
+ const [x, y] = [releaseParts(a), releaseParts(b)];
12
+ return (x[0] - y[0]) || (x[1] - y[1]) || (x[2] - y[2]);
13
+ }).at(-1);
14
+ }
15
+ /**
16
+ * The seq-ci releases the checked-in seq and seq promote workflows call. A hand edit can move these ahead of
17
+ * `.seq/github.yml`, so settings never render the workflows older than they already are.
18
+ */
19
+ export async function workflowSeqCiReleases({ root, read }) {
20
+ const releases = [];
21
+ for (const path of SEQ_CI_WORKFLOW_PATHS) {
22
+ const text = await read(join(root, path));
23
+ for (const match of text?.matchAll(SEQ_CI_WORKFLOW_REF) ?? [])
24
+ releases.push(match[1]);
25
+ }
26
+ return releases;
27
+ }
@@ -35,6 +35,8 @@ export declare function compareSdk({ name, cwd }: {
35
35
  }): SdkComparison;
36
36
  /** The version of `name` this command loaded through importSdk, or undefined before it has. */
37
37
  export declare function selectedSdkVersion(name: string): string | undefined;
38
+ /** Whether the load of `name` was asked for the project's copy, including when it fell back to the bundled one. */
39
+ export declare function projectSdkRequested(name: string): boolean;
38
40
  /**
39
41
  * The file `<name><subpath>` resolves to in the copy this command loaded, so a module imported indirectly (an ORM
40
42
  * schema importing `@sequenceholdings/orm/authoring`) matches it. Undefined when that copy does not export it.
@@ -43,6 +45,19 @@ export declare function selectedSdkFile({ name, subpath }: {
43
45
  name: string;
44
46
  subpath: string;
45
47
  }): string | undefined;
48
+ /**
49
+ * What the CLI itself calls on a module it loads through importSdk, keyed by `<package><subpath>`.
50
+ *
51
+ * A list, not "every export of the bundled copy": a project pinned to an older SDK that has everything the CLI calls
52
+ * must still run, and it never has the helpers a newer bundled copy added for other callers. Add a name here when
53
+ * the CLI starts calling it (orm/delegate.ts, app/adapters.ts). A module not listed is compared against every
54
+ * bundled export.
55
+ *
56
+ * The list covers calls only. What the CLI hands a module through the environment (the ORM's break-glass reason,
57
+ * whose answer also carries the deploy notice) is not an export, so an older copy passes this check and ignores
58
+ * it: the caller that sets such a variable checks the loaded copy reads it (orm/delegate.ts breakGlassRefusal).
59
+ */
60
+ export declare const USED_SDK_EXPORTS: Readonly<Record<string, readonly string[]>>;
46
61
  /**
47
62
  * Import `<name><subpath>` from the copy this command runs. `bundled` is the CLI's own static import, so the bundler
48
63
  * keeps it. Prints a note once when the project's copy is a different version than the one used.
@@ -89,12 +89,16 @@ export function compareSdk({ name, cwd }) {
89
89
  return { name, bundled, project, differs: Boolean(bundled && project && bundled !== project) };
90
90
  }
91
91
  const noted = new Set();
92
- /** The copy of each SDK this command loaded: its version, and the project's directory when it was the project's. */
92
+ /** The copy of each SDK this command loaded: its version, the project's directory when it was the project's, and the mode asked for. */
93
93
  const selected = new Map();
94
94
  /** The version of `name` this command loaded through importSdk, or undefined before it has. */
95
95
  export function selectedSdkVersion(name) {
96
96
  return selected.get(name)?.version;
97
97
  }
98
+ /** Whether the load of `name` was asked for the project's copy, including when it fell back to the bundled one. */
99
+ export function projectSdkRequested(name) {
100
+ return selected.get(name)?.mode === 'project';
101
+ }
98
102
  /**
99
103
  * The file `<name><subpath>` resolves to in the copy this command loaded, so a module imported indirectly (an ORM
100
104
  * schema importing `@sequenceholdings/orm/authoring`) matches it. Undefined when that copy does not export it.
@@ -110,14 +114,29 @@ export function selectedSdkFile({ name, subpath }) {
110
114
  return undefined;
111
115
  }
112
116
  }
113
- /** The API of the bundled copy that the project's copy lacks. */
114
- function missingExports({ loaded, bundled }) {
117
+ /**
118
+ * What the CLI itself calls on a module it loads through importSdk, keyed by `<package><subpath>`.
119
+ *
120
+ * A list, not "every export of the bundled copy": a project pinned to an older SDK that has everything the CLI calls
121
+ * must still run, and it never has the helpers a newer bundled copy added for other callers. Add a name here when
122
+ * the CLI starts calling it (orm/delegate.ts, app/adapters.ts). A module not listed is compared against every
123
+ * bundled export.
124
+ *
125
+ * The list covers calls only. What the CLI hands a module through the environment (the ORM's break-glass reason,
126
+ * whose answer also carries the deploy notice) is not an export, so an older copy passes this check and ignores
127
+ * it: the caller that sets such a variable checks the loaded copy reads it (orm/delegate.ts breakGlassRefusal).
128
+ */
129
+ export const USED_SDK_EXPORTS = {
130
+ '@sequenceholdings/orm/cli': ['runCli', 'setTokenProvider', 'ORM_MODULE_PATH_ENV'],
131
+ };
132
+ /** The API the CLI calls (`used`; else all of the bundled copy's) that the bundled copy has and the project's lacks. */
133
+ function missingExports({ loaded, bundled, used }) {
115
134
  if (typeof bundled !== 'object' || bundled === null || typeof loaded !== 'object' || loaded === null)
116
135
  return [];
117
- return Object.keys(bundled).filter((key) => !(key in loaded));
136
+ return (used ?? Object.keys(bundled)).filter((key) => key in bundled && !(key in loaded));
118
137
  }
119
138
  /** The project's copy at `file`, or the bundled one with a warning when it cannot load or lacks what the CLI calls. */
120
- async function projectCopy({ name, file, directory, bundled, comparison }) {
139
+ async function projectCopy({ name, subpath, file, directory, bundled, comparison }) {
121
140
  const fallbackTo = comparison.bundled ?? 'copy';
122
141
  let loaded;
123
142
  try {
@@ -134,11 +153,11 @@ async function projectCopy({ name, file, directory, bundled, comparison }) {
134
153
  catch {
135
154
  // ORM and pipeline-spec are optional peers of a global CLI: with no bundled copy to compare against or fall
136
155
  // back to, the project's copy that loaded is the one to run.
137
- selected.set(name, { version: comparison.project, projectDirectory: directory });
156
+ selected.set(name, { version: comparison.project, projectDirectory: directory, mode: 'project' });
138
157
  // The project's copy of the same package, which loaded.
139
158
  return loaded;
140
159
  }
141
- const missing = missingExports({ loaded, bundled: fallback });
160
+ const missing = missingExports({ loaded, bundled: fallback, used: USED_SDK_EXPORTS[`${name}${subpath.slice(1)}`] });
142
161
  if (missing.length) {
143
162
  note(name, `warning: this project's ${name} ${comparison.project ?? ''} lacks ${missing.slice(0, 3).join(', ')}${missing.length > 3 ? ', …' : ''}, ` +
144
163
  `which seq-studio uses; using the bundled ${fallbackTo}. Upgrade the project's ${name} to run it.`);
@@ -146,8 +165,8 @@ async function projectCopy({ name, file, directory, bundled, comparison }) {
146
165
  }
147
166
  if (comparison.differs)
148
167
  note(name, `note: using this project's ${name} ${comparison.project} (sdk: project), not the bundled ${comparison.bundled}`);
149
- selected.set(name, { version: comparison.project, projectDirectory: directory });
150
- // Same exports as the bundled copy, checked above: the project's copy of the same package.
168
+ selected.set(name, { version: comparison.project, projectDirectory: directory, mode: 'project' });
169
+ // Has what the CLI calls, checked above: the project's copy of the same package.
151
170
  return loaded;
152
171
  }
153
172
  /**
@@ -160,9 +179,9 @@ export async function importSdk({ name, subpath = '.', bundled, cwd }) {
160
179
  const project = mode === 'project' ? projectSdk({ name, cwd }) : undefined;
161
180
  const file = project ? exportedFile({ directory: project.directory, subpath }) : undefined;
162
181
  // Every path below and every fallback in projectCopy loads the bundled copy; projectCopy overrides on success.
163
- selected.set(name, { version: comparison.bundled });
182
+ selected.set(name, { version: comparison.bundled, mode });
164
183
  if (file && project)
165
- return projectCopy({ name, file, directory: project.directory, bundled, comparison });
184
+ return projectCopy({ name, subpath, file, directory: project.directory, bundled, comparison });
166
185
  if (mode === 'project' && !project)
167
186
  note(name, `note: sdk: project, but this project does not install ${name}; using the bundled ${comparison.bundled ?? 'copy'}`);
168
187
  else if (comparison.differs) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sequenceholdings/studio-cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Unified Sequence Studio CLI — `seq-studio init` / `add` / `deploy` (app monorepos), `seq-studio agents`, `seq-studio process` (Lattice), `seq-studio artifact`, `seq-studio functions` / `secrets`, `seq-studio repos`, and `seq-studio auth whoami`. Includes Auth0 browser login shared with seqapi.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -53,8 +53,8 @@
53
53
  "@sequenceholdings/managed-functions": "0.5.16"
54
54
  },
55
55
  "peerDependencies": {
56
- "@sequenceholdings/orm": "2.12.1",
57
- "@sequenceholdings/pipeline-spec": "0.3.15"
56
+ "@sequenceholdings/pipeline-spec": "0.3.15",
57
+ "@sequenceholdings/orm": "2.12.1"
58
58
  },
59
59
  "peerDependenciesMeta": {
60
60
  "@sequenceholdings/orm": {
@@ -12,5 +12,6 @@
12
12
  "0.9.26": "Includes ORM 2.12.0: resolved tables can set rows: { keys: 'indexed' } so a policy or link filter that probes them by key reaches every source's index instead of rebuilding the view per probed row. Atlas checks that only the generated view reads its key relations.",
13
13
  "0.9.27": "Includes ORM 2.12.1: orm generate --migration-export writes compact JSON, so namespaces with many operations stay under the export size limit, and committed migration chain links carry their reviewed destructive flag, which repository CI reads as consent to apply that data loss.",
14
14
  "1.0.0": "seq-studio 1.0: commands, flags, exit codes and JSON output are now stable. Old spellings still work. promote, secret attach and apply, repos, and --repo from git-service are deprecated: each prints its replacement and is removed in 2.0.",
15
- "1.0.1": "Next.js artifacts may now pin next@16.4.6, which fixes two Next.js security advisories, as well as 16.4.1. New apps are still scaffolded on 16.4.1 until every Atlas environment admits 16.4.6."
15
+ "1.0.1": "Next.js artifacts may now pin next@16.4.6, which fixes two Next.js security advisories, as well as 16.4.1. New apps are still scaffolded on 16.4.1 until every Atlas environment admits 16.4.6.",
16
+ "1.0.2": "seq-studio upgrade and repo init no longer move the seq-ci workflows back to an older release when they were bumped ahead of seq_ci in .seq/github.yml. Top-level help and setup hints now point at seq-studio login <deployment-url>."
16
17
  }