@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
@@ -0,0 +1,94 @@
1
+ import type { ICommentStyle, ICommitAgents, ISignatureHit } from './common/index.ts';
2
+ import { CommitMessage } from './message.ts';
3
+
4
+ /** Any `*-by:` trailer: Co-authored-by, Signed-off-by, Co-developed-by, Assisted-by, Reviewed-by. */
5
+ const TRAILER = /^\s*[A-Za-z][A-Za-z-]*-by\s*:\s*(.*)$/i;
6
+ const ADDRESS = /<([^>]+)>/;
7
+ /** `noreply`, `no-reply`, `no_reply`, or GitHub's `<id>+noreply`: the local part of an address no person reads. */
8
+ const NOREPLY_LOCAL = /^(?:\d+\+)?no[-_]?reply$/i;
9
+ const LEADING_PICTOGRAPH = /^\s*(?:\p{Extended_Pictographic}\s*)?/u;
10
+ /** Markup between "Generated with" and the name: `[`, `**`, a backtick, a space. */
11
+ const MARKUP = /^[\s[\]*_`(]+/;
12
+
13
+ export class AgentSignature {
14
+ static find(opts: {
15
+ message: string;
16
+ agents: ICommitAgents;
17
+ comment?: ICommentStyle;
18
+ }): ISignatureHit[] {
19
+ return CommitMessage.linesOf({ message: opts.message, comment: opts.comment }).flatMap(
20
+ (raw, index) => {
21
+ const text = CommitMessage.cleanOf({ text: raw });
22
+
23
+ if (CommitMessage.isComment({ line: text, comment: opts.comment })) {
24
+ return [];
25
+ }
26
+
27
+ const isSigned =
28
+ AgentSignature.isSigningTrailer({ text, agents: opts.agents }) ||
29
+ AgentSignature.isGeneratedLine({ text, agents: opts.agents });
30
+
31
+ return isSigned ? [{ line: index + 1, text: raw.trim() }] : [];
32
+ },
33
+ );
34
+ }
35
+
36
+ /** A name on the allow list clears a trailer only when it is the whole name and the address is not an agent's. */
37
+ private static isSigningTrailer(opts: { text: string; agents: ICommitAgents }): boolean {
38
+ const value = TRAILER.exec(opts.text)?.[1];
39
+
40
+ if (value === undefined) {
41
+ return false;
42
+ }
43
+
44
+ const address = ADDRESS.exec(value)?.[1] ?? '';
45
+ const display = value.replace(ADDRESS, ' ');
46
+ const isAgentAddress = AgentSignature.isAgentAddress({ address, agents: opts.agents });
47
+ const name = CommitMessage.compactOf({ text: display });
48
+ const isAllowed =
49
+ !isAgentAddress &&
50
+ opts.agents.allow.some((allowed) => CommitMessage.compactOf({ text: allowed }) === name);
51
+
52
+ return (
53
+ !isAllowed &&
54
+ (isAgentAddress ||
55
+ CommitMessage.beginsWithForm({ text: display, forms: opts.agents.products }))
56
+ );
57
+ }
58
+
59
+ /** `noreply` at a vendor's domain, or a local part that names an agent at a domain an agent uses. */
60
+ private static isAgentAddress(opts: { address: string; agents: ICommitAgents }): boolean {
61
+ const at = opts.address.lastIndexOf('@');
62
+
63
+ if (at === -1) {
64
+ return false;
65
+ }
66
+
67
+ const local = opts.address.slice(0, at);
68
+ const bare = local.replace(/^\d+\+/, '').toLowerCase();
69
+ const domain = opts.address.slice(at + 1).toLowerCase();
70
+ const isAt = (domains: string[]): boolean =>
71
+ domains.some((listed) => domain === listed || domain.endsWith(`.${listed}`));
72
+
73
+ return (
74
+ (NOREPLY_LOCAL.test(local) && isAt(opts.agents.noreplyDomains)) ||
75
+ (opts.agents.addressNames.some((name) => name.toLowerCase() === bare) &&
76
+ isAt(opts.agents.addressDomains))
77
+ );
78
+ }
79
+
80
+ /** At the start of a line, and only when an agent's name comes right after: "Generated by scripts/gen.ts from CLAUDE.md" is a note about a file. */
81
+ private static isGeneratedLine(opts: { text: string; agents: ICommitAgents }): boolean {
82
+ const body = opts.text.replace(LEADING_PICTOGRAPH, '').replace(MARKUP, '');
83
+ const lower = body.toLowerCase();
84
+ const phrase = opts.agents.generatedPhrases.find((listed) => lower.startsWith(listed));
85
+
86
+ return (
87
+ phrase !== undefined &&
88
+ CommitMessage.beginsWithForm({
89
+ text: body.slice(phrase.length).replace(MARKUP, ''),
90
+ forms: [...opts.agents.products, ...opts.agents.mentions],
91
+ })
92
+ );
93
+ }
94
+ }
@@ -0,0 +1,40 @@
1
+ import type { ICommentStyle, ICommitSubject, ISubjectProblem } from './common/index.ts';
2
+ import { CommitMessage } from './message.ts';
3
+
4
+ const GENERATED_SUBJECT = /^(?:Merge |Revert "|(?:fixup|squash|amend)! )/;
5
+
6
+ export class SubjectShape {
7
+ static problemOf(opts: {
8
+ message: string;
9
+ subject: ICommitSubject;
10
+ comment?: ICommentStyle;
11
+ }): ISubjectProblem | undefined {
12
+ const lines = CommitMessage.linesOf({ message: opts.message, comment: opts.comment });
13
+ const index = lines.findIndex(
14
+ (text) =>
15
+ text.trim() !== '' && !CommitMessage.isComment({ line: text, comment: opts.comment }),
16
+ );
17
+
18
+ if (index === -1) {
19
+ return undefined;
20
+ }
21
+
22
+ const text = lines[index].trim();
23
+
24
+ if (GENERATED_SUBJECT.test(text) || new RegExp(opts.subject.pattern).test(text)) {
25
+ return undefined;
26
+ }
27
+
28
+ return { line: index + 1, text, hint: opts.subject.hint };
29
+ }
30
+
31
+ static patternError(opts: { pattern: string }): string | undefined {
32
+ try {
33
+ new RegExp(opts.pattern);
34
+
35
+ return undefined;
36
+ } catch (error) {
37
+ return `not a regular expression: ${error instanceof Error ? error.message : String(error)}`;
38
+ }
39
+ }
40
+ }
@@ -9,27 +9,10 @@ export class VulcanCommands {
9
9
  static readonly PROFILE = 'profile';
10
10
  static readonly PRESET = 'preset';
11
11
  static readonly VISUALIZE = 'visualize';
12
+ static readonly COMMIT_CHECK = 'commit-check';
12
13
  static readonly X = 'x';
13
14
  static readonly HELP = 'help';
14
15
  static readonly VERSION = 'version';
15
- static readonly SCHEME_SET = new Set<string>([
16
- this.INIT,
17
- this.ADD,
18
- this.SYNC,
19
- this.AGENTS,
20
- this.DOCTOR,
21
- this.UPGRADE,
22
- this.CLEAN,
23
- this.PROFILE,
24
- this.PRESET,
25
- this.VISUALIZE,
26
- this.X,
27
- this.HELP,
28
- this.VERSION,
29
- ]);
30
- static isValid(value: string): boolean {
31
- return this.SCHEME_SET.has(value);
32
- }
33
16
  }
34
17
 
35
18
  /** The release channels `vulcan upgrade` picks between; the channel is a flag, never stored in the config. */
@@ -38,15 +21,13 @@ export class UpgradeFlags {
38
21
  static readonly NIGHTLY = '--nightly';
39
22
  /** Tests only: a JSON object of dist-tags that stands in for the registry read. */
40
23
  static readonly DIST_TAGS_ENV = 'VULCAN_DIST_TAGS';
41
- static readonly SCHEME_SET = new Set<string>([this.STABLE, this.NIGHTLY]);
42
- static isValid(value: string): boolean {
43
- return this.SCHEME_SET.has(value);
44
- }
45
24
  }
46
25
 
47
26
  export class ExitCodes {
48
27
  static readonly OK = 0;
49
28
  static readonly FAILURE = 1;
29
+ /** A command that cannot run as asked: the arguments, a file or a range it cannot read. */
30
+ static readonly USAGE = 2;
50
31
  }
51
32
 
52
33
  /** The tools `vulcan x` runs; each is a dependency of @venizia/vulcan at the exact same version. */
@@ -18,7 +18,7 @@ export interface ILayout {
18
18
  class LayoutFolderLimits {
19
19
  /** `auroras/apps` is two segments. */
20
20
  static readonly MAX_SEGMENTS = 4;
21
- /** One segment: the pattern a layout folder had before it could have several. */
21
+ /** One segment of a layout folder: lower case letters, digits and hyphens, starting with a letter or digit. */
22
22
  static readonly SEGMENT_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
23
23
  static readonly FORBIDDEN_SEGMENTS = new Set(['node_modules']);
24
24
  }
@@ -32,10 +32,6 @@ export class LayoutKeys {
32
32
  /** The keys `add` can target and `guard-package` guards. */
33
33
  static readonly MANAGED = [this.BACKEND, this.FRONTEND, this.SHARED] as const;
34
34
  static readonly ALL = [...this.MANAGED, this.OTHER] as const;
35
- static readonly SCHEME_SET = new Set<string>(this.ALL);
36
- static isValid(value: string): boolean {
37
- return this.SCHEME_SET.has(value);
38
- }
39
35
  }
40
36
 
41
37
  /** Whether `inner` is `outer` or sits below it. */
@@ -1,11 +1,6 @@
1
- import type { VulcanCommands, VulcanTools } from './constants.ts';
2
-
3
1
  /** The values of a const class's static fields: `TConstValue<typeof Colors>` is `'red' | 'blue'`. */
4
2
  export type TConstValue<TClass> = Extract<TClass[keyof TClass], string | number> & {};
5
3
 
6
- export type TVulcanCommand = TConstValue<typeof VulcanCommands>;
7
- export type TVulcanTool = TConstValue<typeof VulcanTools>;
8
-
9
4
  /** Where `vulcan x` finds a tool: the npm package and the bin it declares. */
10
5
  export interface IToolPackage {
11
6
  packageName: string;
@@ -2,12 +2,6 @@
2
2
  export class PackageKinds {
3
3
  static readonly APP = 'app';
4
4
  static readonly LIB = 'lib';
5
-
6
- static readonly SCHEME_SET = new Set<string>([this.APP, this.LIB]);
7
-
8
- static isValid(value: string): boolean {
9
- return this.SCHEME_SET.has(value);
10
- }
11
5
  }
12
6
 
13
7
  /** Which preset kind made a library: `lib` (may use the project's framework) or `shared` (depends on no framework). */
@@ -22,22 +16,6 @@ export class LibraryKinds {
22
16
  }
23
17
  }
24
18
 
25
- /** Config file extensions, in lookup order. */
26
- export class ConfigExtensions {
27
- static readonly TS = 'ts';
28
- static readonly MTS = 'mts';
29
- static readonly MJS = 'mjs';
30
- static readonly JS = 'js';
31
-
32
- static readonly LOOKUP_ORDER = [this.TS, this.MTS, this.MJS, this.JS] as const;
33
-
34
- static readonly SCHEME_SET = new Set<string>(this.LOOKUP_ORDER);
35
-
36
- static isValid(value: string): boolean {
37
- return this.SCHEME_SET.has(value);
38
- }
39
- }
40
-
41
19
  /** The agents `vulcan sync` writes adapters for. */
42
20
  export class CodingAgents {
43
21
  static readonly CLAUDE = 'claude';
@@ -82,7 +60,8 @@ export class HookEvents {
82
60
 
83
61
  export class ConfigConstants {
84
62
  static readonly DIRECTORY = '.configs';
85
- static readonly BASENAME = 'vulcan.config';
63
+ /** The one config file name, under `.configs/`. */
64
+ static readonly FILE = 'vulcan.config.mts';
86
65
  static readonly DEFAULT_KNOWLEDGE_BUNDLE = '.agents/knowledge';
87
66
  static readonly RULE_ID_PATTERN = /^(?:[A-Z]+-)?[A-Z]-\d{2}$/;
88
67
  /** The rules a session drops most, printed at every session start unless the project lists its own. */
@@ -1,14 +1,5 @@
1
1
  import type { TConstValue } from '../../common/index.ts';
2
- import type {
3
- CodingAgents,
4
- ConfigExtensions,
5
- HookEvents,
6
- LibraryKinds,
7
- PackageKinds,
8
- } from './constants.ts';
2
+ import type { LibraryKinds, PackageKinds } from './constants.ts';
9
3
 
10
- export type TConfigExtension = TConstValue<typeof ConfigExtensions>;
11
- export type TCodingAgent = TConstValue<typeof CodingAgents>;
12
- export type THookEvent = TConstValue<typeof HookEvents>;
13
4
  export type TPackageKind = TConstValue<typeof PackageKinds>;
14
5
  export type TLibraryKind = TConstValue<typeof LibraryKinds>;
@@ -1,7 +1,7 @@
1
1
  import { existsSync } from 'node:fs';
2
2
  import { join, relative } from 'node:path';
3
3
  import { pathToFileURL } from 'node:url';
4
- import { ConfigConstants, ConfigExtensions } from './common/index.ts';
4
+ import { ConfigConstants } from './common/index.ts';
5
5
  import { VULCAN_CONFIG_SCHEMA } from './schema.ts';
6
6
  import type { TResolvedConfig } from './schema.ts';
7
7
 
@@ -13,30 +13,29 @@ const describeError = (opts: { error: unknown }): string =>
13
13
  opts.error instanceof Error ? opts.error.message : String(opts.error);
14
14
 
15
15
  export class ConfigLoader {
16
- /** Every `.configs/vulcan.config.<ext>` present, in lookup order. */
17
- static findFiles(opts: { root: string }): string[] {
18
- return ConfigExtensions.LOOKUP_ORDER.map((extension) =>
19
- join(opts.root, ConfigConstants.DIRECTORY, `${ConfigConstants.BASENAME}.${extension}`),
20
- ).filter((file) => existsSync(file));
16
+ /** `.configs/vulcan.config.mts` when the project has one. */
17
+ static findFile(opts: { root: string }): string | undefined {
18
+ const file = join(opts.root, ConfigConstants.DIRECTORY, ConfigConstants.FILE);
19
+
20
+ return existsSync(file) ? file : undefined;
21
21
  }
22
22
 
23
23
  static async load(opts: { root: string }): Promise<TLoadResult> {
24
- const files = ConfigLoader.findFiles({ root: opts.root });
24
+ const file = ConfigLoader.findFile({ root: opts.root });
25
+
26
+ if (file === undefined) {
27
+ const other = ['ts', 'mjs', 'js']
28
+ .map((extension) => `vulcan.config.${extension}`)
29
+ .find((name) => existsSync(join(opts.root, ConfigConstants.DIRECTORY, name)));
30
+ const hint =
31
+ other === undefined ? '' : ` (${other} is not read: rename it to ${ConfigConstants.FILE})`;
25
32
 
26
- if (files.length === 0) {
27
33
  return {
28
34
  ok: false,
29
- error: `no ${ConfigConstants.DIRECTORY}/${ConfigConstants.BASENAME}.* found in ${opts.root}`,
35
+ error: `no ${ConfigConstants.DIRECTORY}/${ConfigConstants.FILE} found in ${opts.root}${hint}`,
30
36
  };
31
37
  }
32
38
 
33
- if (files.length > 1) {
34
- const names = files.map((file) => relative(opts.root, file)).join(', ');
35
-
36
- return { ok: false, error: `more than one config - keep exactly one of: ${names}` };
37
- }
38
-
39
- const [file] = files;
40
39
  const shown = relative(opts.root, file);
41
40
 
42
41
  let loaded: { default?: unknown };
@@ -2,6 +2,9 @@ import { isAbsolute } from 'node:path';
2
2
  import { z } from 'zod';
3
3
  import { LayoutFolder } from '../common/layout-folder.ts';
4
4
  import { OWNER_SCHEMA } from '../owner/schema.ts';
5
+ import { AgentSignaturePolicies } from '../commit/common/index.ts';
6
+ import type { TAgentSignaturePolicy } from '../commit/common/index.ts';
7
+ import { SubjectShape } from '../commit/subject.ts';
5
8
  import {
6
9
  CodingAgents,
7
10
  ConfigConstants,
@@ -97,9 +100,27 @@ const TRUSTED_SCRIPT = z.union([
97
100
  /** One folder, or a list of them: a side whose apps are grouped keeps each group's folder. */
98
101
  const LAYOUT_VALUE = z.union([LAYOUT_FOLDER, z.array(LAYOUT_FOLDER).min(1)]);
99
102
 
103
+ /** An npm package name, lower case: the pattern and the length atlas applies to every package name of the manifest. */
104
+ const NPM_NAME_PATTERN = /^(?:@[a-z0-9~-][a-z0-9._~-]*\/)?[a-z0-9~-][a-z0-9._~-]*$/;
105
+ const NPM_NAME_MAX_LENGTH = 214;
106
+
107
+ const NPM_PACKAGE_NAME = z.string().superRefine((value, context) => {
108
+ if (value.length > NPM_NAME_MAX_LENGTH || !NPM_NAME_PATTERN.test(value)) {
109
+ context.addIssue({
110
+ code: 'custom',
111
+ message: `package name '${value}' is not an npm package name: npm names are lower case (a to z, digits, . _ ~ -) with an optional @scope/, at most ${NPM_NAME_MAX_LENGTH} characters, and atlas refuses the manifest otherwise`,
112
+ });
113
+ }
114
+ });
115
+
116
+ /** A name that holds a letter or a digit: an entry of only punctuation or spaces would match everything. */
117
+ const AGENT_NAME = z
118
+ .string()
119
+ .regex(/[\p{L}\p{N}]/u, { message: 'a name with at least one letter or digit' });
120
+
100
121
  const PROJECT_PACKAGE = z.strictObject({
101
122
  dir: z.string().regex(/^[a-z0-9][a-z0-9.-]*$/),
102
- name: z.string(),
123
+ name: NPM_PACKAGE_NAME,
103
124
  /** Where the package lives, from the root; default `packages/<dir>`. */
104
125
  path: z.string().optional(),
105
126
  aliases: z.array(z.string()).default([]),
@@ -151,24 +172,16 @@ const checkPackagesUnique = (
151
172
  };
152
173
 
153
174
  /**
154
- * A release template: `<dir>` (synonym `<package>`) is the package DIRECTORY - the `packages` key,
175
+ * A release template: `<dir>` is the package DIRECTORY - the `packages` key,
155
176
  * never the npm name (`packages/core-server` published as `@acme/server` tags `core-server-v1.2.0`); `<version>` is the
156
177
  * version; `<issue>` an issue number. Every other character is literal. When matching a commit, a
157
178
  * leading `[#<issue>] ` is optional and a trailing ` [<mode>]` is tolerated. A release train that
158
179
  * tags once leaves `<dir>` out (`v<version>`).
159
180
  */
160
181
  const RELEASE_TEMPLATE = z.string().refine((value) => value.includes('<version>'), {
161
- message: 'a template with <version> (and <dir> or <package> for per-package releases)',
182
+ message: 'a template with <version> (and <dir> for per-package releases)',
162
183
  });
163
184
 
164
- /** A key the config once accepted and no tool ever read: still named, so the error says it is gone rather than "unrecognized". */
165
- const removedAtlasKey = (opts: { key: string }) =>
166
- z
167
- .never({
168
- error: `atlas.${opts.key} was removed - no tool reads it; delete it from the config`,
169
- })
170
- .optional();
171
-
172
185
  /** A renderer by id: a built-in, or a project module (`module`); a bare string is the id alone. */
173
186
  const OKF_RENDERER = z.union([
174
187
  z.string().transform((id) => ({ id, options: {} })),
@@ -290,16 +303,6 @@ export const VULCAN_CONFIG_SCHEMA = z.strictObject({
290
303
  }),
291
304
  atlas: z
292
305
  .strictObject({
293
- /** Removed in 0.2.0-8; present only so the error can name `packages`. */
294
- packages: z
295
- .never({
296
- error:
297
- 'atlas.packages was removed - move the list to the top-level packages: [{ dir, name }] (release order; dir is the old key, name the old value)',
298
- })
299
- .optional(),
300
- releaseCommit: removedAtlasKey({ key: 'releaseCommit' }),
301
- typescriptFrom: removedAtlasKey({ key: 'typescriptFrom' }),
302
- legacyTagPrefixes: removedAtlasKey({ key: 'legacyTagPrefixes' }),
303
306
  tagPattern: RELEASE_TEMPLATE.default('<dir>-v<version>'),
304
307
  /**
305
308
  * Templates of an earlier tag layout that are still releases: atlas and the changelog check read a tag
@@ -412,6 +415,51 @@ export const VULCAN_CONFIG_SCHEMA = z.strictObject({
412
415
  writes: { trustedScripts: [], commands: [] },
413
416
  git: { askPush: [] },
414
417
  }),
418
+ /**
419
+ * What `vulcan commit-check` looks for in a commit message, and what `vulcan sync` installs the
420
+ * `commit-msg` hook for, nested by scope. Every check is off until the project turns it on:
421
+ * `message.agent.signature: 'deny'` rejects a trailer or a "generated with" line that names an agent
422
+ * (rule W-00 of a project that has one); `message.agent.names` adds names to the shipped list and
423
+ * `message.agent.allow` lists names never flagged; `message.subject` is the project's own one-line
424
+ * shape. Written to the manifest only when a check is on.
425
+ */
426
+ commit: z
427
+ .strictObject({
428
+ message: z
429
+ .strictObject({
430
+ agent: z
431
+ .strictObject({
432
+ signature: z
433
+ .custom<TAgentSignaturePolicy>(
434
+ (value) => typeof value === 'string' && AgentSignaturePolicies.isValid(value),
435
+ { message: `one of ${[...AgentSignaturePolicies.SCHEME_SET].join(', ')}` },
436
+ )
437
+ .default(AgentSignaturePolicies.ALLOW),
438
+ names: z.array(AGENT_NAME).default([]),
439
+ allow: z.array(AGENT_NAME).default([]),
440
+ })
441
+ .default({ signature: AgentSignaturePolicies.ALLOW, names: [], allow: [] }),
442
+ subject: z
443
+ .strictObject({
444
+ pattern: z
445
+ .string()
446
+ .min(1)
447
+ .superRefine((value, context) => {
448
+ const error = SubjectShape.patternError({ pattern: value });
449
+
450
+ if (error !== undefined) {
451
+ context.addIssue({ code: 'custom', message: error });
452
+ }
453
+ }),
454
+ hint: z.string().min(1).optional(),
455
+ })
456
+ .optional(),
457
+ })
458
+ .default({ agent: { signature: AgentSignaturePolicies.ALLOW, names: [], allow: [] } }),
459
+ })
460
+ .default({
461
+ message: { agent: { signature: AgentSignaturePolicies.ALLOW, names: [], allow: [] } },
462
+ }),
415
463
  });
416
464
 
417
465
  export type VulcanConfig = z.input<typeof VULCAN_CONFIG_SCHEMA>;
@@ -529,7 +529,7 @@ export class AppScaffold {
529
529
  [side]: LayoutFolder.withLayoutFolder({ value: parsed.block.layout[side], folder }),
530
530
  },
531
531
  packages: [...parsed.block.packages, entry],
532
- ...(parsed.block.presets === undefined ? {} : { presets: parsed.block.presets }),
532
+ presets: parsed.block.presets,
533
533
  sources: [
534
534
  ...parsed.block.sources,
535
535
  ...newSources.filter(
@@ -541,15 +541,7 @@ export class AppScaffold {
541
541
  block: extended,
542
542
  preset: LibPreset.recordedOf({ spec: recordedSpec, located: located.located }),
543
543
  });
544
- const replaced = AppsBlock.replace({ source, block });
545
- // A config written before presets were recorded does not read them yet: the line that does goes in.
546
- const nextConfig =
547
- replaced === undefined || replaced.includes('apps.presets')
548
- ? replaced
549
- : replaced.replace(
550
- ' packages: apps.packages,\n',
551
- ' packages: apps.packages,\n presets: apps.presets,\n',
552
- );
544
+ const nextConfig = AppsBlock.replace({ source, block });
553
545
 
554
546
  if (nextConfig === undefined) {
555
547
  return AddFailure.fail({ message: ROOT_HINT });
@@ -233,14 +233,7 @@ export class LibraryScaffold {
233
233
  ],
234
234
  },
235
235
  });
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
- );
236
+ const nextConfig = AppsBlock.replace({ source, block });
244
237
 
245
238
  if (nextConfig === undefined) {
246
239
  return AddFailure.fail({
@@ -11,12 +11,6 @@ export class AppSides {
11
11
  export class AppsBlockProblems {
12
12
  static readonly MISSING = 'missing';
13
13
  static readonly INVALID = 'invalid';
14
-
15
- static readonly SCHEME_SET = new Set<string>([this.MISSING, this.INVALID]);
16
-
17
- static isValid(value: string): boolean {
18
- return this.SCHEME_SET.has(value);
19
- }
20
14
  }
21
15
 
22
16
  export class CreateConstants {
@@ -73,10 +67,6 @@ export class DiffEditKinds {
73
67
  static readonly KEEP = 'keep';
74
68
  static readonly ADD = 'add';
75
69
  static readonly REMOVE = 'remove';
76
- static readonly SCHEME_SET = new Set<string>([this.KEEP, this.ADD, this.REMOVE]);
77
- static isValid(value: string): boolean {
78
- return this.SCHEME_SET.has(value);
79
- }
80
70
  }
81
71
 
82
72
  /** What `preset diff` says of a file the preset makes, next to the file the app has. */
@@ -84,8 +74,4 @@ export class PresetDiffStatuses {
84
74
  static readonly SAME = 'same';
85
75
  static readonly DIFFERS = 'differs';
86
76
  static readonly MISSING = 'missing';
87
- static readonly SCHEME_SET = new Set<string>([this.SAME, this.DIFFERS, this.MISSING]);
88
- static isValid(value: string): boolean {
89
- return this.SCHEME_SET.has(value);
90
- }
91
77
  }
@@ -113,7 +113,6 @@ export interface IRecordedPreset {
113
113
  export interface IAppsBlock {
114
114
  layout: ILayout;
115
115
  packages: { dir: string; name: string; path: string; kind?: 'lib'; presetKind?: TLibraryKind }[];
116
- /** Absent in a block written before presets were recorded. */
117
- presets?: IRecordedPreset[];
116
+ presets: IRecordedPreset[];
118
117
  sources: { name: string; repo: string; ref: string }[];
119
118
  }
@@ -152,18 +152,6 @@ export class Preset {
152
152
  const packageVersion = String(manifest.version);
153
153
  const shown = `${packageName}@${packageVersion}`;
154
154
  const vulcan = manifest[CreateConstants.PRESET_FIELD];
155
- const oldKeys = ['preset', 'lib'].filter(
156
- (key) => JsonValue.readProperty({ value: vulcan, key }) !== undefined,
157
- );
158
-
159
- // No fallback to the keys before `presets`: say what the contract is now.
160
- if (oldKeys.length > 0) {
161
- return {
162
- ok: false,
163
- error: `${shown} uses the old keys "vulcan": { ${oldKeys.map((key) => `"${key}"`).join(', ')} }; the contract is now "vulcan": { "presets": { "app": "./path/preset.json", "lib": "./path/lib.json" } }`,
164
- };
165
- }
166
-
167
155
  const presets = JsonValue.readProperty({ value: vulcan, key: 'presets' });
168
156
  const field = JsonValue.readProperty({ value: presets, key: 'app' });
169
157
  const libField = JsonValue.readProperty({ value: presets, key: 'lib' });
@@ -277,8 +277,8 @@ const isRecordedPreset = (value: unknown): boolean =>
277
277
 
278
278
  const isAppsBlock = (value: unknown): value is IAppsBlock =>
279
279
  RecordValue.isRecord(value) &&
280
- (value.presets === undefined ||
281
- (Array.isArray(value.presets) && value.presets.every((entry) => isRecordedPreset(entry)))) &&
280
+ Array.isArray(value.presets) &&
281
+ value.presets.every((entry) => isRecordedPreset(entry)) &&
282
282
  RecordValue.isRecord(value.layout) &&
283
283
  Object.values(value.layout).every(
284
284
  (folders) =>
@@ -511,12 +511,12 @@ export class PresetRecord {
511
511
 
512
512
  /** The block with this preset recorded: once per spec, its side and summary refreshed. */
513
513
  static record(opts: { block: IAppsBlock; preset: IRecordedPreset }): IAppsBlock {
514
- const others = (opts.block.presets ?? []).filter((item) => item.spec !== opts.preset.spec);
515
- const index = (opts.block.presets ?? []).findIndex((item) => item.spec === opts.preset.spec);
514
+ const others = opts.block.presets.filter((item) => item.spec !== opts.preset.spec);
515
+ const index = opts.block.presets.findIndex((item) => item.spec === opts.preset.spec);
516
516
  const presets =
517
517
  index === -1
518
518
  ? [...others, opts.preset]
519
- : (opts.block.presets ?? []).map((item, at) => (at === index ? opts.preset : item));
519
+ : opts.block.presets.map((item, at) => (at === index ? opts.preset : item));
520
520
 
521
521
  return { ...opts.block, presets };
522
522
  }