@venizia/vulcan 0.3.5 → 0.3.6

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 (55) hide show
  1. package/README.md +2 -2
  2. package/base/agents.json +232 -0
  3. package/base/claude/settings.json +12 -0
  4. package/base/hooks/guard-package.ts +29 -0
  5. package/base/rules.md +1 -0
  6. package/base/templates/AGENTS.md +4 -3
  7. package/package.json +3 -3
  8. package/src/agents/atlas-block.ts +54 -0
  9. package/src/agents/common/constants.ts +38 -0
  10. package/src/agents/common/index.ts +3 -0
  11. package/src/agents/common/schema.ts +42 -0
  12. package/src/agents/common/types.ts +30 -0
  13. package/src/agents/detect.ts +36 -0
  14. package/src/agents/exclude.ts +87 -0
  15. package/src/agents/index.ts +9 -0
  16. package/src/agents/local.ts +65 -0
  17. package/src/agents/prompt.ts +22 -0
  18. package/src/agents/render.ts +229 -0
  19. package/src/agents/resolve.ts +145 -0
  20. package/src/agents/table.ts +35 -0
  21. package/src/commands/agents.command.ts +154 -0
  22. package/src/commands/doctor.command.ts +5 -1
  23. package/src/commands/help.command.ts +5 -1
  24. package/src/commands/index.ts +2 -0
  25. package/src/commands/sync.command.ts +112 -3
  26. package/src/common/constants.ts +9 -1
  27. package/src/config/common/constants.ts +11 -1
  28. package/src/config/packages.ts +2 -0
  29. package/src/config/schema.ts +16 -1
  30. package/src/create/add-app.ts +110 -4
  31. package/src/create/add-lib.ts +317 -0
  32. package/src/create/common/constants.ts +3 -0
  33. package/src/create/common/types.ts +18 -2
  34. package/src/create/dockerignore.ts +36 -0
  35. package/src/create/init-monorepo.ts +22 -4
  36. package/src/create/lib-preset.ts +154 -0
  37. package/src/create/preset.ts +22 -3
  38. package/src/create/workspace.ts +94 -3
  39. package/src/doctor/checks.ts +183 -12
  40. package/src/doctor/common/constants.ts +26 -0
  41. package/src/doctor/runner.ts +22 -0
  42. package/src/hooks/guard-package.ts +211 -0
  43. package/src/hooks/index.ts +1 -0
  44. package/src/init/scaffold.ts +8 -5
  45. package/src/manifest/render.ts +4 -0
  46. package/src/router.ts +10 -1
  47. package/src/sync/agent-files.ts +112 -0
  48. package/src/sync/agent-removal.ts +241 -0
  49. package/src/sync/atlas-block.ts +55 -0
  50. package/src/sync/common/constants.ts +2 -0
  51. package/src/sync/exclude.ts +89 -0
  52. package/src/sync/index.ts +5 -0
  53. package/src/sync/local-choice.ts +55 -0
  54. package/src/sync/planner.ts +55 -19
  55. package/src/sync/settings.ts +26 -0
@@ -10,11 +10,13 @@ import {
10
10
  writeFileSync,
11
11
  } from 'node:fs';
12
12
  import { basename, dirname, join, resolve } from 'node:path';
13
+ import { readAgentTable } from '../agents/index.ts';
13
14
  import { BASE_DIRECTORY, stableBaseDirectoryOf } from '../common/index.ts';
14
15
  import { CodingAgents } from '../config/index.ts';
15
16
  import type { TResolvedConfig } from '../config/index.ts';
16
17
  import { ManifestConstants, renderManifest } from '../manifest/index.ts';
17
18
  import { readSlots } from '../rules/index.ts';
19
+ import { planAgentFiles } from './agent-files.ts';
18
20
  import { SyncConstants, SyncStatuses } from './common/index.ts';
19
21
  import type { ISyncAction, TSettings } from './common/index.ts';
