@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.
Files changed (179) hide show
  1. package/base/extensions/vulcan-guards.ts +48 -41
  2. package/base/hooks/antigravity-guards.ts +4 -3
  3. package/base/hooks/codex-guards.ts +17 -6
  4. package/base/hooks/guard-git.ts +8 -8
  5. package/base/hooks/guard-manifest.ts +5 -5
  6. package/base/hooks/guard-outside.ts +8 -8
  7. package/base/hooks/guard-package.ts +6 -6
  8. package/base/hooks/guard-remote-hosts.ts +14 -9
  9. package/base/hooks/guard-scripting.ts +6 -6
  10. package/base/hooks/guard-writes.ts +20 -11
  11. package/base/hooks/post-tool.ts +4 -3
  12. package/base/hooks/prompt-submit.ts +4 -3
  13. package/base/hooks/session-start.ts +5 -3
  14. package/base/hooks/stop.ts +4 -3
  15. package/base/hooks/subagent-start.ts +2 -2
  16. package/base/make/vulcan.mk +1 -4
  17. package/base/skills/build-a-feature/SKILL.md +1 -1
  18. package/base/skills/docs-update/SKILL.md +11 -5
  19. package/base/skills/docs-update/evals/evals.json +1 -1
  20. package/base/skills/docs-writing/SKILL.md +1 -1
  21. package/base/skills/plan-a-change/references/spec-card.md +1 -1
  22. package/base/skills/ship/SKILL.md +1 -1
  23. package/base/skills/visualize-work/SKILL.md +29 -6
  24. package/base/skills/visualize-work/references/spec.md +16 -5
  25. package/package.json +5 -6
  26. package/src/agents/atlas-block.ts +43 -43
  27. package/src/agents/codex-hooks.ts +55 -52
  28. package/src/agents/common/types.ts +1 -1
  29. package/src/agents/detect.ts +19 -16
  30. package/src/agents/exclude.ts +97 -98
  31. package/src/agents/hooks-json.ts +41 -43
  32. package/src/agents/local.ts +46 -43
  33. package/src/agents/prompt.ts +45 -42
  34. package/src/agents/render.ts +203 -201
  35. package/src/agents/resolve.ts +133 -134
  36. package/src/agents/table.ts +12 -8
  37. package/src/cli.ts +3 -1
  38. package/src/commands/add.command.ts +2 -2
  39. package/src/commands/agents.command.ts +11 -17
  40. package/src/commands/clean.command.ts +6 -6
  41. package/src/commands/doctor.command.ts +6 -4
  42. package/src/commands/help.command.ts +11 -9
  43. package/src/commands/init.command.ts +14 -8
  44. package/src/commands/preset.command.ts +2 -2
  45. package/src/commands/profile.command.ts +43 -50
  46. package/src/commands/sync.command.ts +109 -111
  47. package/src/commands/upgrade.command.ts +85 -78
  48. package/src/commands/visualize.command.ts +20 -5
  49. package/src/commands/x.command.ts +55 -50
  50. package/src/common/format.ts +23 -21
  51. package/src/common/index.ts +2 -0
  52. package/src/common/json.ts +8 -5
  53. package/src/common/layout-folder.ts +96 -111
  54. package/src/common/paths.ts +14 -12
  55. package/src/common/record.ts +7 -0
  56. package/src/common/text.ts +7 -0
  57. package/src/config/common/constants.ts +13 -1
  58. package/src/config/common/types.ts +8 -1
  59. package/src/config/loader.ts +53 -48
  60. package/src/config/packages.ts +17 -11
  61. package/src/config/schema.ts +54 -7
  62. package/src/create/add-app.ts +604 -493
  63. package/src/create/add-lib.ts +249 -242
  64. package/src/create/bunfig.ts +26 -23
  65. package/src/create/checks.ts +36 -34
  66. package/src/create/common/constants.ts +1 -0
  67. package/src/create/common/failure.ts +10 -0
  68. package/src/create/common/index.ts +2 -0
  69. package/src/create/common/preset-path.ts +11 -0
  70. package/src/create/common/types.ts +7 -2
  71. package/src/create/diff.ts +21 -23
  72. package/src/create/dockerignore.ts +26 -24
  73. package/src/create/files.ts +7 -5
  74. package/src/create/init-monorepo.ts +78 -80
  75. package/src/create/lib-preset.ts +62 -61
  76. package/src/create/manifest-json.ts +10 -4
  77. package/src/create/names.ts +217 -210
  78. package/src/create/next.ts +27 -24
  79. package/src/create/plan.ts +15 -12
  80. package/src/create/preset-diff.ts +415 -240
  81. package/src/create/preset-menu.ts +40 -34
  82. package/src/create/preset.ts +207 -194
  83. package/src/create/process.ts +80 -71
  84. package/src/create/scratch.ts +49 -48
  85. package/src/create/workspace.ts +423 -398
  86. package/src/doctor/checks.ts +1069 -998
  87. package/src/doctor/makefile.ts +17 -13
  88. package/src/doctor/runner.ts +88 -116
  89. package/src/doctor/skills.ts +97 -95
  90. package/src/doctor/tags.ts +44 -41
  91. package/src/hooks/codex-patch.ts +27 -24
  92. package/src/hooks/command-view.ts +44 -39
  93. package/src/hooks/common/constants.ts +0 -3
  94. package/src/hooks/common/types.ts +15 -1
  95. package/src/hooks/decision.ts +38 -42
  96. package/src/hooks/guard-git.ts +52 -50
  97. package/src/hooks/guard-manifest.ts +58 -55
  98. package/src/hooks/guard-outside.ts +109 -88
  99. package/src/hooks/guard-package.ts +86 -77
  100. package/src/hooks/guard-scripting.ts +20 -15
  101. package/src/hooks/guard-writes.ts +169 -111
  102. package/src/hooks/owner-reply.ts +128 -128
  103. package/src/hooks/post-tool.ts +94 -93
  104. package/src/hooks/project-guards.ts +93 -55
  105. package/src/hooks/project-tmp.ts +27 -24
  106. package/src/hooks/remote-hosts.ts +157 -149
  107. package/src/hooks/session-digest.ts +99 -95
  108. package/src/hooks/shell.ts +519 -500
  109. package/src/hooks/subagent-card.ts +11 -7
  110. package/src/hooks/trusted-scripts.ts +158 -80
  111. package/src/init/common/types.ts +1 -1
  112. package/src/init/scaffold.ts +137 -134
  113. package/src/local/clean.ts +39 -37
  114. package/src/local/format.ts +21 -17
  115. package/src/local/scan.ts +146 -140
  116. package/src/manifest/render.ts +127 -112
  117. package/src/owner/card.ts +51 -46
  118. package/src/owner/profile.ts +100 -96
  119. package/src/owner/reply-switch.ts +9 -6
  120. package/src/owner/shape.ts +72 -70
  121. package/src/owner/survey.ts +175 -164
  122. package/src/owner/view.ts +62 -59
  123. package/src/owner/violations.ts +119 -123
  124. package/src/router.ts +4 -1
  125. package/src/rules/base.ts +15 -11
  126. package/src/rules/common/types.ts +1 -1
  127. package/src/rules/parser.ts +39 -32
  128. package/src/rules/slots.ts +8 -6
  129. package/src/signals/claims.ts +30 -28
  130. package/src/signals/classify.ts +36 -33
  131. package/src/signals/loop.ts +39 -37
  132. package/src/signals/state.ts +80 -85
  133. package/src/skills/frontmatter.ts +28 -28
  134. package/src/sync/agent-files.ts +217 -199
  135. package/src/sync/agent-removal.ts +62 -68
  136. package/src/sync/atlas-block.ts +45 -43
  137. package/src/sync/base-rules.ts +32 -30
  138. package/src/sync/claude-launch.ts +74 -37
  139. package/src/sync/common/constants.ts +4 -0
  140. package/src/sync/common/index.ts +1 -0
  141. package/src/sync/common/symlink.ts +9 -0
  142. package/src/sync/common/types.ts +2 -2
  143. package/src/sync/exclude.ts +77 -69
  144. package/src/sync/local-choice.ts +50 -47
  145. package/src/sync/planner.ts +64 -68
  146. package/src/sync/prune.ts +52 -48
  147. package/src/sync/settings.ts +167 -168
  148. package/src/ui/capability.ts +12 -7
  149. package/src/ui/keyboard.ts +35 -33
  150. package/src/ui/prompt.ts +81 -77
  151. package/src/visualize/assets.ts +379 -195
  152. package/src/visualize/charts.ts +188 -176
  153. package/src/visualize/compare-css.ts +31 -0
  154. package/src/visualize/compare-render.ts +196 -0
  155. package/src/visualize/compare-schema.ts +81 -0
  156. package/src/visualize/compare-validate.ts +126 -0
  157. package/src/visualize/constants.ts +29 -3
  158. package/src/visualize/diagrams.ts +189 -174
  159. package/src/visualize/gate.ts +136 -0
  160. package/src/visualize/grid-span.ts +34 -0
  161. package/src/visualize/icons.ts +9 -4
  162. package/src/visualize/index.ts +2 -0
  163. package/src/visualize/kinds-css.ts +54 -0
  164. package/src/visualize/kinds-render.ts +698 -0
  165. package/src/visualize/kinds-schema.ts +148 -0
  166. package/src/visualize/kinds-validate.ts +186 -0
  167. package/src/visualize/labels-vi.ts +109 -0
  168. package/src/visualize/labels.ts +53 -0
  169. package/src/visualize/layout.ts +112 -92
  170. package/src/visualize/page.ts +140 -114
  171. package/src/visualize/render.ts +158 -114
  172. package/src/visualize/schema.ts +21 -1
  173. package/src/visualize/sections.ts +401 -309
  174. package/src/visualize/sources.ts +270 -0
  175. package/src/visualize/theme.ts +474 -0
  176. package/src/visualize/validate.ts +15 -5
  177. package/src/wiki/anchors.ts +39 -37
  178. package/src/wiki/command.ts +4 -4
  179. package/src/wiki/source-links.ts +49 -49
