@litfamily/litgrok 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,83 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
4
- import { basename, join, resolve } from 'node:path';
5
-
6
- const PACKAGE_ARGUMENT_SKILLS = new Set([
7
- 'lit-burnoff-file', 'autoconference', 'autoresearch', 'browser-drive', 'comment-checker',
8
- 'debugging', 'deep-interview', 'frontend-ui-ux', 'lit-commit', 'lit-crucible', 'lit-init',
9
- 'lit-comprehend', 'lit-plan', 'lit-scientific-visualization', 'litgoal', 'litresearch',
10
- 'litwork', 'refactor', 'lit-burnoff', 'review-work', 'start-work', 'structural-search',
11
- 'lit-korean', 'visual-qa', 'wikify',
12
- ]);
13
-
14
- function fail(code, message) {
15
- process.stderr.write(`FAIL ${code}: ${message}\n`);
16
- process.exit(1);
17
- }
18
-
19
- function isDirectory(path) {
20
- return existsSync(path) && statSync(path).isDirectory();
21
- }
22
-
23
- function isFile(path) {
24
- return existsSync(path) && statSync(path).isFile();
25
- }
26
-
27
- function scalar(value) {
28
- const quoted = value.match(/^(['"])(.*)\1$/);
29
- return quoted ? quoted[2] : value;
30
- }
31
-
32
- function frontmatter(content, skill) {
33
- const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);
34
- if (!match) fail('INVALID_FRONTMATTER', `${skill} missing opening YAML frontmatter`);
35
- const fields = new Map();
36
- for (const [index, line] of match[1].split(/\r?\n/).entries()) {
37
- if (!line.trim() || /^\s/.test(line)) continue;
38
- const field = line.match(/^([A-Za-z][A-Za-z0-9_-]*):\s*(.*?)\s*$/);
39
- if (!field) fail('INVALID_FRONTMATTER', `${skill} line ${index + 2} is not a supported top-level field`);
40
- fields.set(field[1], field[2]);
41
- }
42
- return { fields, end: match[0].length };
43
- }
44
-
45
- const input = process.argv[2] ?? join(process.cwd(), '.grok', 'skills');
46
- if (process.argv.length > 3) fail('USAGE', 'validate-skills.mjs [skills-directory]');
47
- const root = resolve(input);
48
- if (!isDirectory(root)) fail('SKILLS_DIRECTORY_NOT_FOUND', root);
49
-
50
- const directories = readdirSync(root, { withFileTypes: true })
51
- .filter((entry) => entry.isDirectory())
52
- .sort((left, right) => left.name.localeCompare(right.name));
53
- if (directories.length === 0) fail('NO_SKILLS', root);
54
-
55
- for (const directory of directories) {
56
- const skill = directory.name;
57
- const path = join(root, skill, 'SKILL.md');
58
- if (!isFile(path)) fail('SKILL_FILE_MISSING', skill);
59
- const content = readFileSync(path, 'utf8');
60
- const parsed = frontmatter(content, skill);
61
- const name = scalar(parsed.fields.get('name') ?? '');
62
- const description = scalar(parsed.fields.get('description') ?? '').trim();
63
-
64
- if (!name) fail('REQUIRED_FIELD_MISSING', `${skill} name`);
65
- if (name !== basename(join(root, skill))) fail('NAME_MISMATCH', `${skill} declares ${name}`);
66
- if (!description) fail('REQUIRED_FIELD_MISSING', `${skill} description`);
67
- if (parsed.fields.get('user-invocable') !== 'true') {
68
- fail('INVALID_FRONTMATTER', `${skill} user-invocable must be literal true`);
69
- }
70
-
71
- const body = content.slice(parsed.end);
72
- const preamble = body.split(/^## /m)[0];
73
- const argument = preamble.match(/<([A-Za-z][A-Za-z0-9 _-]*)>/)?.[0];
74
- const argumentHint = scalar(parsed.fields.get('argument-hint') ?? '').trim();
75
- if (PACKAGE_ARGUMENT_SKILLS.has(skill) && !argumentHint) {
76
- fail('ARGUMENT_HINT_MISSING', `${skill} package contract requires argument-hint`);
77
- }
78
- if (argument && !argumentHint) {
79
- fail('ARGUMENT_HINT_MISSING', `${skill} preamble declares ${argument}`);
80
- }
81
- }
82
-
83
- process.stdout.write(`PASS skills=${directories.length}\n`);