@venizia/vulcan 0.4.9-0 → 0.4.9-2
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 +2 -2
- package/base/hooks/codex-guards.ts +15 -5
- package/base/hooks/guard-git.ts +8 -8
- package/base/hooks/guard-manifest.ts +4 -5
- package/base/hooks/guard-outside.ts +8 -8
- package/base/hooks/guard-package.ts +5 -6
- package/base/hooks/guard-remote-hosts.ts +6 -7
- package/base/hooks/guard-scripting.ts +5 -6
- package/base/hooks/guard-writes.ts +8 -9
- package/base/hooks/post-tool.ts +2 -2
- package/base/hooks/prompt-submit.ts +2 -2
- package/base/hooks/session-start.ts +3 -3
- package/base/hooks/stop.ts +2 -2
- package/base/hooks/subagent-start.ts +2 -2
- package/base/skills/docs-update/SKILL.md +4 -2
- package/base/skills/visualize-work/SKILL.md +9 -0
- package/package.json +3 -3
- package/src/agents/atlas-block.ts +43 -43
- package/src/agents/codex-hooks.ts +45 -43
- package/src/agents/detect.ts +19 -16
- package/src/agents/exclude.ts +96 -97
- package/src/agents/hooks-json.ts +38 -36
- package/src/agents/local.ts +46 -43
- package/src/agents/prompt.ts +45 -42
- package/src/agents/render.ts +201 -195
- package/src/agents/resolve.ts +133 -134
- package/src/agents/table.ts +12 -8
- 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 +4 -4
- package/src/commands/init.command.ts +12 -8
- package/src/commands/preset.command.ts +2 -2
- package/src/commands/profile.command.ts +42 -49
- package/src/commands/sync.command.ts +109 -111
- package/src/commands/upgrade.command.ts +80 -75
- package/src/commands/visualize.command.ts +7 -13
- package/src/commands/x.command.ts +55 -50
- package/src/common/format.ts +23 -21
- package/src/common/json.ts +8 -5
- package/src/common/layout-folder.ts +94 -91
- package/src/common/paths.ts +14 -12
- package/src/config/loader.ts +52 -49
- package/src/config/packages.ts +14 -11
- package/src/config/schema.ts +3 -3
- package/src/create/add-app.ts +519 -509
- package/src/create/add-lib.ts +237 -240
- package/src/create/bunfig.ts +26 -23
- package/src/create/checks.ts +36 -34
- 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 +75 -80
- package/src/create/lib-preset.ts +59 -63
- package/src/create/manifest-json.ts +10 -4
- package/src/create/names.ts +217 -210
- package/src/create/next.ts +26 -23
- package/src/create/plan.ts +15 -12
- package/src/create/preset-diff.ts +301 -303
- package/src/create/preset-menu.ts +38 -32
- package/src/create/preset.ts +202 -197
- package/src/create/process.ts +79 -72
- package/src/create/scratch.ts +48 -49
- package/src/create/workspace.ts +404 -396
- package/src/doctor/checks.ts +1027 -1014
- package/src/doctor/makefile.ts +17 -13
- package/src/doctor/runner.ts +88 -118
- package/src/doctor/skills.ts +97 -95
- package/src/doctor/tags.ts +42 -37
- package/src/hooks/codex-patch.ts +25 -22
- package/src/hooks/command-view.ts +44 -39
- package/src/hooks/decision.ts +37 -37
- package/src/hooks/guard-git.ts +51 -49
- package/src/hooks/guard-manifest.ts +58 -55
- package/src/hooks/guard-outside.ts +93 -91
- package/src/hooks/guard-package.ts +82 -79
- package/src/hooks/guard-scripting.ts +19 -14
- package/src/hooks/guard-writes.ts +154 -149
- package/src/hooks/owner-reply.ts +127 -127
- package/src/hooks/post-tool.ts +94 -93
- package/src/hooks/project-guards.ts +65 -62
- package/src/hooks/project-tmp.ts +27 -24
- package/src/hooks/remote-hosts.ts +153 -130
- package/src/hooks/session-digest.ts +98 -101
- package/src/hooks/shell.ts +509 -499
- package/src/hooks/subagent-card.ts +11 -7
- package/src/hooks/trusted-scripts.ts +106 -104
- package/src/init/scaffold.ts +135 -132
- package/src/local/clean.ts +38 -36
- package/src/local/format.ts +21 -17
- package/src/local/scan.ts +144 -138
- package/src/manifest/render.ts +110 -104
- package/src/owner/card.ts +51 -46
- package/src/owner/profile.ts +99 -93
- package/src/owner/reply-switch.ts +9 -6
- package/src/owner/shape.ts +71 -69
- package/src/owner/survey.ts +173 -171
- package/src/owner/view.ts +62 -59
- package/src/owner/violations.ts +119 -123
- package/src/rules/base.ts +15 -11
- 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 +38 -33
- package/src/signals/loop.ts +39 -37
- package/src/signals/state.ts +79 -81
- package/src/skills/frontmatter.ts +28 -28
- package/src/sync/agent-files.ts +217 -199
- package/src/sync/agent-removal.ts +56 -59
- package/src/sync/atlas-block.ts +45 -43
- package/src/sync/base-rules.ts +32 -30
- package/src/sync/claude-launch.ts +36 -34
- package/src/sync/exclude.ts +77 -69
- package/src/sync/local-choice.ts +50 -47
- package/src/sync/planner.ts +59 -61
- package/src/sync/prune.ts +52 -48
- package/src/sync/settings.ts +166 -167
- package/src/ui/capability.ts +12 -7
- package/src/ui/keyboard.ts +38 -38
- package/src/ui/prompt.ts +79 -77
- package/src/visualize/assets.ts +33 -24
- package/src/visualize/charts.ts +179 -176
- package/src/visualize/compare-css.ts +3 -2
- package/src/visualize/compare-render.ts +9 -7
- package/src/visualize/diagrams.ts +189 -174
- package/src/visualize/grid-span.ts +34 -0
- package/src/visualize/icons.ts +7 -5
- package/src/visualize/kinds-render.ts +50 -45
- package/src/visualize/kinds-validate.ts +12 -10
- package/src/visualize/labels.ts +21 -17
- package/src/visualize/layout.ts +112 -97
- package/src/visualize/page.ts +92 -104
- package/src/visualize/render.ts +143 -140
- package/src/visualize/sections.ts +395 -384
- package/src/visualize/sources.ts +2 -2
- package/src/visualize/theme.ts +12 -10
- package/src/visualize/validate.ts +13 -9
- package/src/wiki/anchors.ts +38 -36
- package/src/wiki/command.ts +4 -4
- package/src/wiki/source-links.ts +46 -44
package/src/create/add-lib.ts
CHANGED
|
@@ -1,38 +1,22 @@
|
|
|
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
|
-
describeFolders,
|
|
6
|
-
layoutFolderProblem,
|
|
7
|
-
layoutFoldersOf,
|
|
8
|
-
layoutOverlapProblems,
|
|
9
|
-
listedFoldersNote,
|
|
10
|
-
withLayoutFolder,
|
|
11
|
-
} from '../common/layout-folder.ts';
|
|
4
|
+
import { LayoutFolder } from '../common/layout-folder.ts';
|
|
12
5
|
import { LibraryKinds, PackageKinds } from '../config/index.ts';
|
|
13
6
|
import type { IProjectPackage, TLibraryKind, TResolvedConfig } from '../config/index.ts';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
7
|
+
import { ProjectScaffold } from '../init/index.ts';
|
|
8
|
+
import { AppChecks } from './checks.ts';
|
|
16
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._-]*$/;
|
|
@@ -58,7 +42,7 @@ const folderOf = async (opts: {
|
|
|
58
42
|
config: TResolvedConfig;
|
|
59
43
|
packages: IProjectPackage[];
|
|
60
44
|
}): Promise<{ ok: true; folder: string } | { ok: false; error: string }> => {
|
|
61
|
-
const given = readFlag({ args: opts.args, flag: CreateFlags.DIR });
|
|
45
|
+
const given = ProjectNames.readFlag({ args: opts.args, flag: CreateFlags.DIR });
|
|
62
46
|
const libFolders = [
|
|
63
47
|
...new Set(
|
|
64
48
|
opts.packages
|
|
@@ -66,7 +50,7 @@ const folderOf = async (opts: {
|
|
|
66
50
|
.map((entry) => dirname(entry.path)),
|
|
67
51
|
),
|
|
68
52
|
];
|
|
69
|
-
const shared = layoutFoldersOf({ value: opts.config.layout?.shared });
|
|
53
|
+
const shared = LayoutFolder.layoutFoldersOf({ value: opts.config.layout?.shared });
|
|
70
54
|
// One shared folder is the answer; with none the one folder the libraries share is; several are for `--dir` or a menu.
|
|
71
55
|
const fallback =
|
|
72
56
|
shared.length === 1
|
|
@@ -97,7 +81,7 @@ const folderOf = async (opts: {
|
|
|
97
81
|
if (chosen === undefined) {
|
|
98
82
|
return {
|
|
99
83
|
ok: false,
|
|
100
|
-
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 })})` : ''}`,
|
|
101
85
|
};
|
|
102
86
|
}
|
|
103
87
|
|
|
@@ -116,7 +100,7 @@ const nameOf = (opts: {
|
|
|
116
100
|
packages: IProjectPackage[];
|
|
117
101
|
manifest: Record<string, unknown>;
|
|
118
102
|
}): { ok: true; name: string } | { ok: false; error: string } => {
|
|
119
|
-
const given = readFlag({ args: opts.args, flag: CreateFlags.SCOPE });
|
|
103
|
+
const given = ProjectNames.readFlag({ args: opts.args, flag: CreateFlags.SCOPE });
|
|
120
104
|
|
|
121
105
|
if (given !== undefined) {
|
|
122
106
|
return SCOPE_PATTERN.test(given)
|
|
@@ -141,240 +125,253 @@ const nameOf = (opts: {
|
|
|
141
125
|
return { ok: true, name: scope === '' ? opts.lib : `${scope}/${opts.lib}` };
|
|
142
126
|
};
|
|
143
127
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
})
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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,
|
|
168
169
|
});
|
|
169
|
-
}
|
|
170
170
|
|
|
171
|
-
|
|
171
|
+
if (!placed.ok) {
|
|
172
|
+
return AddFailure.fail({ message: placed.error });
|
|
173
|
+
}
|
|
172
174
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
+
});
|
|
176
183
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
interactive: opts.interactive,
|
|
181
|
-
lib: libName,
|
|
182
|
-
config,
|
|
183
|
-
packages: opts.packages,
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
if (!placed.ok) {
|
|
187
|
-
return AddFailure.fail({ message: placed.error });
|
|
188
|
-
}
|
|
184
|
+
if (!named.ok) {
|
|
185
|
+
return AddFailure.fail({ message: named.error });
|
|
186
|
+
}
|
|
189
187
|
|
|
190
|
-
|
|
191
|
-
const named = nameOf({
|
|
192
|
-
args: opts.args,
|
|
193
|
-
lib: libName,
|
|
194
|
-
folder,
|
|
195
|
-
packages: opts.packages,
|
|
196
|
-
manifest: opts.manifest,
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
if (!named.ok) {
|
|
200
|
-
return AddFailure.fail({ message: named.error });
|
|
201
|
-
}
|
|
188
|
+
const path = `${folder}/${libName}`;
|
|
202
189
|
|
|
203
|
-
|
|
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
|
+
}
|
|
204
196
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
opts.packages.some((entry) => entry.dir === libName || entry.name === named.name)
|
|
208
|
-
) {
|
|
209
|
-
return AddFailure.fail({ message: `${path} already exists` });
|
|
210
|
-
}
|
|
197
|
+
const source = readFileSync(opts.configFile, 'utf8');
|
|
198
|
+
const parsed = AppsBlock.parse({ source });
|
|
211
199
|
|
|
212
|
-
|
|
213
|
-
|
|
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
|
+
}
|
|
214
208
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
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
|
+
},
|
|
221
235
|
});
|
|
222
|
-
|
|
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
|
+
}
|
|
223
250
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
? undefined
|
|
230
|
-
: (layoutFolderProblem({ folder }) ??
|
|
231
|
-
layoutOverlapProblems({ layout: { ...parsed.block.layout, shared: grown } }).join('; '));
|
|
232
|
-
const isNewFolder = !isListed && notRecorded === '';
|
|
233
|
-
const block = opts.recorded({
|
|
234
|
-
block: {
|
|
235
|
-
...parsed.block,
|
|
236
|
-
layout: isNewFolder ? { ...parsed.block.layout, shared: grown } : parsed.block.layout,
|
|
237
|
-
packages: [
|
|
238
|
-
...parsed.block.packages,
|
|
239
|
-
{
|
|
240
|
-
dir: libName,
|
|
241
|
-
name: named.name,
|
|
242
|
-
path,
|
|
243
|
-
kind: PackageKinds.LIB,
|
|
244
|
-
...(kind === LibraryKinds.SHARED ? { presetKind: LibraryKinds.SHARED } : {}),
|
|
245
|
-
},
|
|
246
|
-
],
|
|
247
|
-
},
|
|
248
|
-
});
|
|
249
|
-
const replaced = replaceAppsBlock({ source, block });
|
|
250
|
-
const nextConfig =
|
|
251
|
-
replaced === undefined || replaced.includes('apps.presets')
|
|
252
|
-
? replaced
|
|
253
|
-
: replaced.replace(
|
|
254
|
-
' packages: apps.packages,\n',
|
|
255
|
-
' packages: apps.packages,\n presets: apps.presets,\n',
|
|
256
|
-
);
|
|
257
|
-
|
|
258
|
-
if (nextConfig === undefined) {
|
|
259
|
-
return AddFailure.fail({
|
|
260
|
-
message: `the vulcan:apps block of ${opts.configPath} cannot be rewritten`,
|
|
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,
|
|
261
256
|
});
|
|
262
|
-
}
|
|
263
257
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
258
|
+
if (warning !== undefined) {
|
|
259
|
+
process.stderr.write(`${warning}\n`);
|
|
260
|
+
}
|
|
267
261
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
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
|
+
|
|
269
|
+
const rows: [string, string][] = [
|
|
270
|
+
[kind === LibraryKinds.SHARED ? 'shared package' : 'library', path],
|
|
271
|
+
];
|
|
272
|
+
|
|
273
|
+
if (isNewFolder) {
|
|
274
|
+
rows.push([
|
|
275
|
+
'layout',
|
|
276
|
+
`adds '${folder}' to layout.shared (now ${LayoutFolder.describe({ folders: LayoutFolder.layoutFoldersOf({ value: grown }) })})`,
|
|
277
|
+
]);
|
|
278
|
+
}
|
|
271
279
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
`note: '${folder}' is not added to layout.shared (${notRecorded}); guard-package does not cover it\n`,
|
|
280
|
+
rows.push(
|
|
281
|
+
['package', named.name],
|
|
282
|
+
['preset', `${located.packageName} ${located.packageVersion}`],
|
|
276
283
|
);
|
|
277
|
-
}
|
|
278
284
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
285
|
+
const confirmed = await WritePlan.confirm({
|
|
286
|
+
title: `Add ${libName}`,
|
|
287
|
+
lines: WritePlan.planLines({ rows }),
|
|
288
|
+
});
|
|
282
289
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
`adds '${folder}' to layout.shared (now ${describeFolders({ folders: layoutFoldersOf({ value: grown }) })})`,
|
|
287
|
-
]);
|
|
288
|
-
}
|
|
290
|
+
if (!confirmed) {
|
|
291
|
+
return AddFailure.fail({ message: ABORTED });
|
|
292
|
+
}
|
|
289
293
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
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
|
+
});
|
|
294
304
|
|
|
295
|
-
|
|
305
|
+
for (const file of written) {
|
|
306
|
+
process.stderr.write(` created ${path}/${file}\n`);
|
|
307
|
+
}
|
|
296
308
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
309
|
+
ProjectFile.write({
|
|
310
|
+
root: cwd,
|
|
311
|
+
path: `${path}/package.json`,
|
|
312
|
+
content: WorkspaceManifest.renderLib({ name: named.name, lib }),
|
|
313
|
+
});
|
|
300
314
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
[kind === LibraryKinds.SHARED ? 'shared' : 'lib']: libName,
|
|
308
|
-
package: named.name,
|
|
309
|
-
},
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
for (const file of written) {
|
|
313
|
-
process.stderr.write(` created ${path}/${file}\n`);
|
|
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
|
+
});
|
|
315
321
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
path: 'package.json',
|
|
332
|
-
content: renderManifestJson({ value: nextManifest }),
|
|
333
|
-
});
|
|
334
|
-
writeFile({ root: cwd, path: opts.configPath, content: nextConfig });
|
|
335
|
-
writeFile({
|
|
336
|
-
root: cwd,
|
|
337
|
-
path: `${KNOWLEDGE_DIRECTORY}/packages/${libName}.md`,
|
|
338
|
-
content: renderLibConcept({
|
|
339
|
-
name: libName,
|
|
340
|
-
path,
|
|
341
|
-
summary: lib.summary,
|
|
342
|
-
presetPackage: located.packageName,
|
|
343
|
-
kind,
|
|
344
|
-
}),
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
const indexPath = join(cwd, KNOWLEDGE_DIRECTORY, 'index.md');
|
|
348
|
-
|
|
349
|
-
writeFile({
|
|
350
|
-
root: cwd,
|
|
351
|
-
path: `${KNOWLEDGE_DIRECTORY}/index.md`,
|
|
352
|
-
content: existsSync(indexPath)
|
|
353
|
-
? addAppBullet({
|
|
354
|
-
source: readFileSync(indexPath, 'utf8'),
|
|
355
|
-
app: { name: libName, summary: lib.summary },
|
|
356
|
-
})
|
|
357
|
-
: renderKnowledgeIndex({ project, apps: [{ name: libName, summary: lib.summary }] }),
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
for (const step of [
|
|
361
|
-
() => runBun({ cwd, args: ['install'], label: 'bun install' }),
|
|
362
|
-
() =>
|
|
363
|
-
runBun({
|
|
364
|
-
cwd,
|
|
365
|
-
args: [join(cwd, 'node_modules', '.bin', 'vulcan'), 'sync'],
|
|
366
|
-
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,
|
|
367
337
|
}),
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
const
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
const indexPath = join(cwd, KNOWLEDGE_DIRECTORY, 'index.md');
|
|
341
|
+
|
|
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
|
+
});
|
|
371
355
|
|
|
372
|
-
|
|
373
|
-
|
|
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
|
+
}
|
|
374
371
|
}
|
|
375
|
-
}
|
|
376
372
|
|
|
377
|
-
|
|
373
|
+
process.stderr.write(`Done. ${path} is added.\n`);
|
|
378
374
|
|
|
379
|
-
|
|
380
|
-
}
|
|
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
|
+
}
|