@sequenceholdings/studio-cli 0.5.1 → 0.5.3

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 (54) hide show
  1. package/README.md +103 -38
  2. package/dist/agents/apply-chunks.d.ts +5 -1
  3. package/dist/agents/apply-chunks.js +4 -4
  4. package/dist/agents/commands.d.ts +10 -1
  5. package/dist/agents/commands.js +19 -2
  6. package/dist/app/adapters.d.ts +2 -2
  7. package/dist/app/adapters.js +18 -15
  8. package/dist/app/commands.d.ts +1 -1
  9. package/dist/app/commands.js +58 -20
  10. package/dist/app/deploy.d.ts +2 -0
  11. package/dist/app/deploy.js +25 -13
  12. package/dist/app/kinds.d.ts +6 -0
  13. package/dist/app/kinds.js +6 -0
  14. package/dist/app/manifest.js +1 -1
  15. package/dist/app/official-source.d.ts +10 -0
  16. package/dist/app/official-source.js +23 -0
  17. package/dist/app/prepare.d.ts +27 -0
  18. package/dist/app/prepare.js +58 -0
  19. package/dist/app/primitive-ids.d.ts +6 -0
  20. package/dist/app/primitive-ids.js +16 -0
  21. package/dist/app/primitive-scaffold.d.ts +0 -4
  22. package/dist/app/primitive-scaffold.js +7 -18
  23. package/dist/app/readme.js +17 -14
  24. package/dist/app/repository-index.d.ts +19 -0
  25. package/dist/app/repository-index.js +86 -0
  26. package/dist/app/scaffold.d.ts +12 -1
  27. package/dist/app/scaffold.js +31 -18
  28. package/dist/app/workspace-compile.d.ts +9 -0
  29. package/dist/app/workspace-compile.js +13 -1
  30. package/dist/app/workspace-scaffold.js +5 -1
  31. package/dist/auth.d.ts +17 -0
  32. package/dist/auth.js +29 -0
  33. package/dist/config.d.ts +16 -0
  34. package/dist/config.js +38 -5
  35. package/dist/env-registry.d.ts +8 -0
  36. package/dist/env-registry.js +9 -1
  37. package/dist/envs/commands.js +14 -1
  38. package/dist/functions/manifest.d.ts +4 -1
  39. package/dist/functions/manifest.js +8 -2
  40. package/dist/main.js +6 -1
  41. package/dist/orm/delegate.js +5 -2
  42. package/dist/pipeline/clone-deploy.d.ts +1 -1
  43. package/dist/pipeline/clone-deploy.js +3 -2
  44. package/dist/pipeline/commands.js +3 -2
  45. package/dist/process/commands.d.ts +6 -3
  46. package/dist/process/commands.js +26 -10
  47. package/dist/repos/commands.js +1 -1
  48. package/dist/repos/pulls.d.ts +19 -1
  49. package/dist/repos/pulls.js +15 -2
  50. package/dist/templates/process/example-process/process.ts +20 -24
  51. package/dist/templates/process/package.json +1 -1
  52. package/package.json +8 -7
  53. package/templates/process/example-process/process.ts +20 -24
  54. package/templates/process/package.json +1 -1
@@ -14,6 +14,7 @@ import { getJson, getJsonOr404, postJson, AtlasApiError } from '../atlas-client.
14
14
  import { generateProcessFiles } from './codegen.js';
15
15
  import { getAccessToken, getAccessTokenWithMode, inspectAuthPreflight, AuthTokenStoreError, NotLoggedInError, } from '../auth.js';
16
16
  import { readConfig, resolveEnv, resolveConfiguredEnv } from '../config.js';
17
+ import { currentVersion } from '../update-check.js';
17
18
  import { writeScaffoldGuidance } from '../scaffold-guidance.js';
18
19
  import { finalizeCompiledBundle, summarizeBundle } from './build.js';
19
20
  import { buildResolveProcessPinFromEnv } from './resolve-process-pin.js';
