@sequenceholdings/studio-cli 0.1.26 → 0.1.28
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 +265 -81
- package/dist/app/adapters.d.ts +9 -0
- package/dist/app/adapters.js +176 -0
- package/dist/app/commands.d.ts +2 -2
- package/dist/app/commands.js +98 -22
- package/dist/app/deploy.d.ts +9 -10
- package/dist/app/deploy.js +83 -141
- package/dist/app/graph.d.ts +15 -0
- package/dist/app/graph.js +36 -0
- package/dist/app/manifest-validation.d.ts +16 -0
- package/dist/app/manifest-validation.js +99 -0
- package/dist/app/manifest.d.ts +27 -9
- package/dist/app/manifest.js +23 -107
- package/dist/app/paths.d.ts +14 -0
- package/dist/app/paths.js +77 -0
- package/dist/app/primitive-scaffold.d.ts +18 -0
- package/dist/app/primitive-scaffold.js +136 -0
- package/dist/app/readme.d.ts +4 -18
- package/dist/app/readme.js +107 -229
- package/dist/app/run-deployment.d.ts +8 -0
- package/dist/app/run-deployment.js +50 -0
- package/dist/app/scaffold-files.d.ts +13 -0
- package/dist/app/scaffold-files.js +68 -0
- package/dist/app/scaffold.d.ts +11 -3
- package/dist/app/scaffold.js +77 -245
- package/dist/app/workspace-compile.d.ts +18 -0
- package/dist/app/workspace-compile.js +143 -0
- package/dist/app/workspace-model.d.ts +70 -0
- package/dist/app/workspace-model.js +159 -0
- package/dist/app/workspace-scaffold.d.ts +27 -0
- package/dist/app/workspace-scaffold.js +126 -0
- package/dist/app/workspace.d.ts +14 -0
- package/dist/app/workspace.js +147 -0
- package/dist/atlas-client.js +28 -6
- package/dist/auth-cmds/commands.d.ts +1 -1
- package/dist/auth-cmds/commands.js +5 -2
- package/dist/functions/commands.js +7 -1
- package/dist/functions/manifest.d.ts +18 -0
- package/dist/functions/manifest.js +29 -4
- package/dist/main.js +9 -4
- package/dist/orm/delegate.js +30 -23
- package/dist/pat-hints.js +1 -0
- package/dist/pipeline/commands.js +27 -9
- package/dist/pipeline/lifecycle.d.ts +2 -0
- package/dist/pipeline/lifecycle.js +91 -11
- package/dist/process/build.js +59 -43
- package/dist/process/codegen.d.ts +3 -2
- package/dist/process/codegen.js +143 -27
- package/dist/process/commands.d.ts +2 -0
- package/dist/process/commands.js +63 -18
- package/dist/process/discover.d.ts +6 -3
- package/dist/process/discover.js +11 -3
- package/dist/process/lint.d.ts +14 -0
- package/dist/process/lint.js +143 -5
- package/dist/process/plan-diff.d.ts +8 -0
- package/dist/process/plan-diff.js +61 -4
- package/dist/process/safety-baseline.d.ts +154 -0
- package/dist/process/safety-baseline.js +387 -0
- package/dist/process/simulate.js +64 -22
- package/dist/repos/commands.d.ts +1 -1
- package/dist/repos/commands.js +29 -3
- package/package.json +8 -7
package/dist/app/manifest.js
CHANGED
|
@@ -5,15 +5,16 @@
|
|
|
5
5
|
* scaffolding and for the eventual Applications UI. Crawl-only discovery is
|
|
6
6
|
* intentionally not supported — `seq-studio init` / `add` own this file.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* Version 2 is the app deployment graph; version 1 keeps its legacy ordering.
|
|
9
9
|
*/
|
|
10
10
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
11
11
|
import { join, resolve } from 'node:path';
|
|
12
12
|
import { dump as yamlDump, load as yamlLoad } from 'js-yaml';
|
|
13
13
|
import { z } from 'zod';
|
|
14
14
|
import { currentVersion, isNewerVersion } from '../update-check.js';
|
|
15
|
+
import { validateManifestGraph } from './manifest-validation.js';
|
|
15
16
|
export const APP_MANIFEST_FILENAME = 'sequence.app.yml';
|
|
16
|
-
export const PRIMITIVE_KINDS = ['orm', 'function', 'artifact'];
|
|
17
|
+
export const PRIMITIVE_KINDS = ['orm', 'function', 'agent', 'process', 'pipeline', 'artifact'];
|
|
17
18
|
export function isPrimitiveKind(value) {
|
|
18
19
|
return PRIMITIVE_KINDS.includes(value);
|
|
19
20
|
}
|
|
@@ -31,7 +32,12 @@ const primitiveEntrySchema = z
|
|
|
31
32
|
namespace: z.string().min(1).optional(),
|
|
32
33
|
slug: z.string().min(1).optional(),
|
|
33
34
|
project_id: z.string().min(1).optional(),
|
|
35
|
+
target: z.string().min(1).optional(),
|
|
36
|
+
only: z.array(z.string().min(1)).min(1).optional(),
|
|
37
|
+
repo: z.string().regex(/^pipelines\/[a-z0-9][a-z0-9-]*$/).optional(),
|
|
38
|
+
ref: z.string().min(1).refine((ref) => !ref.startsWith('-'), 'ref cannot start with -').optional(),
|
|
34
39
|
})
|
|
40
|
+
.strict()
|
|
35
41
|
.superRefine((entry, ctx) => {
|
|
36
42
|
if (entry.kind === 'orm' && entry.namespace === undefined) {
|
|
37
43
|
ctx.addIssue({ code: 'custom', message: `orm primitive "${entry.id}" requires namespace`, path: ['namespace'] });
|
|
@@ -47,114 +53,36 @@ const primitiveEntrySchema = z
|
|
|
47
53
|
});
|
|
48
54
|
}
|
|
49
55
|
});
|
|
56
|
+
const relativeDirectorySchema = z.string().min(1).refine((path) => path.trim() === path && !path.includes('\\') && !/^[A-Za-z]:/.test(path) &&
|
|
57
|
+
!/[\x00-\x1f]/.test(path) && path.split('/').every((part) => part !== '' && part !== '.' && part !== '..'), 'path must be a relative directory within the app root');
|
|
50
58
|
export const appManifestSchema = z
|
|
51
59
|
.object({
|
|
52
|
-
schema_version: z.literal(1),
|
|
60
|
+
schema_version: z.union([z.literal(1), z.literal(2)]),
|
|
53
61
|
app: z.object({
|
|
54
62
|
id: appIdSchema,
|
|
55
63
|
title: z.string().min(1),
|
|
56
64
|
description: z.string().optional(),
|
|
57
|
-
}),
|
|
65
|
+
}).strict(),
|
|
58
66
|
studio: z.object({
|
|
59
67
|
created_with: z.string().min(1),
|
|
60
68
|
min_cli: z.string().min(1),
|
|
61
|
-
}),
|
|
69
|
+
}).strict(),
|
|
62
70
|
primitives: z.array(primitiveEntrySchema),
|
|
71
|
+
packages: z.array(z.object({
|
|
72
|
+
name: z.string().regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/),
|
|
73
|
+
path: relativeDirectorySchema,
|
|
74
|
+
}).strict()).optional(),
|
|
63
75
|
deploy: z
|
|
64
76
|
.object({
|
|
65
77
|
order: z.array(z.string().min(1)).optional(),
|
|
66
78
|
on_error: z.enum(['stop', 'continue']).default('stop'),
|
|
67
|
-
})
|
|
79
|
+
}).strict()
|
|
68
80
|
.default({ on_error: 'stop' }),
|
|
69
|
-
})
|
|
70
|
-
.superRefine(
|
|
71
|
-
const seenIds = new Set();
|
|
72
|
-
const seenPaths = new Set();
|
|
73
|
-
for (const [index, entry] of manifest.primitives.entries()) {
|
|
74
|
-
if (seenIds.has(entry.id)) {
|
|
75
|
-
ctx.addIssue({
|
|
76
|
-
code: 'custom',
|
|
77
|
-
message: `duplicate primitive id "${entry.id}"`,
|
|
78
|
-
path: ['primitives', index, 'id'],
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
seenIds.add(entry.id);
|
|
82
|
-
if (seenPaths.has(entry.path)) {
|
|
83
|
-
ctx.addIssue({
|
|
84
|
-
code: 'custom',
|
|
85
|
-
message: `duplicate primitive path "${entry.path}"`,
|
|
86
|
-
path: ['primitives', index, 'path'],
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
seenPaths.add(entry.path);
|
|
90
|
-
}
|
|
91
|
-
for (const [index, entry] of manifest.primitives.entries()) {
|
|
92
|
-
for (const [depIndex, dep] of entry.depends_on.entries()) {
|
|
93
|
-
if (!seenIds.has(dep)) {
|
|
94
|
-
ctx.addIssue({
|
|
95
|
-
code: 'custom',
|
|
96
|
-
message: `depends_on references unknown primitive id "${dep}"`,
|
|
97
|
-
path: ['primitives', index, 'depends_on', depIndex],
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
const order = manifest.deploy.order;
|
|
103
|
-
if (order !== undefined) {
|
|
104
|
-
const seenOrder = new Set();
|
|
105
|
-
for (const [index, id] of order.entries()) {
|
|
106
|
-
if (seenOrder.has(id)) {
|
|
107
|
-
ctx.addIssue({
|
|
108
|
-
code: 'custom',
|
|
109
|
-
message: `duplicate deploy.order entry "${id}"`,
|
|
110
|
-
path: ['deploy', 'order', index],
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
seenOrder.add(id);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
// Effective deploy order (explicit + missing ids, or default kind ranking).
|
|
117
|
-
const effectiveOrder = order && order.length > 0
|
|
118
|
-
? (() => {
|
|
119
|
-
const ordered = [...order];
|
|
120
|
-
for (const entry of manifest.primitives) {
|
|
121
|
-
if (!ordered.includes(entry.id))
|
|
122
|
-
ordered.push(entry.id);
|
|
123
|
-
}
|
|
124
|
-
return ordered;
|
|
125
|
-
})()
|
|
126
|
-
: defaultDeployOrderForValidation(manifest.primitives);
|
|
127
|
-
const position = new Map(effectiveOrder.map((id, index) => [id, index]));
|
|
128
|
-
for (const entry of manifest.primitives) {
|
|
129
|
-
const entryPos = position.get(entry.id);
|
|
130
|
-
if (entryPos === undefined)
|
|
131
|
-
continue;
|
|
132
|
-
for (const dep of entry.depends_on) {
|
|
133
|
-
const depPos = position.get(dep);
|
|
134
|
-
if (depPos === undefined)
|
|
135
|
-
continue;
|
|
136
|
-
if (depPos >= entryPos) {
|
|
137
|
-
ctx.addIssue({
|
|
138
|
-
code: 'custom',
|
|
139
|
-
message: `deploy order places "${entry.id}" before its dependency "${dep}"`,
|
|
140
|
-
path: ['deploy', 'order'],
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
});
|
|
81
|
+
}).strict()
|
|
82
|
+
.superRefine(validateManifestGraph);
|
|
146
83
|
/** Local helper so schema refinement does not depend on later exports. */
|
|
147
84
|
function defaultDeployOrderForValidation(primitives) {
|
|
148
|
-
const rank = (kind) =>
|
|
149
|
-
switch (kind) {
|
|
150
|
-
case 'orm':
|
|
151
|
-
return 0;
|
|
152
|
-
case 'function':
|
|
153
|
-
return 1;
|
|
154
|
-
case 'artifact':
|
|
155
|
-
return 2;
|
|
156
|
-
}
|
|
157
|
-
};
|
|
85
|
+
const rank = (kind) => PRIMITIVE_KINDS.indexOf(kind);
|
|
158
86
|
return [...primitives]
|
|
159
87
|
.sort((a, b) => rank(a.kind) - rank(b.kind) || a.id.localeCompare(b.id))
|
|
160
88
|
.map((entry) => entry.id);
|
|
@@ -217,24 +145,12 @@ export async function writeAppManifest({ rootDir, manifest, }) {
|
|
|
217
145
|
noRefs: true,
|
|
218
146
|
sortKeys: false,
|
|
219
147
|
});
|
|
220
|
-
await writeFile(path, `#
|
|
148
|
+
await writeFile(path, `# Sequence app bundle — review deployment dependencies and package sources in git.\n${body}`, 'utf8');
|
|
221
149
|
return path;
|
|
222
150
|
}
|
|
223
151
|
/** Default deploy order: orm → functions → artifact. */
|
|
224
152
|
export function defaultDeployOrder(primitives) {
|
|
225
|
-
|
|
226
|
-
switch (kind) {
|
|
227
|
-
case 'orm':
|
|
228
|
-
return 0;
|
|
229
|
-
case 'function':
|
|
230
|
-
return 1;
|
|
231
|
-
case 'artifact':
|
|
232
|
-
return 2;
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
return [...primitives]
|
|
236
|
-
.sort((a, b) => rank(a.kind) - rank(b.kind) || a.id.localeCompare(b.id))
|
|
237
|
-
.map((entry) => entry.id);
|
|
153
|
+
return defaultDeployOrderForValidation(primitives);
|
|
238
154
|
}
|
|
239
155
|
/**
|
|
240
156
|
* Extend deploy.order when adding a primitive. Preserves any explicit custom
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Check existing parents before creating ignored build/report directories. */
|
|
2
|
+
export declare function ensureAppOutputDirectory({ rootDir, entryPath }: {
|
|
3
|
+
rootDir: string;
|
|
4
|
+
entryPath: string;
|
|
5
|
+
}): Promise<string>;
|
|
6
|
+
/**
|
|
7
|
+
* Resolve a manifest primitive path under the app root. Rejects absolute paths,
|
|
8
|
+
* lexical traversal, and symlink escapes (via realpath) before a deployer runs.
|
|
9
|
+
* Missing targets keep the lexical candidate after a lexical containment check.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveContainedPrimitivePath({ rootDir, entryPath, }: {
|
|
12
|
+
rootDir: string;
|
|
13
|
+
entryPath: string;
|
|
14
|
+
}): Promise<string>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { mkdir, realpath } from 'node:fs/promises';
|
|
2
|
+
import { isAbsolute, relative, resolve, sep } from 'node:path';
|
|
3
|
+
const APP_MANIFEST_HINT = 'sequence.app.yml';
|
|
4
|
+
/** Check existing parents before creating ignored build/report directories. */
|
|
5
|
+
export async function ensureAppOutputDirectory({ rootDir, entryPath }) {
|
|
6
|
+
assertRelativePrimitivePath(entryPath);
|
|
7
|
+
const root = await realpath(rootDir);
|
|
8
|
+
let directory = root;
|
|
9
|
+
for (const segment of entryPath.split('/')) {
|
|
10
|
+
directory = resolve(directory, segment);
|
|
11
|
+
try {
|
|
12
|
+
directory = await realpath(directory);
|
|
13
|
+
assertPathInsideRoot({ rootDir: root, candidate: directory, entryPath });
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
if (!(error instanceof Error) || !('code' in error) || error.code !== 'ENOENT')
|
|
17
|
+
throw error;
|
|
18
|
+
await mkdir(directory);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return directory;
|
|
22
|
+
}
|
|
23
|
+
function assertRelativePrimitivePath(entryPath) {
|
|
24
|
+
const segments = entryPath.split('/');
|
|
25
|
+
if (entryPath.length === 0 ||
|
|
26
|
+
entryPath.trim() !== entryPath ||
|
|
27
|
+
isAbsolute(entryPath) ||
|
|
28
|
+
entryPath.includes('\\') ||
|
|
29
|
+
[...entryPath].some((character) => character.charCodeAt(0) < 0x20) ||
|
|
30
|
+
segments.some((segment) => segment.length === 0 || segment === '.' || segment === '..')) {
|
|
31
|
+
throw new Error(`${APP_MANIFEST_HINT}: primitive path must be a relative directory within the app root (got ${JSON.stringify(entryPath)})`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function assertPathInsideRoot({ rootDir, candidate, entryPath, }) {
|
|
35
|
+
const relativePath = relative(rootDir, candidate);
|
|
36
|
+
if (relativePath === '..' ||
|
|
37
|
+
relativePath.startsWith(`..${sep}`) ||
|
|
38
|
+
isAbsolute(relativePath)) {
|
|
39
|
+
throw new Error(`${APP_MANIFEST_HINT}: primitive path escapes the app root (got ${JSON.stringify(entryPath)})`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Resolve a manifest primitive path under the app root. Rejects absolute paths,
|
|
44
|
+
* lexical traversal, and symlink escapes (via realpath) before a deployer runs.
|
|
45
|
+
* Missing targets keep the lexical candidate after a lexical containment check.
|
|
46
|
+
*/
|
|
47
|
+
export async function resolveContainedPrimitivePath({ rootDir, entryPath, }) {
|
|
48
|
+
assertRelativePrimitivePath(entryPath);
|
|
49
|
+
const root = resolve(rootDir);
|
|
50
|
+
let canonicalRoot = root;
|
|
51
|
+
try {
|
|
52
|
+
canonicalRoot = await realpath(root);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (error.code !== 'ENOENT')
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
// Resolve against the canonical root so macOS /var → /private/var does not
|
|
59
|
+
// look like an escape when comparing realpath(root) to a lexical candidate.
|
|
60
|
+
const candidate = resolve(canonicalRoot, entryPath);
|
|
61
|
+
assertPathInsideRoot({ rootDir: canonicalRoot, candidate, entryPath });
|
|
62
|
+
try {
|
|
63
|
+
const canonicalCandidate = await realpath(candidate);
|
|
64
|
+
assertPathInsideRoot({
|
|
65
|
+
rootDir: canonicalRoot,
|
|
66
|
+
candidate: canonicalCandidate,
|
|
67
|
+
entryPath,
|
|
68
|
+
});
|
|
69
|
+
return canonicalCandidate;
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
if (error.code !== 'ENOENT')
|
|
73
|
+
throw error;
|
|
74
|
+
// Target does not exist yet (dry-run / pre-scaffold) — lexical check stands.
|
|
75
|
+
return candidate;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type PrimitiveEntry, type PrimitiveKind } from './manifest.js';
|
|
2
|
+
export type AppPipelineType = 'ingestion' | 'transformation' | 'serving';
|
|
3
|
+
export declare function primitiveIdFor({ kind, name }: {
|
|
4
|
+
kind: PrimitiveKind;
|
|
5
|
+
name: string;
|
|
6
|
+
}): string;
|
|
7
|
+
export declare function relativePathFor({ kind, appId, name, }: {
|
|
8
|
+
kind: PrimitiveKind;
|
|
9
|
+
appId: string;
|
|
10
|
+
name: string;
|
|
11
|
+
}): string;
|
|
12
|
+
export declare function scaffoldKind({ kind, appRoot, appId, name, pipelineType, }: {
|
|
13
|
+
kind: PrimitiveKind;
|
|
14
|
+
appRoot: string;
|
|
15
|
+
appId: string;
|
|
16
|
+
name: string;
|
|
17
|
+
pipelineType?: AppPipelineType;
|
|
18
|
+
}): Promise<PrimitiveEntry>;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/** Per-primitive scaffolding delegates to each primitive's real init command. */
|
|
2
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { dirname, join } from 'node:path';
|
|
5
|
+
import { functionsInitCommand } from '../functions/commands.js';
|
|
6
|
+
import { initCommand as processInitCommand, parseArgs } from '../process/commands.js';
|
|
7
|
+
import { agentsInitCommand } from '../agents/scaffold.js';
|
|
8
|
+
import { pipelineInitCommand } from '../pipeline/commands.js';
|
|
9
|
+
import { ormNamespaceFromAppId, titleizeSlug } from './manifest.js';
|
|
10
|
+
export function primitiveIdFor({ kind, name }) {
|
|
11
|
+
switch (kind) {
|
|
12
|
+
case 'orm':
|
|
13
|
+
return `${name}-orm`;
|
|
14
|
+
case 'artifact':
|
|
15
|
+
return `${name}-ui`;
|
|
16
|
+
case 'function':
|
|
17
|
+
return name;
|
|
18
|
+
case 'agent':
|
|
19
|
+
case 'process':
|
|
20
|
+
case 'pipeline':
|
|
21
|
+
return `${name}-${kind}`;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function relativePathFor({ kind, appId, name, }) {
|
|
25
|
+
switch (kind) {
|
|
26
|
+
case 'orm':
|
|
27
|
+
return join('orm', ormNamespaceFromAppId(name));
|
|
28
|
+
case 'function':
|
|
29
|
+
return join('functions', name);
|
|
30
|
+
case 'artifact':
|
|
31
|
+
return name === appId ? 'artifact' : join('artifacts', name);
|
|
32
|
+
case 'agent':
|
|
33
|
+
return join('agents', name);
|
|
34
|
+
case 'process':
|
|
35
|
+
return join('processes', name);
|
|
36
|
+
case 'pipeline':
|
|
37
|
+
return join('pipelines', name);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function buildPrimitiveEntry({ kind, appId, name, dependsOn, }) {
|
|
41
|
+
const path = relativePathFor({ kind, appId, name }).replace(/\\/g, '/');
|
|
42
|
+
const id = primitiveIdFor({ kind, name });
|
|
43
|
+
const base = { id, kind, path, depends_on: dependsOn };
|
|
44
|
+
switch (kind) {
|
|
45
|
+
case 'orm':
|
|
46
|
+
return { ...base, namespace: ormNamespaceFromAppId(name) };
|
|
47
|
+
case 'function':
|
|
48
|
+
return { ...base, slug: name };
|
|
49
|
+
case 'artifact':
|
|
50
|
+
return { ...base, project_id: name };
|
|
51
|
+
case 'agent':
|
|
52
|
+
case 'process':
|
|
53
|
+
case 'pipeline':
|
|
54
|
+
return base;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async function rewriteArtifactIdentity({ artifactDir, appId, }) {
|
|
58
|
+
const title = titleizeSlug(appId);
|
|
59
|
+
const manifestPath = join(artifactDir, 'artifact.bundle.yml');
|
|
60
|
+
if (existsSync(manifestPath)) {
|
|
61
|
+
const body = await readFile(manifestPath, 'utf8');
|
|
62
|
+
const next = body
|
|
63
|
+
.replace(/(project_id:\s*)\S+/g, `$1${appId}`)
|
|
64
|
+
.replace(/^(\s*)title:\s*.*$/m, `$1title: "${title}"`);
|
|
65
|
+
if (next !== body)
|
|
66
|
+
await writeFile(manifestPath, next, 'utf8');
|
|
67
|
+
}
|
|
68
|
+
const pkgPath = join(artifactDir, 'package.json');
|
|
69
|
+
if (existsSync(pkgPath)) {
|
|
70
|
+
try {
|
|
71
|
+
const pkg = JSON.parse(await readFile(pkgPath, 'utf8'));
|
|
72
|
+
pkg.name = appId;
|
|
73
|
+
await writeFile(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`, 'utf8');
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
// leave non-JSON package.json alone
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async function scaffoldOrm({ absPath }) {
|
|
81
|
+
const { runOrmCommand } = await import('../orm/delegate.js');
|
|
82
|
+
const code = await runOrmCommand('init', [absPath]);
|
|
83
|
+
if (code !== 0) {
|
|
84
|
+
throw new Error(`orm init failed for ${absPath} (exit ${code}). ` +
|
|
85
|
+
'`seq-studio init --with orm` requires `@sequenceholdings/orm` ' +
|
|
86
|
+
'(workspace / internal installs today; not yet available via public npm).');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async function scaffoldArtifact({ absPath, appId, }) {
|
|
90
|
+
const { runCli } = await import('@sequenceholdings/artifact-studio/cli');
|
|
91
|
+
const code = await runCli(['init', absPath]);
|
|
92
|
+
if (code !== 0) {
|
|
93
|
+
throw new Error(`artifact init failed for ${absPath} (exit ${code})`);
|
|
94
|
+
}
|
|
95
|
+
await rewriteArtifactIdentity({ artifactDir: absPath, appId });
|
|
96
|
+
}
|
|
97
|
+
async function scaffoldFunction({ absPath }) {
|
|
98
|
+
const code = await functionsInitCommand(parseArgs([absPath]));
|
|
99
|
+
if (code !== 0) {
|
|
100
|
+
throw new Error(`functions init failed for ${absPath} (exit ${code})`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export async function scaffoldKind({ kind, appRoot, appId, name, pipelineType = 'transformation', }) {
|
|
104
|
+
const relPath = relativePathFor({ kind, appId, name }).replace(/\\/g, '/');
|
|
105
|
+
const absPath = join(appRoot, relPath);
|
|
106
|
+
const entry = buildPrimitiveEntry({ kind, appId, name, dependsOn: [] });
|
|
107
|
+
switch (kind) {
|
|
108
|
+
case 'orm':
|
|
109
|
+
await mkdir(dirname(absPath), { recursive: true });
|
|
110
|
+
await scaffoldOrm({ absPath });
|
|
111
|
+
break;
|
|
112
|
+
case 'function':
|
|
113
|
+
await scaffoldFunction({ absPath });
|
|
114
|
+
break;
|
|
115
|
+
case 'artifact':
|
|
116
|
+
await mkdir(absPath, { recursive: true });
|
|
117
|
+
await scaffoldArtifact({ absPath, appId: name });
|
|
118
|
+
break;
|
|
119
|
+
case 'agent':
|
|
120
|
+
if (await agentsInitCommand(parseArgs([absPath])) !== 0) {
|
|
121
|
+
throw new Error(`agents init failed for ${absPath}`);
|
|
122
|
+
}
|
|
123
|
+
break;
|
|
124
|
+
case 'process':
|
|
125
|
+
if (await processInitCommand(parseArgs([absPath])) !== 0) {
|
|
126
|
+
throw new Error(`process init failed for ${absPath}`);
|
|
127
|
+
}
|
|
128
|
+
break;
|
|
129
|
+
case 'pipeline':
|
|
130
|
+
if (await pipelineInitCommand({ positional: [name], flags: { type: pipelineType, dir: absPath } }) !== 0) {
|
|
131
|
+
throw new Error(`pipeline init failed for ${absPath}`);
|
|
132
|
+
}
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
return entry;
|
|
136
|
+
}
|
package/dist/app/readme.d.ts
CHANGED
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
* createRepo initial commit). Third-party developers should be able to clone
|
|
4
|
-
* a new app repo and start building on Artifact Studio, the ORM, and
|
|
5
|
-
* Managed Functions without guessing the platform model.
|
|
6
|
-
*
|
|
7
|
-
* Keep in sync with atlas/src/server/services/git-service/initial-readme.ts.
|
|
8
|
-
*/
|
|
9
|
-
import type { PrimitiveKind } from './manifest.js';
|
|
1
|
+
/** App README generated by init; git-service seed detection stays stable. */
|
|
2
|
+
import { type PrimitiveKind } from './manifest.js';
|
|
10
3
|
export declare const SEQUENCE_DOCS_URL = "https://docs.seqholdings.com/";
|
|
11
|
-
/**
|
|
12
|
-
* Hidden marker written into the git-service createRepo README.
|
|
13
|
-
* `seq-studio init .` only overwrites a non-empty target when this is present,
|
|
14
|
-
* so an ordinary docs-only repository is not treated as a seed clone.
|
|
15
|
-
*
|
|
16
|
-
* Keep identical to atlas/src/server/services/git-service/initial-readme.ts.
|
|
17
|
-
*/
|
|
4
|
+
/** Keep identical to atlas/src/server/services/git-service/initial-readme.ts. */
|
|
18
5
|
export declare const GIT_SERVICE_SEED_MARKER = "<!-- seq-studio:git-service-seed -->";
|
|
19
6
|
export declare function isGitServiceSeedReadme(body: string): boolean;
|
|
20
7
|
export declare const README_REQUIRED_SECTIONS: readonly ["https://docs.seqholdings.com/", "Artifact Studio", "ORM", "Managed Function", "seq-studio init", "seq.functions.invoke"];
|
|
@@ -26,8 +13,7 @@ export interface AppReadmeInput {
|
|
|
26
13
|
functionName?: string;
|
|
27
14
|
}
|
|
28
15
|
export declare function renderAppReadme(input: AppReadmeInput): string;
|
|
29
|
-
|
|
30
|
-
export declare function renderEmptyRepoReadme({ repoName, namespaceSlug, }: {
|
|
16
|
+
export declare function renderEmptyRepoReadme({ repoName, namespaceSlug }: {
|
|
31
17
|
repoName: string;
|
|
32
18
|
namespaceSlug?: string;
|
|
33
19
|
}): string;
|