add-skill-kit 3.2.7 → 3.2.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.
@@ -1,70 +1,70 @@
1
- /**
2
- * @fileoverview Analyze command - Skill structure analysis
3
- */
4
-
5
- import fs from "fs";
6
- import path from "path";
7
- import { resolveScope, getDirSize } from "../helpers.js";
8
- import { parseSkillMdFrontmatter, detectSkillStructure } from "../skills.js";
9
- import { step, stepLine, S, c, fatal } from "../ui.js";
10
-
11
- /**
12
- * Analyze skill structure
13
- * @param {string} skillName - Skill to analyze
14
- */
15
- export async function run(skillName) {
16
- if (!skillName) fatal("Missing skill name");
17
-
18
- const scope = resolveScope();
19
- const skillDir = path.join(scope, skillName);
20
-
21
- if (!fs.existsSync(skillDir)) fatal(`Skill not found: ${skillName}`);
22
-
23
- stepLine();
24
- step(c.bold(`Skill Analysis: ${skillName}`), S.diamondFilled, "cyan");
25
- console.log(`${c.gray(S.branch)} ${c.dim("Path: " + skillDir)}`);
26
- stepLine();
27
-
28
- // SKILL.md frontmatter
29
- const smp = path.join(skillDir, "SKILL.md");
30
- if (fs.existsSync(smp)) {
31
- const m = parseSkillMdFrontmatter(smp);
32
- console.log(`${c.gray(S.branch)} ${c.cyan("SKILL.md Frontmatter:")}`);
33
- console.log(`${c.gray(S.branch)} Name: ${m.name || c.dim("(not set)")}`);
34
- console.log(`${c.gray(S.branch)} Description: ${m.description ? m.description.substring(0, 60) : c.red("(MISSING)")}`);
35
- if (m.tags) console.log(`${c.gray(S.branch)} Tags: ${m.tags.join(", ")}`);
36
- stepLine();
37
- }
38
-
39
- // Structure
40
- const structure = detectSkillStructure(skillDir);
41
- console.log(`${c.gray(S.branch)} ${c.cyan("Structure:")}`);
42
-
43
- const items = [
44
- ["resources", structure.hasResources],
45
- ["examples", structure.hasExamples],
46
- ["scripts", structure.hasScripts],
47
- ["constitution", structure.hasConstitution],
48
- ["doctrines", structure.hasDoctrines]
49
- ];
50
-
51
- items.forEach(([n, has]) => {
52
- console.log(`${c.gray(S.branch)} ${has ? c.green(S.check) : c.dim("")} ${has ? c.bold(n) : c.dim(n)}`);
53
- });
54
-
55
- stepLine();
56
-
57
- // Antigravity Score
58
- let score = 0;
59
- if (fs.existsSync(smp)) score += 20;
60
- const m = parseSkillMdFrontmatter(smp);
61
- if (m.description) score += 25;
62
- if (m.tags && m.tags.length > 0) score += 10;
63
- if (structure.hasResources || structure.hasExamples || structure.hasScripts) score += 20;
64
- if (fs.existsSync(path.join(skillDir, ".skill-source.json"))) score += 10;
65
- if (structure.hasConstitution || structure.hasDoctrines) score += 15;
66
-
67
- const scoreColor = score >= 80 ? c.green : score >= 50 ? c.yellow : c.red;
68
- console.log(`${c.gray(S.branch)} ${c.cyan("Antigravity Score:")} ${scoreColor(score + "/100")}`);
69
- stepLine();
70
- }
1
+ /**
2
+ * @fileoverview Analyze command - Skill structure analysis
3
+ */
4
+
5
+ import fs from "fs";
6
+ import path from "path";
7
+ import { resolveScope, getDirSize } from "../helpers.js";
8
+ import { parseSkillMdFrontmatter, detectSkillStructure } from "../skills.js";
9
+ import { step, stepLine, S, c, fatal } from "../ui.js";
10
+
11
+ /**
12
+ * Analyze skill structure
13
+ * @param {string} skillName - Skill to analyze
14
+ */
15
+ export async function run(skillName) {
16
+ if (!skillName) fatal("Missing skill name");
17
+
18
+ const scope = resolveScope();
19
+ const skillDir = path.join(scope, skillName);
20
+
21
+ if (!fs.existsSync(skillDir)) fatal(`Skill not found: ${skillName}`);
22
+
23
+ stepLine();
24
+ step(c.bold(`Skill Analysis: ${skillName}`), S.diamondFilled, "cyan");
25
+ console.log(`${c.gray(S.branch)} ${c.dim("Path: " + skillDir)}`);
26
+ stepLine();
27
+
28
+ // SKILL.md frontmatter
29
+ const smp = path.join(skillDir, "SKILL.md");
30
+ if (fs.existsSync(smp)) {
31
+ const m = parseSkillMdFrontmatter(smp);
32
+ console.log(`${c.gray(S.branch)} ${c.cyan("SKILL.md Frontmatter:")}`);
33
+ console.log(`${c.gray(S.branch)} Name: ${m.name || c.dim("(not set)")}`);
34
+ console.log(`${c.gray(S.branch)} Description: ${m.description ? m.description.substring(0, 60) : c.red("(MISSING)")}`);
35
+ if (m.tags) console.log(`${c.gray(S.branch)} Tags: ${m.tags.join(", ")}`);
36
+ stepLine();
37
+ }
38
+
39
+ // Structure
40
+ const structure = detectSkillStructure(skillDir);
41
+ console.log(`${c.gray(S.branch)} ${c.cyan("Structure:")}`);
42
+
43
+ const items = [
44
+ ["resources", structure.hasResources],
45
+ ["examples", structure.hasExamples],
46
+ ["scripts", structure.hasScripts],
47
+ ["constitution", structure.hasConstitution],
48
+ ["doctrines", structure.hasDoctrines]
49
+ ];
50
+
51
+ items.forEach(([n, has]) => {
52
+ console.log(`${c.gray(S.branch)} ${has ? c.green(S.check) : c.dim("â—‹")} ${has ? c.bold(n) : c.dim(n)}`);
53
+ });
54
+
55
+ stepLine();
56
+
57
+ // Antigravity Score
58
+ let score = 0;
59
+ if (fs.existsSync(smp)) score += 20;
60
+ const m = parseSkillMdFrontmatter(smp);
61
+ if (m.description) score += 25;
62
+ if (m.tags && m.tags.length > 0) score += 10;
63
+ if (structure.hasResources || structure.hasExamples || structure.hasScripts) score += 20;
64
+ if (fs.existsSync(path.join(skillDir, ".skill-source.json"))) score += 10;
65
+ if (structure.hasConstitution || structure.hasDoctrines) score += 15;
66
+
67
+ const scoreColor = score >= 80 ? c.green : score >= 50 ? c.yellow : c.red;
68
+ console.log(`${c.gray(S.branch)} ${c.cyan("Antigravity Score:")} ${scoreColor(score + "/100")}`);
69
+ stepLine();
70
+ }
@@ -1,65 +1,65 @@
1
- /**
2
- * @fileoverview Cache command
3
- */
4
-
5
- import fs from "fs";
6
- import { step, stepLine, S, c, fatal, success } from "../ui.js";
7
- import { getDirSize, formatBytes, listBackups } from "../helpers.js";
8
- import { CACHE_ROOT, REGISTRY_CACHE, BACKUP_DIR, DRY } from "../config.js";
9
-
10
- /**
11
- * Manage cache
12
- * @param {string} [sub] - Subcommand: info, clear, backups
13
- */
14
- export async function run(sub) {
15
- stepLine();
16
-
17
- if (sub === "clear") {
18
- if (DRY) {
19
- step(`Would clear: ${CACHE_ROOT}`, S.diamond);
20
- return;
21
- }
22
- if (fs.existsSync(CACHE_ROOT)) {
23
- const size = getDirSize(CACHE_ROOT);
24
- fs.rmSync(CACHE_ROOT, { recursive: true, force: true });
25
- success(`Cache cleared (${formatBytes(size)})`);
26
- } else {
27
- step("Cache already empty", S.diamond);
28
- }
29
- return;
30
- }
31
-
32
- if (sub === "info" || !sub) {
33
- if (!fs.existsSync(CACHE_ROOT)) {
34
- step("Cache is empty", S.diamond);
35
- return;
36
- }
37
-
38
- const rs = fs.existsSync(REGISTRY_CACHE) ? getDirSize(REGISTRY_CACHE) : 0;
39
- const bs = fs.existsSync(BACKUP_DIR) ? getDirSize(BACKUP_DIR) : 0;
40
-
41
- step(c.bold("Cache Info"), S.diamondFilled, "cyan");
42
- console.log(`${c.gray(S.branch)} Location: ${CACHE_ROOT}`);
43
- console.log(`${c.gray(S.branch)} Registries: ${formatBytes(rs)}`);
44
- console.log(`${c.gray(S.branch)} Backups: ${formatBytes(bs)}`);
45
- console.log(`${c.gray(S.branch)} Total: ${formatBytes(getDirSize(CACHE_ROOT))}`);
46
- stepLine();
47
- return;
48
- }
49
-
50
- if (sub === "backups") {
51
- const backups = listBackups();
52
- if (backups.length === 0) {
53
- step("No backups found", S.diamond);
54
- return;
55
- }
56
-
57
- step(c.bold("Backups"), S.diamondFilled, "cyan");
58
- stepLine();
59
- backups.forEach(b => console.log(`${c.gray(S.branch)} ${b.name} (${formatBytes(b.size)})`));
60
- stepLine();
61
- return;
62
- }
63
-
64
- fatal(`Unknown cache subcommand: ${sub}`);
65
- }
1
+ /**
2
+ * @fileoverview Cache command
3
+ */
4
+
5
+ import fs from "fs";
6
+ import { step, stepLine, S, c, fatal, success } from "../ui.js";
7
+ import { getDirSize, formatBytes, listBackups } from "../helpers.js";
8
+ import { CACHE_ROOT, REGISTRY_CACHE, BACKUP_DIR, DRY } from "../config.js";
9
+
10
+ /**
11
+ * Manage cache
12
+ * @param {string} [sub] - Subcommand: info, clear, backups
13
+ */
14
+ export async function run(sub) {
15
+ stepLine();
16
+
17
+ if (sub === "clear") {
18
+ if (DRY) {
19
+ step(`Would clear: ${CACHE_ROOT}`, S.diamond);
20
+ return;
21
+ }
22
+ if (fs.existsSync(CACHE_ROOT)) {
23
+ const size = getDirSize(CACHE_ROOT);
24
+ fs.rmSync(CACHE_ROOT, { recursive: true, force: true });
25
+ success(`Cache cleared (${formatBytes(size)})`);
26
+ } else {
27
+ step("Cache already empty", S.diamond);
28
+ }
29
+ return;
30
+ }
31
+
32
+ if (sub === "info" || !sub) {
33
+ if (!fs.existsSync(CACHE_ROOT)) {
34
+ step("Cache is empty", S.diamond);
35
+ return;
36
+ }
37
+
38
+ const rs = fs.existsSync(REGISTRY_CACHE) ? getDirSize(REGISTRY_CACHE) : 0;
39
+ const bs = fs.existsSync(BACKUP_DIR) ? getDirSize(BACKUP_DIR) : 0;
40
+
41
+ step(c.bold("Cache Info"), S.diamondFilled, "cyan");
42
+ console.log(`${c.gray(S.branch)} Location: ${CACHE_ROOT}`);
43
+ console.log(`${c.gray(S.branch)} Registries: ${formatBytes(rs)}`);
44
+ console.log(`${c.gray(S.branch)} Backups: ${formatBytes(bs)}`);
45
+ console.log(`${c.gray(S.branch)} Total: ${formatBytes(getDirSize(CACHE_ROOT))}`);
46
+ stepLine();
47
+ return;
48
+ }
49
+
50
+ if (sub === "backups") {
51
+ const backups = listBackups();
52
+ if (backups.length === 0) {
53
+ step("No backups found", S.diamond);
54
+ return;
55
+ }
56
+
57
+ step(c.bold("Backups"), S.diamondFilled, "cyan");
58
+ stepLine();
59
+ backups.forEach(b => console.log(`${c.gray(S.branch)} ${b.name} (${formatBytes(b.size)})`));
60
+ stepLine();
61
+ return;
62
+ }
63
+
64
+ fatal(`Unknown cache subcommand: ${sub}`);
65
+ }
@@ -1,75 +1,75 @@
1
- /**
2
- * @fileoverview Doctor command - Health check
3
- */
4
-
5
- import fs from "fs";
6
- import path from "path";
7
- import { resolveScope, merkleHash, loadSkillLock } from "../helpers.js";
8
- import { step, stepLine, S, c } from "../ui.js";
9
- import { STRICT, FIX, DRY, cwd } from "../config.js";
10
-
11
- /**
12
- * Run health check on installed skills
13
- */
14
- export async function run() {
15
- const scope = resolveScope();
16
-
17
- if (!fs.existsSync(scope)) {
18
- stepLine();
19
- step("No skills directory found", S.diamond);
20
- return;
21
- }
22
-
23
- stepLine();
24
- step(c.bold("Health Check"), S.diamondFilled, "cyan");
25
- stepLine();
26
-
27
- let errors = 0, warnings = 0;
28
- const lock = fs.existsSync(path.join(cwd, ".agent", "skill-lock.json")) ? loadSkillLock() : null;
29
-
30
- for (const name of fs.readdirSync(scope)) {
31
- const dir = path.join(scope, name);
32
- if (!fs.statSync(dir).isDirectory()) continue;
33
-
34
- // Check SKILL.md
35
- if (!fs.existsSync(path.join(dir, "SKILL.md"))) {
36
- step(`${name}: ${c.red("missing SKILL.md")}`, S.cross, "red");
37
- errors++;
38
- continue;
39
- }
40
-
41
- // Check metadata
42
- const mf = path.join(dir, ".skill-source.json");
43
- if (!fs.existsSync(mf)) {
44
- step(`${name}: ${c.red("missing metadata")}`, S.cross, "red");
45
- errors++;
46
- continue;
47
- }
48
-
49
- const m = JSON.parse(fs.readFileSync(mf, "utf-8"));
50
- const actual = merkleHash(dir);
51
-
52
- // Check checksum
53
- if (actual !== m.checksum) {
54
- if (FIX && !DRY) {
55
- m.checksum = actual;
56
- fs.writeFileSync(mf, JSON.stringify(m, null, 2));
57
- step(`${name}: ${c.yellow("checksum fixed")}`, S.diamond, "yellow");
58
- } else {
59
- step(`${name}: ${c.yellow("checksum drift")}`, S.diamond, "yellow");
60
- STRICT ? errors++ : warnings++;
61
- }
62
- } else if (lock && !lock.skills[name]) {
63
- step(`${name}: ${c.yellow("not in lock")}`, S.diamond, "yellow");
64
- STRICT ? errors++ : warnings++;
65
- } else {
66
- step(`${name}: ${c.green("healthy")}`, S.check, "green");
67
- }
68
- }
69
-
70
- stepLine();
71
- console.log(`${c.gray(S.branch)} Errors: ${errors}, Warnings: ${warnings}`);
72
- stepLine();
73
-
74
- if (STRICT && errors) process.exit(1);
75
- }
1
+ /**
2
+ * @fileoverview Doctor command - Health check
3
+ */
4
+
5
+ import fs from "fs";
6
+ import path from "path";
7
+ import { resolveScope, merkleHash, loadSkillLock } from "../helpers.js";
8
+ import { step, stepLine, S, c } from "../ui.js";
9
+ import { STRICT, FIX, DRY, cwd } from "../config.js";
10
+
11
+ /**
12
+ * Run health check on installed skills
13
+ */
14
+ export async function run() {
15
+ const scope = resolveScope();
16
+
17
+ if (!fs.existsSync(scope)) {
18
+ stepLine();
19
+ step("No skills directory found", S.diamond);
20
+ return;
21
+ }
22
+
23
+ stepLine();
24
+ step(c.bold("Health Check"), S.diamondFilled, "cyan");
25
+ stepLine();
26
+
27
+ let errors = 0, warnings = 0;
28
+ const lock = fs.existsSync(path.join(cwd, ".agent", "skill-lock.json")) ? loadSkillLock() : null;
29
+
30
+ for (const name of fs.readdirSync(scope)) {
31
+ const dir = path.join(scope, name);
32
+ if (!fs.statSync(dir).isDirectory()) continue;
33
+
34
+ // Check SKILL.md
35
+ if (!fs.existsSync(path.join(dir, "SKILL.md"))) {
36
+ step(`${name}: ${c.red("missing SKILL.md")}`, S.cross, "red");
37
+ errors++;
38
+ continue;
39
+ }
40
+
41
+ // Check metadata
42
+ const mf = path.join(dir, ".skill-source.json");
43
+ if (!fs.existsSync(mf)) {
44
+ step(`${name}: ${c.red("missing metadata")}`, S.cross, "red");
45
+ errors++;
46
+ continue;
47
+ }
48
+
49
+ const m = JSON.parse(fs.readFileSync(mf, "utf-8"));
50
+ const actual = merkleHash(dir);
51
+
52
+ // Check checksum
53
+ if (actual !== m.checksum) {
54
+ if (FIX && !DRY) {
55
+ m.checksum = actual;
56
+ fs.writeFileSync(mf, JSON.stringify(m, null, 2));
57
+ step(`${name}: ${c.yellow("checksum fixed")}`, S.diamond, "yellow");
58
+ } else {
59
+ step(`${name}: ${c.yellow("checksum drift")}`, S.diamond, "yellow");
60
+ STRICT ? errors++ : warnings++;
61
+ }
62
+ } else if (lock && !lock.skills[name]) {
63
+ step(`${name}: ${c.yellow("not in lock")}`, S.diamond, "yellow");
64
+ STRICT ? errors++ : warnings++;
65
+ } else {
66
+ step(`${name}: ${c.green("healthy")}`, S.check, "green");
67
+ }
68
+ }
69
+
70
+ stepLine();
71
+ console.log(`${c.gray(S.branch)} Errors: ${errors}, Warnings: ${warnings}`);
72
+ stepLine();
73
+
74
+ if (STRICT && errors) process.exit(1);
75
+ }