20
22
  import {
@@ -174,11 +176,22 @@ const findSkillDirectories = (opts: { directory: string }): string[] =>
174
176
  existsSync(join(opts.directory, entry.name, SyncConstants.SKILL_FILE)),
175
177
  )
176
178
  .map(entry => join(opts.directory, entry.name))
179
+ // readdir order is the filesystem's: the plan lists skills by name, the same on every machine.
180
+ .sort()
177
181
  : [];
178
182
 
179
- /** Shipped and project skills, linked flat into `.claude/skills/<name>`; a real directory there is left alone. */
180
- const planSkillLinks = (opts: { root: string }): ISyncAction[] => {
181
- const target = join(opts.root, SyncConstants.CLAUDE_DIRECTORY, SyncConstants.SKILLS_DIRECTORY);
183
+ /**
184
+ * Shipped skills, and for Claude the project's too, linked flat into `directory/<name>`; a real
185
+ * directory there is left alone. The project's own skills already live in `.agents/skills`, so that
186
+ * folder gets the shipped links only.
187
+ */
188
+ const planSkillLinks = (opts: {
189
+ root: string;
190
+ /** The agent's skills folder from the table, relative to the project. */
191
+ directory: string;
192
+ withProject: boolean;
193
+ }): ISyncAction[] => {
194
+ const target = join(opts.root, opts.directory);
182
195
 
183
196
  // A symlinked skills directory points outside the project: writing links through it would land them there.
184
197
  if (isSymlink({ path: target })) {
@@ -197,9 +210,11 @@ const planSkillLinks = (opts: { root: string }): ISyncAction[] => {
197
210
  directory: join(BASE_DIRECTORY, SyncConstants.SKILLS_DIRECTORY),
198
211
  }).map(source => join(stableSkills, basename(source)));
199
212
  const shippedNames = new Set(shipped.map(source => basename(source)));
200
- const project = findSkillDirectories({
201
- directory: join(opts.root, '.agents', SyncConstants.SKILLS_DIRECTORY),
202
- });
213
+ const project = opts.withProject
214
+ ? findSkillDirectories({
215
+ directory: join(opts.root, '.agents', SyncConstants.SKILLS_DIRECTORY),
216
+ })
217
+ : [];
203
218
 
204
219
  // Extend only: a project skill never takes a shipped skill's link; doctor reports the clash.
205
220
  const shadowing: ISyncAction[] = project
@@ -245,20 +260,25 @@ const planSkillLinks = (opts: { root: string }): ISyncAction[] => {
245
260
  // A link into the shipped skills whose skill this VULCAN no longer has (a downgrade, a retired
246
261
  // skill) is sync's own and dead: taken back. Any other link or directory stays.
247
262
  const shippedRoots = [stableSkills, join(BASE_DIRECTORY, SyncConstants.SKILLS_DIRECTORY)];
263
+ // A link into the project's own skills whose folder the user removed is dead the same way.
264
+ const projectRoot = join(opts.root, '.agents', SyncConstants.SKILLS_DIRECTORY);
248
265
  const linked = new Set(sources.map(source => basename(source)));
249
266
  const stale = (existsSync(target) ? readdirSync(target) : [])
250
267
  .filter(name => !linked.has(name))
251
268
  .map(name => join(target, name))
269
+ .filter(path => isSymlink({ path }) && !existsSync(path))
270
+ .map(path => ({ path, destination: readlinkSync(path) }))
252
271
  .filter(
253
- path =>
254
- isSymlink({ path }) &&
255
- !existsSync(path) &&
256
- shippedRoots.some(root => readlinkSync(path).startsWith(`${root}/`)),
272
+ ({ destination }) =>
273
+ shippedRoots.some(root => destination.startsWith(`${root}/`)) ||
274
+ (opts.withProject && destination.startsWith(`${projectRoot}/`)),
257
275
  )
258
- .map((path): ISyncAction => ({
276
+ .map(({ path, destination }): ISyncAction => ({
259
277
  path,
260
278
  status: SyncStatuses.REMOVED,
261
- note: 'a shipped skill this version no longer has',
279
+ note: destination.startsWith(`${projectRoot}/`)
280
+ ? 'a skill that is gone'
281
+ : 'a shipped skill this version no longer has',
262
282
  apply: () => rmSync(path),
263
283
  }));
264
284
 
@@ -283,14 +303,30 @@ export const planManifest = (opts: { root: string; config: TResolvedConfig }): I
283
303
  : { path, status: SyncStatuses.REPLACED, apply: write };
284
304
  };
285
305
 
306
+ const CLAUDE_SKILLS = join(SyncConstants.CLAUDE_DIRECTORY, SyncConstants.SKILLS_DIRECTORY);
307
+
308
+ /** The skills folders of the chosen agents, each once, in table order: agents that read one folder share its links. */
309
+ const skillDirectoriesOf = (opts: { agents: string[] }): string[] => [
310
+ ...new Set(
311
+ readAgentTable()
312
+ .filter(entry => opts.agents.includes(entry.id))
313
+ .map(entry => entry.skills.dir),
314
+ ),
315
+ ];
316
+
286
317
  /** Every adapter the project's agents need, and the manifest every project carries - planned, not written. */
287
- export const planSync = (opts: { root: string; config: TResolvedConfig }): ISyncAction[] => [
288
- ...(opts.config.agents.includes(CodingAgents.CLAUDE)
289
- ? [
290
- planClaudeImport({ root: opts.root }),
291
- planSettings(opts),
292
- ...planSkillLinks({ root: opts.root }),
293
- ]
318
+ export const planSync = (opts: {
319
+ root: string;
320
+ config: TResolvedConfig;
321
+ /** The agents this machine chose (`resolveAgents`); only Claude has adapters until the renderers land. */
322
+ agents: string[];
323
+ }): ISyncAction[] => [
324
+ ...(opts.agents.includes(CodingAgents.CLAUDE)
325
+ ? [planClaudeImport({ root: opts.root }), planSettings(opts)]
294
326
  : []),
327
+ ...skillDirectoriesOf({ agents: opts.agents }).flatMap(directory =>
328
+ planSkillLinks({ root: opts.root, directory, withProject: directory === CLAUDE_SKILLS }),
329
+ ),
330
+ ...planAgentFiles({ root: opts.root, agents: opts.agents }),
295
331
  planManifest(opts),
296
332
  ];
@@ -20,6 +20,15 @@ export const mergeSettings = (opts: { base: TSettings; overlay: TSettings }): TS
20
20
  const current = { value: merged[key] };
21
21
  const incoming = { value };
22
22
 
23
+ if (
24
+ SyncConstants.UNION_ARRAYS.has(key) &&
25
+ Array.isArray(current.value) &&
26
+ Array.isArray(value)
27
+ ) {
28
+ merged[key] = mergeArrays({ base: current.value, overlay: value });
29
+ continue;
30
+ }
31
+
23
32
  if (
24
33
  !SyncConstants.MERGE_ONE_LEVEL.has(key) ||
25
34
  !isSettingsObject(current) ||
@@ -155,6 +164,23 @@ export const removeManagedSettings = (opts: {
155
164
  const current = { value: remaining[key] };
156
165
  const managed = { value: managedValue };
157
166
 
167
+ if (
168
+ SyncConstants.UNION_ARRAYS.has(key) &&
169
+ Array.isArray(current.value) &&
170
+ Array.isArray(managedValue)
171
+ ) {
172
+ const managedEntries = new Set(managedValue.map(entry => toKey({ value: entry })));
173
+ const kept = current.value.filter(entry => !managedEntries.has(toKey({ value: entry })));
174
+
175
+ if (kept.length > 0) {
176
+ remaining[key] = kept;
177
+ } else {
178
+ delete remaining[key];
179
+ }
180
+
181
+ continue;
182
+ }
183
+
158
184
  if (
159
185
  !SyncConstants.MERGE_ONE_LEVEL.has(key) ||
160
186
  !isSettingsObject(current) ||