@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.
Files changed (141) hide show
  1. package/base/extensions/vulcan-guards.ts +48 -41
  2. package/base/hooks/antigravity-guards.ts +2 -2
  3. package/base/hooks/codex-guards.ts +15 -5
  4. package/base/hooks/guard-git.ts +8 -8
  5. package/base/hooks/guard-manifest.ts +4 -5
  6. package/base/hooks/guard-outside.ts +8 -8
  7. package/base/hooks/guard-package.ts +5 -6
  8. package/base/hooks/guard-remote-hosts.ts +6 -7
  9. package/base/hooks/guard-scripting.ts +5 -6
  10. package/base/hooks/guard-writes.ts +8 -9
  11. package/base/hooks/post-tool.ts +2 -2
  12. package/base/hooks/prompt-submit.ts +2 -2
  13. package/base/hooks/session-start.ts +3 -3
  14. package/base/hooks/stop.ts +2 -2
  15. package/base/hooks/subagent-start.ts +2 -2
  16. package/base/skills/docs-update/SKILL.md +4 -2
  17. package/base/skills/visualize-work/SKILL.md +9 -0
  18. package/package.json +3 -3
  19. package/src/agents/atlas-block.ts +43 -43
  20. package/src/agents/codex-hooks.ts +45 -43
  21. package/src/agents/detect.ts +19 -16
  22. package/src/agents/exclude.ts +96 -97
  23. package/src/agents/hooks-json.ts +38 -36
  24. package/src/agents/local.ts +46 -43
  25. package/src/agents/prompt.ts +45 -42
  26. package/src/agents/render.ts +201 -195
  27. package/src/agents/resolve.ts +133 -134
  28. package/src/agents/table.ts +12 -8
  29. package/src/commands/add.command.ts +2 -2
  30. package/src/commands/agents.command.ts +11 -17
  31. package/src/commands/clean.command.ts +6 -6
  32. package/src/commands/doctor.command.ts +4 -4
  33. package/src/commands/init.command.ts +12 -8
  34. package/src/commands/preset.command.ts +2 -2
  35. package/src/commands/profile.command.ts +42 -49
  36. package/src/commands/sync.command.ts +109 -111
  37. package/src/commands/upgrade.command.ts +80 -75
  38. package/src/commands/visualize.command.ts +7 -13
  39. package/src/commands/x.command.ts +55 -50
  40. package/src/common/format.ts +23 -21
  41. package/src/common/json.ts +8 -5
  42. package/src/common/layout-folder.ts +94 -91
  43. package/src/common/paths.ts +14 -12
  44. package/src/config/loader.ts +52 -49
  45. package/src/config/packages.ts +14 -11
  46. package/src/config/schema.ts +3 -3
  47. package/src/create/add-app.ts +519 -509
  48. package/src/create/add-lib.ts +237 -240
  49. package/src/create/bunfig.ts +26 -23
  50. package/src/create/checks.ts +36 -34
  51. package/src/create/diff.ts +21 -23
  52. package/src/create/dockerignore.ts +26 -24
  53. package/src/create/files.ts +7 -5
  54. package/src/create/init-monorepo.ts +75 -80
  55. package/src/create/lib-preset.ts +59 -63
  56. package/src/create/manifest-json.ts +10 -4
  57. package/src/create/names.ts +217 -210
  58. package/src/create/next.ts +26 -23
  59. package/src/create/plan.ts +15 -12
  60. package/src/create/preset-diff.ts +301 -303
  61. package/src/create/preset-menu.ts +38 -32
  62. package/src/create/preset.ts +202 -197
  63. package/src/create/process.ts +79 -72
  64. package/src/create/scratch.ts +48 -49
  65. package/src/create/workspace.ts +404 -396
  66. package/src/doctor/checks.ts +1027 -1014
  67. package/src/doctor/makefile.ts +17 -13
  68. package/src/doctor/runner.ts +88 -118
  69. package/src/doctor/skills.ts +97 -95
  70. package/src/doctor/tags.ts +42 -37
  71. package/src/hooks/codex-patch.ts +25 -22
  72. package/src/hooks/command-view.ts +44 -39
  73. package/src/hooks/decision.ts +37 -37
  74. package/src/hooks/guard-git.ts +51 -49
  75. package/src/hooks/guard-manifest.ts +58 -55
  76. package/src/hooks/guard-outside.ts +93 -91
  77. package/src/hooks/guard-package.ts +82 -79
  78. package/src/hooks/guard-scripting.ts +19 -14
  79. package/src/hooks/guard-writes.ts +154 -149
  80. package/src/hooks/owner-reply.ts +127 -127
  81. package/src/hooks/post-tool.ts +94 -93
  82. package/src/hooks/project-guards.ts +65 -62
  83. package/src/hooks/project-tmp.ts +27 -24
  84. package/src/hooks/remote-hosts.ts +153 -130
  85. package/src/hooks/session-digest.ts +98 -101
  86. package/src/hooks/shell.ts +509 -499
  87. package/src/hooks/subagent-card.ts +11 -7
  88. package/src/hooks/trusted-scripts.ts +106 -104
  89. package/src/init/scaffold.ts +135 -132
  90. package/src/local/clean.ts +38 -36
  91. package/src/local/format.ts +21 -17
  92. package/src/local/scan.ts +144 -138
  93. package/src/manifest/render.ts +110 -104
  94. package/src/owner/card.ts +51 -46
  95. package/src/owner/profile.ts +99 -93
  96. package/src/owner/reply-switch.ts +9 -6
  97. package/src/owner/shape.ts +71 -69
  98. package/src/owner/survey.ts +173 -171
  99. package/src/owner/view.ts +62 -59
  100. package/src/owner/violations.ts +119 -123
  101. package/src/rules/base.ts +15 -11
  102. package/src/rules/parser.ts +39 -32
  103. package/src/rules/slots.ts +8 -6
  104. package/src/signals/claims.ts +30 -28
  105. package/src/signals/classify.ts +38 -33
  106. package/src/signals/loop.ts +39 -37
  107. package/src/signals/state.ts +79 -81
  108. package/src/skills/frontmatter.ts +28 -28
  109. package/src/sync/agent-files.ts +217 -199
  110. package/src/sync/agent-removal.ts +56 -59
  111. package/src/sync/atlas-block.ts +45 -43
  112. package/src/sync/base-rules.ts +32 -30
  113. package/src/sync/claude-launch.ts +36 -34
  114. package/src/sync/exclude.ts +77 -69
  115. package/src/sync/local-choice.ts +50 -47
  116. package/src/sync/planner.ts +59 -61
  117. package/src/sync/prune.ts +52 -48
  118. package/src/sync/settings.ts +166 -167
  119. package/src/ui/capability.ts +12 -7
  120. package/src/ui/keyboard.ts +38 -38
  121. package/src/ui/prompt.ts +79 -77
  122. package/src/visualize/assets.ts +33 -24
  123. package/src/visualize/charts.ts +179 -176
  124. package/src/visualize/compare-css.ts +3 -2
  125. package/src/visualize/compare-render.ts +9 -7
  126. package/src/visualize/diagrams.ts +189 -174
  127. package/src/visualize/grid-span.ts +34 -0
  128. package/src/visualize/icons.ts +7 -5
  129. package/src/visualize/kinds-render.ts +50 -45
  130. package/src/visualize/kinds-validate.ts +12 -10
  131. package/src/visualize/labels.ts +21 -17
  132. package/src/visualize/layout.ts +112 -97
  133. package/src/visualize/page.ts +92 -104
  134. package/src/visualize/render.ts +143 -140
  135. package/src/visualize/sections.ts +395 -384
  136. package/src/visualize/sources.ts +2 -2
  137. package/src/visualize/theme.ts +12 -10
  138. package/src/visualize/validate.ts +13 -9
  139. package/src/wiki/anchors.ts +38 -36
  140. package/src/wiki/command.ts +4 -4
  141. package/src/wiki/source-links.ts +46 -44
