@venizia/vulcan 0.4.9-0 → 0.4.9-2

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 (141) hide show
  1. package/base/extensions/vulcan-guards.ts +48 -41
  2. package/base/hooks/antigravity-guards.ts +2 -2
  3. package/base/hooks/codex-guards.ts +15 -5
  4. package/base/hooks/guard-git.ts +8 -8
  5. package/base/hooks/guard-manifest.ts +4 -5
  6. package/base/hooks/guard-outside.ts +8 -8
  7. package/base/hooks/guard-package.ts +5 -6
  8. package/base/hooks/guard-remote-hosts.ts +6 -7
  9. package/base/hooks/guard-scripting.ts +5 -6
  10. package/base/hooks/guard-writes.ts +8 -9
  11. package/base/hooks/post-tool.ts +2 -2
  12. package/base/hooks/prompt-submit.ts +2 -2
  13. package/base/hooks/session-start.ts +3 -3
  14. package/base/hooks/stop.ts +2 -2
  15. package/base/hooks/subagent-start.ts +2 -2
  16. package/base/skills/docs-update/SKILL.md +4 -2
  17. package/base/skills/visualize-work/SKILL.md +9 -0
  18. package/package.json +3 -3
  19. package/src/agents/atlas-block.ts +43 -43
  20. package/src/agents/codex-hooks.ts +45 -43
  21. package/src/agents/detect.ts +19 -16
  22. package/src/agents/exclude.ts +96 -97
  23. package/src/agents/hooks-json.ts +38 -36
  24. package/src/agents/local.ts +46 -43
  25. package/src/agents/prompt.ts +45 -42
  26. package/src/agents/render.ts +201 -195
  27. package/src/agents/resolve.ts +133 -134
  28. package/src/agents/table.ts +12 -8
  29. package/src/commands/add.command.ts +2 -2
  30. package/src/commands/agents.command.ts +11 -17
  31. package/src/commands/clean.command.ts +6 -6
  32. package/src/commands/doctor.command.ts +4 -4
  33. package/src/commands/init.command.ts +12 -8
  34. package/src/commands/preset.command.ts +2 -2
  35. package/src/commands/profile.command.ts +42 -49
  36. package/src/commands/sync.command.ts +109 -111
  37. package/src/commands/upgrade.command.ts +80 -75
  38. package/src/commands/visualize.command.ts +7 -13
  39. package/src/commands/x.command.ts +55 -50
  40. package/src/common/format.ts +23 -21
  41. package/src/common/json.ts +8 -5
  42. package/src/common/layout-folder.ts +94 -91
  43. package/src/common/paths.ts +14 -12
  44. package/src/config/loader.ts +52 -49
  45. package/src/config/packages.ts +14 -11
  46. package/src/config/schema.ts +3 -3
  47. package/src/create/add-app.ts +519 -509
  48. package/src/create/add-lib.ts +237 -240
  49. package/src/create/bunfig.ts +26 -23
  50. package/src/create/checks.ts +36 -34
  51. package/src/create/diff.ts +21 -23
  52. package/src/create/dockerignore.ts +26 -24
  53. package/src/create/files.ts +7 -5
  54. package/src/create/init-monorepo.ts +75 -80
  55. package/src/create/lib-preset.ts +59 -63
  56. package/src/create/manifest-json.ts +10 -4
  57. package/src/create/names.ts +217 -210
  58. package/src/create/next.ts +26 -23
  59. package/src/create/plan.ts +15 -12
  60. package/src/create/preset-diff.ts +301 -303
  61. package/src/create/preset-menu.ts +38 -32
  62. package/src/create/preset.ts +202 -197
  63. package/src/create/process.ts +79 -72
  64. package/src/create/scratch.ts +48 -49
  65. package/src/create/workspace.ts +404 -396
  66. package/src/doctor/checks.ts +1027 -1014
  67. package/src/doctor/makefile.ts +17 -13
  68. package/src/doctor/runner.ts +88 -118
  69. package/src/doctor/skills.ts +97 -95
  70. package/src/doctor/tags.ts +42 -37
  71. package/src/hooks/codex-patch.ts +25 -22
  72. package/src/hooks/command-view.ts +44 -39
  73. package/src/hooks/decision.ts +37 -37
  74. package/src/hooks/guard-git.ts +51 -49
  75. package/src/hooks/guard-manifest.ts +58 -55
  76. package/src/hooks/guard-outside.ts +93 -91
  77. package/src/hooks/guard-package.ts +82 -79
  78. package/src/hooks/guard-scripting.ts +19 -14
  79. package/src/hooks/guard-writes.ts +154 -149
  80. package/src/hooks/owner-reply.ts +127 -127
  81. package/src/hooks/post-tool.ts +94 -93
  82. package/src/hooks/project-guards.ts +65 -62
  83. package/src/hooks/project-tmp.ts +27 -24
  84. package/src/hooks/remote-hosts.ts +153 -130
  85. package/src/hooks/session-digest.ts +98 -101
  86. package/src/hooks/shell.ts +509 -499
  87. package/src/hooks/subagent-card.ts +11 -7
  88. package/src/hooks/trusted-scripts.ts +106 -104
  89. package/src/init/scaffold.ts +135 -132
  90. package/src/local/clean.ts +38 -36
  91. package/src/local/format.ts +21 -17
  92. package/src/local/scan.ts +144 -138
  93. package/src/manifest/render.ts +110 -104
  94. package/src/owner/card.ts +51 -46
  95. package/src/owner/profile.ts +99 -93
  96. package/src/owner/reply-switch.ts +9 -6
  97. package/src/owner/shape.ts +71 -69
  98. package/src/owner/survey.ts +173 -171
  99. package/src/owner/view.ts +62 -59
  100. package/src/owner/violations.ts +119 -123
  101. package/src/rules/base.ts +15 -11
  102. package/src/rules/parser.ts +39 -32
  103. package/src/rules/slots.ts +8 -6
  104. package/src/signals/claims.ts +30 -28
  105. package/src/signals/classify.ts +38 -33
  106. package/src/signals/loop.ts +39 -37
  107. package/src/signals/state.ts +79 -81
  108. package/src/skills/frontmatter.ts +28 -28
  109. package/src/sync/agent-files.ts +217 -199
  110. package/src/sync/agent-removal.ts +56 -59
  111. package/src/sync/atlas-block.ts +45 -43
  112. package/src/sync/base-rules.ts +32 -30
  113. package/src/sync/claude-launch.ts +36 -34
  114. package/src/sync/exclude.ts +77 -69
  115. package/src/sync/local-choice.ts +50 -47
  116. package/src/sync/planner.ts +59 -61
  117. package/src/sync/prune.ts +52 -48
  118. package/src/sync/settings.ts +166 -167
  119. package/src/ui/capability.ts +12 -7
  120. package/src/ui/keyboard.ts +38 -38
  121. package/src/ui/prompt.ts +79 -77
  122. package/src/visualize/assets.ts +33 -24
  123. package/src/visualize/charts.ts +179 -176
  124. package/src/visualize/compare-css.ts +3 -2
  125. package/src/visualize/compare-render.ts +9 -7
  126. package/src/visualize/diagrams.ts +189 -174
  127. package/src/visualize/grid-span.ts +34 -0
  128. package/src/visualize/icons.ts +7 -5
  129. package/src/visualize/kinds-render.ts +50 -45
  130. package/src/visualize/kinds-validate.ts +12 -10
  131. package/src/visualize/labels.ts +21 -17
  132. package/src/visualize/layout.ts +112 -97
  133. package/src/visualize/page.ts +92 -104
  134. package/src/visualize/render.ts +143 -140
  135. package/src/visualize/sections.ts +395 -384
  136. package/src/visualize/sources.ts +2 -2
  137. package/src/visualize/theme.ts +12 -10
  138. package/src/visualize/validate.ts +13 -9
  139. package/src/wiki/anchors.ts +38 -36
  140. package/src/wiki/command.ts +4 -4
  141. package/src/wiki/source-links.ts +46 -44
