@venizia/vulcan 0.2.0 → 0.3.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 +9 -4
- package/package.json +3 -3
- package/src/commands/add.command.ts +5 -0
- package/src/commands/help.command.ts +8 -1
- package/src/commands/index.ts +2 -0
- package/src/commands/init.command.ts +40 -7
- package/src/commands/upgrade.command.ts +163 -10
- package/src/common/constants.ts +17 -1
- package/src/common/index.ts +1 -0
- package/src/common/json.ts +5 -0
- package/src/config/schema.ts +21 -4
- package/src/create/add-app.ts +462 -0
- package/src/create/checks.ts +45 -0
- package/src/create/common/constants.ts +51 -0
- package/src/create/common/index.ts +2 -0
- package/src/create/common/types.ts +78 -0
- package/src/create/files.ts +10 -0
- package/src/create/index.ts +4 -0
- package/src/create/init-monorepo.ts +348 -0
- package/src/create/names.ts +194 -0
- package/src/create/next.ts +53 -0
- package/src/create/preset.ts +234 -0
- package/src/create/process.ts +62 -0
- package/src/create/scratch.ts +38 -0
- package/src/create/workspace.ts +374 -0
- package/src/doctor/checks.ts +39 -1
- package/src/doctor/common/constants.ts +2 -0
- package/src/doctor/runner.ts +2 -0
- package/src/init/common/constants.ts +8 -1
- package/src/init/scaffold.ts +84 -17
- package/src/manifest/render.ts +0 -1
- package/src/router.ts +32 -3
- package/src/sync/common/constants.ts +4 -0
- package/src/sync/planner.ts +17 -9
package/README.md
CHANGED
|
@@ -16,10 +16,12 @@ flag `bun x` fetches it when `@venizia/vulcan` is not installed yet.
|
|
|
16
16
|
|
|
17
17
|
| Command | What it does |
|
|
18
18
|
|---|---|
|
|
19
|
-
| `init [--config ts\|mts\|mjs\|js]` | Scaffold the project layer: `AGENTS.md`, `.configs/vulcan.config.*`, the three lint configs, `.agents/rules.md`, `.agents/knowledge/index.md`, the atlas `.mcp.json`, a Makefile with the `-include` and a fallback rule for a missing `vulcan.mk`. A project whose `package.json` declares `workspaces` gets no root lint configs. Never overwrites; prints what to add to existing files |
|
|
20
|
-
| `
|
|
19
|
+
| `init [--config ts\|mts\|mjs\|js]` | Scaffold the project layer: `AGENTS.md`, `.configs/vulcan.config.*`, the three lint configs, `.agents/rules.md`, `.agents/knowledge/index.md`, the atlas `.mcp.json`, a Makefile with the `-include` and a fallback rule for a missing `vulcan.mk`. Appends the agent entries to `.gitignore`, installs the lint tools (listing them first; a failed install exits 1), and ends with a numbered list of what is left. Needs a `package.json` in the directory. A project whose `package.json` declares `workspaces` gets no root lint configs. Never overwrites; prints what to add to existing files |
|
|
20
|
+
| `init --preset <name\|file:path> --project <name> --app <name> [--backend-dir\|--frontend-dir <name>] [--shared-dir <name>]` | Create a new monorepo with its first app from a framework preset: the root manifests, the app's files, the VULCAN layer and a knowledge bundle, then install, `git init` (a missing git is reported, not fatal), `sync` and the checks, and ends with `cd <project> && make dev` and the app's URL. A name missing from the flags is asked in a terminal; none has a default. Refuses a folder that is not empty |
|
|
21
|
+
| `add --preset <name\|file:path> --app <name> [--backend-dir\|--frontend-dir <name>] [--api <app> \| --no-api]` | Add an app from a preset to a monorepo `init --preset` created: registers it in `workspaces`, the `catalog`, the config and the knowledge bundle, picks a free port, then installs, syncs and checks. A frontend says which backend app to proxy `/api` to |
|
|
22
|
+
| `sync [--dry-run] [--prune]` | Write the gitignored agent adapters: `CLAUDE.md` (`@AGENTS.md`; the one `bun init` writes is replaced, any other hand-written file is left alone), `.claude/settings.json` (shipped + slot + project hooks + `claude.settings` over your personal keys; what it applied is recorded in `.claude/vulcan-managed.json`, so a removed choice is removed, and a hook it wrote is taken back by its command even after you edited its entry), `.claude/skills/` links, and the committed `.agents/vulcan.manifest.json`. Prints each base rule added, changed or removed since the manifest last recorded it, with its new text, then records the new hashes. `--prune` also removes what sync proves stale and did not write: an old VULCAN or plugin-era hook command (a shipped hook exactly as an older VULCAN released it, or a `.agents/` hook whose file is gone) and a dead `.claude/skills` link - never a developer's own hook, a customised shipped command, a real directory or a symlinked `.claude/skills`. `--dry-run` writes nothing and labels each line `would create`, `would replace` or `would remove`. Idempotent |
|
|
21
23
|
| `doctor` | Check the project follows VULCAN; exit 1 on any violation |
|
|
22
|
-
| `upgrade [<version\|tag>]` | Install the target `@venizia/vulcan` (default
|
|
24
|
+
| `upgrade [--stable \| --nightly] [<version\|tag>]` | Install the target `@venizia/vulcan`, then run `sync` from the newly installed CLI. `--stable` (default) is the `latest` dist-tag, never a prerelease; `--nightly` is the higher of `latest` and `next`; a named version or tag wins over both. `--nightly` that cannot read the dist-tags exits 1; a stable upgrade from an installed prerelease says that `--nightly` keeps the prerelease line |
|
|
23
25
|
| `x <tool> [args...]` | Run a shipped tool at the pinned version: `okf`, `atlas`. `x --help` prints the help; `x <tool> --help` goes to the tool |
|
|
24
26
|
| `help`, `version` | |
|
|
25
27
|
|
|
@@ -28,7 +30,7 @@ clean MCP stdio server.
|
|
|
28
30
|
|
|
29
31
|
## The project config
|
|
30
32
|
|
|
31
|
-
`.configs/vulcan.config.<ext>`, `<ext>` one of `
|
|
33
|
+
`.configs/vulcan.config.<ext>`, `<ext>` one of `mts` (what `init` writes), `ts`, `mjs`, `js` (exactly one):
|
|
32
34
|
|
|
33
35
|
```ts
|
|
34
36
|
import type { VulcanConfig } from '@venizia/vulcan';
|
|
@@ -40,6 +42,7 @@ export default {
|
|
|
40
42
|
hooks: [{ event: 'Stop', command: 'echo done' }],
|
|
41
43
|
claude: { settings: { permissions: { allow: ['Bash(make test)'] } } }, // team-shared, committed
|
|
42
44
|
digest: { oftenDropped: ['V-B-03', 'W-00'] }, // repeated at every session start; base or own IDs
|
|
45
|
+
layout: { backend: 'services', frontend: 'web', shared: 'libs' }, // written by init --preset and add
|
|
43
46
|
} satisfies VulcanConfig;
|
|
44
47
|
```
|
|
45
48
|
|
|
@@ -62,7 +65,9 @@ or shadows a shipped one.
|
|
|
62
65
|
`V-` ID a project rule points at - an `Extends` list or a first cell - is a base rule, not a retired one) · `rule-slots` (every slot chosen, valid option) · `skills` (no shipped skill
|
|
63
66
|
shadowed) · `make` (includes `vulcan.mk`, no shipped target redefined) · `hooks` (shipped hooks are
|
|
64
67
|
not re-registered) · `adapters` (sync is current, no hand-written `CLAUDE.md`, valid settings) ·
|
|
68
|
+
`manifest` (`.agents/vulcan.manifest.json` exists and matches the config) · `tags` (every release tag `atlas.tagPattern` reads names a declared package, an alias or an ignored tag) ·
|
|
65
69
|
`prune` (no stale hook command or dead skill link - `sync --prune` removes them) ·
|
|
70
|
+
`apps` (every `layout` folder is a workspace and every package lives in one; skipped without `layout`) ·
|
|
66
71
|
`style` (`@venizia/dev-configs` declared by the package holding the lint config or the root, every lint config builds on it; the packages are `packages/*` and every configured package `path`) ·
|
|
67
72
|
`scaffold` (the config is filled in: a project whose `package.json` declares `workspaces` lists its `packages`, and `.agents/knowledge/index.md` no longer holds the `vulcan:scaffold` line `init` writes).
|
|
68
73
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venizia/vulcan",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
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": {
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"test": "NODE_ENV=test bun test --env-file=.env.test"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@venizia/vulcan-atlas": "0.
|
|
48
|
-
"@venizia/vulcan-okf": "0.
|
|
47
|
+
"@venizia/vulcan-atlas": "0.3.1",
|
|
48
|
+
"@venizia/vulcan-okf": "0.3.1",
|
|
49
49
|
"zod": "^4.5.4"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
@@ -5,10 +5,17 @@ const HELP = `vulcan ${VULCAN_VERSION} - one setup, one workflow for every proje
|
|
|
5
5
|
Usage: bun x vulcan <command>
|
|
6
6
|
|
|
7
7
|
init [--config ts|mts|mjs|js] Scaffold the project layer (never overwrites)
|
|
8
|
+
init --preset <name|file:path> --project <name> --app <name> [--backend-dir|--frontend-dir <name>]
|
|
9
|
+
[--shared-dir <name>] Create a monorepo with its first app, from a framework preset
|
|
10
|
+
(a name missing from the flags is asked in a terminal)
|
|
11
|
+
add --preset <name|file:path> --app <name> [--backend-dir|--frontend-dir <name>]
|
|
12
|
+
[--api <app> | --no-api] Add an app to the monorepo (a frontend says which backend to proxy to)
|
|
8
13
|
sync [--dry-run] [--prune] Write the gitignored agent adapters (CLAUDE.md, .claude/);
|
|
9
14
|
--prune also removes stale hooks and dead skill links
|
|
10
15
|
doctor Check the project follows VULCAN; exit 1 on any violation
|
|
11
|
-
upgrade [<version|tag>]
|
|
16
|
+
upgrade [--stable | --nightly] [<version|tag>]
|
|
17
|
+
Bump the pinned @venizia/vulcan, then sync; --stable (default)
|
|
18
|
+
takes the latest tag, --nightly the newest of latest and next
|
|
12
19
|
x <tool> [args...] Run a shipped tool at the pinned version: okf, atlas
|
|
13
20
|
help · version
|
|
14
21
|
`;
|
package/src/commands/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { VulcanCommands } from '../common/index.ts';
|
|
2
2
|
import type { TCommandHandler } from '../common/index.ts';
|
|
3
|
+
import { runAddCommand } from './add.command.ts';
|
|
3
4
|
import { runDoctorCommand } from './doctor.command.ts';
|
|
4
5
|
import { runHelpCommand, runVersionCommand } from './help.command.ts';
|
|
5
6
|
import { runInitCommand } from './init.command.ts';
|
|
@@ -9,6 +10,7 @@ import { runXCommand } from './x.command.ts';
|
|
|
9
10
|
|
|
10
11
|
/** The handler of every implemented command. */
|
|
11
12
|
export const COMMAND_HANDLERS: Record<string, TCommandHandler> = {
|
|
13
|
+
[VulcanCommands.ADD]: runAddCommand,
|
|
12
14
|
[VulcanCommands.DOCTOR]: runDoctorCommand,
|
|
13
15
|
[VulcanCommands.HELP]: runHelpCommand,
|
|
14
16
|
[VulcanCommands.INIT]: runInitCommand,
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { ExitCodes } from '../common/index.ts';
|
|
2
4
|
import type { ICommandContext } from '../common/index.ts';
|
|
3
5
|
import { ConfigExtensions } from '../config/index.ts';
|
|
6
|
+
import { CreateFlags } from '../create/common/index.ts';
|
|
7
|
+
import { createMonorepo } from '../create/init-monorepo.ts';
|
|
8
|
+
import { runBun } from '../create/process.ts';
|
|
4
9
|
import { InitConstants, scaffoldProject } from '../init/index.ts';
|
|
5
10
|
|
|
6
11
|
export const runInitCommand = async (opts: ICommandContext): Promise<number> => {
|
|
12
|
+
if (opts.args.includes(CreateFlags.PRESET)) {
|
|
13
|
+
return createMonorepo({ cwd: opts.cwd, args: opts.args });
|
|
14
|
+
}
|
|
15
|
+
|
|
7
16
|
const flagIndex = opts.args.indexOf(InitConstants.CONFIG_FLAG);
|
|
8
|
-
const requested = flagIndex === -1 ? ConfigExtensions.
|
|
17
|
+
const requested = flagIndex === -1 ? ConfigExtensions.MTS : (opts.args[flagIndex + 1] ?? '');
|
|
9
18
|
const extension = ConfigExtensions.LOOKUP_ORDER.find(value => value === requested);
|
|
10
19
|
|
|
11
20
|
if (extension === undefined) {
|
|
@@ -16,13 +25,37 @@ export const runInitCommand = async (opts: ICommandContext): Promise<number> =>
|
|
|
16
25
|
return ExitCodes.FAILURE;
|
|
17
26
|
}
|
|
18
27
|
|
|
19
|
-
|
|
28
|
+
// Without it `bun add` walks up to a parent project and installs there.
|
|
29
|
+
if (!existsSync(join(opts.cwd, 'package.json'))) {
|
|
30
|
+
process.stderr.write(
|
|
31
|
+
`vulcan init: no package.json in ${opts.cwd} - run 'bun init' first, or use --preset to create a new project\n`,
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return ExitCodes.FAILURE;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const result = scaffoldProject({ root: opts.cwd, extension });
|
|
38
|
+
|
|
39
|
+
for (const entry of result.entries) {
|
|
20
40
|
process.stderr.write(` ${entry.status.padEnd(8)} ${entry.subject}\n`);
|
|
21
41
|
}
|
|
22
42
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
)
|
|
43
|
+
let installCode: number = ExitCodes.OK;
|
|
44
|
+
|
|
45
|
+
if (result.install.length > 0) {
|
|
46
|
+
// Exact versions: V-S-05 pins what a project installs, and a range would drift on the next install.
|
|
47
|
+
const args = ['add', '-d', '--exact', ...result.install];
|
|
48
|
+
|
|
49
|
+
process.stderr.write(`installing ${result.install.join(' ')}\n`);
|
|
50
|
+
installCode = await runBun({ cwd: opts.cwd, args, label: `bun ${args.join(' ')}` });
|
|
51
|
+
|
|
52
|
+
if (installCode !== ExitCodes.OK) {
|
|
53
|
+
process.stderr.write(`vulcan init: 'bun ${args.join(' ')}' failed - run it yourself\n`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
process.stderr.write('left to do:\n');
|
|
58
|
+
result.todo.forEach((line, index) => process.stderr.write(` ${index + 1}. ${line}\n`));
|
|
26
59
|
|
|
27
|
-
return ExitCodes.OK;
|
|
60
|
+
return installCode === ExitCodes.OK ? ExitCodes.OK : ExitCodes.FAILURE;
|
|
28
61
|
};
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
-
import { ExitCodes, PACKAGE_NAME } from '../common/index.ts';
|
|
3
|
+
import { ExitCodes, PACKAGE_NAME, readProperty, UpgradeFlags } from '../common/index.ts';
|
|
4
4
|
import type { ICommandContext } from '../common/index.ts';
|
|
5
|
+
import { CreateConstants } from '../create/common/index.ts';
|
|
6
|
+
import { bunExecutable, isInstallSkipped, runBun } from '../create/process.ts';
|
|
5
7
|
|
|
6
|
-
/**
|
|
7
|
-
const DEFAULT_TARGET = '
|
|
8
|
+
/** `latest` is the stable channel: never a prerelease. */
|
|
9
|
+
const DEFAULT_TARGET = 'latest';
|
|
10
|
+
|
|
11
|
+
interface IDistTags {
|
|
12
|
+
latest?: string;
|
|
13
|
+
next?: string;
|
|
14
|
+
}
|
|
8
15
|
|
|
9
16
|
export const buildUpgradeArgs = (opts: { target?: string }): string[] => [
|
|
10
17
|
'add',
|
|
@@ -13,6 +20,132 @@ export const buildUpgradeArgs = (opts: { target?: string }): string[] => [
|
|
|
13
20
|
`${PACKAGE_NAME}@${opts.target ?? DEFAULT_TARGET}`,
|
|
14
21
|
];
|
|
15
22
|
|
|
23
|
+
/** A tag that is present must be a plain version; anything else cannot be compared or installed. */
|
|
24
|
+
const parseTag = (opts: { tags: unknown; key: keyof IDistTags }): string | undefined | null => {
|
|
25
|
+
const value = readProperty({ value: opts.tags, key: opts.key });
|
|
26
|
+
|
|
27
|
+
if (value === undefined) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return typeof value === 'string' && CreateConstants.VERSION_PATTERN.test(value) ? value : null;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** The `latest` and `next` tags of a registry answer, or undefined when it is not an object of versions. */
|
|
35
|
+
export const parseDistTags = (opts: { text: string }): IDistTags | undefined => {
|
|
36
|
+
let parsed: unknown;
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
parsed = JSON.parse(opts.text);
|
|
40
|
+
} catch {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const latest = parseTag({ tags: parsed, key: 'latest' });
|
|
49
|
+
const next = parseTag({ tags: parsed, key: 'next' });
|
|
50
|
+
|
|
51
|
+
return latest === null || next === null ? undefined : { latest, next };
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The one place that reads the registry: `bun pm view` goes through the project's own registry and
|
|
56
|
+
* auth settings. `VULCAN_DIST_TAGS` replaces it so tests run offline. Undefined when the read fails,
|
|
57
|
+
* after printing why bun failed.
|
|
58
|
+
*/
|
|
59
|
+
export const readDistTags = async (opts: { cwd: string }): Promise<IDistTags | undefined> => {
|
|
60
|
+
const injected = process.env[UpgradeFlags.DIST_TAGS_ENV];
|
|
61
|
+
|
|
62
|
+
if (injected !== undefined) {
|
|
63
|
+
return parseDistTags({ text: injected });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const child = Bun.spawn([bunExecutable(), 'pm', 'view', PACKAGE_NAME, 'dist-tags', '--json'], {
|
|
67
|
+
cwd: opts.cwd,
|
|
68
|
+
stdout: 'pipe',
|
|
69
|
+
stderr: 'pipe',
|
|
70
|
+
});
|
|
71
|
+
const [text, errorText] = await Promise.all([
|
|
72
|
+
new Response(child.stdout).text(),
|
|
73
|
+
new Response(child.stderr).text(),
|
|
74
|
+
]);
|
|
75
|
+
|
|
76
|
+
if ((await child.exited) !== ExitCodes.OK) {
|
|
77
|
+
process.stderr.write(errorText.endsWith('\n') ? errorText : `${errorText}\n`);
|
|
78
|
+
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return parseDistTags({ text });
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/** The higher of the two tags by semver, so a stale `next` never pulls a project below the stable release. */
|
|
86
|
+
export const pickNightly = (opts: IDistTags): string | undefined => {
|
|
87
|
+
const { latest, next } = opts;
|
|
88
|
+
|
|
89
|
+
if (latest === undefined || next === undefined) {
|
|
90
|
+
return latest ?? next;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return Bun.semver.order(next, latest) === 1 ? next : latest;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/** The version of the `@venizia/vulcan` the project has installed, undefined when none is readable. */
|
|
97
|
+
const readInstalledVersion = (opts: { cwd: string }): string | undefined => {
|
|
98
|
+
const file = join(opts.cwd, 'node_modules', PACKAGE_NAME, 'package.json');
|
|
99
|
+
|
|
100
|
+
if (!existsSync(file)) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
const version = readProperty({ value: JSON.parse(readFileSync(file, 'utf8')), key: 'version' });
|
|
106
|
+
|
|
107
|
+
return typeof version === 'string' ? version : undefined;
|
|
108
|
+
} catch {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* What to install: an explicit version or tag wins over the channel; `--nightly` is the newest of the
|
|
115
|
+
* `latest` and `next` tags; otherwise `latest`. Undefined, after saying why on stderr, when `--nightly`
|
|
116
|
+
* cannot be resolved.
|
|
117
|
+
*/
|
|
118
|
+
export const resolveUpgradeTarget = async (opts: ICommandContext): Promise<string | undefined> => {
|
|
119
|
+
const explicit = opts.args.find(arg => !arg.startsWith('-'));
|
|
120
|
+
|
|
121
|
+
if (explicit !== undefined) {
|
|
122
|
+
return explicit;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (!opts.args.includes(UpgradeFlags.NIGHTLY)) {
|
|
126
|
+
const installed = readInstalledVersion({ cwd: opts.cwd });
|
|
127
|
+
|
|
128
|
+
if (installed !== undefined && CreateConstants.PRERELEASE_PATTERN.test(installed)) {
|
|
129
|
+
process.stderr.write(
|
|
130
|
+
`vulcan upgrade: ${installed} is installed, a prerelease; ${UpgradeFlags.STABLE} installs the latest stable release and ${UpgradeFlags.NIGHTLY} keeps the prerelease line\n`,
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return DEFAULT_TARGET;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const tags = await readDistTags({ cwd: opts.cwd });
|
|
138
|
+
const target = tags === undefined ? undefined : pickNightly(tags);
|
|
139
|
+
|
|
140
|
+
if (target === undefined) {
|
|
141
|
+
process.stderr.write(
|
|
142
|
+
`vulcan upgrade: ${UpgradeFlags.NIGHTLY} could not read the dist-tags of ${PACKAGE_NAME} - pass a version instead\n`,
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return target;
|
|
147
|
+
};
|
|
148
|
+
|
|
16
149
|
/**
|
|
17
150
|
* Runs `sync` from the CLI the install just wrote, as a child: this process still holds the old
|
|
18
151
|
* version's code and base, so an in-process sync would write the old adapters.
|
|
@@ -38,12 +171,32 @@ export const runInstalledSync = async (opts: { cwd: string }): Promise<number> =
|
|
|
38
171
|
|
|
39
172
|
/** Installs the target version, then syncs with it, so the adapters always match the installed base. */
|
|
40
173
|
export const runUpgradeCommand = async (opts: ICommandContext): Promise<number> => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
174
|
+
if (opts.args.includes(UpgradeFlags.STABLE) && opts.args.includes(UpgradeFlags.NIGHTLY)) {
|
|
175
|
+
process.stderr.write(
|
|
176
|
+
`vulcan upgrade: ${UpgradeFlags.STABLE} and ${UpgradeFlags.NIGHTLY} cannot be combined - pick one\n`,
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
return ExitCodes.FAILURE;
|
|
180
|
+
}
|
|
45
181
|
|
|
46
|
-
const
|
|
182
|
+
const target = await resolveUpgradeTarget(opts);
|
|
183
|
+
|
|
184
|
+
if (target === undefined) {
|
|
185
|
+
return ExitCodes.FAILURE;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const args = buildUpgradeArgs({ target });
|
|
189
|
+
const code = await runBun({ cwd: opts.cwd, args, label: `bun ${args.join(' ')}` });
|
|
190
|
+
|
|
191
|
+
if (code !== ExitCodes.OK) {
|
|
192
|
+
return code;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (isInstallSkipped()) {
|
|
196
|
+
process.stderr.write(' skipped vulcan sync (VULCAN_NO_INSTALL)\n');
|
|
197
|
+
|
|
198
|
+
return ExitCodes.OK;
|
|
199
|
+
}
|
|
47
200
|
|
|
48
|
-
return
|
|
201
|
+
return runInstalledSync({ cwd: opts.cwd });
|
|
49
202
|
};
|
package/src/common/constants.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export class VulcanCommands {
|
|
2
2
|
static readonly INIT = 'init';
|
|
3
|
+
static readonly ADD = 'add';
|
|
3
4
|
static readonly SYNC = 'sync';
|
|
4
5
|
static readonly DOCTOR = 'doctor';
|
|
5
6
|
static readonly UPGRADE = 'upgrade';
|
|
@@ -8,6 +9,7 @@ export class VulcanCommands {
|
|
|
8
9
|
static readonly VERSION = 'version';
|
|
9
10
|
static readonly SCHEME_SET = new Set<string>([
|
|
10
11
|
this.INIT,
|
|
12
|
+
this.ADD,
|
|
11
13
|
this.SYNC,
|
|
12
14
|
this.DOCTOR,
|
|
13
15
|
this.UPGRADE,
|
|
@@ -20,6 +22,18 @@ export class VulcanCommands {
|
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
|
|
25
|
+
/** The release channels `vulcan upgrade` picks between; the channel is a flag, never stored in the config. */
|
|
26
|
+
export class UpgradeFlags {
|
|
27
|
+
static readonly STABLE = '--stable';
|
|
28
|
+
static readonly NIGHTLY = '--nightly';
|
|
29
|
+
/** Tests only: a JSON object of dist-tags that stands in for the registry read. */
|
|
30
|
+
static readonly DIST_TAGS_ENV = 'VULCAN_DIST_TAGS';
|
|
31
|
+
static readonly SCHEME_SET = new Set<string>([this.STABLE, this.NIGHTLY]);
|
|
32
|
+
static isValid(value: string): boolean {
|
|
33
|
+
return this.SCHEME_SET.has(value);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
23
37
|
export class ExitCodes {
|
|
24
38
|
static readonly OK = 0;
|
|
25
39
|
static readonly FAILURE = 1;
|
|
@@ -46,7 +60,9 @@ export class ProjectLayout {
|
|
|
46
60
|
/** `-include`: a fresh clone runs `make install` before node_modules exists. */
|
|
47
61
|
static readonly MAKE_INCLUDE_LINE = '-include node_modules/@venizia/vulcan/base/make/vulcan.mk';
|
|
48
62
|
static readonly STYLE_PACKAGE = '@venizia/dev-configs';
|
|
49
|
-
static readonly GITIGNORE_ENTRIES = ['CLAUDE.md', '.claude/'];
|
|
63
|
+
static readonly GITIGNORE_ENTRIES = ['CLAUDE.md', 'CLAUDE.*.md', '.claude/', '.agents/plans'];
|
|
64
|
+
/** What the scaffolded lint configs run; optional peers of dev-configs, so bun never installs them alone. */
|
|
65
|
+
static readonly LINT_TOOLS = ['oxlint', 'oxlint-tsgolint', 'oxfmt', 'eslint'];
|
|
50
66
|
/** Written into a scaffolded file the project must fill in; doctor fails the file while it holds this. */
|
|
51
67
|
static readonly SCAFFOLD_MARKER = 'vulcan:scaffold';
|
|
52
68
|
}
|
package/src/common/index.ts
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** The value under `key` of anything that is an object, else undefined: untrusted JSON is read without a cast. */
|
|
2
|
+
export const readProperty = (opts: { value: unknown; key: string }): unknown =>
|
|
3
|
+
typeof opts.value === 'object' && opts.value !== null
|
|
4
|
+
? Reflect.get(opts.value, opts.key)
|
|
5
|
+
: undefined;
|
package/src/config/schema.ts
CHANGED
|
@@ -8,6 +8,8 @@ const HOOK_EVENT = z.string().refine(value => HookEvents.isValid(value), {
|
|
|
8
8
|
message: `one of: ${[...HookEvents.SCHEME_SET].join(', ')}`,
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
+
const FOLDER_NAME = z.string().regex(/^[a-z0-9][a-z0-9-]*$/);
|
|
12
|
+
|
|
11
13
|
const PROJECT_PACKAGE = z.strictObject({
|
|
12
14
|
dir: z.string().regex(/^[a-z0-9][a-z0-9.-]*$/),
|
|
13
15
|
name: z.string(),
|
|
@@ -68,6 +70,14 @@ const RELEASE_TEMPLATE = z.string().refine(value => value.includes('<version>'),
|
|
|
68
70
|
message: 'a template with <version> (and <dir> or <package> for per-package releases)',
|
|
69
71
|
});
|
|
70
72
|
|
|
73
|
+
/** A key the config once accepted and no tool ever read: still named, so the error says it is gone rather than "unrecognized". */
|
|
74
|
+
const removedAtlasKey = (opts: { key: string }) =>
|
|
75
|
+
z
|
|
76
|
+
.never({
|
|
77
|
+
error: `atlas.${opts.key} was removed - no tool reads it; delete it from the config`,
|
|
78
|
+
})
|
|
79
|
+
.optional();
|
|
80
|
+
|
|
71
81
|
/** A renderer by id: a built-in, or a project module (`module`); a bare string is the id alone. */
|
|
72
82
|
const OKF_RENDERER = z.union([
|
|
73
83
|
z.string().transform(id => ({ id, options: {} })),
|
|
@@ -100,6 +110,14 @@ export const VULCAN_CONFIG_SCHEMA = z.strictObject({
|
|
|
100
110
|
.optional(),
|
|
101
111
|
agents: z.array(CODING_AGENT).default([CodingAgents.CLAUDE]),
|
|
102
112
|
rules: z.record(z.string().regex(ConfigConstants.RULE_ID_PATTERN), z.string()).default({}),
|
|
113
|
+
/** The folders `vulcan init` and `add` put apps in, as the user named them. */
|
|
114
|
+
layout: z
|
|
115
|
+
.strictObject({
|
|
116
|
+
backend: FOLDER_NAME.optional(),
|
|
117
|
+
frontend: FOLDER_NAME.optional(),
|
|
118
|
+
shared: FOLDER_NAME.optional(),
|
|
119
|
+
})
|
|
120
|
+
.optional(),
|
|
103
121
|
/** The project's packages in release order; okf, atlas, make and release read this one list. */
|
|
104
122
|
packages: z.array(PROJECT_PACKAGE).superRefine(checkPackagesUnique).default([]),
|
|
105
123
|
knowledge: z
|
|
@@ -166,7 +184,9 @@ export const VULCAN_CONFIG_SCHEMA = z.strictObject({
|
|
|
166
184
|
'atlas.packages was removed - move the list to the top-level packages: [{ dir, name }] (release order; dir is the old key, name the old value)',
|
|
167
185
|
})
|
|
168
186
|
.optional(),
|
|
169
|
-
releaseCommit:
|
|
187
|
+
releaseCommit: removedAtlasKey({ key: 'releaseCommit' }),
|
|
188
|
+
typescriptFrom: removedAtlasKey({ key: 'typescriptFrom' }),
|
|
189
|
+
legacyTagPrefixes: removedAtlasKey({ key: 'legacyTagPrefixes' }),
|
|
170
190
|
tagPattern: RELEASE_TEMPLATE.default('<dir>-v<version>'),
|
|
171
191
|
sources: z
|
|
172
192
|
.array(
|
|
@@ -177,13 +197,10 @@ export const VULCAN_CONFIG_SCHEMA = z.strictObject({
|
|
|
177
197
|
}),
|
|
178
198
|
)
|
|
179
199
|
.default([]),
|
|
180
|
-
legacyTagPrefixes: z.array(z.string()).optional(),
|
|
181
200
|
/** Tags neither read nor checked (globs) - an old layout's tags. */
|
|
182
201
|
ignoreTags: z.array(z.string()).optional(),
|
|
183
|
-
typescriptFrom: z.string().optional(),
|
|
184
202
|
})
|
|
185
203
|
.default({
|
|
186
|
-
releaseCommit: '[#<issue>] chore(<dir>): release v<version>',
|
|
187
204
|
tagPattern: '<dir>-v<version>',
|
|
188
205
|
sources: [],
|
|
189
206
|
}),
|