@venizia/vulcan 0.4.9-1 → 0.4.9-3
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 +5 -6
- package/base/make/vulcan.mk +1 -11
- package/base/rules.md +3 -8
- package/base/skills/docs-update/SKILL.md +4 -2
- package/package.json +3 -3
- package/src/agents/atlas-block.ts +2 -2
- package/src/agents/common/constants.ts +1 -21
- package/src/agents/exclude.ts +2 -2
- package/src/agents/render.ts +2 -2
- package/src/agents/resolve.ts +1 -16
- package/src/commands/agents.command.ts +1 -1
- package/src/commands/help.command.ts +3 -4
- package/src/commands/init.command.ts +2 -15
- package/src/commands/sync.command.ts +0 -5
- package/src/commands/x.command.ts +1 -1
- package/src/common/constants.ts +0 -22
- package/src/common/layout-folder.ts +1 -5
- package/src/common/types.ts +0 -5
- package/src/config/common/constants.ts +2 -23
- package/src/config/common/types.ts +1 -10
- package/src/config/loader.ts +15 -16
- package/src/config/schema.ts +16 -21
- package/src/create/add-app.ts +2 -10
- package/src/create/add-lib.ts +1 -8
- package/src/create/common/constants.ts +0 -14
- package/src/create/common/types.ts +1 -2
- package/src/create/preset.ts +0 -12
- package/src/create/workspace.ts +5 -5
- package/src/doctor/checks.ts +20 -85
- package/src/doctor/common/constants.ts +2 -33
- package/src/doctor/runner.ts +0 -1
- package/src/doctor/tags.ts +4 -5
- package/src/hooks/codex-patch.ts +0 -6
- package/src/hooks/common/constants.ts +0 -24
- package/src/hooks/guard-manifest.ts +1 -1
- package/src/hooks/subagent-card.ts +1 -4
- package/src/init/common/constants.ts +0 -11
- package/src/init/scaffold.ts +8 -16
- package/src/manifest/render.ts +1 -25
- package/src/owner/constants.ts +0 -4
- package/src/owner/violations.ts +1 -15
- package/src/router.ts +1 -2
- package/src/rules/base.ts +0 -4
- package/src/rules/parser.ts +0 -10
- package/src/signals/classify.ts +2 -0
- package/src/sync/base-rules.ts +1 -2
- package/src/sync/common/constants.ts +0 -18
- package/src/sync/common/types.ts +1 -1
- package/src/sync/index.ts +0 -1
- package/src/sync/planner.ts +1 -17
- package/src/sync/settings.ts +0 -9
- package/src/visualize/assets.ts +1 -1
- package/src/visualize/compare-schema.ts +0 -4
- package/src/visualize/constants.ts +0 -24
- package/src/visualize/kinds-schema.ts +0 -8
- package/src/wiki/constants.ts +0 -4
- package/base/templates/vulcan.config.js +0 -5
- package/base/templates/vulcan.config.mjs +0 -5
- package/base/templates/vulcan.config.ts +0 -6
- package/src/sync/prune.ts +0 -142
package/src/owner/violations.ts
CHANGED
|
@@ -19,8 +19,6 @@ const isKnownClass = (value: string): boolean =>
|
|
|
19
19
|
export class ViolationConstants {
|
|
20
20
|
/** One line per checked reply that broke the shape: the date and the classes, never the reply. */
|
|
21
21
|
static readonly LOG_FILE = 'violations.jsonl';
|
|
22
|
-
/** The one-file-per-project note of 0.4.2 and before; removed when a session note is written. */
|
|
23
|
-
static readonly LEGACY_LAST_FILE = 'last-reply.json';
|
|
24
22
|
/** One note per session under the cache: its last checked reply's classes, for that session's next reminder. */
|
|
25
23
|
static readonly NOTES_DIRECTORY = 'cache/replies';
|
|
26
24
|
/** The note name of an event that carries no session id. */
|
|
@@ -148,21 +146,9 @@ const readNote = (opts: { root: string; session?: string }): Record<string, unkn
|
|
|
148
146
|
}
|
|
149
147
|
};
|
|
150
148
|
|
|
151
|
-
/**
|
|
152
|
-
* Removes the notes older than the reminder window, the oldest beyond the cap, and the one-file note
|
|
153
|
-
* of 0.4.2 and before, so the folder never grows. A note that cannot be removed is left.
|
|
154
|
-
*/
|
|
149
|
+
/** Removes the notes older than the reminder window and the oldest beyond the cap, so the folder never grows. A note that cannot be removed is left. */
|
|
155
150
|
const pruneNotes = (opts: { root: string; now: number }): void => {
|
|
156
151
|
const directory = notesDirectoryOf({ root: opts.root, create: false });
|
|
157
|
-
const local = LocalScan.localRootOf({ root: opts.root });
|
|
158
|
-
|
|
159
|
-
if (local !== undefined) {
|
|
160
|
-
const legacy = join(local, ViolationConstants.LEGACY_LAST_FILE);
|
|
161
|
-
|
|
162
|
-
if (lstatSync(legacy, { throwIfNoEntry: false })?.isFile() === true) {
|
|
163
|
-
rmSync(legacy, { force: true });
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
152
|
|
|
167
153
|
if (directory === undefined) {
|
|
168
154
|
return;
|
package/src/router.ts
CHANGED
|
@@ -20,7 +20,6 @@ const ACCEPTED_ARGS: Record<string, IAcceptedArgs> = {
|
|
|
20
20
|
[VulcanCommands.INIT]: {
|
|
21
21
|
flags: [CreateFlags.NO_API],
|
|
22
22
|
values: [
|
|
23
|
-
'--config',
|
|
24
23
|
CreateFlags.PRESET,
|
|
25
24
|
CreateFlags.PROJECT,
|
|
26
25
|
CreateFlags.BACKEND_DIR,
|
|
@@ -53,7 +52,7 @@ const ACCEPTED_ARGS: Record<string, IAcceptedArgs> = {
|
|
|
53
52
|
positionals: 2,
|
|
54
53
|
},
|
|
55
54
|
[VulcanCommands.SYNC]: {
|
|
56
|
-
flags: ['--dry-run'
|
|
55
|
+
flags: ['--dry-run'],
|
|
57
56
|
values: [AgentConstants.FLAG],
|
|
58
57
|
positionals: 0,
|
|
59
58
|
},
|
package/src/rules/base.ts
CHANGED
package/src/rules/parser.ts
CHANGED
|
@@ -9,8 +9,6 @@ const EXTENDS_LIST = new RegExp(
|
|
|
9
9
|
'g',
|
|
10
10
|
);
|
|
11
11
|
|
|
12
|
-
const RETIRED_ITEM = new RegExp(`^- \`(${RuleConstants.BASE_ID_SOURCE})\` - `);
|
|
13
|
-
|
|
14
12
|
export class RuleParser {
|
|
15
13
|
/** Rule IDs in table order, from rows whose first cell is `W-01`, `V-W-01` or either in bold. */
|
|
16
14
|
static parseIds(opts: { markdown: string }): string[] {
|
|
@@ -45,12 +43,4 @@ export class RuleParser {
|
|
|
45
43
|
|
|
46
44
|
return [...references];
|
|
47
45
|
}
|
|
48
|
-
|
|
49
|
-
/** The IDs the base retired, one `` - `V-X-NN` - why `` bullet each; they are never reused. */
|
|
50
|
-
static parseRetiredIds(opts: { markdown: string }): string[] {
|
|
51
|
-
return opts.markdown
|
|
52
|
-
.split('\n')
|
|
53
|
-
.map((line) => RETIRED_ITEM.exec(line)?.[1])
|
|
54
|
-
.filter((id): id is string => id !== undefined);
|
|
55
|
-
}
|
|
56
46
|
}
|
package/src/signals/classify.ts
CHANGED
|
@@ -62,8 +62,10 @@ const isGateProgram = (opts: { name: string; args: string[] }): boolean => {
|
|
|
62
62
|
const first = args.find((arg) => !arg.startsWith('-')) ?? '';
|
|
63
63
|
|
|
64
64
|
if (name === 'bun') {
|
|
65
|
+
// `check` is Bun's own type-check (Bun >= 1.4.4), two words like `test`; `tsc` stays in GATE_TOOLS for other projects.
|
|
65
66
|
return (
|
|
66
67
|
first === 'test' ||
|
|
68
|
+
first === 'check' ||
|
|
67
69
|
(first === 'run' && GATE_SCRIPTS.has(args[args.indexOf('run') + 1] ?? '')) ||
|
|
68
70
|
(first === 'x' && args.includes('vulcan') && args.includes('doctor'))
|
|
69
71
|
);
|
package/src/sync/base-rules.ts
CHANGED
|
@@ -46,7 +46,6 @@ export class BaseRulesDiff {
|
|
|
46
46
|
|
|
47
47
|
const installed = ProjectManifest.buildBaseRuleHashes();
|
|
48
48
|
const rows = BaseRules.read();
|
|
49
|
-
const retired = new Set(BaseRules.readRetiredIds());
|
|
50
49
|
const changes: IBaseRuleChange[] = [];
|
|
51
50
|
|
|
52
51
|
for (const [id, hash] of Object.entries(installed)) {
|
|
@@ -65,7 +64,7 @@ export class BaseRulesDiff {
|
|
|
65
64
|
changes.push({
|
|
66
65
|
id,
|
|
67
66
|
change: BaseRuleChanges.REMOVED,
|
|
68
|
-
text:
|
|
67
|
+
text: '',
|
|
69
68
|
});
|
|
70
69
|
}
|
|
71
70
|
|
|
@@ -5,27 +5,13 @@ export class SyncStatuses {
|
|
|
5
5
|
static readonly REPLACED = 'replaced';
|
|
6
6
|
static readonly UNCHANGED = 'unchanged';
|
|
7
7
|
static readonly SKIPPED = 'skipped';
|
|
8
|
-
/** Taken out by `sync --prune`. */
|
|
9
8
|
static readonly REMOVED = 'removed';
|
|
10
|
-
static readonly SCHEME_SET = new Set<string>([
|
|
11
|
-
this.CREATED,
|
|
12
|
-
this.REPLACED,
|
|
13
|
-
this.UNCHANGED,
|
|
14
|
-
this.SKIPPED,
|
|
15
|
-
this.REMOVED,
|
|
16
|
-
]);
|
|
17
|
-
static isValid(value: string): boolean {
|
|
18
|
-
return this.SCHEME_SET.has(value);
|
|
19
|
-
}
|
|
20
9
|
}
|
|
21
10
|
|
|
22
11
|
export class SyncConstants {
|
|
23
12
|
static readonly CLAUDE_IMPORT_LINE = '@AGENTS.md';
|
|
24
13
|
static readonly CLAUDE_TOOL_FILE = 'CLAUDE.md';
|
|
25
14
|
|
|
26
|
-
/** The first line of the CLAUDE.md `bun init` writes: Bun's tips, never the project's own words. */
|
|
27
|
-
static readonly BUN_INIT_CLAUDE_MARKER = 'Default to using Bun instead of Node.js.';
|
|
28
|
-
|
|
29
15
|
static readonly CLAUDE_DIRECTORY = '.claude';
|
|
30
16
|
static readonly SETTINGS_FILE = 'settings.json';
|
|
31
17
|
/** The hook sync adds when the config sets `remoteHosts`; lives next to the shipped settings. */
|
|
@@ -49,8 +35,4 @@ export class BaseRuleChanges {
|
|
|
49
35
|
static readonly ADDED = 'added';
|
|
50
36
|
static readonly CHANGED = 'changed';
|
|
51
37
|
static readonly REMOVED = 'removed';
|
|
52
|
-
static readonly SCHEME_SET = new Set<string>([this.ADDED, this.CHANGED, this.REMOVED]);
|
|
53
|
-
static isValid(value: string): boolean {
|
|
54
|
-
return this.SCHEME_SET.has(value);
|
|
55
|
-
}
|
|
56
38
|
}
|
package/src/sync/common/types.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface ISyncAction {
|
|
|
15
15
|
|
|
16
16
|
type TBaseRuleChange = TConstValue<typeof BaseRuleChanges>;
|
|
17
17
|
|
|
18
|
-
/** One base rule that moved since the last sync; `text` is its new text,
|
|
18
|
+
/** One base rule that moved since the last sync; `text` is its new text, empty for a removed rule. */
|
|
19
19
|
export interface IBaseRuleChange {
|
|
20
20
|
id: string;
|
|
21
21
|
change: TBaseRuleChange;
|
package/src/sync/index.ts
CHANGED
package/src/sync/planner.ts
CHANGED
|
@@ -22,23 +22,11 @@ import { isSettingsObject, ProjectSettings } from './settings.ts';
|
|
|
22
22
|
|
|
23
23
|
const NO_CHANGE = (): void => {};
|
|
24
24
|
|
|
25
|
-
/** `CLAUDE.md` holds only `@AGENTS.md`:
|
|
25
|
+
/** `CLAUDE.md` holds only `@AGENTS.md`: sync writes it when absent and leaves any other file alone. */
|
|
26
26
|
const planClaudeImport = (opts: { root: string }): ISyncAction => {
|
|
27
27
|
const path = join(opts.root, SyncConstants.CLAUDE_TOOL_FILE);
|
|
28
28
|
const write = (): void => writeFileSync(path, `${SyncConstants.CLAUDE_IMPORT_LINE}\n`);
|
|
29
29
|
|
|
30
|
-
if (SyncLinks.isSymlink({ path })) {
|
|
31
|
-
return {
|
|
32
|
-
path,
|
|
33
|
-
status: SyncStatuses.REPLACED,
|
|
34
|
-
note: 'old symlink',
|
|
35
|
-
apply: () => {
|
|
36
|
-
rmSync(path);
|
|
37
|
-
write();
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
30
|
if (!existsSync(path)) {
|
|
43
31
|
return { path, status: SyncStatuses.CREATED, apply: write };
|
|
44
32
|
}
|
|
@@ -49,10 +37,6 @@ const planClaudeImport = (opts: { root: string }): ISyncAction => {
|
|
|
49
37
|
return { path, status: SyncStatuses.UNCHANGED, apply: NO_CHANGE };
|
|
50
38
|
}
|
|
51
39
|
|
|
52
|
-
if (content.trimStart().startsWith(SyncConstants.BUN_INIT_CLAUDE_MARKER)) {
|
|
53
|
-
return { path, status: SyncStatuses.REPLACED, note: "bun init's template", apply: write };
|
|
54
|
-
}
|
|
55
|
-
|
|
56
40
|
return {
|
|
57
41
|
path,
|
|
58
42
|
status: SyncStatuses.SKIPPED,
|
package/src/sync/settings.ts
CHANGED
|
@@ -96,15 +96,6 @@ export class ProjectSettings {
|
|
|
96
96
|
return merged;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
/** Every hook command of a settings file, across its events. */
|
|
100
|
-
static extractHookCommands(opts: { settings: TSettings | undefined }): string[] {
|
|
101
|
-
const hooks = { value: opts.settings?.[SyncConstants.HOOKS_KEY] };
|
|
102
|
-
|
|
103
|
-
return isSettingsObject(hooks)
|
|
104
|
-
? Object.values(hooks.value).flatMap((entries) => extractEntryCommands({ entries }))
|
|
105
|
-
: [];
|
|
106
|
-
}
|
|
107
|
-
|
|
108
99
|
/**
|
|
109
100
|
* `entries` without the hooks whose command is in `commands`: an entry's other hooks and keys stay,
|
|
110
101
|
* an entry left with no hooks goes, and anything that is not an entry is kept as it is.
|
package/src/visualize/assets.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface IStatePalette {
|
|
|
19
19
|
* Fixed state colours and the five chart series. `warn` is the amber of an inferred claim; a task that waits for the
|
|
20
20
|
* owner is the project's hot accent instead, so what needs the owner is one colour on the page.
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
const STATE_PALETTE: { light: IStatePalette; dark: IStatePalette } = {
|
|
23
23
|
light: {
|
|
24
24
|
ok: '#157a3a',
|
|
25
25
|
okBg: '#e4f3e8',
|
|
@@ -8,10 +8,6 @@ export class EdgeSides {
|
|
|
8
8
|
static readonly A = 'a';
|
|
9
9
|
static readonly B = 'b';
|
|
10
10
|
static readonly SCHEME_SET = new Set<string>([this.BOTH, this.A, this.B]);
|
|
11
|
-
|
|
12
|
-
static isValid(value: string): boolean {
|
|
13
|
-
return this.SCHEME_SET.has(value);
|
|
14
|
-
}
|
|
15
11
|
}
|
|
16
12
|
|
|
17
13
|
/** The limits of the compare view; the shared ones come from `VisualizeLimits`. */
|
|
@@ -4,12 +4,6 @@ import type { TConstValue } from '../common/index.ts';
|
|
|
4
4
|
export class ChangeKinds {
|
|
5
5
|
static readonly ADDED = 'added';
|
|
6
6
|
static readonly REMOVED = 'removed';
|
|
7
|
-
|
|
8
|
-
static readonly SCHEME_SET = new Set<string>([this.ADDED, this.REMOVED]);
|
|
9
|
-
|
|
10
|
-
static isValid(value: string): boolean {
|
|
11
|
-
return this.SCHEME_SET.has(value);
|
|
12
|
-
}
|
|
13
7
|
}
|
|
14
8
|
|
|
15
9
|
export type TChangeKind = TConstValue<typeof ChangeKinds>;
|
|
@@ -20,9 +14,6 @@ export class StatusStates {
|
|
|
20
14
|
static readonly BLOCKED = 'blocked';
|
|
21
15
|
static readonly INFO = 'info';
|
|
22
16
|
static readonly SCHEME_SET = new Set<string>([this.OK, this.WARN, this.BLOCKED, this.INFO]);
|
|
23
|
-
static isValid(value: string): boolean {
|
|
24
|
-
return this.SCHEME_SET.has(value);
|
|
25
|
-
}
|
|
26
17
|
}
|
|
27
18
|
|
|
28
19
|
/** Where a task stands on the minimap: a shape and a word each, never colour alone. */
|
|
@@ -41,9 +32,6 @@ export class MinimapStates {
|
|
|
41
32
|
this.BLOCKED,
|
|
42
33
|
this.DROPPED,
|
|
43
34
|
]);
|
|
44
|
-
static isValid(value: string): boolean {
|
|
45
|
-
return this.SCHEME_SET.has(value);
|
|
46
|
-
}
|
|
47
35
|
|
|
48
36
|
/** The class and chrome key of a state: the words have spaces, the keys do not. */
|
|
49
37
|
static keyOf(value: string): string {
|
|
@@ -54,9 +42,6 @@ export class MinimapStates {
|
|
|
54
42
|
/** The state of a box, a milestone or a chart part: a minimap state, or plain information. Never told by colour alone. */
|
|
55
43
|
export class NodeStates {
|
|
56
44
|
static readonly SCHEME_SET = new Set<string>([...MinimapStates.SCHEME_SET, 'info']);
|
|
57
|
-
static isValid(value: string): boolean {
|
|
58
|
-
return this.SCHEME_SET.has(value);
|
|
59
|
-
}
|
|
60
45
|
|
|
61
46
|
/** The colour family of a state: green, blue, amber, red, or neutral. */
|
|
62
47
|
static toneOf(value: string): string {
|
|
@@ -93,9 +78,6 @@ export class EdgeVariants {
|
|
|
93
78
|
this.FANOUT,
|
|
94
79
|
this.ERROR,
|
|
95
80
|
]);
|
|
96
|
-
static isValid(value: string): boolean {
|
|
97
|
-
return this.SCHEME_SET.has(value);
|
|
98
|
-
}
|
|
99
81
|
}
|
|
100
82
|
|
|
101
83
|
export class NodeKinds {
|
|
@@ -111,9 +93,6 @@ export class NodeKinds {
|
|
|
111
93
|
this.ACTOR,
|
|
112
94
|
this.EXTERNAL,
|
|
113
95
|
]);
|
|
114
|
-
static isValid(value: string): boolean {
|
|
115
|
-
return this.SCHEME_SET.has(value);
|
|
116
|
-
}
|
|
117
96
|
}
|
|
118
97
|
|
|
119
98
|
/** What a claim in the evidence table rests on. An analogy is never shown as a fact. */
|
|
@@ -122,9 +101,6 @@ export class EvidenceLabels {
|
|
|
122
101
|
static readonly INFERRED = 'inferred';
|
|
123
102
|
static readonly GUESS = 'guess';
|
|
124
103
|
static readonly SCHEME_SET = new Set<string>([this.VERIFIED, this.INFERRED, this.GUESS]);
|
|
125
|
-
static isValid(value: string): boolean {
|
|
126
|
-
return this.SCHEME_SET.has(value);
|
|
127
|
-
}
|
|
128
104
|
}
|
|
129
105
|
|
|
130
106
|
export class VisualizeLimits {
|
|
@@ -7,10 +7,6 @@ export class MessageKinds {
|
|
|
7
7
|
static readonly REPLY = 'reply';
|
|
8
8
|
static readonly ASYNC = 'async';
|
|
9
9
|
static readonly SCHEME_SET = new Set<string>([this.CALL, this.REPLY, this.ASYNC]);
|
|
10
|
-
|
|
11
|
-
static isValid(value: string): boolean {
|
|
12
|
-
return this.SCHEME_SET.has(value);
|
|
13
|
-
}
|
|
14
10
|
}
|
|
15
11
|
|
|
16
12
|
/** What a state is in a lifecycle: where it begins, a state in between, or where it ends. */
|
|
@@ -19,10 +15,6 @@ export class LifecycleKinds {
|
|
|
19
15
|
static readonly NORMAL = 'normal';
|
|
20
16
|
static readonly END = 'end';
|
|
21
17
|
static readonly SCHEME_SET = new Set<string>([this.START, this.NORMAL, this.END]);
|
|
22
|
-
|
|
23
|
-
static isValid(value: string): boolean {
|
|
24
|
-
return this.SCHEME_SET.has(value);
|
|
25
|
-
}
|
|
26
18
|
}
|
|
27
19
|
|
|
28
20
|
/** The limits of the three kinds; the shared ones come from `VisualizeLimits`. */
|
package/src/wiki/constants.ts
CHANGED
|
@@ -4,10 +4,6 @@ import type { TConstValue } from '../common/index.ts';
|
|
|
4
4
|
export class AnchorProblems {
|
|
5
5
|
static readonly MISSING_PAGE = 'missing page';
|
|
6
6
|
static readonly DEAD_ANCHOR = 'dead anchor';
|
|
7
|
-
static readonly SCHEME_SET = new Set<string>([this.MISSING_PAGE, this.DEAD_ANCHOR]);
|
|
8
|
-
static isValid(value: string): boolean {
|
|
9
|
-
return this.SCHEME_SET.has(value);
|
|
10
|
-
}
|
|
11
7
|
}
|
|
12
8
|
|
|
13
9
|
export type TAnchorProblem = TConstValue<typeof AnchorProblems>;
|
package/src/sync/prune.ts
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { existsSync, lstatSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { BASE_DIRECTORY } from '../common/index.ts';
|
|
4
|
-
import { SyncConstants, SyncStatuses } from './common/index.ts';
|
|
5
|
-
import type { ISyncAction, TSettings } from './common/index.ts';
|
|
6
|
-
import { isSettingsObject, ProjectSettings } from './settings.ts';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The exact hook commands released VULCAN versions shipped (0.1.0-x, then 0.2.0-0). Only these are
|
|
10
|
-
* an old VULCAN form: a shipped hook a developer customised is theirs, and never pruned.
|
|
11
|
-
*/
|
|
12
|
-
const RETIRED_SHIPPED_COMMANDS = new Set([
|
|
13
|
-
`bun "\${CLAUDE_PROJECT_DIR}"/node_modules/@venizia/vulcan/base/hooks/session-start.ts`,
|
|
14
|
-
`bun "\${CLAUDE_PROJECT_DIR}"/node_modules/@venizia/vulcan/base/hooks/guard-writes.ts`,
|
|
15
|
-
`f="\${CLAUDE_PROJECT_DIR}/node_modules/@venizia/vulcan/base/hooks/session-start.ts"; if [ -f "$f" ] && command -v bun >/dev/null 2>&1; then bun "$f"; s=$?; [ "$s" -eq 0 ] && exit 0; exit 2; fi; echo "vulcan: the session-start hook cannot run (node_modules/@venizia/vulcan or bun is missing) - run bun install" >&2; exit 2`,
|
|
16
|
-
`f="\${CLAUDE_PROJECT_DIR}/node_modules/@venizia/vulcan/base/hooks/guard-writes.ts"; if [ -f "$f" ] && command -v bun >/dev/null 2>&1; then bun "$f"; s=$?; [ "$s" -eq 0 ] && exit 0; exit 2; fi; if grep -Eq '"command" *: *"bun (install|i)( --?[a-z][a-z0-9-]*(=[A-Za-z0-9._-]+)?)*"'; then exit 0; fi; echo "vulcan: the guard-writes hook cannot run (node_modules/@venizia/vulcan or bun is missing) - run bun install (the one command that passes until then)" >&2; exit 2`,
|
|
17
|
-
]);
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* A hook a project kept under its own `.agents/` - where plugin-era setups put theirs: the whole
|
|
21
|
-
* command is `bun` or `node` on that file, from the project root. Any other shape - another
|
|
22
|
-
* directory's `.agents/`, `$HOME`, a `cd` first - is a developer's own and never pruned.
|
|
23
|
-
*/
|
|
24
|
-
const AGENTS_HOOK =
|
|
25
|
-
/^(?:bun|node)\s+(?:"?\$\{?CLAUDE_PROJECT_DIR\}?"?\/)?(\.agents\/[\w./-]+\.ts)\s*$/;
|
|
26
|
-
|
|
27
|
-
const readJson = (opts: { path: string }): TSettings | undefined => {
|
|
28
|
-
if (!existsSync(opts.path)) {
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
const parsed = { value: JSON.parse(readFileSync(opts.path, 'utf8')) };
|
|
34
|
-
|
|
35
|
-
return isSettingsObject(parsed) ? parsed.value : undefined;
|
|
36
|
-
} catch (error) {
|
|
37
|
-
console.error(
|
|
38
|
-
`[readJson] ${opts.path} | ${error instanceof Error ? error.message : String(error)}`,
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* A command sync did not write that is known to be stale: a shipped hook exactly as an older VULCAN
|
|
47
|
-
* released it, or a `.agents/` hook whose file is gone. Any other command is a developer's own.
|
|
48
|
-
*/
|
|
49
|
-
const isStaleCommand = (opts: { root: string; command: string; shipped: Set<string> }): boolean => {
|
|
50
|
-
if (RETIRED_SHIPPED_COMMANDS.has(opts.command)) {
|
|
51
|
-
return !opts.shipped.has(opts.command);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const agentsHook = AGENTS_HOOK.exec(opts.command)?.[1];
|
|
55
|
-
|
|
56
|
-
return agentsHook !== undefined && !existsSync(join(opts.root, agentsHook));
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
/** Takes one command out of the settings file; an entry or an event left empty goes with it. */
|
|
60
|
-
const removeHookCommand = (opts: { path: string; command: string }): void => {
|
|
61
|
-
const settings = readJson({ path: opts.path });
|
|
62
|
-
const hooks = { value: settings?.[SyncConstants.HOOKS_KEY] };
|
|
63
|
-
|
|
64
|
-
if (settings === undefined || !isSettingsObject(hooks)) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
for (const [event, entries] of Object.entries(hooks.value)) {
|
|
69
|
-
if (!Array.isArray(entries)) {
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const kept = ProjectSettings.removeHookCommands({ entries, commands: new Set([opts.command]) });
|
|
74
|
-
|
|
75
|
-
if (kept.length > 0) {
|
|
76
|
-
hooks.value[event] = kept;
|
|
77
|
-
} else {
|
|
78
|
-
delete hooks.value[event];
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
writeFileSync(opts.path, `${JSON.stringify(settings, null, 2)}\n`);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const isDeadLink = (opts: { path: string }): boolean => {
|
|
86
|
-
try {
|
|
87
|
-
return lstatSync(opts.path).isSymbolicLink() && !existsSync(opts.path);
|
|
88
|
-
} catch {
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export class PrunePlan {
|
|
94
|
-
/**
|
|
95
|
-
* `sync --prune`: what sync can prove is stale and did not write itself - old VULCAN and plugin-era
|
|
96
|
-
* hook commands, and skill links whose target is gone. What sync wrote last time it takes back on
|
|
97
|
-
* every run; a developer's own hooks and any real directory are never touched.
|
|
98
|
-
*/
|
|
99
|
-
static plan(opts: { root: string }): ISyncAction[] {
|
|
100
|
-
const directory = join(opts.root, SyncConstants.CLAUDE_DIRECTORY);
|
|
101
|
-
const settingsPath = join(directory, SyncConstants.SETTINGS_FILE);
|
|
102
|
-
const managed = new Set(
|
|
103
|
-
ProjectSettings.extractHookCommands({
|
|
104
|
-
settings: readJson({ path: join(directory, SyncConstants.MANAGED_FILE) }),
|
|
105
|
-
}),
|
|
106
|
-
);
|
|
107
|
-
const shipped = new Set(
|
|
108
|
-
ProjectSettings.extractHookCommands({
|
|
109
|
-
settings: readJson({ path: join(BASE_DIRECTORY, 'claude', SyncConstants.SETTINGS_FILE) }),
|
|
110
|
-
}),
|
|
111
|
-
);
|
|
112
|
-
const staleCommands = [
|
|
113
|
-
...new Set(
|
|
114
|
-
ProjectSettings.extractHookCommands({ settings: readJson({ path: settingsPath }) }),
|
|
115
|
-
),
|
|
116
|
-
].filter(
|
|
117
|
-
(command) => !managed.has(command) && isStaleCommand({ root: opts.root, command, shipped }),
|
|
118
|
-
);
|
|
119
|
-
const skills = join(directory, SyncConstants.SKILLS_DIRECTORY);
|
|
120
|
-
// lstat, not stat: a symlinked skills directory leads out of the project and is never walked.
|
|
121
|
-
const deadLinks = lstatSync(skills, { throwIfNoEntry: false })?.isDirectory()
|
|
122
|
-
? readdirSync(skills)
|
|
123
|
-
.map((name) => join(skills, name))
|
|
124
|
-
.filter((path) => isDeadLink({ path }))
|
|
125
|
-
: [];
|
|
126
|
-
|
|
127
|
-
return [
|
|
128
|
-
...staleCommands.map((command): ISyncAction => ({
|
|
129
|
-
path: settingsPath,
|
|
130
|
-
status: SyncStatuses.REMOVED,
|
|
131
|
-
note: `stale hook: ${command}`,
|
|
132
|
-
apply: () => removeHookCommand({ path: settingsPath, command }),
|
|
133
|
-
})),
|
|
134
|
-
...deadLinks.map((path): ISyncAction => ({
|
|
135
|
-
path,
|
|
136
|
-
status: SyncStatuses.REMOVED,
|
|
137
|
-
note: 'dead link',
|
|
138
|
-
apply: () => rmSync(path),
|
|
139
|
-
})),
|
|
140
|
-
];
|
|
141
|
-
}
|
|
142
|
-
}
|