@@ -1,17 +1,21 @@
1
1
  const RULE_TARGET = /^([A-Za-z0-9][A-Za-z0-9_.-]*)\s*:(?!=)/;
2
2
 
3
- /** Explicit rule targets: `name:` at column 0 - no recipes, assignments, specials or `$(...)` rules. */
4
- export const parseMakeTargets = (opts: { makefile: string }): string[] =>
5
- opts.makefile
6
- .split('\n')
7
- .map((line) => RULE_TARGET.exec(line)?.[1])
8
- .filter((target): target is string => target !== undefined);
9
-
10
3
  const INCLUDE_LINE = /^\s*(?:-include|sinclude|include)\s+(.+?)\s*$/;
11
4
 
12
- /** The paths and globs an `include`, `-include` or `sinclude` line names; one built from a variable is skipped. */
13
- export const parseMakeIncludes = (opts: { makefile: string }): string[] =>
14
- opts.makefile
15
- .split('\n')
16
- .flatMap((line) => INCLUDE_LINE.exec(line)?.[1].split(/\s+/) ?? [])
17
- .filter((path) => !path.includes('$('));
5
+ export class Makefile {
6
+ /** Explicit rule targets: `name:` at column 0 - no recipes, assignments, specials or `$(...)` rules. */
7
+ static parseMakeTargets(opts: { makefile: string }): string[] {
8
+ return opts.makefile
9
+ .split('\n')
10
+ .map((line) => RULE_TARGET.exec(line)?.[1])
11
+ .filter((target): target is string => target !== undefined);
12
+ }
13
+
14
+ /** The paths and globs an `include`, `-include` or `sinclude` line names; one built from a variable is skipped. */
15
+ static parseMakeIncludes(opts: { makefile: string }): string[] {
16
+ return opts.makefile
17
+ .split('\n')
18
+ .flatMap((line) => INCLUDE_LINE.exec(line)?.[1].split(/\s+/) ?? [])
19
+ .filter((path) => !path.includes('$('));
20
+ }
21
+ }
@@ -1,136 +1,106 @@
1
1
  import { relative } from 'node:path';
