@venizia/vulcan 0.4.9-2 → 0.4.9-4

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 (73) hide show
  1. package/README.md +5 -6
  2. package/base/claude/commit-attribution.json +7 -0
  3. package/base/commit-agents.json +41 -0
  4. package/base/make/vulcan.mk +1 -11
  5. package/base/rules.md +3 -8
  6. package/package.json +3 -3
  7. package/src/agents/atlas-block.ts +2 -2
  8. package/src/agents/common/constants.ts +1 -21
  9. package/src/agents/exclude.ts +2 -2
  10. package/src/agents/render.ts +2 -2
  11. package/src/agents/resolve.ts +1 -16
  12. package/src/commands/agents.command.ts +1 -1
  13. package/src/commands/commit-check.command.ts +5 -0
  14. package/src/commands/help.command.ts +7 -4
  15. package/src/commands/index.ts +25 -27
  16. package/src/commands/init.command.ts +2 -15
  17. package/src/commands/sync.command.ts +2 -5
  18. package/src/commands/x.command.ts +1 -1
  19. package/src/commit/agents.ts +32 -0
  20. package/src/commit/check.ts +160 -0
  21. package/src/commit/common/constants.ts +28 -0
  22. package/src/commit/common/index.ts +2 -0
  23. package/src/commit/common/types.ts +57 -0
  24. package/src/commit/hook.ts +187 -0
  25. package/src/commit/index.ts +8 -0
  26. package/src/commit/message.ts +74 -0
  27. package/src/commit/policy.ts +110 -0
  28. package/src/commit/signature.ts +94 -0
  29. package/src/commit/subject.ts +40 -0
  30. package/src/common/constants.ts +3 -22
  31. package/src/common/layout-folder.ts +1 -5
  32. package/src/common/types.ts +0 -5
  33. package/src/config/common/constants.ts +2 -23
  34. package/src/config/common/types.ts +1 -10
  35. package/src/config/loader.ts +15 -16
  36. package/src/config/schema.ts +69 -21
  37. package/src/create/add-app.ts +2 -10
  38. package/src/create/add-lib.ts +1 -8
  39. package/src/create/common/constants.ts +0 -14
  40. package/src/create/common/types.ts +1 -2
  41. package/src/create/preset.ts +0 -12
  42. package/src/create/workspace.ts +5 -5
  43. package/src/doctor/checks.ts +68 -85
  44. package/src/doctor/common/constants.ts +3 -33
  45. package/src/doctor/runner.ts +1 -1
  46. package/src/doctor/tags.ts +4 -5
  47. package/src/hooks/codex-patch.ts +0 -6
  48. package/src/hooks/common/constants.ts +0 -24
  49. package/src/hooks/guard-manifest.ts +1 -1
  50. package/src/hooks/subagent-card.ts +1 -4
  51. package/src/init/common/constants.ts +0 -11
  52. package/src/init/scaffold.ts +8 -16
  53. package/src/manifest/render.ts +25 -25
  54. package/src/owner/constants.ts +0 -4
  55. package/src/owner/violations.ts +1 -15
  56. package/src/router.ts +24 -9
  57. package/src/rules/base.ts +0 -4
  58. package/src/rules/parser.ts +0 -10
  59. package/src/sync/base-rules.ts +1 -2
  60. package/src/sync/common/constants.ts +1 -18
  61. package/src/sync/common/types.ts +1 -1
  62. package/src/sync/index.ts +0 -1
  63. package/src/sync/planner.ts +12 -18
  64. package/src/sync/settings.ts +0 -9
  65. package/src/visualize/assets.ts +1 -1
  66. package/src/visualize/compare-schema.ts +0 -4
  67. package/src/visualize/constants.ts +0 -24
  68. package/src/visualize/kinds-schema.ts +0 -8
  69. package/src/wiki/constants.ts +0 -4
  70. package/base/templates/vulcan.config.js +0 -5
  71. package/base/templates/vulcan.config.mjs +0 -5
  72. package/base/templates/vulcan.config.ts +0 -6
  73. package/src/sync/prune.ts +0 -142
package/src/router.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AgentConstants } from './agents/index.ts';
2
- import { COMMAND_HANDLERS } from './commands/index.ts';
3
- import { runHelpCommand } from './commands/help.command.ts';
2
+ import { COMMAND_LOADERS } from './commands/index.ts';
3
+ import { CommitCheckFlags } from './commit/common/index.ts';
4
4
  import { ExitCodes, UpgradeFlags, VulcanCommands } from './common/index.ts';
5
5
  import { CreateFlags } from './create/common/index.ts';
6
6
  import { PipedInputRefusal } from './ui/keyboard.ts';
@@ -10,6 +10,8 @@ const VERSION_ALIASES = new Set(['--version', '-v']);
10
10
 