@@ -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
- describeFolders,
6
- layoutFolderProblem,
7
- layoutFoldersOf,
8
- layoutOverlapProblems,
9
- listedFoldersNote,
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 { 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._-]*$/;
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 answer =
89
- (
90
- await askInTerminal({
91
- question: 'Folder',
92
- previous: fallback,
93
- choices: [
94
- ...new Set([...shared, ...(fallback === undefined ? [] : [fallback]), ...libFolders]),
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 ? ` (${listedFoldersNote({ folders: shared })})` : ''}`,
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
- /** The sibling-name rule needs the entries the config holds, not only the folder's directories. */
153
- export const addLibrary = async (opts: {
154
- cwd: string;
155
- args: string[];
156
- interactive: boolean;
157
- presetValue: string;
158
- spec: IPresetSpec;
159
- located: ILocatedPreset;
160
- config: TResolvedConfig;
161
- configFile: string;
162
- configPath: string;
163
- manifest: Record<string, unknown>;
164
- packages: IProjectPackage[];
165
- libName: string;
166
- recorded: (opts: { block: IAppsBlock }) => IAppsBlock;
167
- }): Promise<number> => {
168
- const { cwd, config, located, libName } = opts;
169
-
170
- if (!CreateConstants.NAME_PATTERN.test(libName)) {
171
- return fail({
172
- 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,
173
169
  });
174
- }
175
170
 
176
- const read = readLibPreset({ located });
171
+ if (!placed.ok) {
172
+ return AddFailure.fail({ message: placed.error });
173
+ }
177
174
 
178
- if (!read.ok) {
179
- return fail({ message: read.error });
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
- const lib: TLibPreset = read.lib;
183
- const placed = await folderOf({
184
- args: opts.args,
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
- const { folder } = placed;
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
- 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
+ }
209
196
 
210
- if (
211
- existsSync(join(cwd, path)) ||
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
- const source = readFileSync(opts.configFile, 'utf8');
218
- 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
+ }
219
208
 
220
- if (!parsed.ok) {
221
- return fail({
222
- message:
223
- parsed.reason === AppsBlockProblems.MISSING
224
- ? `the vulcan:apps block is gone from ${opts.configPath} - add the package by hand: { dir: '${libName}', name: '${named.name}', path: '${path}', kind: 'lib' }`
225
- : `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
+ },
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
- const sharedBefore = parsed.block.layout.shared;
230
- const grown = withLayoutFolder({ value: sharedBefore, folder });
231
- // A valid folder the layout does not list yet is added to layout.shared, unless it would nest with another folder.
232
- const isListed = layoutFoldersOf({ value: sharedBefore }).includes(folder);
233
- const notRecorded = isListed
234
- ? undefined
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
- const project =
262
- config.name ?? (typeof opts.manifest.name === 'string' ? opts.manifest.name : libName);
263
- const warning = filePresetWarning({ spec: opts.spec, packageName: located.packageName });
258
+ if (warning !== undefined) {
259
+ process.stderr.write(`${warning}\n`);
260
+ }
264
261
 
265
- if (warning !== undefined) {
266
- process.stderr.write(`${warning}\n`);
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
- // The folder is used all the same; the layout does not list it, so `guard-package` does not cover it.
270
- if (notRecorded !== undefined && notRecorded !== '') {
271
- process.stderr.write(
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
- const rows: [string, string][] = [['library', path]];
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
- if (isNewFolder) {
279
- rows.push([
280
- 'layout',
281
- `adds '${folder}' to layout.shared (now ${describeFolders({ folders: layoutFoldersOf({ value: grown }) })})`,
282
- ]);
283
- }
280
+ rows.push(
281
+ ['package', named.name],
282
+ ['preset', `${located.packageName} ${located.packageVersion}`],
283
+ );
284
284
 
285
- rows.push(
286
- ['package', named.name],
287
- ['preset', `${located.packageName} ${located.packageVersion}`],
288
- );
285
+ const confirmed = await WritePlan.confirm({
286
+ title: `Add ${libName}`,
287
+ lines: WritePlan.planLines({ rows }),
288
+ });
289
289
 
290
- const confirmed = await confirmWrite({ title: `Add ${libName}`, lines: planLines({ rows }) });
290
+ if (!confirmed) {
291
+ return AddFailure.fail({ message: ABORTED });
292
+ }
291
293
 
292
- if (!confirmed) {
293
- return fail({ message: ABORTED });
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
- const written = copyPresetFiles({
297
- located,
298
- files: lib.files,
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
- for (const file of written) {
304
- process.stderr.write(` created ${path}/${file}\n`);
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
- writeFile({
308
- root: cwd,
309
- path: `${path}/package.json`,
310
- content: renderLibManifest({ name: named.name, lib }),
311
- });
312
-
313
- const nextManifest = planRootManifest({
314
- manifest: opts.manifest,
315
- globs: readWorkspaceGlobs({ root: cwd }),
316
- folder,
317
- additions: { ...lib.dependencies, ...lib.devDependencies, ...lib.peerDependencies },
318
- });
319
-
320
- writeFile({
321
- root: cwd,
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
- () => runAppChecks({ root: cwd, appDirectory: join(cwd, path), checks: lib.checks }),
359
- ]) {
360
- const code = await step();
338
+ });
339
+
340
+ const indexPath = join(cwd, KNOWLEDGE_DIRECTORY, 'index.md');
361
341
 
362
- if (code !== ExitCodes.OK) {
363
- return code;
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
- process.stderr.write(`Done. ${path} is added.\n`);
373
+ process.stderr.write(`Done. ${path} is added.\n`);
368
374
 
369
- return ExitCodes.OK;
370
- };
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
+ }