@venizia/vulcan 0.4.8 → 0.4.9-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/base/extensions/vulcan-guards.ts +48 -41
- package/base/hooks/antigravity-guards.ts +4 -3
- package/base/hooks/codex-guards.ts +17 -6
- package/base/hooks/guard-git.ts +8 -8
- package/base/hooks/guard-manifest.ts +5 -5
- package/base/hooks/guard-outside.ts +8 -8
- package/base/hooks/guard-package.ts +6 -6
- package/base/hooks/guard-remote-hosts.ts +14 -9
- package/base/hooks/guard-scripting.ts +6 -6
- package/base/hooks/guard-writes.ts +20 -11
- package/base/hooks/post-tool.ts +4 -3
- package/base/hooks/prompt-submit.ts +4 -3
- package/base/hooks/session-start.ts +5 -3
- package/base/hooks/stop.ts +4 -3
- package/base/hooks/subagent-start.ts +2 -2
- package/base/make/vulcan.mk +1 -4
- package/base/skills/build-a-feature/SKILL.md +1 -1
- package/base/skills/docs-update/SKILL.md +11 -5
- package/base/skills/docs-update/evals/evals.json +1 -1
- package/base/skills/docs-writing/SKILL.md +1 -1
- package/base/skills/plan-a-change/references/spec-card.md +1 -1
- package/base/skills/ship/SKILL.md +1 -1
- package/base/skills/visualize-work/SKILL.md +29 -6
- package/base/skills/visualize-work/references/spec.md +16 -5
- package/package.json +5 -6
- package/src/agents/atlas-block.ts +43 -43
- package/src/agents/codex-hooks.ts +55 -52
- package/src/agents/common/types.ts +1 -1
- package/src/agents/detect.ts +19 -16
- package/src/agents/exclude.ts +97 -98
- package/src/agents/hooks-json.ts +41 -43
- package/src/agents/local.ts +46 -43
- package/src/agents/prompt.ts +45 -42
- package/src/agents/render.ts +203 -201
- package/src/agents/resolve.ts +133 -134
- package/src/agents/table.ts +12 -8
- package/src/cli.ts +3 -1
- package/src/commands/add.command.ts +2 -2
- package/src/commands/agents.command.ts +11 -17
- package/src/commands/clean.command.ts +6 -6
- package/src/commands/doctor.command.ts +6 -4
- package/src/commands/help.command.ts +11 -9
- package/src/commands/init.command.ts +14 -8
- package/src/commands/preset.command.ts +2 -2
- package/src/commands/profile.command.ts +43 -50
- package/src/commands/sync.command.ts +109 -111
- package/src/commands/upgrade.command.ts +85 -78
- package/src/commands/visualize.command.ts +20 -5
- package/src/commands/x.command.ts +55 -50
- package/src/common/format.ts +23 -21
- package/src/common/index.ts +2 -0
- package/src/common/json.ts +8 -5
- package/src/common/layout-folder.ts +96 -111
- package/src/common/paths.ts +14 -12
- package/src/common/record.ts +7 -0
- package/src/common/text.ts +7 -0
- package/src/config/common/constants.ts +13 -1
- package/src/config/common/types.ts +8 -1
- package/src/config/loader.ts +53 -48
- package/src/config/packages.ts +17 -11
- package/src/config/schema.ts +54 -7
- package/src/create/add-app.ts +604 -493
- package/src/create/add-lib.ts +249 -242
- package/src/create/bunfig.ts +26 -23
- package/src/create/checks.ts +36 -34
- package/src/create/common/constants.ts +1 -0
- package/src/create/common/failure.ts +10 -0
- package/src/create/common/index.ts +2 -0
- package/src/create/common/preset-path.ts +11 -0
- package/src/create/common/types.ts +7 -2
- package/src/create/diff.ts +21 -23
- package/src/create/dockerignore.ts +26 -24
- package/src/create/files.ts +7 -5
- package/src/create/init-monorepo.ts +78 -80
- package/src/create/lib-preset.ts +62 -61
- package/src/create/manifest-json.ts +10 -4
- package/src/create/names.ts +217 -210
- package/src/create/next.ts +27 -24
- package/src/create/plan.ts +15 -12
- package/src/create/preset-diff.ts +415 -240
- package/src/create/preset-menu.ts +40 -34
- package/src/create/preset.ts +207 -194
- package/src/create/process.ts +80 -71
- package/src/create/scratch.ts +49 -48
- package/src/create/workspace.ts +423 -398
- package/src/doctor/checks.ts +1069 -998
- package/src/doctor/makefile.ts +17 -13
- package/src/doctor/runner.ts +88 -116
- package/src/doctor/skills.ts +97 -95
- package/src/doctor/tags.ts +44 -41
- package/src/hooks/codex-patch.ts +27 -24
- package/src/hooks/command-view.ts +44 -39
- package/src/hooks/common/constants.ts +0 -3
- package/src/hooks/common/types.ts +15 -1
- package/src/hooks/decision.ts +38 -42
- package/src/hooks/guard-git.ts +52 -50
- package/src/hooks/guard-manifest.ts +58 -55
- package/src/hooks/guard-outside.ts +109 -88
- package/src/hooks/guard-package.ts +86 -77
- package/src/hooks/guard-scripting.ts +20 -15
- package/src/hooks/guard-writes.ts +169 -111
- package/src/hooks/owner-reply.ts +128 -128
- package/src/hooks/post-tool.ts +94 -93
- package/src/hooks/project-guards.ts +93 -55
- package/src/hooks/project-tmp.ts +27 -24
- package/src/hooks/remote-hosts.ts +157 -149
- package/src/hooks/session-digest.ts +99 -95
- package/src/hooks/shell.ts +519 -500
- package/src/hooks/subagent-card.ts +11 -7
- package/src/hooks/trusted-scripts.ts +158 -80
- package/src/init/common/types.ts +1 -1
- package/src/init/scaffold.ts +137 -134
- package/src/local/clean.ts +39 -37
- package/src/local/format.ts +21 -17
- package/src/local/scan.ts +146 -140
- package/src/manifest/render.ts +127 -112
- package/src/owner/card.ts +51 -46
- package/src/owner/profile.ts +100 -96
- package/src/owner/reply-switch.ts +9 -6
- package/src/owner/shape.ts +72 -70
- package/src/owner/survey.ts +175 -164
- package/src/owner/view.ts +62 -59
- package/src/owner/violations.ts +119 -123
- package/src/router.ts +4 -1
- package/src/rules/base.ts +15 -11
- package/src/rules/common/types.ts +1 -1
- package/src/rules/parser.ts +39 -32
- package/src/rules/slots.ts +8 -6
- package/src/signals/claims.ts +30 -28
- package/src/signals/classify.ts +36 -33
- package/src/signals/loop.ts +39 -37
- package/src/signals/state.ts +80 -85
- package/src/skills/frontmatter.ts +28 -28
- package/src/sync/agent-files.ts +217 -199
- package/src/sync/agent-removal.ts +62 -68
- package/src/sync/atlas-block.ts +45 -43
- package/src/sync/base-rules.ts +32 -30
- package/src/sync/claude-launch.ts +74 -37
- package/src/sync/common/constants.ts +4 -0
- package/src/sync/common/index.ts +1 -0
- package/src/sync/common/symlink.ts +9 -0
- package/src/sync/common/types.ts +2 -2
- package/src/sync/exclude.ts +77 -69
- package/src/sync/local-choice.ts +50 -47
- package/src/sync/planner.ts +64 -68
- package/src/sync/prune.ts +52 -48
- package/src/sync/settings.ts +167 -168
- package/src/ui/capability.ts +12 -7
- package/src/ui/keyboard.ts +35 -33
- package/src/ui/prompt.ts +81 -77
- package/src/visualize/assets.ts +379 -195
- package/src/visualize/charts.ts +188 -176
- package/src/visualize/compare-css.ts +31 -0
- package/src/visualize/compare-render.ts +196 -0
- package/src/visualize/compare-schema.ts +81 -0
- package/src/visualize/compare-validate.ts +126 -0
- package/src/visualize/constants.ts +29 -3
- package/src/visualize/diagrams.ts +189 -174
- package/src/visualize/gate.ts +136 -0
- package/src/visualize/grid-span.ts +34 -0
- package/src/visualize/icons.ts +9 -4
- package/src/visualize/index.ts +2 -0
- package/src/visualize/kinds-css.ts +54 -0
- package/src/visualize/kinds-render.ts +698 -0
- package/src/visualize/kinds-schema.ts +148 -0
- package/src/visualize/kinds-validate.ts +186 -0
- package/src/visualize/labels-vi.ts +109 -0
- package/src/visualize/labels.ts +53 -0
- package/src/visualize/layout.ts +112 -92
- package/src/visualize/page.ts +140 -114
- package/src/visualize/render.ts +158 -114
- package/src/visualize/schema.ts +21 -1
- package/src/visualize/sections.ts +401 -309
- package/src/visualize/sources.ts +270 -0
- package/src/visualize/theme.ts +474 -0
- package/src/visualize/validate.ts +15 -5
- package/src/wiki/anchors.ts +39 -37
- package/src/wiki/command.ts +4 -4
- package/src/wiki/source-links.ts +49 -49
package/src/create/add-lib.ts
CHANGED
|
@@ -1,48 +1,26 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
3
|
import { ExitCodes } from '../common/index.ts';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
withLayoutFolder,
|
|
11
|
-
} from '../common/layout-folder.ts';
|
|
12
|
-
import { PackageKinds } from '../config/index.ts';
|
|
13
|
-
import type { IProjectPackage, TResolvedConfig } from '../config/index.ts';
|
|
14
|
-
import { readWorkspaceGlobs } from '../init/index.ts';
|
|
15
|
-
import { runAppChecks } from './checks.ts';
|
|
16
|
-
import { AppsBlockProblems, CreateConstants, CreateFlags } from './common/index.ts';
|
|
4
|
+
import { LayoutFolder } from '../common/layout-folder.ts';
|
|
5
|
+
import { LibraryKinds, PackageKinds } from '../config/index.ts';
|
|
6
|
+
import type { IProjectPackage, TLibraryKind, TResolvedConfig } from '../config/index.ts';
|
|
7
|
+
import { ProjectScaffold } from '../init/index.ts';
|
|
8
|
+
import { AppChecks } from './checks.ts';
|
|
9
|
+
import { AddFailure, AppsBlockProblems, CreateConstants, CreateFlags } from './common/index.ts';
|
|
17
10
|
import type { IAppsBlock, ILocatedPreset, IPresetSpec } from './common/index.ts';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
11
|
+
import { ProjectFile } from './files.ts';
|
|
12
|
+
import { LibPreset } from './lib-preset.ts';
|
|
13
|
+
import { ManifestJson } from './manifest-json.ts';
|
|
21
14
|
import type { TLibPreset } from './lib-preset.ts';
|
|
22
|
-
import { ABORTED,
|
|
23
|
-
import { askInTerminal,
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
addAppBullet,
|
|
28
|
-
filePresetWarning,
|
|
29
|
-
parseAppsBlock,
|
|
30
|
-
planRootManifest,
|
|
31
|
-
renderKnowledgeIndex,
|
|
32
|
-
renderLibConcept,
|
|
33
|
-
renderLibManifest,
|
|
34
|
-
replaceAppsBlock,
|
|
35
|
-
} from './workspace.ts';
|
|
15
|
+
import { ABORTED, WritePlan } from './plan.ts';
|
|
16
|
+
import { askInTerminal, ProjectNames, SCOPE_PATTERN } from './names.ts';
|
|
17
|
+
import { Preset } from './preset.ts';
|
|
18
|
+
import { SubProcess } from './process.ts';
|
|
19
|
+
import { AppsBlock, WorkspaceDocs, WorkspaceManifest } from './workspace.ts';
|
|
36
20
|
|
|
37
21
|
const KNOWLEDGE_DIRECTORY = '.agents/knowledge';
|
|
38
22
|
const DIRECTORY_SEGMENT = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
39
23
|
|
|
40
|
-
const fail = (opts: { message: string }): number => {
|
|
41
|
-
process.stderr.write(`vulcan add: ${opts.message}\n`);
|
|
42
|
-
|
|
43
|
-
return ExitCodes.FAILURE;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
24
|
/** A folder from the root, written with slashes, never climbing out or absolute. */
|
|
47
25
|
const isProjectFolder = (opts: { folder: string }): boolean =>
|
|
48
26
|
opts.folder
|
|
@@ -64,7 +42,7 @@ const folderOf = async (opts: {
|
|
|
64
42
|
config: TResolvedConfig;
|
|
65
43
|
packages: IProjectPackage[];
|
|
66
44
|
}): Promise<{ ok: true; folder: string } | { ok: false; error: string }> => {
|
|
67
|
-
const given = readFlag({ args: opts.args, flag: CreateFlags.DIR });
|
|
45
|
+
const given = ProjectNames.readFlag({ args: opts.args, flag: CreateFlags.DIR });
|
|
68
46
|
const libFolders = [
|
|
69
47
|
...new Set(
|
|
70
48
|
opts.packages
|
|
@@ -72,7 +50,7 @@ const folderOf = async (opts: {
|
|
|
72
50
|
.map((entry) => dirname(entry.path)),
|
|
73
51
|
),
|
|
74
52
|
];
|
|
75
|
-
const shared = layoutFoldersOf({ value: opts.config.layout?.shared });
|
|
53
|
+
const shared = LayoutFolder.layoutFoldersOf({ value: opts.config.layout?.shared });
|
|
76
54
|
// One shared folder is the answer; with none the one folder the libraries share is; several are for `--dir` or a menu.
|
|
77
55
|
const fallback =
|
|
78
56
|
shared.length === 1
|
|
@@ -85,16 +63,14 @@ const folderOf = async (opts: {
|
|
|
85
63
|
if (chosen === undefined) {
|
|
86
64
|
if (opts.interactive) {
|
|
87
65
|
// The folders the project's libraries already live in are picked; a new one is typed.
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
})
|
|
97
|
-
)?.trim() ?? '';
|
|
66
|
+
const typedFolder = await askInTerminal({
|
|
67
|
+
question: 'Folder',
|
|
68
|
+
previous: fallback,
|
|
69
|
+
choices: [
|
|
70
|
+
...new Set([...shared, ...(fallback === undefined ? [] : [fallback]), ...libFolders]),
|
|
71
|
+
],
|
|
72
|
+
});
|
|
73
|
+
const answer = typedFolder?.trim() ?? '';
|
|
98
74
|
|
|
99
75
|
chosen = answer === '' ? fallback : answer;
|
|
100
76
|
} else {
|
|
@@ -105,7 +81,7 @@ const folderOf = async (opts: {
|
|
|
105
81
|
if (chosen === undefined) {
|
|
106
82
|
return {
|
|
107
83
|
ok: false,
|
|
108
|
-
error: `where should ${opts.lib} go? pass ${CreateFlags.DIR} <folder>${shared.length > 1 ? ` (${
|
|
84
|
+
error: `where should ${opts.lib} go? pass ${CreateFlags.DIR} <folder>${shared.length > 1 ? ` (${LayoutFolder.listedNote({ folders: shared })})` : ''}`,
|
|
109
85
|
};
|
|
110
86
|
}
|
|
111
87
|
|
|
@@ -124,7 +100,7 @@ const nameOf = (opts: {
|
|
|
124
100
|
packages: IProjectPackage[];
|
|
125
101
|
manifest: Record<string, unknown>;
|
|
126
102
|
}): { ok: true; name: string } | { ok: false; error: string } => {
|
|
127
|
-
const given = readFlag({ args: opts.args, flag: CreateFlags.SCOPE });
|
|
103
|
+
const given = ProjectNames.readFlag({ args: opts.args, flag: CreateFlags.SCOPE });
|
|
128
104
|
|
|
129
105
|
if (given !== undefined) {
|
|
130
106
|
return SCOPE_PATTERN.test(given)
|
|
@@ -149,222 +125,253 @@ const nameOf = (opts: {
|
|
|
149
125
|
return { ok: true, name: scope === '' ? opts.lib : `${scope}/${opts.lib}` };
|
|
150
126
|
};
|
|
151
127
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
128
|
+
export class LibraryScaffold {
|
|
129
|
+
/** The sibling-name rule needs the entries the config holds, not only the folder's directories. */
|
|
130
|
+
static async add(opts: {
|
|
131
|
+
cwd: string;
|
|
132
|
+
args: string[];
|
|
133
|
+
interactive: boolean;
|
|
134
|
+
presetValue: string;
|
|
135
|
+
spec: IPresetSpec;
|
|
136
|
+
located: ILocatedPreset;
|
|
137
|
+
config: TResolvedConfig;
|
|
138
|
+
configFile: string;
|
|
139
|
+
configPath: string;
|
|
140
|
+
manifest: Record<string, unknown>;
|
|
141
|
+
packages: IProjectPackage[];
|
|
142
|
+
libName: string;
|
|
143
|
+
/** Which preset kind makes the package: `lib` (the default) or the side-neutral `shared`. */
|
|
144
|
+
kind?: TLibraryKind;
|
|
145
|
+
recorded: (opts: { block: IAppsBlock }) => IAppsBlock;
|
|
146
|
+
}): Promise<number> {
|
|
147
|
+
const { cwd, config, located, libName } = opts;
|
|
148
|
+
const kind = opts.kind ?? LibraryKinds.LIB;
|
|
149
|
+
|
|
150
|
+
if (!CreateConstants.NAME_PATTERN.test(libName)) {
|
|
151
|
+
return AddFailure.fail({
|
|
152
|
+
message: `'${libName}' is not a name - lowercase letters, digits and -, starting with a letter or digit`,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const read = LibPreset.read({ located, kind });
|
|
157
|
+
|
|
158
|
+
if (!read.ok) {
|
|
159
|
+
return AddFailure.fail({ message: read.error });
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const lib: TLibPreset = read.lib;
|
|
163
|
+
const placed = await folderOf({
|
|
164
|
+
args: opts.args,
|
|
165
|
+
interactive: opts.interactive,
|
|
166
|
+
lib: libName,
|
|
167
|
+
config,
|
|
168
|
+
packages: opts.packages,
|
|
173
169
|
});
|
|
174
|
-
}
|
|
175
170
|
|
|
176
|
-
|
|
171
|
+
if (!placed.ok) {
|
|
172
|
+
return AddFailure.fail({ message: placed.error });
|
|
173
|
+
}
|
|
177
174
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
175
|
+
const { folder } = placed;
|
|
176
|
+
const named = nameOf({
|
|
177
|
+
args: opts.args,
|
|
178
|
+
lib: libName,
|
|
179
|
+
folder,
|
|
180
|
+
packages: opts.packages,
|
|
181
|
+
manifest: opts.manifest,
|
|
182
|
+
});
|
|
181
183
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
interactive: opts.interactive,
|
|
186
|
-
lib: libName,
|
|
187
|
-
config,
|
|
188
|
-
packages: opts.packages,
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
if (!placed.ok) {
|
|
192
|
-
return fail({ message: placed.error });
|
|
193
|
-
}
|
|
184
|
+
if (!named.ok) {
|
|
185
|
+
return AddFailure.fail({ message: named.error });
|
|
186
|
+
}
|
|
194
187
|
|
|
195
|
-
|
|
196
|
-
const named = nameOf({
|
|
197
|
-
args: opts.args,
|
|
198
|
-
lib: libName,
|
|
199
|
-
folder,
|
|
200
|
-
packages: opts.packages,
|
|
201
|
-
manifest: opts.manifest,
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
if (!named.ok) {
|
|
205
|
-
return fail({ message: named.error });
|
|
206
|
-
}
|
|
188
|
+
const path = `${folder}/${libName}`;
|
|
207
189
|
|
|
208
|
-
|
|
190
|
+
if (
|
|
191
|
+
existsSync(join(cwd, path)) ||
|
|
192
|
+
opts.packages.some((entry) => entry.dir === libName || entry.name === named.name)
|
|
193
|
+
) {
|
|
194
|
+
return AddFailure.fail({ message: `${path} already exists` });
|
|
195
|
+
}
|
|
209
196
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
opts.packages.some((entry) => entry.dir === libName || entry.name === named.name)
|
|
213
|
-
) {
|
|
214
|
-
return fail({ message: `${path} already exists` });
|
|
215
|
-
}
|
|
197
|
+
const source = readFileSync(opts.configFile, 'utf8');
|
|
198
|
+
const parsed = AppsBlock.parse({ source });
|
|
216
199
|
|
|
217
|
-
|
|
218
|
-
|
|
200
|
+
if (!parsed.ok) {
|
|
201
|
+
return AddFailure.fail({
|
|
202
|
+
message:
|
|
203
|
+
parsed.reason === AppsBlockProblems.MISSING
|
|
204
|
+
? `the vulcan:apps block is gone from ${opts.configPath} - add the package by hand: { dir: '${libName}', name: '${named.name}', path: '${path}', kind: 'lib' }`
|
|
205
|
+
: `the vulcan:apps block in ${opts.configPath} is not the JSON vulcan wrote - add the package by hand: { dir: '${libName}', name: '${named.name}', path: '${path}', kind: 'lib' }`,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
219
208
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
209
|
+
const sharedBefore = parsed.block.layout.shared;
|
|
210
|
+
const grown = LayoutFolder.withLayoutFolder({ value: sharedBefore, folder });
|
|
211
|
+
// A valid folder the layout does not list yet is added to layout.shared, unless it would nest with another folder.
|
|
212
|
+
const isListed = LayoutFolder.layoutFoldersOf({ value: sharedBefore }).includes(folder);
|
|
213
|
+
const notRecorded = isListed
|
|
214
|
+
? undefined
|
|
215
|
+
: (LayoutFolder.layoutFolderProblem({ folder }) ??
|
|
216
|
+
LayoutFolder.layoutOverlapProblems({
|
|
217
|
+
layout: { ...parsed.block.layout, shared: grown },
|
|
218
|
+
}).join('; '));
|
|
219
|
+
const isNewFolder = !isListed && notRecorded === '';
|
|
220
|
+
const block = opts.recorded({
|
|
221
|
+
block: {
|
|
222
|
+
...parsed.block,
|
|
223
|
+
layout: isNewFolder ? { ...parsed.block.layout, shared: grown } : parsed.block.layout,
|
|
224
|
+
packages: [
|
|
225
|
+
...parsed.block.packages,
|
|
226
|
+
{
|
|
227
|
+
dir: libName,
|
|
228
|
+
name: named.name,
|
|
229
|
+
path,
|
|
230
|
+
kind: PackageKinds.LIB,
|
|
231
|
+
...(kind === LibraryKinds.SHARED ? { presetKind: LibraryKinds.SHARED } : {}),
|
|
232
|
+
},
|
|
233
|
+
],
|
|
234
|
+
},
|
|
226
235
|
});
|
|
227
|
-
|
|
236
|
+
const replaced = AppsBlock.replace({ source, block });
|
|
237
|
+
const nextConfig =
|
|
238
|
+
replaced === undefined || replaced.includes('apps.presets')
|
|
239
|
+
? replaced
|
|
240
|
+
: replaced.replace(
|
|
241
|
+
' packages: apps.packages,\n',
|
|
242
|
+
' packages: apps.packages,\n presets: apps.presets,\n',
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
if (nextConfig === undefined) {
|
|
246
|
+
return AddFailure.fail({
|
|
247
|
+
message: `the vulcan:apps block of ${opts.configPath} cannot be rewritten`,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
228
250
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
: (layoutFolderProblem({ folder }) ??
|
|
236
|
-
layoutOverlapProblems({ layout: { ...parsed.block.layout, shared: grown } }).join('; '));
|
|
237
|
-
const isNewFolder = !isListed && notRecorded === '';
|
|
238
|
-
const block = opts.recorded({
|
|
239
|
-
block: {
|
|
240
|
-
...parsed.block,
|
|
241
|
-
layout: isNewFolder ? { ...parsed.block.layout, shared: grown } : parsed.block.layout,
|
|
242
|
-
packages: [
|
|
243
|
-
...parsed.block.packages,
|
|
244
|
-
{ dir: libName, name: named.name, path, kind: PackageKinds.LIB },
|
|
245
|
-
],
|
|
246
|
-
},
|
|
247
|
-
});
|
|
248
|
-
const replaced = replaceAppsBlock({ source, block });
|
|
249
|
-
const nextConfig =
|
|
250
|
-
replaced === undefined || replaced.includes('apps.presets')
|
|
251
|
-
? replaced
|
|
252
|
-
: replaced.replace(
|
|
253
|
-
' packages: apps.packages,\n',
|
|
254
|
-
' packages: apps.packages,\n presets: apps.presets,\n',
|
|
255
|
-
);
|
|
256
|
-
|
|
257
|
-
if (nextConfig === undefined) {
|
|
258
|
-
return fail({ message: `the vulcan:apps block of ${opts.configPath} cannot be rewritten` });
|
|
259
|
-
}
|
|
251
|
+
const project =
|
|
252
|
+
config.name ?? (typeof opts.manifest.name === 'string' ? opts.manifest.name : libName);
|
|
253
|
+
const warning = WorkspaceDocs.filePresetWarning({
|
|
254
|
+
spec: opts.spec,
|
|
255
|
+
packageName: located.packageName,
|
|
256
|
+
});
|
|
260
257
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
258
|
+
if (warning !== undefined) {
|
|
259
|
+
process.stderr.write(`${warning}\n`);
|
|
260
|
+
}
|
|
264
261
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
262
|
+
// The folder is used all the same; the layout does not list it, so `guard-package` does not cover it.
|
|
263
|
+
if (notRecorded !== undefined && notRecorded !== '') {
|
|
264
|
+
process.stderr.write(
|
|
265
|
+
`note: '${folder}' is not added to layout.shared (${notRecorded}); guard-package does not cover it\n`,
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
268
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
`note: '${folder}' is not added to layout.shared (${notRecorded}); guard-package does not cover it\n`,
|
|
273
|
-
);
|
|
274
|
-
}
|
|
269
|
+
const rows: [string, string][] = [
|
|
270
|
+
[kind === LibraryKinds.SHARED ? 'shared package' : 'library', path],
|
|
271
|
+
];
|
|
275
272
|
|
|
276
|
-
|
|
273
|
+
if (isNewFolder) {
|
|
274
|
+
rows.push([
|
|
275
|
+
'layout',
|
|
276
|
+
`adds '${folder}' to layout.shared (now ${LayoutFolder.describe({ folders: LayoutFolder.layoutFoldersOf({ value: grown }) })})`,
|
|
277
|
+
]);
|
|
278
|
+
}
|
|
277
279
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
'
|
|
281
|
-
|
|
282
|
-
]);
|
|
283
|
-
}
|
|
280
|
+
rows.push(
|
|
281
|
+
['package', named.name],
|
|
282
|
+
['preset', `${located.packageName} ${located.packageVersion}`],
|
|
283
|
+
);
|
|
284
284
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
285
|
+
const confirmed = await WritePlan.confirm({
|
|
286
|
+
title: `Add ${libName}`,
|
|
287
|
+
lines: WritePlan.planLines({ rows }),
|
|
288
|
+
});
|
|
289
289
|
|
|
290
|
-
|
|
290
|
+
if (!confirmed) {
|
|
291
|
+
return AddFailure.fail({ message: ABORTED });
|
|
292
|
+
}
|
|
291
293
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
294
|
+
const written = Preset.copyFiles({
|
|
295
|
+
located,
|
|
296
|
+
files: lib.files,
|
|
297
|
+
target: join(cwd, path),
|
|
298
|
+
tokens: {
|
|
299
|
+
project,
|
|
300
|
+
[kind === LibraryKinds.SHARED ? 'shared' : 'lib']: libName,
|
|
301
|
+
package: named.name,
|
|
302
|
+
},
|
|
303
|
+
});
|
|
295
304
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
target: join(cwd, path),
|
|
300
|
-
tokens: { project, lib: libName, package: named.name },
|
|
301
|
-
});
|
|
305
|
+
for (const file of written) {
|
|
306
|
+
process.stderr.write(` created ${path}/${file}\n`);
|
|
307
|
+
}
|
|
302
308
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
309
|
+
ProjectFile.write({
|
|
310
|
+
root: cwd,
|
|
311
|
+
path: `${path}/package.json`,
|
|
312
|
+
content: WorkspaceManifest.renderLib({ name: named.name, lib }),
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
const nextManifest = WorkspaceManifest.planRoot({
|
|
316
|
+
manifest: opts.manifest,
|
|
317
|
+
globs: ProjectScaffold.readWorkspaceGlobs({ root: cwd }),
|
|
318
|
+
folder,
|
|
319
|
+
additions: { ...lib.dependencies, ...lib.devDependencies, ...lib.peerDependencies },
|
|
320
|
+
});
|
|
306
321
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
path: 'package.json',
|
|
323
|
-
content: renderManifestJson({ value: nextManifest }),
|
|
324
|
-
});
|
|
325
|
-
writeFile({ root: cwd, path: opts.configPath, content: nextConfig });
|
|
326
|
-
writeFile({
|
|
327
|
-
root: cwd,
|
|
328
|
-
path: `${KNOWLEDGE_DIRECTORY}/packages/${libName}.md`,
|
|
329
|
-
content: renderLibConcept({
|
|
330
|
-
name: libName,
|
|
331
|
-
path,
|
|
332
|
-
summary: lib.summary,
|
|
333
|
-
presetPackage: located.packageName,
|
|
334
|
-
}),
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
const indexPath = join(cwd, KNOWLEDGE_DIRECTORY, 'index.md');
|
|
338
|
-
|
|
339
|
-
writeFile({
|
|
340
|
-
root: cwd,
|
|
341
|
-
path: `${KNOWLEDGE_DIRECTORY}/index.md`,
|
|
342
|
-
content: existsSync(indexPath)
|
|
343
|
-
? addAppBullet({
|
|
344
|
-
source: readFileSync(indexPath, 'utf8'),
|
|
345
|
-
app: { name: libName, summary: lib.summary },
|
|
346
|
-
})
|
|
347
|
-
: renderKnowledgeIndex({ project, apps: [{ name: libName, summary: lib.summary }] }),
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
for (const step of [
|
|
351
|
-
() => runBun({ cwd, args: ['install'], label: 'bun install' }),
|
|
352
|
-
() =>
|
|
353
|
-
runBun({
|
|
354
|
-
cwd,
|
|
355
|
-
args: [join(cwd, 'node_modules', '.bin', 'vulcan'), 'sync'],
|
|
356
|
-
label: 'vulcan sync',
|
|
322
|
+
ProjectFile.write({
|
|
323
|
+
root: cwd,
|
|
324
|
+
path: 'package.json',
|
|
325
|
+
content: ManifestJson.render({ value: nextManifest }),
|
|
326
|
+
});
|
|
327
|
+
ProjectFile.write({ root: cwd, path: opts.configPath, content: nextConfig });
|
|
328
|
+
ProjectFile.write({
|
|
329
|
+
root: cwd,
|
|
330
|
+
path: `${KNOWLEDGE_DIRECTORY}/packages/${libName}.md`,
|
|
331
|
+
content: WorkspaceDocs.renderLibConcept({
|
|
332
|
+
name: libName,
|
|
333
|
+
path,
|
|
334
|
+
summary: lib.summary,
|
|
335
|
+
presetPackage: located.packageName,
|
|
336
|
+
kind,
|
|
357
337
|
}),
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
const
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
const indexPath = join(cwd, KNOWLEDGE_DIRECTORY, 'index.md');
|
|
361
341
|
|
|
362
|
-
|
|
363
|
-
|
|
342
|
+
ProjectFile.write({
|
|
343
|
+
root: cwd,
|
|
344
|
+
path: `${KNOWLEDGE_DIRECTORY}/index.md`,
|
|
345
|
+
content: existsSync(indexPath)
|
|
346
|
+
? AppsBlock.addBullet({
|
|
347
|
+
source: readFileSync(indexPath, 'utf8'),
|
|
348
|
+
app: { name: libName, summary: lib.summary },
|
|
349
|
+
})
|
|
350
|
+
: WorkspaceDocs.renderKnowledgeIndex({
|
|
351
|
+
project,
|
|
352
|
+
apps: [{ name: libName, summary: lib.summary }],
|
|
353
|
+
}),
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
for (const step of [
|
|
357
|
+
() => SubProcess.runBun({ cwd, args: ['install'], label: 'bun install' }),
|
|
358
|
+
() =>
|
|
359
|
+
SubProcess.runBun({
|
|
360
|
+
cwd,
|
|
361
|
+
args: [join(cwd, 'node_modules', '.bin', 'vulcan'), 'sync'],
|
|
362
|
+
label: 'vulcan sync',
|
|
363
|
+
}),
|
|
364
|
+
() => AppChecks.run({ root: cwd, appDirectory: join(cwd, path), checks: lib.checks }),
|
|
365
|
+
]) {
|
|
366
|
+
const code = await step();
|
|
367
|
+
|
|
368
|
+
if (code !== ExitCodes.OK) {
|
|
369
|
+
return code;
|
|
370
|
+
}
|
|
364
371
|
}
|
|
365
|
-
}
|
|
366
372
|
|
|
367
|
-
|
|
373
|
+
process.stderr.write(`Done. ${path} is added.\n`);
|
|
368
374
|
|
|
369
|
-
|
|
370
|
-
}
|
|
375
|
+
return ExitCodes.OK;
|
|
376
|
+
}
|
|
377
|
+
}
|
package/src/create/bunfig.ts
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
export class Bunfig {
|
|
2
|
+
/**
|
|
3
|
+
* The root `bunfig.toml` `init` writes: Bun's telemetry off, and the `[fmt]` section `bun fmt` reads.
|
|
4
|
+
* The three options are the settings of the shared style (`@venizia/dev-configs`, formerly
|
|
5
|
+
* `oxfmtConfigs`); the rest is Bun's defaults (tab width 2, trailing commas, semicolons, bracket
|
|
6
|
+
* spacing). `flavor = "oxfmt"` pins the oxfmt output: without it `bun fmt` formats like Prettier
|
|
7
|
+
* whenever oxfmt is not a dependency (a union type's first member moves to its own line, for one).
|
|
8
|
+
* No `minimumReleaseAge`: a gate of a few days fails a fresh install whose version floors are the
|
|
9
|
+
* latest releases (measured on a real project: ten packages), so it stays out; Phat's rule is floors
|
|
10
|
+
* at the latest.
|
|
11
|
+
*/
|
|
12
|
+
static render(): string {
|
|
13
|
+
return [
|
|
14
|
+
'# Bun reads this file from the directory a command runs in, and bun fmt also inherits it from a parent.',
|
|
15
|
+
'# So it sits at the root, and [fmt] applies to every folder below it.',
|
|
16
|
+
'telemetry = false',
|
|
17
|
+
'',
|
|
18
|
+
'[fmt]',
|
|
19
|
+
'printWidth = 100',
|
|
20
|
+
'singleQuote = true',
|
|
21
|
+
'arrowParens = "always"',
|
|
22
|
+
'flavor = "oxfmt"',
|
|
23
|
+
'',
|
|
24
|
+
].join('\n');
|
|
25
|
+
}
|
|
26
|
+
}
|