11
11
  interface IAcceptedArgs {
12
12
  flags: string[];
13
+ /** The exit code for an argument the command does not take; `1` when absent. */
14
+ unknownExit?: number;
13
15
  /** Flags that take the next argument as their value. */
14
16
  values: string[];
15
17
  positionals: number;
@@ -20,7 +22,6 @@ const ACCEPTED_ARGS: Record<string, IAcceptedArgs> = {
20
22
  [VulcanCommands.INIT]: {
21
23
  flags: [CreateFlags.NO_API],
22
24
  values: [
23
- '--config',
24
25
  CreateFlags.PRESET,
25
26
  CreateFlags.PROJECT,
26
27
  CreateFlags.BACKEND_DIR,
@@ -53,7 +54,7 @@ const ACCEPTED_ARGS: Record<string, IAcceptedArgs> = {
53
54
  positionals: 2,
54
55
  },
55
56
  [VulcanCommands.SYNC]: {
56
- flags: ['--dry-run', '--prune'],
57
+ flags: ['--dry-run'],
57
58
  values: [AgentConstants.FLAG],
58
59
  positionals: 0,
59
60
  },
@@ -73,6 +74,12 @@ const ACCEPTED_ARGS: Record<string, IAcceptedArgs> = {
73
74
  values: [],
74
75
  positionals: 0,
75
76
  },
77
+ [VulcanCommands.COMMIT_CHECK]: {
78
+ flags: [],
79
+ unknownExit: ExitCodes.USAGE,
80
+ values: [CommitCheckFlags.RANGE, CommitCheckFlags.TEXT],
81
+ positionals: 2,
82
+ },
76
83
  [VulcanCommands.DOCTOR]: { flags: [], values: [], positionals: 0 },
77
84
  [VulcanCommands.PROFILE]: { flags: ['--yes'], values: [], positionals: 1 },
78
85
  [VulcanCommands.VISUALIZE]: { flags: ['--schema'], values: ['--out'], positionals: 1 },
@@ -118,12 +125,18 @@ const findUnknownArg = (opts: { args: string[]; accepted: IAcceptedArgs }): stri
118
125
  return undefined;
119
126
  };
120
127
 
128
+ const runHelp = async (opts: { cwd: string }): Promise<number> => {
129
+ const help = await COMMAND_LOADERS[VulcanCommands.HELP]();
130
+
131
+ return help({ args: [], cwd: opts.cwd });
132
+ };
133
+
121
134
  export const runVulcan = async (opts: { argv: string[]; cwd: string }): Promise<number> => {
122
135
  const [first, ...args] = opts.argv;
123
136
  const name = resolveCommandName({ first });
124
- const handler = COMMAND_HANDLERS[name];
137
+ const load = COMMAND_LOADERS[name];
125
138
 
126
- if (handler === undefined) {
139
+ if (load === undefined) {
127
140
  process.stderr.write(`vulcan: unknown command '${name}' - run 'bun x vulcan help'\n`);
128
141
 
129
142
  return ExitCodes.FAILURE;
@@ -131,14 +144,14 @@ export const runVulcan = async (opts: { argv: string[]; cwd: string }): Promise<
131
144
 
132
145
  // `x` hands its arguments to the tool, so only a help flag in the tool's place is vulcan's.
133
146
  if (name === VulcanCommands.X && HELP_ALIASES.has(args[0] ?? '')) {
134
- return runHelpCommand();
147
+ return runHelp({ cwd: opts.cwd });
135
148
  }
136
149
 
137
150
  const accepted = ACCEPTED_ARGS[name];
138
151
 
139
152
  if (accepted !== undefined) {
140
153
  if (args.some((arg) => HELP_ALIASES.has(arg))) {
141
- return runHelpCommand();
154
+ return runHelp({ cwd: opts.cwd });
142
155
  }
143
156
 
144
157
  const unknown = findUnknownArg({ args, accepted });
@@ -148,10 +161,12 @@ export const runVulcan = async (opts: { argv: string[]; cwd: string }): Promise<
148
161
  `vulcan ${name}: unknown argument '${unknown}' - run 'bun x vulcan help'\n`,
149
162
  );
150
163
 
151
- return ExitCodes.FAILURE;
164
+ return accepted.unknownExit ?? ExitCodes.FAILURE;
152
165
  }
153
166
  }
154
167
 
168
+ const handler = await load();
169
+
155
170
  try {
156
171
  const exitCode = await handler({ args, cwd: opts.cwd });
157
172
 
package/src/rules/base.ts CHANGED
@@ -16,8 +16,4 @@ export class BaseRules {
16
16
  }),
17
17
  );
18
18
  }
19
-
20
- static readRetiredIds(): string[] {
21
- return RuleParser.parseRetiredIds({ markdown: readBaseMarkdown() });
22
- }
23
19
  }
@@ -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
  }
@@ -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: retired.has(id) ? '(retired)' : '',
67
+ text: '',
69
68
  });
70
69
  }
71
70
 
@@ -5,31 +5,18 @@ 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. */
32
18
  static readonly REMOTE_HOSTS_FILE = 'remote-hosts.json';
19
+ static readonly COMMIT_ATTRIBUTION_FILE = 'commit-attribution.json';
33
20
  /** What sync applied last time, so a later sync can take back what the project no longer asks for. */