2
- import { loadConfig } from '../config/index.ts';
3
- import {
4
- checkAdapters,
5
- checkAgents,
6
- checkAppScripts,
7
- checkAtlasBlock,
8
- checkSkillTriggers,
9
- checkDockerignore,
10
- checkFormat,
11
- checkMcpAtlas,
12
- checkApps,
13
- checkManifest,
14
- checkLocalSize,
15
- checkProfile,
16
- checkOwnerReplySettings,
17
- checkOwnerReplySwitch,
18
- checkReplyShape,
19
- checkPrune,
20
- checkStaleLocal,
21
- ReadOnlySubcommandChecks,
22
- checkStaleTrustedScripts,
23
- checkTrustedScripts,
24
- checkHooks,
25
- checkLayout,
26
- checkGuardPatterns,
27
- checkLocalWorkspace,
28
- checkMake,
29
- checkOutsideWorktrees,
30
- checkRuleIds,
31
- checkRuleSlots,
32
- checkScaffold,
33
- checkSkills,
34
- checkStyle,
35
- } from './checks.ts';
36
- import { checkSkillLint } from './skills.ts';
37
- import { checkTags } from './tags.ts';
2
+ import { ConfigLoader } from '../config/index.ts';
3
+ import { ProjectContract, ReadOnlySubcommandChecks } from './checks.ts';
4
+ import { SkillLint } from './skills.ts';
5
+ import { TagCheck } from './tags.ts';
38
6
  import { DoctorChecks } from './common/index.ts';
39
7
  import type { IViolation } from './common/index.ts';
40
8
 