@@ -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 { readWorkspaceGlobs } from '../init/index.ts';
15
- import { runAppChecks } from './checks.ts';
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 { writeFile } from './files.ts';
19
- import { readLibPreset } from './lib-preset.ts';
20
- import { renderManifestJson } from './manifest-json.ts';
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, confirmWrite, planLines } from './plan.ts';
23
- import { askInTerminal, readFlag, SCOPE_PATTERN } from './names.ts';
24
- import { copyPresetFiles } from './preset.ts';
25
- import { runBun } from './process.ts';
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 ? ` (${listedFoldersNote({ folders: shared })})` : ''}`,
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
- /** The sibling-name rule needs the entries the config holds, not only the folder's directories. */
145
- export const addLibrary = async (opts: {
146
- cwd: string;
147
- args: string[];
148
- interactive: boolean;
149
- presetValue: string;
150
- spec: IPresetSpec;
151
- located: ILocatedPreset;
152
- config: TResolvedConfig;
153
- configFile: string;
154
- configPath: string;
155
- manifest: Record<string, unknown>;
156
- packages: IProjectPackage[];
157
- libName: string;
158
- /** Which preset kind makes the package: `lib` (the default) or the side-neutral `shared`. */
159
- kind?: TLibraryKind;
160
- recorded: (opts: { block: IAppsBlock }) => IAppsBlock;
161
- }): Promise<number> => {
162
- const { cwd, config, located, libName } = opts;
163
- const kind = opts.kind ?? LibraryKinds.LIB;
164
-
165
- if (!CreateConstants.NAME_PATTERN.test(libName)) {
166
- return AddFailure.fail({
167
- message: `'${libName}' is not a name - lowercase letters, digits and -, starting with a letter or digit`,
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
- const read = readLibPreset({ located, kind });
171
+ if (!placed.ok) {
172
+ return AddFailure.fail({ message: placed.error });
173
+ }
172
174
 
173
- if (!read.ok) {
174
- return AddFailure.fail({ message: read.error });
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
- const lib: TLibPreset = read.lib;
178
- const placed = await folderOf({
179
- args: opts.args,
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
- const { folder } = placed;
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
- const path = `${folder}/${libName}`;
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
- if (
206
- existsSync(join(cwd, path)) ||
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
- const source = readFileSync(opts.configFile, 'utf8');
213
- const parsed = parseAppsBlock({ source });
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
- if (!parsed.ok) {
216
- return AddFailure.fail({
217
- message:
218
- parsed.reason === AppsBlockProblems.MISSING
219
- ? `the vulcan:apps block is gone from ${opts.configPath} - add the package by hand: { dir: '${libName}', name: '${named.name}', path: '${path}', kind: 'lib' }`
220
- : `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' }`,
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
- const sharedBefore = parsed.block.layout.shared;
225
- const grown = withLayoutFolder({ value: sharedBefore, folder });
226
- // A valid folder the layout does not list yet is added to layout.shared, unless it would nest with another folder.
227
- const isListed = layoutFoldersOf({ value: sharedBefore }).includes(folder);
228
- const notRecorded = isListed
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
- const project =
265
- config.name ?? (typeof opts.manifest.name === 'string' ? opts.manifest.name : libName);
266
- const warning = filePresetWarning({ spec: opts.spec, packageName: located.packageName });
258
+ if (warning !== undefined) {
259
+ process.stderr.write(`${warning}\n`);
260
+ }
267
261
 