34
21
  static readonly MANAGED_FILE = 'vulcan-managed.json';
35
22
  static readonly SKILLS_DIRECTORY = 'skills';
@@ -49,8 +36,4 @@ export class BaseRuleChanges {
49
36
  static readonly ADDED = 'added';
50
37
  static readonly CHANGED = 'changed';
51
38
  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
39
  }
@@ -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, or `(retired)` when the base retired it. */
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
@@ -1,7 +1,6 @@
1
1
  export * from './common/index.ts';
2
2
  export * from './base-rules.ts';
3
3
  export * from './planner.ts';
4
- export * from './prune.ts';
5
4
  export * from './settings.ts';
6
5
  export * from './local-choice.ts';
7
6
  export * from './claude-launch.ts';
@@ -11,6 +11,7 @@ import {
11
11
  import { basename, dirname, join, resolve } from 'node:path';
12
12
  import { AgentTable } from '../agents/index.ts';
13
13
  import { BASE_DIRECTORY, BaseDirectory } from '../common/index.ts';
14
+ import { AgentSignaturePolicies } from '../commit/common/index.ts';
14
15
  import { CodingAgents } from '../config/index.ts';
15
16
  import type { TResolvedConfig } from '../config/index.ts';
16
17
  import { ManifestConstants, ProjectManifest } from '../manifest/index.ts';
@@ -22,23 +23,11 @@ import { isSettingsObject, ProjectSettings } from './settings.ts';
22
23
 
23
24
  const NO_CHANGE = (): void => {};
24
25
 
25
- /** `CLAUDE.md` holds only `@AGENTS.md`: an old symlink or bun init's template is replaced, a hand-written file is left alone. */
26
+ /** `CLAUDE.md` holds only `@AGENTS.md`: sync writes it when absent and leaves any other file alone. */
26
27
  const planClaudeImport = (opts: { root: string }): ISyncAction => {
27
28
  const path = join(opts.root, SyncConstants.CLAUDE_TOOL_FILE);
28
29
  const write = (): void => writeFileSync(path, `${SyncConstants.CLAUDE_IMPORT_LINE}\n`);
29
30
 
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
31
  if (!existsSync(path)) {
43
32
  return { path, status: SyncStatuses.CREATED, apply: write };
44
33
  }
@@ -49,10 +38,6 @@ const planClaudeImport = (opts: { root: string }): ISyncAction => {
49
38
  return { path, status: SyncStatuses.UNCHANGED, apply: NO_CHANGE };
50
39
  }
51
40
 
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
41
  return {
57
42
  path,
58
43
  status: SyncStatuses.SKIPPED,
@@ -79,7 +64,7 @@ const readSettingsFile = (opts: { path: string }): TSettings | undefined => {
79
64
  }
80
65
  };
81
66
 
82
- /** Shipped settings, the chosen slot options, the project's hooks and `claude.settings` - what sync owns. */
67
+ /** Shipped settings, the chosen slot options, the empty attribution of a project that denies agent signatures, the project's hooks and `claude.settings` - what sync owns. */
83
68
  const buildManagedOverlay = (opts: { config: TResolvedConfig }): TSettings => {
84
69
  let overlay: TSettings = JSON.parse(
85
70
  readFileSync(join(BASE_DIRECTORY, 'claude', SyncConstants.SETTINGS_FILE), 'utf8'),
@@ -103,6 +88,15 @@ const buildManagedOverlay = (opts: { config: TResolvedConfig }): TSettings => {
103
88
  });
104
89
  }
105
90
 
91
+ if (opts.config.commit.message.agent.signature === AgentSignaturePolicies.DENY) {
92
+ overlay = ProjectSettings.merge({
93
+ base: overlay,
94
+ overlay: JSON.parse(
95
+ readFileSync(join(BASE_DIRECTORY, 'claude', SyncConstants.COMMIT_ATTRIBUTION_FILE), 'utf8'),
96
+ ),
97
+ });
98
+ }
99
+
106
100
  overlay = ProjectSettings.merge({
107
101
  base: overlay,
108
102
  overlay: ProjectSettings.buildHook({ hooks: opts.config.hooks }),
@@ -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.
@@ -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
- export const STATE_PALETTE: { light: IStatePalette; dark: IStatePalette } = {
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`. */
@@ -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>;
@@ -1,5 +0,0 @@
1
- /** @type {import('@venizia/vulcan').VulcanConfig} */
2
- export default {
3
- agents: ['claude'],
4
- rules: { 'V-W-01': 'on-user-word' },
5
- };
@@ -1,5 +0,0 @@
1
- /** @type {import('@venizia/vulcan').VulcanConfig} */
2
- export default {
3
- agents: ['claude'],
4
- rules: { 'V-W-01': 'on-user-word' },
5
- };
@@ -1,6 +0,0 @@
1
- import type { VulcanConfig } from '@venizia/vulcan';
2
-
3
- export default {
4
- agents: ['claude'],
5
- rules: { 'V-W-01': 'on-user-word' },
6
- } satisfies VulcanConfig;
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
- }