@venizia/vulcan 0.3.4 → 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.
- package/README.md +2 -2
- package/base/agents.json +232 -0
- package/base/claude/settings.json +12 -0
- package/base/hooks/guard-package.ts +29 -0
- package/base/rules.md +2 -0
- package/base/templates/AGENTS.md +4 -3
- package/package.json +3 -3
- package/src/agents/atlas-block.ts +54 -0
- package/src/agents/common/constants.ts +38 -0
- package/src/agents/common/index.ts +3 -0
- package/src/agents/common/schema.ts +42 -0
- package/src/agents/common/types.ts +30 -0
- package/src/agents/detect.ts +36 -0
- package/src/agents/exclude.ts +87 -0
- package/src/agents/index.ts +9 -0
- package/src/agents/local.ts +65 -0
- package/src/agents/prompt.ts +22 -0
- package/src/agents/render.ts +229 -0
- package/src/agents/resolve.ts +145 -0
- package/src/agents/table.ts +35 -0
- package/src/commands/agents.command.ts +154 -0
- package/src/commands/doctor.command.ts +5 -1
- package/src/commands/help.command.ts +5 -1
- package/src/commands/index.ts +2 -0
- package/src/commands/sync.command.ts +112 -3
- package/src/common/constants.ts +9 -1
- package/src/config/common/constants.ts +12 -1
- package/src/config/packages.ts +2 -0
- package/src/config/schema.ts +16 -1
- package/src/create/add-app.ts +110 -4
- package/src/create/add-lib.ts +317 -0
- package/src/create/common/constants.ts +3 -0
- package/src/create/common/types.ts +18 -2
- package/src/create/dockerignore.ts +36 -0
- package/src/create/init-monorepo.ts +22 -4
- package/src/create/lib-preset.ts +154 -0
- package/src/create/preset.ts +22 -3
- package/src/create/workspace.ts +94 -3
- package/src/doctor/checks.ts +183 -12
- package/src/doctor/common/constants.ts +26 -0
- package/src/doctor/runner.ts +22 -0
- package/src/hooks/guard-package.ts +211 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/session-digest.ts +27 -1
- package/src/init/scaffold.ts +8 -5
- package/src/manifest/render.ts +4 -0
- package/src/router.ts +10 -1
- package/src/sync/agent-files.ts +112 -0
- package/src/sync/agent-removal.ts +241 -0
- package/src/sync/atlas-block.ts +55 -0
- package/src/sync/common/constants.ts +2 -0
- package/src/sync/exclude.ts +89 -0
- package/src/sync/index.ts +5 -0
- package/src/sync/local-choice.ts +55 -0
- package/src/sync/planner.ts +55 -19
- package/src/sync/settings.ts +26 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { LOCAL_AGENTS_FILE, renderLocalChoice } from '../agents/index.ts';
|
|
4
|
+
import { SyncStatuses } from './common/index.ts';
|
|
5
|
+
import type { ISyncAction } from './common/index.ts';
|
|
6
|
+
|
|
7
|
+
const NO_CHANGE = (): void => {};
|
|
8
|
+
|
|
9
|
+
/** The developer's stored agents: written when the machine just chose, reported unchanged when it was read. */
|
|
10
|
+
export const planLocalChoice = (opts: { root: string; agents: string[] }): ISyncAction => {
|
|
11
|
+
const path = join(opts.root, LOCAL_AGENTS_FILE);
|
|
12
|
+
const text = renderLocalChoice({ agents: opts.agents });
|
|
13
|
+
const before = existsSync(path) ? readFileSync(path, 'utf8') : undefined;
|
|
14
|
+
|
|
15
|
+
if (before === text) {
|
|
16
|
+
return { path, status: SyncStatuses.UNCHANGED, apply: NO_CHANGE };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
path,
|
|
21
|
+
status: before === undefined ? SyncStatuses.CREATED : SyncStatuses.REPLACED,
|
|
22
|
+
apply: () => {
|
|
23
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
24
|
+
writeFileSync(path, text);
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** The one line sync adds to a committed `.gitignore`; a project without one is left alone. */
|
|
30
|
+
export const planLocalIgnore = (opts: { root: string }): ISyncAction[] => {
|
|
31
|
+
const path = join(opts.root, '.gitignore');
|
|
32
|
+
|
|
33
|
+
if (!existsSync(path)) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const text = readFileSync(path, 'utf8');
|
|
38
|
+
|
|
39
|
+
if (text.split('\n').some(line => line.trim() === LOCAL_AGENTS_FILE)) {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return [
|
|
44
|
+
{
|
|
45
|
+
path,
|
|
46
|
+
status: SyncStatuses.REPLACED,
|
|
47
|
+
note: `added ${LOCAL_AGENTS_FILE}`,
|
|
48
|
+
apply: () =>
|
|
49
|
+
writeFileSync(
|
|
50
|
+
path,
|
|
51
|
+
`${text}${text === '' || text.endsWith('\n') ? '' : '\n'}${LOCAL_AGENTS_FILE}\n`,
|
|
52
|
+
),
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
};
|
package/src/sync/planner.ts
CHANGED
|
@@ -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
|
-
/**
|
|
180
|
-
|
|
181
|
-
|
|
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 =
|
|
201
|
-
|
|
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
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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:
|
|
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: {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
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
|
];
|
package/src/sync/settings.ts
CHANGED
|
@@ -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) ||
|