@@ -48,21 +49,31 @@ async function getEnvAndAuth(args) {
48
49
  const auth = await getAccessTokenWithMode({ env: env.name, targetUrl: env.url });
49
50
  return { authMode: auth.authMode, env, token: auth.token };
50
51
  }
52
+ /** Platform namespaces reserved for primitives other than processes. */
53
+ const OTHER_KIND_NAMESPACES = new Set([
54
+ 'agents',
55
+ 'artifacts',
56
+ 'external-systems',
57
+ 'managed-functions',
58
+ 'pipelines',
59
+ 'templates',
60
+ ]);
51
61
  /**
52
- * Parse the process-apply source flags. `--repo processes/<name>` materializes
62
+ * Parse the process-apply source flags. `--repo <namespace>/<name>` materializes
53
63
  * from the platform git service; absent means local (cwd / LATTICE_PROCESSES_ROOT).
54
64
  * `--git-url` is passed through to the underlying `resolveArtifactSource` when
55
65
  * the repo flag is a full ns/name pair (future); today only git-service is
56
66
  * supported.
57
67
  *
58
- * Process repos live exclusively in the `processes` namespace — other namespaces
59
- * (artifacts, managed-functions) are rejected to avoid cross-kind accidents.
68
+ * Process repos live in `processes`, an `apps` monorepo, or a builder's own
69
+ * namespace. Platform namespaces that hold another kind are rejected to avoid
70
+ * cross-kind accidents.
60
71
  */