41
- /** Every violation of the VULCAN contract in the project at `root`; empty means conformant. */
42
- export const runDoctorChecks = async (opts: { root: string }): Promise<IViolation[]> => {
43
- const loaded = await loadConfig({ root: opts.root });
9
+ export class DoctorRunner {
10
+ /** Every violation of the VULCAN contract in the project at `root`; empty means conformant. */
11
+ static async runChecks(opts: { root: string }): Promise<IViolation[]> {
12
+ const loaded = await ConfigLoader.load({ root: opts.root });
13
+
14
+ if (!loaded.ok) {
15
+ return [
16
+ {
17
+ check: DoctorChecks.CONFIG,
18
+ file: loaded.file === undefined ? '.configs/' : relative(opts.root, loaded.file),
19
+ message: loaded.error,
20
+ },
21
+ ];
22
+ }
23
+
24
+ const context = {
25
+ root: opts.root,
26
+ config: loaded.config,
27
+ configFile: relative(opts.root, loaded.file),
28
+ };
44
29
 
45
- if (!loaded.ok) {
46
30
  return [
47
- {
48
- check: DoctorChecks.CONFIG,
49
- file: loaded.file === undefined ? '.configs/' : relative(opts.root, loaded.file),
50
- message: loaded.error,
51
- },
31
+ ...ProjectContract.checkLayout(context),
32
+ ...ProjectContract.checkRuleIds(context),
33
+ ...ProjectContract.checkRuleSlots(context),
34
+ ...ProjectContract.checkSkills(context),
35
+ ...ProjectContract.checkMake(context),
36
+ ...ProjectContract.checkHooks(context),
37
+ ...ProjectContract.checkAdapters(context),
38
+ ...ProjectContract.checkAgents(context),
39
+ ...ProjectContract.checkPrune(context),
40
+ ...ProjectContract.checkManifest(context),
41
+ ...TagCheck.check(context),
42
+ ...SkillLint.check(context),
43
+ ...ProjectContract.checkStyle(context),
44
+ ...ProjectContract.checkScaffold(context),
45
+ ...ProjectContract.checkApps(context),
52
46
  ];
53
47
  }
54
48
 
55
- const context = {
56
- root: opts.root,
57
- config: loaded.config,
58
- configFile: relative(opts.root, loaded.file),
59
- };
49
+ /** Notes that never fail the doctor: what a project could change, one line each. */
50
+ static async runNotes(opts: {
51
+ root: string;
52
+ /** The environment of the shell running doctor; defaults to the process environment. */
53
+ env?: Record<string, string | undefined>;
54
+ }): Promise<IViolation[]> {
55
+ const loaded = await ConfigLoader.load({ root: opts.root });
60
56
 
61
- return [
62
- ...checkLayout(context),
63
- ...checkRuleIds(context),
64
- ...checkRuleSlots(context),
65
- ...checkSkills(context),
66
- ...checkMake(context),
67
- ...checkHooks(context),
68
- ...checkAdapters(context),
69
- ...checkAgents(context),
70
- ...checkPrune(context),
71
- ...checkManifest(context),
72
- ...checkTags(context),
73
- ...checkSkillLint(context),
74
- ...checkStyle(context),
75
- ...checkScaffold(context),
76
- ...checkApps(context),
77
- ];
78
- };
57
+ if (!loaded.ok) {
58
+ return [];
59
+ }
79
60
 
80
- /** Notes that never fail the doctor: what a project could change, one line each. */
81
- export const runDoctorNotes = async (opts: {
82
- root: string;
83
- /** The environment of the shell running doctor; defaults to the process environment. */
84
- env?: Record<string, string | undefined>;
85
- }): Promise<IViolation[]> => {
86
- const loaded = await loadConfig({ root: opts.root });
61
+ const context = {
62
+ root: opts.root,
63
+ config: loaded.config,
64
+ configFile: relative(opts.root, loaded.file),
65
+ };
87
66
 
88
- if (!loaded.ok) {
89
- return [];
67
+ return [
68
+ ...ProjectContract.checkAppScripts(context),
69
+ ...ProjectContract.checkAtlasBlock(context),
70
+ ...ProjectContract.checkLocalSize(context),
71
+ ...ProjectContract.checkGuardPatterns(context),
72
+ ...ProjectContract.checkReplyShape(context),
73
+ ...ProjectContract.checkOwnerReplySwitch({ env: opts.env ?? process.env }),
74
+ ...ProjectContract.checkTrustedScripts(context),
75
+ ...ReadOnlySubcommandChecks.check(context),
76
+ ];
90
77
  }
91
78
 
92
- const context = {
93
- root: opts.root,
94
- config: loaded.config,
95
- configFile: relative(opts.root, loaded.file),
96
- };
79
+ /** Warnings: louder than a note, still never a failure - a security gap a project made earlier may carry. */
80
+ static async runWarnings(opts: { root: string }): Promise<IViolation[]> {
81
+ const loaded = await ConfigLoader.load({ root: opts.root });
97
82
 
98
- return [
99
- ...checkAppScripts(context),
100
- ...checkAtlasBlock(context),
101
- ...checkLocalSize(context),
102
- ...checkGuardPatterns(context),
103
- ...checkReplyShape(context),
104
- ...checkOwnerReplySwitch({ env: opts.env ?? process.env }),
105
- ...checkTrustedScripts(context),
106
- ...ReadOnlySubcommandChecks.check(context),
107
- ];
108
- };
83
+ if (!loaded.ok) {
84
+ return [];
85
+ }
109
86
 
110
- /** Warnings: louder than a note, still never a failure - a security gap a project made earlier may carry. */
111
- export const runDoctorWarnings = async (opts: { root: string }): Promise<IViolation[]> => {
112
- const loaded = await loadConfig({ root: opts.root });
87
+ const context = {
88
+ root: opts.root,
89
+ config: loaded.config,
90
+ configFile: relative(opts.root, loaded.file),
91
+ };
113
92
 
114
- if (!loaded.ok) {
115
- return [];
93
+ return [
94
+ ...ProjectContract.checkMcpAtlas(context),
95
+ ...ProjectContract.checkDockerignore(context),
96
+ ...ProjectContract.checkSkillTriggers(context),
97
+ ...ProjectContract.checkFormat(context),
98
+ ...ProjectContract.checkLocalWorkspace(context),
99
+ ...ProjectContract.checkOutsideWorktrees(context),
100
+ ...ProjectContract.checkProfile(context),
101
+ ...ProjectContract.checkOwnerReplySettings(context),
102
+ ...ProjectContract.checkStaleLocal(context),
103
+ ...ProjectContract.checkStaleTrustedScripts(context),
104
+ ];
116
105
  }
117
-
118
- const context = {
119
- root: opts.root,
120
- config: loaded.config,
121
- configFile: relative(opts.root, loaded.file),
122
- };
123
-
124
- return [
125
- ...checkMcpAtlas(context),
126
- ...checkDockerignore(context),
127
- ...checkSkillTriggers(context),
128
- ...checkFormat(context),
129
- ...checkLocalWorkspace(context),
130
- ...checkOutsideWorktrees(context),
131
- ...checkProfile(context),
132
- ...checkOwnerReplySettings(context),
133
- ...checkStaleLocal(context),
134
- ...checkStaleTrustedScripts(context),
135
- ];
136
- };
106
+ }
@@ -3,7 +3,7 @@ import { dirname, join, relative, resolve } from 'node:path';
3
3
  import type { ICheckContext } from './checks.ts';
4
4
  import { DoctorChecks } from './common/index.ts';
5
5
  import type { IViolation } from './common/index.ts';
6
- import { frontmatterOf } from '../skills/index.ts';
6
+ import { SkillFrontmatter } from '../skills/index.ts';
7
7
 
8
8
  /**
9
9
  * Anthropic's skill-authoring rules (platform.claude.com, Agent Skills best practices), as checks:
@@ -34,120 +34,122 @@ const filesOf = (opts: { directory: string }): string[] =>
34
34
  const lineCountOf = (opts: { text: string }): number =>
35
35
  opts.text.replace(/\n$/, '').split('\n').length;
36
36
 
37
- /** Every rule one skill directory breaks, each a message naming the file. */
38
- export const lintSkill = (opts: { directory: string }): string[] => {
39
- const skillFile = join(opts.directory, 'SKILL.md');
37
+ export class SkillLint {
38
+ /** Every rule one skill directory breaks, each a message naming the file. */
39
+ static lint(opts: { directory: string }): string[] {
40
+ const skillFile = join(opts.directory, 'SKILL.md');
40
41
 
41
- if (!existsSync(skillFile)) {
42
- return ['SKILL.md is missing'];
43
- }
44
-
45
- const problems: string[] = [];
46
- const text = readFileSync(skillFile, 'utf8');
47
- const frontmatter = frontmatterOf({ text });
48
- const { name, description } = frontmatter.data;
49
-
50
- // One file a project cannot parse is a finding about that file - the other checks still run.
51
- if (frontmatter.error !== undefined) {
52
- problems.push(`SKILL.md: ${frontmatter.error}`);
53
- } else if (typeof name !== 'string' || !NAME_PATTERN.test(name) || RESERVED_NAME.test(name)) {
54
- problems.push(
55
- `SKILL.md: name '${String(name)}' - at most 64 characters of a-z, 0-9 and hyphens, never 'claude' or 'anthropic'`,
56
- );
57
- }
58
-
59
- if (
60
- frontmatter.error === undefined &&
61
- (typeof description !== 'string' ||
62
- description.trim().length === 0 ||
63
- description.length > MAX_DESCRIPTION ||
64
- XML_TAG.test(description))
65
- ) {
66
- problems.push('SKILL.md: the description must be 1-1024 characters with no XML tags');
67
- }
42
+ if (!existsSync(skillFile)) {
43
+ return ['SKILL.md is missing'];
44
+ }
68
45
 
69
- const body = text.slice(FRONTMATTER.exec(text)?.[0].length ?? 0);
70
- const bodyLines = lineCountOf({ text: body });
46
+ const problems: string[] = [];
47
+ const text = readFileSync(skillFile, 'utf8');
48
+ const frontmatter = SkillFrontmatter.frontmatterOf({ text });
49
+ const { name, description } = frontmatter.data;
71
50
 
72
- if (bodyLines >= MAX_BODY_LINES) {
73
- problems.push(
74
- `SKILL.md: the body is ${bodyLines} lines - keep it under ${MAX_BODY_LINES}, move detail into reference files`,
75
- );
76
- }
51
+ // One file a project cannot parse is a finding about that file - the other checks still run.
52
+ if (frontmatter.error !== undefined) {
53
+ problems.push(`SKILL.md: ${frontmatter.error}`);
54
+ } else if (typeof name !== 'string' || !NAME_PATTERN.test(name) || RESERVED_NAME.test(name)) {
55
+ problems.push(
56
+ `SKILL.md: name '${String(name)}' - at most 64 characters of a-z, 0-9 and hyphens, never 'claude' or 'anthropic'`,
57
+ );
58
+ }
77
59
 
78
- const files = filesOf({ directory: opts.directory }).sort();
79
- const shown = (path: string): string => relative(opts.directory, path);
60
+ if (
61
+ frontmatter.error === undefined &&
62
+ (typeof description !== 'string' ||
63
+ description.trim().length === 0 ||
64
+ description.length > MAX_DESCRIPTION ||
65
+ XML_TAG.test(description))
66
+ ) {
67
+ problems.push('SKILL.md: the description must be 1-1024 characters with no XML tags');
68
+ }
80
69
 
81
- for (const file of files.filter((path) => path.endsWith('.md'))) {
82
- const content = readFileSync(file, 'utf8');
83
- const count = lineCountOf({ text: content });
84
- const opening = content.split('\n').slice(0, CONTENTS_WITHIN_LINES);
70
+ const body = text.slice(FRONTMATTER.exec(text)?.[0].length ?? 0);
71
+ const bodyLines = lineCountOf({ text: body });
85
72
 
86
- if (count > CONTENTS_AFTER_LINES && !opening.some((line) => CONTENTS_MARK.test(line))) {
73
+ if (bodyLines >= MAX_BODY_LINES) {
87
74
  problems.push(
88
- `${shown(file)}: ${count} lines and no contents list in its first ${CONTENTS_WITHIN_LINES} lines - an agent may read only the first lines`,
75
+ `SKILL.md: the body is ${bodyLines} lines - keep it under ${MAX_BODY_LINES}, move detail into reference files`,
89
76
  );
90
77
  }
91
78
 
92
- if (file === skillFile) {
93
- continue;
94
- }
79
+ const files = filesOf({ directory: opts.directory }).sort();
80
+ const shown = (path: string): string => relative(opts.directory, path);
95
81
 
96
- for (const match of content.matchAll(MARKDOWN_LINK)) {
97
- const target = resolve(dirname(file), match[1]);
82
+ for (const file of files.filter((path) => path.endsWith('.md'))) {
83
+ const content = readFileSync(file, 'utf8');
84
+ const count = lineCountOf({ text: content });
85
+ const opening = content.split('\n').slice(0, CONTENTS_WITHIN_LINES);
98
86
 
99
- if (target !== skillFile && target.startsWith(`${opts.directory}/`) && existsSync(target)) {
87
+ if (count > CONTENTS_AFTER_LINES && !opening.some((line) => CONTENTS_MARK.test(line))) {
100
88
  problems.push(
101
- `${shown(file)} links ${shown(target)} - link every reference from SKILL.md, one level deep`,
89
+ `${shown(file)}: ${count} lines and no contents list in its first ${CONTENTS_WITHIN_LINES} lines - an agent may read only the first lines`,
102
90
  );
103
91
  }
104
- }
105
- }
106
92
 
107
- if (files.some((path) => SCRIPT.test(path)) && !REQUIREMENTS.test(text)) {
108
- problems.push(
109
- 'SKILL.md: the skill runs scripts and has no ## Requirements section - name what they need',
110
- );
111
- }
93
+ if (file === skillFile) {
94
+ continue;
95
+ }
112
96
 
113
- return problems;
114
- };
97
+ for (const match of content.matchAll(MARKDOWN_LINK)) {
98
+ const target = resolve(dirname(file), match[1]);
115
99
 
116
- /** The project's own skills, linted; a nested one is reported - sync links flat skills only. */
117
- export const checkSkillLint = (opts: ICheckContext): IViolation[] => {
118
- const skills = join(opts.root, '.agents', 'skills');
100
+ if (target !== skillFile && target.startsWith(`${opts.directory}/`) && existsSync(target)) {
101
+ problems.push(
102
+ `${shown(file)} links ${shown(target)} - link every reference from SKILL.md, one level deep`,
103
+ );
104
+ }
105
+ }
106
+ }
119
107
 
120
- if (!existsSync(skills)) {
121
- return [];
122
- }
108
+ if (files.some((path) => SCRIPT.test(path)) && !REQUIREMENTS.test(text)) {
109
+ problems.push(
110
+ 'SKILL.md: the skill runs scripts and has no ## Requirements section - name what they need',
111
+ );
112
+ }
123
113
 
124
- return readdirSync(skills)
125
- .filter((name) => statSync(join(skills, name)).isDirectory())
126
- .sort()
127
- .flatMap((name) => {
128
- const directory = join(skills, name);
129
- const file = `.agents/skills/${name}`;
114
+ return problems;
115
+ }
130
116
 
131
- if (!existsSync(join(directory, 'SKILL.md'))) {
132
- const inner = readdirSync(directory).find((child) =>
133
- existsSync(join(directory, child, 'SKILL.md')),
134
- );
117
+ /** The project's own skills, linted; a nested one is reported - sync links flat skills only. */
118
+ static check(opts: ICheckContext): IViolation[] {
119
+ const skills = join(opts.root, '.agents', 'skills');
135
120
 
136
- return inner === undefined
137
- ? []
138
- : [
139
- {
140
- check: DoctorChecks.SKILLS,
141
- file,
142
- message: `skills are flat - sync links .agents/skills/<name> only; move ${name}/${inner} up to .agents/skills/${inner}`,
143
- },
144
- ];
145
- }
121
+ if (!existsSync(skills)) {
122
+ return [];
123
+ }
146
124
 
147
- return lintSkill({ directory }).map((message) => ({
148
- check: DoctorChecks.SKILLS,
149
- file,
150
- message,
151
- }));
152
- });
153
- };
125
+ return readdirSync(skills)
126
+ .filter((name) => statSync(join(skills, name)).isDirectory())
127
+ .sort()
128
+ .flatMap((name) => {
129
+ const directory = join(skills, name);
130
+ const file = `.agents/skills/${name}`;
131
+
132
+ if (!existsSync(join(directory, 'SKILL.md'))) {
133
+ const inner = readdirSync(directory).find((child) =>
134
+ existsSync(join(directory, child, 'SKILL.md')),
135
+ );
136
+
137
+ return inner === undefined
138
+ ? []
139
+ : [
140
+ {
141
+ check: DoctorChecks.SKILLS,
142
+ file,
143
+ message: `skills are flat - sync links .agents/skills/<name> only; move ${name}/${inner} up to .agents/skills/${inner}`,
144
+ },
145
+ ];
146
+ }
147
+
148
+ return SkillLint.lint({ directory }).map((message) => ({
149
+ check: DoctorChecks.SKILLS,
150
+ file,
151
+ message,
152
+ }));
153
+ });
154
+ }
155
+ }
@@ -1,6 +1,6 @@
1
1
  import { spawnSync } from 'node:child_process';
2
2
  import { TextValue } from '../common/text.ts';
3
- import { resolvePackages } from '../config/index.ts';
3
+ import { ProjectPackages } from '../config/index.ts';
4
4
  import type { ICheckContext } from './checks.ts';
5
5
  import { DoctorChecks } from './common/index.ts';
6
6
  import type { IViolation } from './common/index.ts';
@@ -33,45 +33,50 @@ const tagPatternOf = (opts: { template: string }): RegExp =>
33
33
  .join('')}$`,
34
34
  );
35
35
 
36
- /**
37
- * Project Contract v1, C4: every tag `atlas.tagPattern` reads names a declared package - by
38
- * directory or alias, retired ones included - because atlas computes releases from the tags. A tag
39
- * of an old layout is ignored through `atlas.ignoreTags`. A repo-level pattern (no `<dir>`) has
40
- * nothing to check; a directory that is not a git repository has no tags.
41
- */
42
- export const checkTags = (opts: ICheckContext): IViolation[] => {
43
- const template = opts.config.atlas.tagPattern;
36
+ export class TagCheck {
37
+ /**
38
+ * Project Contract v1, C4: every tag `atlas.tagPattern` reads names a declared package - by
39
+ * directory or alias, retired ones included - because atlas computes releases from the tags. A tag
40
+ * of an old layout is ignored through `atlas.ignoreTags`. A repo-level pattern (no `<dir>`) has
41
+ * nothing to check; a directory that is not a git repository has no tags.
42
+ */
43
+ static check(opts: ICheckContext): IViolation[] {
44
+ const template = opts.config.atlas.tagPattern;
44
45
 
45
- if (!/<(?:dir|package)>/.test(template)) {
46
- return [];
47
- }
46
+ if (!/<(?:dir|package)>/.test(template)) {
47
+ return [];
48
+ }
48
49
 
49
- const listed = spawnSync('git', ['tag', '--list'], { cwd: opts.root, encoding: 'utf8' });
50
+ const listed = spawnSync('git', ['tag', '--list'], { cwd: opts.root, encoding: 'utf8' });
50
51
 
51
- if (listed.status !== 0) {
52
- return [];
53
- }
52
+ if (listed.status !== 0) {
53
+ return [];
54
+ }
54
55
 
55
- const pattern = tagPatternOf({ template });
56
- const ignored = (opts.config.atlas.ignoreTags ?? []).map((glob) => new Bun.Glob(glob));
57
- const names = new Set(
58
- resolvePackages({ config: opts.config }).flatMap((entry) => [entry.dir, ...entry.aliases]),
59
- );
56
+ const pattern = tagPatternOf({ template });
57
+ const ignored = (opts.config.atlas.ignoreTags ?? []).map((glob) => new Bun.Glob(glob));
58
+ const names = new Set(
59
+ ProjectPackages.resolve({ config: opts.config }).flatMap((entry) => [
60
+ entry.dir,
61
+ ...entry.aliases,
62
+ ]),
63
+ );
60
64
 
61
- return listed.stdout
62
- .split('\n')
63
- .filter((tag) => tag.length > 0 && !ignored.some((glob) => glob.match(tag)))
64
- .flatMap((tag) => {
65
- const dir = pattern.exec(tag)?.groups?.dir;
65
+ return listed.stdout
66
+ .split('\n')
67
+ .filter((tag) => tag.length > 0 && !ignored.some((glob) => glob.match(tag)))
68
+ .flatMap((tag) => {
69
+ const dir = pattern.exec(tag)?.groups?.dir;
66
70
 
67
- return dir === undefined || names.has(dir)
68
- ? []
69
- : [
70
- {
71
- check: DoctorChecks.TAGS,
72
- file: 'git tags',
73
- message: `tag ${tag} reads as a release of '${dir}', which no package declares - declare it (retired: true if it is gone), add it as an alias, or ignore the tag (atlas.ignoreTags)`,
74
- },
75
- ];
76
- });
77
- };
71
+ return dir === undefined || names.has(dir)
72
+ ? []
73
+ : [
74
+ {
75
+ check: DoctorChecks.TAGS,
76
+ file: 'git tags',
77
+ message: `tag ${tag} reads as a release of '${dir}', which no package declares - declare it (retired: true if it is gone), add it as an alias, or ignore the tag (atlas.ignoreTags)`,
78
+ },
79
+ ];
80
+ });
81
+ }
82
+ }
@@ -23,25 +23,28 @@ interface IPatchedFile {
23
23
  const HEADER = /^\*\*\* (Add|Update|Delete) File: (.+)$/;
24
24
  const MOVE = /^\*\*\* Move to: (.+)$/;
25
25
 
26
- /**
27
- * The files an `apply_patch` touches, from the patch text Codex sends as `tool_input.command`: the
28
- * `*** Add File:`, `*** Update File:`, `*** Delete File:` and `*** Move to:` lines, made absolute against `cwd`.
29
- */
30
- export const patchedFilesOf = (opts: { patch: string; cwd: string }): IPatchedFile[] =>
31
- opts.patch.split('\n').flatMap((line): IPatchedFile[] => {
32
- const header = HEADER.exec(line);
33
- const target = header?.[2] ?? MOVE.exec(line)?.[1];
34
-
35
- if (target === undefined) {
36
- return [];
37
- }
38
-
39
- const path = target.trim();
40
-
41
- return [
42
- {
43
- path: isAbsolute(path) ? path : resolve(opts.cwd, path),
44
- tool: header?.[1] === 'Add' ? PatchedTools.WRITE : PatchedTools.EDIT,
45
- },
46
- ];
47
- });
26
+ export class CodexPatch {
27
+ /**
28
+ * The files an `apply_patch` touches, from the patch text Codex sends as `tool_input.command`: the
29
+ * `*** Add File:`, `*** Update File:`, `*** Delete File:` and `*** Move to:` lines, made absolute against `cwd`.
30
+ */
31
+ static patchedFilesOf(opts: { patch: string; cwd: string }): IPatchedFile[] {
32
+ return opts.patch.split('\n').flatMap((line): IPatchedFile[] => {
33
+ const header = HEADER.exec(line);
34
+ const target = header?.[2] ?? MOVE.exec(line)?.[1];
35
+
36
+ if (target === undefined) {
37
+ return [];
38
+ }
39
+
40
+ const path = target.trim();
41
+
42
+ return [
43
+ {
44
+ path: isAbsolute(path) ? path : resolve(opts.cwd, path),
45
+ tool: header?.[1] === 'Add' ? PatchedTools.WRITE : PatchedTools.EDIT,
46
+ },
47
+ ];
48
+ });
49
+ }
50
+ }