@zgeoff/chex 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/package.json +2 -2
- package/src/docs/check-links.sh +3 -2
- package/src/docs/check-skill.sh +23 -8
package/README.md
CHANGED
|
@@ -75,8 +75,8 @@ skipped file back:
|
|
|
75
75
|
under `.agents/skills/`, `.claude/skills/`, `skills/` and `sync/skills/`, which hold the banned
|
|
76
76
|
patterns as examples.
|
|
77
77
|
- `links` skips `project-docs-writing` under `.agents/skills/` and `.claude/skills/`, and
|
|
78
|
-
`docs-writing` and `skill-writing` under `.claude/skills/` and `sync/skills/`,
|
|
79
|
-
placeholder targets as examples.
|
|
78
|
+
`docs-writing` and `skill-writing` under `.agents/skills/`, `.claude/skills/` and `sync/skills/`,
|
|
79
|
+
which link to placeholder targets as examples.
|
|
80
80
|
- `prose`, `links`, `readmes` and `skill` skip each file that `.gitattributes` marks
|
|
81
81
|
`linguist-vendored`.
|
|
82
82
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zgeoff/chex",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Run each shared docs and repo check as one subcommand, with the lefthook pre-push baseline that calls them",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"checks",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/bun": "1.4.4",
|
|
44
|
-
"@zgeoff/rig": "0.1.
|
|
44
|
+
"@zgeoff/rig": "0.1.5",
|
|
45
45
|
"@zgeoff/std": "0.4.2",
|
|
46
46
|
"@zgeoff/testing": "0.2.1",
|
|
47
47
|
"tiny-invariant": "1.3.3",
|
package/src/docs/check-links.sh
CHANGED
|
@@ -22,10 +22,11 @@ if [ "$#" -eq 0 ]; then
|
|
|
22
22
|
fi
|
|
23
23
|
|
|
24
24
|
# The repo's project-docs-writing skill links to placeholder targets as examples, and so do the
|
|
25
|
-
# docs-writing and skill-writing
|
|
25
|
+
# shared docs-writing and skill-writing skills, which a repo installs under .agents/skills/ or
|
|
26
26
|
# .claude/skills/. A file git marks linguist-vendored belongs to someone else.
|
|
27
27
|
set -- "$@" ':(exclude).agents/skills/project-docs-writing' \
|
|
28
|
-
':(exclude).claude/skills/project-docs-writing' ':(exclude).
|
|
28
|
+
':(exclude).claude/skills/project-docs-writing' ':(exclude).agents/skills/docs-writing' \
|
|
29
|
+
':(exclude).agents/skills/skill-writing' ':(exclude).claude/skills/docs-writing' \
|
|
29
30
|
':(exclude).claude/skills/skill-writing' ':(exclude)sync/skills/docs-writing' \
|
|
30
31
|
':(exclude)sync/skills/skill-writing' ':(exclude,attr:linguist-vendored)' \
|
|
31
32
|
':(exclude,attr:linguist-vendored=true)'
|
package/src/docs/check-skill.sh
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
# .gitattributes.
|
|
9
9
|
# Fails on: a missing name or description, a name that differs from the folder or breaks the name
|
|
10
10
|
# format, a description over 1,024 characters, a plain description that holds a colon YAML reads as a
|
|
11
|
-
# key, frontmatter that Bun.YAML.parse refuses, a link with a line anchor outside code, and a SKILL.md body over 1,700 words.
|
|
11
|
+
# key, frontmatter that Bun.YAML.parse refuses (at the line it fails on), a link with a line anchor outside code, and a SKILL.md body over 1,700 words.
|
|
12
12
|
# Warns on: a SKILL.md body over 1,500 words, a SKILL.md over 500
|
|
13
13
|
# lines, a reference that SKILL.md does not list under ## References, a reference over 100 lines
|
|
14
14
|
# with two or more headings and no contents list near its top, a code-formatted span outside a table that names an existing repo file, and a bullet in
|
|
@@ -338,16 +338,30 @@ sub check_frontmatter {
|
|
|
338
338
|
if $colon;
|
|
339
339
|
|
|
340
340
|
# The colon error already names the cause of the parse error that the colon brings.
|
|
341
|
-
my $yaml_error = $colon ?
|
|
342
|
-
|
|
341
|
+
my ($yaml_line, $yaml_error) = $colon ? () : read_yaml_error(join("\n", @block));
|
|
342
|
+
# The block starts on the line after the opening ---.
|
|
343
|
+
my $where = defined $yaml_line ? "$skill:" . ($yaml_line + 1) : $skill;
|
|
344
|
+
fail($where, "frontmatter is not valid YAML ($yaml_error), so a strict loader refuses the skill; escape each quote inside a quoted value, or write the value as a block scalar (>-)")
|
|
343
345
|
if defined $yaml_error;
|
|
344
346
|
}
|
|
345
347
|
|
|
346
|
-
# Returns the
|
|
347
|
-
#
|
|
348
|
+
# Returns the line that Bun.YAML.parse fails on and its error, or an empty list when it parses.
|
|
349
|
+
# The error of Bun holds no line. A head cut inside a valid quoted value fails with another error,
|
|
350
|
+
# so the line is the first one from which each head fails with the error that the whole text gives.
|
|
348
351
|
sub read_yaml_error {
|
|
349
352
|
my ($text) = @_;
|
|
350
|
-
my $parse = q{
|
|
353
|
+
my $parse = q{
|
|
354
|
+
const lines = process.argv.at(-1).split("\n");
|
|
355
|
+
const readError = (count) => {
|
|
356
|
+
try { Bun.YAML.parse(lines.slice(0, count).join("\n")); return null } catch (error) { return error.message }
|
|
357
|
+
};
|
|
358
|
+
const message = readError(lines.length);
|
|
359
|
+
if (message === null) process.exit(0);
|
|
360
|
+
let line = lines.length;
|
|
361
|
+
while (line > 1 && readError(line - 1) === message) line--;
|
|
362
|
+
console.log(`${line}\t${message}`);
|
|
363
|
+
process.exit(1);
|
|
364
|
+
};
|
|
351
365
|
my $parser;
|
|
352
366
|
# The check prints its own message when bun is missing, in place of the warning perl adds.
|
|
353
367
|
no warnings "exec";
|
|
@@ -357,11 +371,12 @@ sub read_yaml_error {
|
|
|
357
371
|
}
|
|
358
372
|
my $output = do { local $/; <$parser> } // "";
|
|
359
373
|
close $parser;
|
|
360
|
-
return
|
|
374
|
+
return () if $? == 0;
|
|
361
375
|
utf8::decode($output);
|
|
362
376
|
$output =~ s/\s+\z//;
|
|
363
377
|
$output =~ s/\s*\n\s*/ /g;
|
|
364
|
-
return $
|
|
378
|
+
return ($1, $2) if $output =~ /\A([0-9]+)\t(.+)\z/;
|
|
379
|
+
return (undef, $output eq "" ? "bun exited with status " . ($? >> 8) : $output);
|
|
365
380
|
}
|
|
366
381
|
|
|
367
382
|
# Returns block, quoted or plain for the text after a key, or undef when the text is empty or only a
|