61
72
  export function parseProcessSourceSpec(flags) {
62
73
  const repo = typeof flags.repo === 'string' ? flags.repo : undefined;
63
74
  const ref = typeof flags.ref === 'string' ? flags.ref : undefined;
64
75
  if (flags.repo === true)
65
- throw new Error('--repo requires a value: --repo processes/<name>');
76
+ throw new Error('--repo requires a value: --repo <namespace>/<name>');
66
77
  if (flags.ref === true)
67
78
  throw new Error('--ref requires a value.');
68
79
  if (flags.dir === true)
@@ -77,17 +88,21 @@ export function parseProcessSourceSpec(flags) {
77
88
  return { kind: 'local' };
78
89
  const parts = repo.split('/');
79
90
  if (parts.length !== 2 || !parts[0] || !parts[1]) {
80
- throw new Error(`--repo must be "processes/<name>" (got "${repo}").`);
91
+ throw new Error(`--repo must be "<namespace>/<name>", such as processes/<name> or your app's namespace (got "${repo}").`);
81
92
  }
82
- if (parts[0] !== 'processes') {
83
- throw new Error(`Process deploys require the "processes" namespace — got "${parts[0]}". ` +
84
- `Use --repo processes/<name>.`);
93
+ if (OTHER_KIND_NAMESPACES.has(parts[0])) {
94
+ throw new Error(`The "${parts[0]}" namespace holds another kind of primitive, not processes. ` +
95
+ `Use --repo processes/<name> or your app's namespace.`);
85
96
  }
86
97
  return { kind: 'git-service', namespace: parts[0], name: parts[1], ref };
87
98
  }
88
99
  // ---------------------------------------------------------------------------
89
100
  // init
90
101
  // ---------------------------------------------------------------------------
102
+ /** The last segment of a directory path, whichever separator the platform uses. */
103
+ export function scaffoldName(dir) {
104
+ return dir.split(/[\\/]/).filter(Boolean).at(-1) ?? 'my-process';
105
+ }
91
106
  export async function initCommand(args) {
92
107
  const target = args.positional[0];
93
108
  if (!target) {
@@ -95,7 +110,7 @@ export async function initCommand(args) {
95
110
  return 1;
96
111
  }
97
112
  const dir = resolve(target);
98
- const name = dir.split('/').filter(Boolean).at(-1) ?? 'my-process';
113
+ const name = scaffoldName(dir);
99
114
  if (existsSync(dir)) {
100
115
  console.error(`${dir} already exists`);
101
116
  return 1;
@@ -129,7 +144,8 @@ export async function initCommand(args) {
129
144
  if (existsSync(path)) {
130
145
  const body = (await readFile(path, 'utf8'))
131
146
  .replace(/\{\{name\}\}/g, name)
132
- .replace(/\{\{slug\}\}/g, slug);
147
+ .replace(/\{\{slug\}\}/g, slug)
148
+ .replace(/\{\{cliVersion\}\}/g, currentVersion());
133
149
  await writeFile(path, body, 'utf8');
134
150
  }
135
151
  }
@@ -173,7 +173,7 @@ export async function reposNamespacesCommand(args) {
173
173
  const ctx = await reposContext(args);
174
174
  if (action === 'create') {
175
175
  if (!slug) {
176
- console.error('usage: seq-studio repos namespaces create <slug> -e <env>');
176
+ console.error('usage: seq-studio repos namespaces create <slug> -e <env> (needs Can create on Repositories)');
177
177
  return 1;
178
178
  }
179
179
  const created = await postJson({
@@ -1,3 +1,21 @@
1
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";
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. When repository CI\n checks the branch, merge sends the checked head and base revisions; a newer push\n makes the server refuse until checks rerun. 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
+ /** Only the revisions this command needs from GET .../pulls/<n>/ci. */
4
+ interface PullCiStatus {
5
+ plan?: {
6
+ headSha?: string;
7
+ baseSha?: string;
8
+ } | null;
9
+ }
10
+ /**
11
+ * A branch under repository CI only merges the exact revisions its checks
12
+ * planned (the server returns 409 without them). Unchecked branches need none.
13
+ */
14
+ export declare function checkedMergeRevision({ fetchStatus }: {
15
+ fetchStatus: () => Promise<PullCiStatus>;
16
+ }): Promise<{
17
+ expectedHeadSha: string;
18
+ expectedBaseSha: string;
19
+ } | Record<string, never>>;
3
20
  export declare function reposPullsCommand(input: ParsedArgs): Promise<number>;
21
+ export {};
@@ -15,14 +15,25 @@ export const PULLS_USAGE = `usage:
15
15
  All results are JSON (--json is accepted). Authenticate: seq-studio login --env <env>.
16
16
  create needs repository write; merge needs merge/admin authority and passing server
17
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.
18
+ Merge operates on the current branch head under server policy. When repository CI
19
+ checks the branch, merge sends the checked head and base revisions; a newer push
20
+ makes the server refuse until checks rerun. Default merge method: squash.
20
21
  list returns one page with nextCursor; pass --cursor to continue.
21
22
  diff compares live base/head branches for open Pulls, recorded SHAs for terminal
22
23
  Pulls, and reports truncated when its file
23
24
  limit is reached (default 100, maximum 500).
24
25
  repos pull (singular) materializes files; repos pulls manages review requests.
25
26
  `;
27
+ /**
28
+ * A branch under repository CI only merges the exact revisions its checks
29
+ * planned (the server returns 409 without them). Unchecked branches need none.
30
+ */
31
+ export async function checkedMergeRevision({ fetchStatus }) {
32
+ const status = await fetchStatus();
33
+ const headSha = status.plan?.headSha;
34
+ const baseSha = status.plan?.baseSha;
35
+ return headSha && baseSha ? { expectedHeadSha: headSha, expectedBaseSha: baseSha } : {};
36
+ }
26
37
  function integerFlag({ args, key, max }) {
27
38
  const value = args.flags[key];
28
39
  if (value === undefined)
@@ -66,9 +77,11 @@ async function mergePull({ args, ctx, path, repoPath }) {
66
77
  const confirmed = await confirmYes({ confirmed: args.flags.yes === true, preview: [] });
67
78
  if (!confirmed)
68
79
  return 1;
80
+ const revision = await checkedMergeRevision({ fetchStatus: () => getJson({ ...clientOptions(ctx), path: `${path}/ci` }) });
69
81
  const result = await postJson({ ...clientOptions(ctx), path: `${path}/merge`, body: {
70
82
  method: args.flags.method ?? 'squash',
71
83
  ...(args.flags.message === undefined ? {} : { message: args.flags.message }),
84
+ ...revision,
72
85
  } });
73
86
  console.log(JSON.stringify(result, null, 2));
74
87
  return 0;
@@ -1,43 +1,39 @@
1
- import {
2
- defineProcess,
3
- defineNativeAutomationNode,
4
- defineHumanNode,
5
- } from '@sequenceholdings/lattice'
6
-
7
- // Automation nodes run a function registered in the Atlas native-function
8
- // registry, referenced by id. `health-check` is the built-in reference handler;
9
- // swap in your own id once you register it under
10
- // atlas/src/server/lib/lattice/native-functions/functions/.
11
- const start = defineNativeAutomationNode({
12
- id: 'start',
13
- title: 'Start',
14
- outgoing_edges: [{ id: 'start-to-review', to: 'review' }] as const,
15
- function: 'health-check',
16
- })
1
+ import { defineProcess, defineHumanNode } from '@sequenceholdings/lattice'
17
2
 
3
+ // A starter process any author can publish: people-only steps, so it needs no
4
+ // service account. To automate a step, add a Managed Function or agent node
5
+ // (defineManagedFunctionNode / defineAgentNode) with
6
+ // `run_as: { service_account: '<account id>' }` — automation always runs as a
7
+ // service account you hold the Actor role on. `close` is the natural step to
8
+ // replace with a function that records the result.
18
9
  const review = defineHumanNode({
19
10
  id: 'review',
20
11
  title: 'Review',
21
12
  outgoing_edges: [
22
- { id: 'approve', to: 'done' },
23
- { id: 'reject', to: 'done' },
13
+ { id: 'approve', to: 'close' },
14
+ { id: 'reject', to: 'close' },
24
15
  ] as const,
25
16
  artifact_refs: [],
26
17
  metadata: {},
27
18
  timeout: '7d',
19
+ // An unanswered review rejects after 7 days; every timeout needs a route.
20
+ on_timeout_edge_id: 'reject',
28
21
  })
29
22
 
30
- const done = defineNativeAutomationNode({
31
- id: 'done',
32
- title: 'Done',
23
+ // No outgoing edges: completing this step completes the run.
24
+ const close = defineHumanNode({
25
+ id: 'close',
26
+ title: 'Close',
33
27
  outgoing_edges: [] as const,
34
- function: 'health-check',
28
+ artifact_refs: [],
29
+ metadata: {},
30
+ completeLabel: 'Close',
35
31
  })
36
32
 
37
33
  export default defineProcess({
38
34
  id: '{{slug}}',
39
35
  name: '{{name}}',
40
36
  entity: { type: '{{slug}}' },
41
- start_node_id: 'start',
42
- nodes: [start, review, done],
37
+ start_node_id: 'review',
38
+ nodes: [review, close],
43
39
  })
@@ -7,7 +7,7 @@
7
7
  "@sequenceholdings/lattice": "^0.1.5"
8
8
  },
9
9
  "devDependencies": {
10
- "@sequenceholdings/studio-cli": "^0.4.0",
10
+ "@sequenceholdings/studio-cli": "^{{cliVersion}}",
11
11
  "@types/node": "^22.0.0",
12
12
  "typescript": "^5.6.0"
13
13
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sequenceholdings/studio-cli",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
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": {
@@ -41,15 +41,16 @@
41
41
  "smol-toml": "^1.9.0",
42
42
  "tsx": "^4.20.3",
43
43
  "zod": "^4.1.13",
44
- "@sequenceholdings/artifact-studio": "0.7.0",
44
+ "yaml": "^2.8.4",
45
45
  "@sequenceholdings/agent-spec": "0.1.3",
46
+ "@sequenceholdings/artifact-studio": "0.8.0",
46
47
  "@sequenceholdings/lattice": "0.1.5",
47
- "@sequenceholdings/managed-functions": "0.4.0",
48
+ "@sequenceholdings/managed-functions": "0.4.1",
48
49
  "@sequenceholdings/storage": "0.1.1"
49
50
  },
50
51
  "peerDependencies": {
51
- "@sequenceholdings/pipeline-spec": "0.2.4",
52
- "@sequenceholdings/orm": "2.6.0"
52
+ "@sequenceholdings/orm": "2.6.1",
53
+ "@sequenceholdings/pipeline-spec": "0.2.5"
53
54
  },
54
55
  "peerDependenciesMeta": {
55
56
  "@sequenceholdings/orm": {
@@ -64,8 +65,8 @@
64
65
  "@types/node": "^22.0.0",
65
66
  "typescript": "^5.6.0",
66
67
  "vitest": "^4.1.11",
67
- "@sequenceholdings/orm": "2.6.0",
68
- "@sequenceholdings/pipeline-spec": "0.2.4"
68
+ "@sequenceholdings/orm": "2.6.1",
69
+ "@sequenceholdings/pipeline-spec": "0.2.5"
69
70
  },
70
71
  "engines": {
71
72
  "node": ">=20"
@@ -1,43 +1,39 @@
1
- import {
2
- defineProcess,
3
- defineNativeAutomationNode,
4
- defineHumanNode,
5
- } from '@sequenceholdings/lattice'
6
-
7
- // Automation nodes run a function registered in the Atlas native-function
8
- // registry, referenced by id. `health-check` is the built-in reference handler;
9
- // swap in your own id once you register it under
10
- // atlas/src/server/lib/lattice/native-functions/functions/.
11
- const start = defineNativeAutomationNode({
12
- id: 'start',
13
- title: 'Start',
14
- outgoing_edges: [{ id: 'start-to-review', to: 'review' }] as const,
15
- function: 'health-check',
16
- })
1
+ import { defineProcess, defineHumanNode } from '@sequenceholdings/lattice'
17
2
 
3
+ // A starter process any author can publish: people-only steps, so it needs no
4
+ // service account. To automate a step, add a Managed Function or agent node
5
+ // (defineManagedFunctionNode / defineAgentNode) with
6
+ // `run_as: { service_account: '<account id>' }` — automation always runs as a
7
+ // service account you hold the Actor role on. `close` is the natural step to
8
+ // replace with a function that records the result.
18
9
  const review = defineHumanNode({
19
10
  id: 'review',
20
11
  title: 'Review',
21
12
  outgoing_edges: [
22
- { id: 'approve', to: 'done' },
23
- { id: 'reject', to: 'done' },
13
+ { id: 'approve', to: 'close' },
14
+ { id: 'reject', to: 'close' },
24
15
  ] as const,
25
16
  artifact_refs: [],
26
17
  metadata: {},
27
18
  timeout: '7d',
19
+ // An unanswered review rejects after 7 days; every timeout needs a route.
20
+ on_timeout_edge_id: 'reject',
28
21
  })
29
22
 
30
- const done = defineNativeAutomationNode({
31
- id: 'done',
32
- title: 'Done',
23
+ // No outgoing edges: completing this step completes the run.
24
+ const close = defineHumanNode({
25
+ id: 'close',
26
+ title: 'Close',
33
27
  outgoing_edges: [] as const,
34
- function: 'health-check',
28
+ artifact_refs: [],
29
+ metadata: {},
30
+ completeLabel: 'Close',
35
31
  })
36
32
 
37
33
  export default defineProcess({
38
34
  id: '{{slug}}',
39
35
  name: '{{name}}',
40
36
  entity: { type: '{{slug}}' },
41
- start_node_id: 'start',
42
- nodes: [start, review, done],
37
+ start_node_id: 'review',
38
+ nodes: [review, close],
43
39
  })
@@ -7,7 +7,7 @@
7
7
  "@sequenceholdings/lattice": "^0.1.5"
8
8
  },
9
9
  "devDependencies": {
10
- "@sequenceholdings/studio-cli": "^0.4.0",
10
+ "@sequenceholdings/studio-cli": "^{{cliVersion}}",
11
11
  "@types/node": "^22.0.0",
12
12
  "typescript": "^5.6.0"
13
13
  },