268
- if (warning !== undefined) {
269
- process.stderr.write(`${warning}\n`);
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
- // The folder is used all the same; the layout does not list it, so `guard-package` does not cover it.
273
- if (notRecorded !== undefined && notRecorded !== '') {
274
- process.stderr.write(
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
- const rows: [string, string][] = [
280
- [kind === LibraryKinds.SHARED ? 'shared package' : 'library', path],
281
- ];
285
+ const confirmed = await WritePlan.confirm({
286
+ title: `Add ${libName}`,
287
+ lines: WritePlan.planLines({ rows }),
288
+ });
282
289
 
283
- if (isNewFolder) {
284
- rows.push([
285
- 'layout',
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
- rows.push(
291
- ['package', named.name],
292
- ['preset', `${located.packageName} ${located.packageVersion}`],
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
- const confirmed = await confirmWrite({ title: `Add ${libName}`, lines: planLines({ rows }) });
305
+ for (const file of written) {
306
+ process.stderr.write(` created ${path}/${file}\n`);
307
+ }
296
308
 
297
- if (!confirmed) {
298
- return AddFailure.fail({ message: ABORTED });
299
- }
309
+ ProjectFile.write({
310
+ root: cwd,
311
+ path: `${path}/package.json`,
312
+ content: WorkspaceManifest.renderLib({ name: named.name, lib }),
313
+ });
300
314
 
301
- const written = copyPresetFiles({
302
- located,
303
- files: lib.files,
304
- target: join(cwd, path),
305
- tokens: {
306
- project,
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
- writeFile({
317
- root: cwd,
318
- path: `${path}/package.json`,
319
- content: renderLibManifest({ name: named.name, lib }),
320
- });
321
-
322
- const nextManifest = planRootManifest({
323
- manifest: opts.manifest,
324
- globs: readWorkspaceGlobs({ root: cwd }),
325
- folder,
326
- additions: { ...lib.dependencies, ...lib.devDependencies, ...lib.peerDependencies },
327
- });
328
-
329
- writeFile({
330
- root: cwd,
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
- () => runAppChecks({ root: cwd, appDirectory: join(cwd, path), checks: lib.checks }),
369
- ]) {
370
- const code = await step();
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
- if (code !== ExitCodes.OK) {
373
- return code;
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
- process.stderr.write(`Done. ${path} is added.\n`);
373
+ process.stderr.write(`Done. ${path} is added.\n`);
378
374
 
379
- return ExitCodes.OK;
380
- };
375
+ return ExitCodes.OK;
376
+ }
377
+ }
@@ -1,23 +1,26 @@
1
- /**
2
- * The root `bunfig.toml` `init` writes: Bun's telemetry off, and the `[fmt]` section `bun fmt` reads.
3
- * The three options are the settings of the shared style (`@venizia/dev-configs`, formerly
4
- * `oxfmtConfigs`); the rest is Bun's defaults (tab width 2, trailing commas, semicolons, bracket
5
- * spacing). `flavor = "oxfmt"` pins the oxfmt output: without it `bun fmt` formats like Prettier
6
- * whenever oxfmt is not a dependency (a union type's first member moves to its own line, for one).
7
- * No `minimumReleaseAge`: a gate of a few days fails a fresh install whose version floors are the
8
- * latest releases (measured on a real project: ten packages), so it stays out; Phat's rule is floors
9
- * at the latest.
10
- */
11
- export const renderBunfig = (): string =>
12
- [
13
- '# Bun reads this file from the directory a command runs in, and bun fmt also inherits it from a parent.',
14
- '# So it sits at the root, and [fmt] applies to every folder below it.',
15
- 'telemetry = false',
16
- '',
17
- '[fmt]',
18
- 'printWidth = 100',
19
- 'singleQuote = true',
20
- 'arrowParens = "always"',
21
- 'flavor = "oxfmt"',
22
- '',
23
- ].join('\n');
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
+ }