@venizia/vulcan 0.3.10 → 0.3.11
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/package.json +3 -3
- package/src/commands/help.command.ts +5 -3
- package/src/create/add-app.ts +23 -2
- package/src/create/add-lib.ts +1 -2
- package/src/create/init-monorepo.ts +30 -4
- package/src/create/names.ts +34 -0
- package/src/create/workspace.ts +3 -1
- package/src/router.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venizia/vulcan",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.11",
|
|
4
4
|
"description": "VULCAN - one setup, one workflow for every project: init, sync, doctor, upgrade, and `vulcan x` for the shipped tools. Bun-only.",
|
|
5
5
|
"homepage": "https://github.com/VENIZIA-AI/vulcan/tree/main/packages/cli",
|
|
6
6
|
"repository": {
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@clack/prompts": "1.8.1",
|
|
49
|
-
"@venizia/vulcan-atlas": "0.3.
|
|
50
|
-
"@venizia/vulcan-okf": "0.3.
|
|
49
|
+
"@venizia/vulcan-atlas": "0.3.11",
|
|
50
|
+
"@venizia/vulcan-okf": "0.3.11",
|
|
51
51
|
"zod": "^4.6.7"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
@@ -6,13 +6,15 @@ Usage: bun x vulcan <command>
|
|
|
6
6
|
|
|
7
7
|
init [--config ts|mts|mjs|js] Scaffold the project layer (never overwrites)
|
|
8
8
|
init --preset <name|file:path> --project <name> --app <name> [--backend-dir|--frontend-dir <name>]
|
|
9
|
-
[--shared-dir <name>]
|
|
9
|
+
[--shared-dir <name>] [--scope <@scope>]
|
|
10
|
+
Create a monorepo with its first app, from a framework preset
|
|
10
11
|
(a name missing from the flags is asked in a terminal)
|
|
11
12
|
add --preset <name|file:path> (--app <name> | --lib <name>) [--dir <folder>] [--scope <@scope>]
|
|
12
13
|
[--backend-dir|--frontend-dir <name>] [--api <app> | --no-api]
|
|
13
14
|
Add an app or a shared library to the monorepo (a frontend says which
|
|
14
|
-
backend to proxy to; --dir
|
|
15
|
-
|
|
15
|
+
backend to proxy to; --dir is for a library; --scope names the package
|
|
16
|
+
@scope/<name>, for an app or a library; a terminal asks for the kind
|
|
17
|
+
and every name the flags leave out)
|
|
16
18
|
sync [--agents <list>|list] [--dry-run] [--prune]
|
|
17
19
|
Write the adapters of the agents you chose (--agents claude,omp or none,
|
|
18
20
|
stored in .agents/vulcan.local.json; --agents list shows the table);
|
package/src/create/add-app.ts
CHANGED
|
@@ -15,9 +15,11 @@ import { askPresetSpec } from './preset-menu.ts';
|
|
|
15
15
|
import { ABORTED, confirmWrite, planLines } from './plan.ts';
|
|
16
16
|
import {
|
|
17
17
|
askInTerminal,
|
|
18
|
+
askScope,
|
|
18
19
|
askWithPrompt,
|
|
19
20
|
nameProblem,
|
|
20
21
|
readFlag,
|
|
22
|
+
readScope,
|
|
21
23
|
resolveNames,
|
|
22
24
|
SIDE_FIELDS,
|
|
23
25
|
} from './names.ts';
|
|
@@ -329,6 +331,12 @@ const runAdd = async (opts: { cwd: string; args: string[]; scratch: string }): P
|
|
|
329
331
|
return fail({ message: `${CreateFlags.APP} and ${CreateFlags.LIB} cannot be used together` });
|
|
330
332
|
}
|
|
331
333
|
|
|
334
|
+
const flaggedScope = readScope({ args: opts.args });
|
|
335
|
+
|
|
336
|
+
if (!flaggedScope.ok) {
|
|
337
|
+
return fail({ message: flaggedScope.error });
|
|
338
|
+
}
|
|
339
|
+
|
|
332
340
|
if (libFlag && libName === undefined) {
|
|
333
341
|
return fail({ message: `${CreateFlags.LIB} needs a name` });
|
|
334
342
|
}
|
|
@@ -452,9 +460,20 @@ const runAdd = async (opts: { cwd: string; args: string[]; scratch: string }): P
|
|
|
452
460
|
});
|
|
453
461
|
}
|
|
454
462
|
|
|
463
|
+
// Optional, asked only where menus are drawn; a plain terminal and a script give --scope.
|
|
464
|
+
const scope = flaggedScope.scope ?? (menusAvailable() ? await askScope() : undefined);
|
|
465
|
+
|
|
466
|
+
if (scope === null) {
|
|
467
|
+
return fail({ message: ABORTED });
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
const packageOfApp = scope === undefined ? app : `${scope}/${app}`;
|
|
455
471
|
const packages = resolvePackages({ config });
|
|
456
472
|
|
|
457
|
-
if (
|
|
473
|
+
if (
|
|
474
|
+
existsSync(join(cwd, folder, app)) ||
|
|
475
|
+
packages.some(entry => entry.dir === app || entry.name === packageOfApp)
|
|
476
|
+
) {
|
|
458
477
|
return fail({ message: `${folder}/${app} already exists` });
|
|
459
478
|
}
|
|
460
479
|
|
|
@@ -478,7 +497,7 @@ const runAdd = async (opts: { cwd: string; args: string[]; scratch: string }): P
|
|
|
478
497
|
}
|
|
479
498
|
|
|
480
499
|
const source = readFileSync(loaded.file, 'utf8');
|
|
481
|
-
const entry = { dir: app, name:
|
|
500
|
+
const entry = { dir: app, name: packageOfApp, path: `${folder}/${app}` };
|
|
482
501
|
const knownSources = new Set(config.atlas.sources.map(known => known.name));
|
|
483
502
|
const newSources = preset.atlas.filter(candidate => !knownSources.has(candidate.name));
|
|
484
503
|
const parsed = parseAppsBlock({ source });
|
|
@@ -538,6 +557,7 @@ const runAdd = async (opts: { cwd: string; args: string[]; scratch: string }): P
|
|
|
538
557
|
lines: planLines({
|
|
539
558
|
rows: [
|
|
540
559
|
['app', `${folder}/${app}`],
|
|
560
|
+
...(scope === undefined ? [] : [['package', packageOfApp] as [string, string]]),
|
|
541
561
|
['side', side],
|
|
542
562
|
['preset', `${packageName} ${packageVersion}`],
|
|
543
563
|
['port', String(devPort)],
|
|
@@ -562,6 +582,7 @@ const runAdd = async (opts: { cwd: string; args: string[]; scratch: string }): P
|
|
|
562
582
|
path: `${folder}/${app}/package.json`,
|
|
563
583
|
content: renderAppManifest({
|
|
564
584
|
app,
|
|
585
|
+
name: packageOfApp,
|
|
565
586
|
preset,
|
|
566
587
|
presetPackage: { name: packageName, version: packageVersion },
|
|
567
588
|
}),
|
package/src/create/add-lib.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { today, writeFile } from './files.ts';
|
|
|
10
10
|
import { readLibPreset } from './lib-preset.ts';
|
|
11
11
|
import type { TLibPreset } from './lib-preset.ts';
|
|
12
12
|
import { ABORTED, confirmWrite, planLines } from './plan.ts';
|
|
13
|
-
import { askInTerminal, readFlag } from './names.ts';
|
|
13
|
+
import { askInTerminal, readFlag, SCOPE_PATTERN } from './names.ts';
|
|
14
14
|
import { copyPresetFiles } from './preset.ts';
|
|
15
15
|
import { runBun } from './process.ts';
|
|
16
16
|
import {
|
|
@@ -26,7 +26,6 @@ import {
|
|
|
26
26
|
} from './workspace.ts';
|
|
27
27
|
|
|
28
28
|
const KNOWLEDGE_DIRECTORY = '.agents/knowledge';
|
|
29
|
-
const SCOPE_PATTERN = /^@[a-z0-9][a-z0-9-]*$/;
|
|
30
29
|
const DIRECTORY_SEGMENT = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
31
30
|
|
|
32
31
|
const fail = (opts: { message: string }): number => {
|
|
@@ -18,7 +18,15 @@ import { renderDockerignore } from './dockerignore.ts';
|
|
|
18
18
|
import { menusAvailable } from '../ui/index.ts';
|
|
19
19
|
import { askPresetSpec } from './preset-menu.ts';
|
|
20
20
|
import { ABORTED, confirmWrite, planLines } from './plan.ts';
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
askInTerminal,
|
|
23
|
+
askScope,
|
|
24
|
+
findFolderClash,
|
|
25
|
+
readFlag,
|
|
26
|
+
readScope,
|
|
27
|
+
resolveNames,
|
|
28
|
+
SIDE_FIELDS,
|
|
29
|
+
} from './names.ts';
|
|
22
30
|
import { copyPresetFiles, locatePreset, parsePresetSpec } from './preset.ts';
|
|
23
31
|
import { renderNext } from './next.ts';
|
|
24
32
|
import { isInstallSkipped, runBun, runGitInit } from './process.ts';
|
|
@@ -81,9 +89,12 @@ const writeMonorepo = (opts: {
|
|
|
81
89
|
located: ILocatedPreset;
|
|
82
90
|
folder: string;
|
|
83
91
|
app: string;
|
|
92
|
+
/** `@scope` for the app's package name; the folder stays bare. */
|
|
93
|
+
scope: string | undefined;
|
|
84
94
|
shared: string;
|
|
85
95
|
}): void => {
|
|
86
|
-
const { root, project, spec, presetValue, located, folder, app, shared } = opts;
|
|
96
|
+
const { root, project, spec, presetValue, located, folder, app, shared, scope } = opts;
|
|
97
|
+
const packageOfApp = scope === undefined ? app : `${scope}/${app}`;
|
|
87
98
|
const { preset, packageName, packageVersion } = located;
|
|
88
99
|
const side = preset.side;
|
|
89
100
|
const catalog = {
|
|
@@ -138,6 +149,7 @@ const writeMonorepo = (opts: {
|
|
|
138
149
|
path: `${folder}/${app}/package.json`,
|
|
139
150
|
content: renderAppManifest({
|
|
140
151
|
app,
|
|
152
|
+
name: packageOfApp,
|
|
141
153
|
preset,
|
|
142
154
|
presetPackage: { name: packageName, version: packageVersion },
|
|
143
155
|
}),
|
|
@@ -155,7 +167,7 @@ const writeMonorepo = (opts: {
|
|
|
155
167
|
|
|
156
168
|
const block: IAppsBlock = {
|
|
157
169
|
layout: { [side]: folder, ...(shared === '' ? {} : { shared }) },
|
|
158
|
-
packages: [{ dir: app, name:
|
|
170
|
+
packages: [{ dir: app, name: packageOfApp, path: `${folder}/${app}` }],
|
|
159
171
|
presets: [
|
|
160
172
|
recordedPresetOf({
|
|
161
173
|
spec: presetSpecOf({ value: presetValue, root, cwd: dirname(root) }),
|
|
@@ -212,6 +224,12 @@ const runCreate = async (opts: {
|
|
|
212
224
|
return fail({ message: '--preset needs a value (a package name, or file:<path>)' });
|
|
213
225
|
}
|
|
214
226
|
|
|
227
|
+
const flaggedScope = readScope({ args: opts.args });
|
|
228
|
+
|
|
229
|
+
if (!flaggedScope.ok) {
|
|
230
|
+
return fail({ message: flaggedScope.error });
|
|
231
|
+
}
|
|
232
|
+
|
|
215
233
|
const spec = parsePresetSpec({ value: presetValue, cwd: opts.cwd });
|
|
216
234
|
const interactive = process.stdin.isTTY === true;
|
|
217
235
|
const first = await resolveNames({
|
|
@@ -313,6 +331,13 @@ const runCreate = async (opts: {
|
|
|
313
331
|
return fail({ message: clash });
|
|
314
332
|
}
|
|
315
333
|
|
|
334
|
+
// Optional, asked only where menus are drawn; a plain terminal and a script give --scope.
|
|
335
|
+
const scope = flaggedScope.scope ?? (menusAvailable() ? await askScope() : undefined);
|
|
336
|
+
|
|
337
|
+
if (scope === null) {
|
|
338
|
+
return fail({ message: ABORTED });
|
|
339
|
+
}
|
|
340
|
+
|
|
316
341
|
const warning = filePresetWarning({
|
|
317
342
|
spec,
|
|
318
343
|
packageName: located.packageName,
|
|
@@ -329,6 +354,7 @@ const runCreate = async (opts: {
|
|
|
329
354
|
['project', project],
|
|
330
355
|
['preset', `${located.packageName} ${located.packageVersion}`],
|
|
331
356
|
[`${side} app`, `${folder}/${app}`],
|
|
357
|
+
...(scope === undefined ? [] : [['package', `${scope}/${app}`] as [string, string]]),
|
|
332
358
|
['shared', shared === '' ? '(none)' : shared],
|
|
333
359
|
],
|
|
334
360
|
}),
|
|
@@ -338,7 +364,7 @@ const runCreate = async (opts: {
|
|
|
338
364
|
return fail({ message: ABORTED });
|
|
339
365
|
}
|
|
340
366
|
|
|
341
|
-
writeMonorepo({ root, project, spec, presetValue, located, folder, app, shared });
|
|
367
|
+
writeMonorepo({ root, project, spec, presetValue, located, folder, app, scope, shared });
|
|
342
368
|
|
|
343
369
|
for (const step of [
|
|
344
370
|
() => runBun({ cwd: root, args: ['install'], label: 'bun install' }),
|
package/src/create/names.ts
CHANGED
|
@@ -25,12 +25,46 @@ export const SIDE_FIELDS: Record<TAppSide, INameField> = {
|
|
|
25
25
|
},
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
+
/** `@acme`: what `--scope` takes, for a library and for an app. */
|
|
29
|
+
export const SCOPE_PATTERN = /^@[a-z0-9][a-z0-9-]*$/;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The optional scope question of a menu: a package scope typed, or nothing for a bare name. Asked only
|
|
33
|
+
* where menus are drawn; a plain terminal and a script give `--scope`. `null` is a cancel.
|
|
34
|
+
*/
|
|
35
|
+
export const askScope = async (): Promise<string | undefined | null> => {
|
|
36
|
+
const answer = await promptText({
|
|
37
|
+
message: 'Package scope (optional, like @acme; empty for none)',
|
|
38
|
+
validate: value =>
|
|
39
|
+
value.trim() === '' || SCOPE_PATTERN.test(value.trim())
|
|
40
|
+
? undefined
|
|
41
|
+
: `'${value.trim()}' is not a scope like @acme`,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return answer === null ? null : answer.trim() === '' ? undefined : answer.trim();
|
|
45
|
+
};
|
|
46
|
+
|
|
28
47
|
export const readFlag = (opts: { args: string[]; flag: string }): string | undefined => {
|
|
29
48
|
const index = opts.args.indexOf(opts.flag);
|
|
30
49
|
|
|
31
50
|
return index === -1 ? undefined : opts.args[index + 1];
|
|
32
51
|
};
|
|
33
52
|
|
|
53
|
+
/** The scope the flag names, validated: none when absent, an error that names the flag when it is not `@scope`. */
|
|
54
|
+
export const readScope = (opts: {
|
|
55
|
+
args: string[];
|
|
56
|
+
}): { ok: true; scope: string | undefined } | { ok: false; error: string } => {
|
|
57
|
+
const given = readFlag({ args: opts.args, flag: CreateFlags.SCOPE });
|
|
58
|
+
|
|
59
|
+
if (given === undefined) {
|
|
60
|
+
return { ok: true, scope: undefined };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return SCOPE_PATTERN.test(given)
|
|
64
|
+
? { ok: true, scope: given }
|
|
65
|
+
: { ok: false, error: `${CreateFlags.SCOPE} '${given}' is not a scope like @acme` };
|
|
66
|
+
};
|
|
67
|
+
|
|
34
68
|
const isValidName = (opts: { name: string }): boolean =>
|
|
35
69
|
CreateConstants.NAME_PATTERN.test(opts.name);
|
|
36
70
|
|
package/src/create/workspace.ts
CHANGED
|
@@ -153,12 +153,14 @@ const toCatalog = (opts: { dependencies: Record<string, string> }): Record<strin
|
|
|
153
153
|
|
|
154
154
|
export const renderAppManifest = (opts: {
|
|
155
155
|
app: string;
|
|
156
|
+
/** The package name when it is not the app name: `@scope/<app>`. */
|
|
157
|
+
name?: string;
|
|
156
158
|
preset: IPreset;
|
|
157
159
|
presetPackage: { name: string; version: string };
|
|
158
160
|
}): string =>
|
|
159
161
|
json({
|
|
160
162
|
value: {
|
|
161
|
-
name: opts.app,
|
|
163
|
+
name: opts.name ?? opts.app,
|
|
162
164
|
version: '0.0.0',
|
|
163
165
|
private: true,
|
|
164
166
|
// The preset's own text: no token is replaced here, a path pattern has no use for one.
|