@ladamczyk/skillslint 4.1.2 → 4.1.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.
- package/bin/cli.js +6 -1
- package/lib/index.cjs +128 -123
- package/lib/index.mjs +102 -119
- package/lib/src/cli.d.ts +2 -0
- package/lib/src/helpers/threshold.test.d.ts +1 -0
- package/package.json +13 -20
package/bin/cli.js
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
2
|
+
import{EExitCode as e,getPackageInfo as t,getRelativePath as n,resolveCwdRelativePath as r}from"@ladamczyk/qoq-utils";import i from"cac";import{assessQuality as a,formatScoreBar as o,getScoreColor as s}from"agent-skills-cli";import c from"picocolors";import{createLinter as l,loadFixerFormatter as u,loadLinterFormatter as d,loadTextlintrc as f}from"textlint";import{writeFile as p}from"fs/promises";import{resolve as m}from"path";import{readdirSync as h}from"fs";const g=()=>{try{let{rootPath:e}=t(`@ladamczyk/skillslint`)??{};return e}catch{return process.cwd()}},_=e=>m(`${g()}${e}`),v=e=>n(_(e)),y=async(e,t)=>{let n=await f({configFilePath:v(`/.textlintrc.json`)}),r=l({descriptor:n});try{if(!t)return await r.lintFiles([e]);let n=await r.fixFiles([e]);return await Promise.all(n.map(e=>p(e.filePath,e.output,`utf-8`))),n}catch(e){if(e instanceof Error&&e.name===`TextlintFileSearchError`)return[];throw e}},b=e=>e.some(e=>(`remainingMessages`in e?e.remainingMessages:e.messages).some(e=>e.severity===2)),x=[`overall`,`structure`,`clarity`,`specificity`,`advanced`],S=async(e,t)=>t?(await u({formatterName:`stylish`})).format(e):(await d({formatterName:`stylish`})).format(e),C=async e=>{let t=``,n=await S(e.textlint,e.fixed);return n.trim()&&(t+=`${n}\n`),e.fixed&&b(e.textlint)&&(t+=c.red(`Can't perform automatic fix!
|
|
3
|
+
|
|
4
|
+
`)),e.skills.forEach(({name:e,scores:n})=>{t+=c.gray(`\n/${e}\n`),x.forEach(e=>{let r=`${e[0]?.toUpperCase()}${e.slice(1)}:`.padEnd(13),i=c[s(n[e])];t+=i(`${r}${o(n[e],25)}\n`)})}),e.skills.some(e=>!e.passed)&&(t+=c.red(`At least one skill doesn't meet required threshold!
|
|
5
|
+
`)),e.passed&&(t+=c.green(`
|
|
6
|
+
All good!
|
|
7
|
+
`)),t},w=e=>{let{threshold:t,overall:n,structure:r,clarity:i,specificity:a,advanced:o}=e,s={};return n&&(s.overall=n),r&&(s.structure=r),i&&(s.clarity=i),a&&(s.specificity=a),o&&(s.advanced=o),Object.keys(s).length===0&&(s.overall=t??70),s},T=(e,t)=>e.overall<(t.overall??0)||e.structure<(t.structure??0)||e.clarity<(t.clarity??0)||e.specificity<(t.specificity??0)||e.advanced<(t.advanced??0),E=async(e={})=>{let{fix:t=!1,path:n,ignored:i}=e,o=`/${n??`./skills`}`,s=w(e),c=r(o),l=await y(r(`${o}/**/*.md`),t),u=h(c,{withFileTypes:!0}).filter(e=>e.isDirectory()&&!(i??[]).includes(e.name)).map(({name:e})=>e),d=await Promise.all(u.map(async e=>{let{overall:t,structure:n,clarity:r,specificity:i,advanced:o}=await a(`${c}/${e}`),l={overall:t,structure:n,clarity:r,specificity:i,advanced:o};return{name:e,scores:l,passed:!T(l,s)}}));return{textlint:l,fixed:t,skills:d,passed:!b(l)&&d.every(e=>e.passed)}},D=i(`skillslint`);D.command(``,`Linter for agents skills`).option(`-p,--path <path>`,`Lint path`,{default:`./skills`}).option(`-t, --threshold <threshold>`,`Same as --overall 70, will take effect only if no other threshold options are configured`,{default:70}).option(`-f,--fix`,`Try to fix findings`).option(`-i,--ignored [ignored]`,`Ignored skills`).option(`--overall <threshold>`,`Overall required threshold`).option(`--structure <threshold>`,`Structure required threshold`).option(`--clarity <threshold>`,`Clarity required threshold`).option(`--specificity <threshold>`,`Specificity required threshold`).option(`--advanced <threshold>`,`Advanced required threshold`).action(async t=>{let n=await E(t);process.stdout.write(await C(n)),process.exit(n.passed?e.OK:e.ERROR)}),D.help(),D.parse();
|
package/lib/index.cjs
CHANGED
|
@@ -1,142 +1,147 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
24
|
+
let agent_skills_cli = require("agent-skills-cli");
|
|
25
|
+
let picocolors = require("picocolors");
|
|
26
|
+
picocolors = __toESM(picocolors, 1);
|
|
27
|
+
let textlint = require("textlint");
|
|
28
|
+
let fs_promises = require("fs/promises");
|
|
29
|
+
let path = require("path");
|
|
30
|
+
let _ladamczyk_qoq_utils = require("@ladamczyk/qoq-utils");
|
|
31
|
+
let fs = require("fs");
|
|
32
|
+
//#region src/helpers/paths.ts
|
|
33
|
+
const PACKAGE_NAME = "@ladamczyk/skillslint";
|
|
12
34
|
const getCliPackagePath = () => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return process.cwd();
|
|
20
|
-
}
|
|
35
|
+
try {
|
|
36
|
+
const { rootPath } = (0, _ladamczyk_qoq_utils.getPackageInfo)(PACKAGE_NAME) ?? {};
|
|
37
|
+
return rootPath;
|
|
38
|
+
} catch {
|
|
39
|
+
return process.cwd();
|
|
40
|
+
}
|
|
21
41
|
};
|
|
22
|
-
const resolveCliPackagePath = (path$1) => path.resolve(`${getCliPackagePath()}${path$1}`);
|
|
23
|
-
const resolveCliRelativePath = (path) =>
|
|
24
|
-
|
|
42
|
+
const resolveCliPackagePath = (path$1) => (0, path.resolve)(`${getCliPackagePath()}${path$1}`);
|
|
43
|
+
const resolveCliRelativePath = (path$2) => (0, _ladamczyk_qoq_utils.getRelativePath)(resolveCliPackagePath(path$2));
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/helpers/textlint.ts
|
|
25
46
|
const ERROR_SEVERITY = 2;
|
|
26
|
-
const NO_TARGET_FILES_ERROR =
|
|
47
|
+
const NO_TARGET_FILES_ERROR = "TextlintFileSearchError";
|
|
27
48
|
const runTextlint = async (target, fix) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return results;
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
// textlint throws when no markdown files match the glob; treat as nothing to lint.
|
|
43
|
-
if (error instanceof Error && error.name === NO_TARGET_FILES_ERROR) {
|
|
44
|
-
return [];
|
|
45
|
-
}
|
|
46
|
-
throw error;
|
|
47
|
-
}
|
|
49
|
+
const descriptor = await (0, textlint.loadTextlintrc)({ configFilePath: resolveCliRelativePath("/.textlintrc.json") });
|
|
50
|
+
const linter = (0, textlint.createLinter)({ descriptor });
|
|
51
|
+
try {
|
|
52
|
+
if (!fix) return await linter.lintFiles([target]);
|
|
53
|
+
const results = await linter.fixFiles([target]);
|
|
54
|
+
await Promise.all(results.map((result) => (0, fs_promises.writeFile)(result.filePath, result.output, "utf-8")));
|
|
55
|
+
return results;
|
|
56
|
+
} catch (error) {
|
|
57
|
+
if (error instanceof Error && error.name === NO_TARGET_FILES_ERROR) return [];
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
48
60
|
};
|
|
49
|
-
const hasTextlintErrors = (results) => results.some((result) => (
|
|
50
|
-
|
|
61
|
+
const hasTextlintErrors = (results) => results.some((result) => ("remainingMessages" in result ? result.remainingMessages : result.messages).some((message) => message.severity === ERROR_SEVERITY));
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/format.ts
|
|
51
64
|
const BAR_WIDTH = 25;
|
|
52
|
-
const DIMENSIONS = [
|
|
65
|
+
const DIMENSIONS = [
|
|
66
|
+
"overall",
|
|
67
|
+
"structure",
|
|
68
|
+
"clarity",
|
|
69
|
+
"specificity",
|
|
70
|
+
"advanced"
|
|
71
|
+
];
|
|
53
72
|
const formatTextlint = async (textlint$1, fixed) => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return formatter.format(textlint$1);
|
|
57
|
-
}
|
|
58
|
-
const formatter = await textlint.loadLinterFormatter({ formatterName: 'stylish' });
|
|
59
|
-
return formatter.format(textlint$1);
|
|
73
|
+
if (fixed) return (await (0, textlint.loadFixerFormatter)({ formatterName: "stylish" })).format(textlint$1);
|
|
74
|
+
return (await (0, textlint.loadLinterFormatter)({ formatterName: "stylish" })).format(textlint$1);
|
|
60
75
|
};
|
|
61
76
|
/**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
77
|
+
* Renders an {@link ILintResult} into a console-ready, colorized string
|
|
78
|
+
* (textlint findings, per-skill score bars and the summary verdict).
|
|
79
|
+
*/
|
|
65
80
|
const format = async (result) => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
if (result.skills.some((skill) => !skill.passed)) {
|
|
83
|
-
output += c.red(`At least one skill doesn't meet required threshold!\n`);
|
|
84
|
-
}
|
|
85
|
-
if (result.passed) {
|
|
86
|
-
output += c.green('\nAll good!\n');
|
|
87
|
-
}
|
|
88
|
-
return output;
|
|
81
|
+
let output = "";
|
|
82
|
+
const textlint$2 = await formatTextlint(result.textlint, result.fixed);
|
|
83
|
+
if (textlint$2.trim()) output += `${textlint$2}\n`;
|
|
84
|
+
if (result.fixed && hasTextlintErrors(result.textlint)) output += picocolors.default.red("Can't perform automatic fix!\n\n");
|
|
85
|
+
result.skills.forEach(({ name, scores }) => {
|
|
86
|
+
output += picocolors.default.gray(`\n/${name}\n`);
|
|
87
|
+
DIMENSIONS.forEach((dimension) => {
|
|
88
|
+
const label = `${dimension[0]?.toUpperCase()}${dimension.slice(1)}:`.padEnd(13);
|
|
89
|
+
const color = picocolors.default[(0, agent_skills_cli.getScoreColor)(scores[dimension])];
|
|
90
|
+
output += color(`${label}${(0, agent_skills_cli.formatScoreBar)(scores[dimension], BAR_WIDTH)}\n`);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
if (result.skills.some((skill) => !skill.passed)) output += picocolors.default.red(`At least one skill doesn't meet required threshold!\n`);
|
|
94
|
+
if (result.passed) output += picocolors.default.green("\nAll good!\n");
|
|
95
|
+
return output;
|
|
89
96
|
};
|
|
90
|
-
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/helpers/threshold.ts
|
|
91
99
|
const DEFAULT_THRESHOLD = 70;
|
|
92
100
|
const buildThreshold = (options) => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
threshold.clarity = clarity;
|
|
103
|
-
}
|
|
104
|
-
if (specificity) {
|
|
105
|
-
threshold.specificity = specificity;
|
|
106
|
-
}
|
|
107
|
-
if (advanced) {
|
|
108
|
-
threshold.advanced = advanced;
|
|
109
|
-
}
|
|
110
|
-
if (Object.keys(threshold).length === 0) {
|
|
111
|
-
threshold.overall = optionsThreshold ?? DEFAULT_THRESHOLD;
|
|
112
|
-
}
|
|
113
|
-
return threshold;
|
|
101
|
+
const { threshold: optionsThreshold, overall, structure, clarity, specificity, advanced } = options;
|
|
102
|
+
const threshold = {};
|
|
103
|
+
if (overall) threshold.overall = overall;
|
|
104
|
+
if (structure) threshold.structure = structure;
|
|
105
|
+
if (clarity) threshold.clarity = clarity;
|
|
106
|
+
if (specificity) threshold.specificity = specificity;
|
|
107
|
+
if (advanced) threshold.advanced = advanced;
|
|
108
|
+
if (Object.keys(threshold).length === 0) threshold.overall = optionsThreshold ?? 70;
|
|
109
|
+
return threshold;
|
|
114
110
|
};
|
|
115
|
-
const failsThreshold = (scores, threshold) => scores.overall < (threshold.overall ?? 0) ||
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
scores.advanced < (threshold.advanced ?? 0);
|
|
120
|
-
|
|
121
|
-
const DEFAULT_PATH = './skills';
|
|
111
|
+
const failsThreshold = (scores, threshold) => scores.overall < (threshold.overall ?? 0) || scores.structure < (threshold.structure ?? 0) || scores.clarity < (threshold.clarity ?? 0) || scores.specificity < (threshold.specificity ?? 0) || scores.advanced < (threshold.advanced ?? 0);
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/lint.ts
|
|
114
|
+
const DEFAULT_PATH = "./skills";
|
|
122
115
|
const lint = async (options = {}) => {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
116
|
+
const { fix = false, path: optionsPath, ignored } = options;
|
|
117
|
+
const path = `/${optionsPath ?? "./skills"}`;
|
|
118
|
+
const threshold = buildThreshold(options);
|
|
119
|
+
const skillsPath = (0, _ladamczyk_qoq_utils.resolveCwdRelativePath)(path);
|
|
120
|
+
const textlint = await runTextlint((0, _ladamczyk_qoq_utils.resolveCwdRelativePath)(`${path}/**/*.md`), fix);
|
|
121
|
+
const skillNames = (0, fs.readdirSync)(skillsPath, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !(ignored ?? []).includes(entry.name)).map(({ name }) => name);
|
|
122
|
+
const skills = await Promise.all(skillNames.map(async (name) => {
|
|
123
|
+
const { overall, structure, clarity, specificity, advanced } = await (0, agent_skills_cli.assessQuality)(`${skillsPath}/${name}`);
|
|
124
|
+
const scores = {
|
|
125
|
+
overall,
|
|
126
|
+
structure,
|
|
127
|
+
clarity,
|
|
128
|
+
specificity,
|
|
129
|
+
advanced
|
|
130
|
+
};
|
|
131
|
+
return {
|
|
132
|
+
name,
|
|
133
|
+
scores,
|
|
134
|
+
passed: !failsThreshold(scores, threshold)
|
|
135
|
+
};
|
|
136
|
+
}));
|
|
137
|
+
return {
|
|
138
|
+
textlint,
|
|
139
|
+
fixed: fix,
|
|
140
|
+
skills,
|
|
141
|
+
passed: !hasTextlintErrors(textlint) && skills.every((skill) => skill.passed)
|
|
142
|
+
};
|
|
138
143
|
};
|
|
139
|
-
|
|
144
|
+
//#endregion
|
|
140
145
|
exports.DEFAULT_PATH = DEFAULT_PATH;
|
|
141
146
|
exports.DEFAULT_THRESHOLD = DEFAULT_THRESHOLD;
|
|
142
147
|
exports.buildThreshold = buildThreshold;
|
package/lib/index.mjs
CHANGED
|
@@ -1,138 +1,121 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import c from
|
|
3
|
-
import {
|
|
4
|
-
import { writeFile } from
|
|
5
|
-
import { resolve } from
|
|
6
|
-
import {
|
|
7
|
-
import { readdirSync } from
|
|
8
|
-
|
|
9
|
-
const PACKAGE_NAME =
|
|
1
|
+
import { assessQuality, formatScoreBar, getScoreColor } from "agent-skills-cli";
|
|
2
|
+
import c from "picocolors";
|
|
3
|
+
import { createLinter, loadFixerFormatter, loadLinterFormatter, loadTextlintrc } from "textlint";
|
|
4
|
+
import { writeFile } from "fs/promises";
|
|
5
|
+
import { resolve } from "path";
|
|
6
|
+
import { getPackageInfo, getRelativePath, resolveCwdRelativePath } from "@ladamczyk/qoq-utils";
|
|
7
|
+
import { readdirSync } from "fs";
|
|
8
|
+
//#region src/helpers/paths.ts
|
|
9
|
+
const PACKAGE_NAME = "@ladamczyk/skillslint";
|
|
10
10
|
const getCliPackagePath = () => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return process.cwd();
|
|
18
|
-
}
|
|
11
|
+
try {
|
|
12
|
+
const { rootPath } = getPackageInfo(PACKAGE_NAME) ?? {};
|
|
13
|
+
return rootPath;
|
|
14
|
+
} catch {
|
|
15
|
+
return process.cwd();
|
|
16
|
+
}
|
|
19
17
|
};
|
|
20
18
|
const resolveCliPackagePath = (path) => resolve(`${getCliPackagePath()}${path}`);
|
|
21
19
|
const resolveCliRelativePath = (path) => getRelativePath(resolveCliPackagePath(path));
|
|
22
|
-
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/helpers/textlint.ts
|
|
23
22
|
const ERROR_SEVERITY = 2;
|
|
24
|
-
const NO_TARGET_FILES_ERROR =
|
|
23
|
+
const NO_TARGET_FILES_ERROR = "TextlintFileSearchError";
|
|
25
24
|
const runTextlint = async (target, fix) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return results;
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
// textlint throws when no markdown files match the glob; treat as nothing to lint.
|
|
41
|
-
if (error instanceof Error && error.name === NO_TARGET_FILES_ERROR) {
|
|
42
|
-
return [];
|
|
43
|
-
}
|
|
44
|
-
throw error;
|
|
45
|
-
}
|
|
25
|
+
const descriptor = await loadTextlintrc({ configFilePath: resolveCliRelativePath("/.textlintrc.json") });
|
|
26
|
+
const linter = createLinter({ descriptor });
|
|
27
|
+
try {
|
|
28
|
+
if (!fix) return await linter.lintFiles([target]);
|
|
29
|
+
const results = await linter.fixFiles([target]);
|
|
30
|
+
await Promise.all(results.map((result) => writeFile(result.filePath, result.output, "utf-8")));
|
|
31
|
+
return results;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
if (error instanceof Error && error.name === NO_TARGET_FILES_ERROR) return [];
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
46
36
|
};
|
|
47
|
-
const hasTextlintErrors = (results) => results.some((result) => (
|
|
48
|
-
|
|
37
|
+
const hasTextlintErrors = (results) => results.some((result) => ("remainingMessages" in result ? result.remainingMessages : result.messages).some((message) => message.severity === ERROR_SEVERITY));
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/format.ts
|
|
49
40
|
const BAR_WIDTH = 25;
|
|
50
|
-
const DIMENSIONS = [
|
|
41
|
+
const DIMENSIONS = [
|
|
42
|
+
"overall",
|
|
43
|
+
"structure",
|
|
44
|
+
"clarity",
|
|
45
|
+
"specificity",
|
|
46
|
+
"advanced"
|
|
47
|
+
];
|
|
51
48
|
const formatTextlint = async (textlint, fixed) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return formatter.format(textlint);
|
|
55
|
-
}
|
|
56
|
-
const formatter = await loadLinterFormatter({ formatterName: 'stylish' });
|
|
57
|
-
return formatter.format(textlint);
|
|
49
|
+
if (fixed) return (await loadFixerFormatter({ formatterName: "stylish" })).format(textlint);
|
|
50
|
+
return (await loadLinterFormatter({ formatterName: "stylish" })).format(textlint);
|
|
58
51
|
};
|
|
59
52
|
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
* Renders an {@link ILintResult} into a console-ready, colorized string
|
|
54
|
+
* (textlint findings, per-skill score bars and the summary verdict).
|
|
55
|
+
*/
|
|
63
56
|
const format = async (result) => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
});
|
|
80
|
-
if (result.skills.some((skill) => !skill.passed)) {
|
|
81
|
-
output += c.red(`At least one skill doesn't meet required threshold!\n`);
|
|
82
|
-
}
|
|
83
|
-
if (result.passed) {
|
|
84
|
-
output += c.green('\nAll good!\n');
|
|
85
|
-
}
|
|
86
|
-
return output;
|
|
57
|
+
let output = "";
|
|
58
|
+
const textlint = await formatTextlint(result.textlint, result.fixed);
|
|
59
|
+
if (textlint.trim()) output += `${textlint}\n`;
|
|
60
|
+
if (result.fixed && hasTextlintErrors(result.textlint)) output += c.red("Can't perform automatic fix!\n\n");
|
|
61
|
+
result.skills.forEach(({ name, scores }) => {
|
|
62
|
+
output += c.gray(`\n/${name}\n`);
|
|
63
|
+
DIMENSIONS.forEach((dimension) => {
|
|
64
|
+
const label = `${dimension[0]?.toUpperCase()}${dimension.slice(1)}:`.padEnd(13);
|
|
65
|
+
const color = c[getScoreColor(scores[dimension])];
|
|
66
|
+
output += color(`${label}${formatScoreBar(scores[dimension], BAR_WIDTH)}\n`);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
if (result.skills.some((skill) => !skill.passed)) output += c.red(`At least one skill doesn't meet required threshold!\n`);
|
|
70
|
+
if (result.passed) output += c.green("\nAll good!\n");
|
|
71
|
+
return output;
|
|
87
72
|
};
|
|
88
|
-
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/helpers/threshold.ts
|
|
89
75
|
const DEFAULT_THRESHOLD = 70;
|
|
90
76
|
const buildThreshold = (options) => {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
threshold.clarity = clarity;
|
|
101
|
-
}
|
|
102
|
-
if (specificity) {
|
|
103
|
-
threshold.specificity = specificity;
|
|
104
|
-
}
|
|
105
|
-
if (advanced) {
|
|
106
|
-
threshold.advanced = advanced;
|
|
107
|
-
}
|
|
108
|
-
if (Object.keys(threshold).length === 0) {
|
|
109
|
-
threshold.overall = optionsThreshold ?? DEFAULT_THRESHOLD;
|
|
110
|
-
}
|
|
111
|
-
return threshold;
|
|
77
|
+
const { threshold: optionsThreshold, overall, structure, clarity, specificity, advanced } = options;
|
|
78
|
+
const threshold = {};
|
|
79
|
+
if (overall) threshold.overall = overall;
|
|
80
|
+
if (structure) threshold.structure = structure;
|
|
81
|
+
if (clarity) threshold.clarity = clarity;
|
|
82
|
+
if (specificity) threshold.specificity = specificity;
|
|
83
|
+
if (advanced) threshold.advanced = advanced;
|
|
84
|
+
if (Object.keys(threshold).length === 0) threshold.overall = optionsThreshold ?? 70;
|
|
85
|
+
return threshold;
|
|
112
86
|
};
|
|
113
|
-
const failsThreshold = (scores, threshold) => scores.overall < (threshold.overall ?? 0) ||
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
scores.advanced < (threshold.advanced ?? 0);
|
|
118
|
-
|
|
119
|
-
const DEFAULT_PATH = './skills';
|
|
87
|
+
const failsThreshold = (scores, threshold) => scores.overall < (threshold.overall ?? 0) || scores.structure < (threshold.structure ?? 0) || scores.clarity < (threshold.clarity ?? 0) || scores.specificity < (threshold.specificity ?? 0) || scores.advanced < (threshold.advanced ?? 0);
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/lint.ts
|
|
90
|
+
const DEFAULT_PATH = "./skills";
|
|
120
91
|
const lint = async (options = {}) => {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
92
|
+
const { fix = false, path: optionsPath, ignored } = options;
|
|
93
|
+
const path = `/${optionsPath ?? "./skills"}`;
|
|
94
|
+
const threshold = buildThreshold(options);
|
|
95
|
+
const skillsPath = resolveCwdRelativePath(path);
|
|
96
|
+
const textlint = await runTextlint(resolveCwdRelativePath(`${path}/**/*.md`), fix);
|
|
97
|
+
const skillNames = readdirSync(skillsPath, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !(ignored ?? []).includes(entry.name)).map(({ name }) => name);
|
|
98
|
+
const skills = await Promise.all(skillNames.map(async (name) => {
|
|
99
|
+
const { overall, structure, clarity, specificity, advanced } = await assessQuality(`${skillsPath}/${name}`);
|
|
100
|
+
const scores = {
|
|
101
|
+
overall,
|
|
102
|
+
structure,
|
|
103
|
+
clarity,
|
|
104
|
+
specificity,
|
|
105
|
+
advanced
|
|
106
|
+
};
|
|
107
|
+
return {
|
|
108
|
+
name,
|
|
109
|
+
scores,
|
|
110
|
+
passed: !failsThreshold(scores, threshold)
|
|
111
|
+
};
|
|
112
|
+
}));
|
|
113
|
+
return {
|
|
114
|
+
textlint,
|
|
115
|
+
fixed: fix,
|
|
116
|
+
skills,
|
|
117
|
+
passed: !hasTextlintErrors(textlint) && skills.every((skill) => skill.passed)
|
|
118
|
+
};
|
|
136
119
|
};
|
|
137
|
-
|
|
120
|
+
//#endregion
|
|
138
121
|
export { DEFAULT_PATH, DEFAULT_THRESHOLD, buildThreshold, failsThreshold, format, hasTextlintErrors, lint, runTextlint };
|
package/lib/src/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ladamczyk/skillslint",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.3",
|
|
4
4
|
"description": "Linter for agents skills",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"AGENTS.md"
|
|
40
40
|
],
|
|
41
41
|
"scripts": {
|
|
42
|
-
"build": "rimraf ./bin ./lib &&
|
|
42
|
+
"build": "rimraf ./bin ./lib && rolldown -c && tsc --emitDeclarationOnly && chmod +x ./bin/cli.js",
|
|
43
43
|
"dev": "npm run build && node ./bin/cli.js",
|
|
44
44
|
"husky:pre-push": "run-s qoq:check test build",
|
|
45
45
|
"prepare": "husky",
|
|
@@ -52,39 +52,32 @@
|
|
|
52
52
|
"test:coverage": "npm run test -- --coverage"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@ladamczyk/qoq-utils": "5.
|
|
56
|
-
"@textlint/textlint-plugin-markdown": "15.
|
|
57
|
-
"@textlint/textlint-plugin-text": "15.
|
|
55
|
+
"@ladamczyk/qoq-utils": "5.3.1",
|
|
56
|
+
"@textlint/textlint-plugin-markdown": "15.8.0",
|
|
57
|
+
"@textlint/textlint-plugin-text": "15.8.0",
|
|
58
58
|
"agent-skills-cli": "1.1.9",
|
|
59
59
|
"cac": "7.0.0",
|
|
60
60
|
"picocolors": "1.1.1",
|
|
61
|
-
"textlint": "15.
|
|
61
|
+
"textlint": "15.8.0",
|
|
62
62
|
"textlint-rule-common-misspellings": "1.0.1",
|
|
63
63
|
"textlint-rule-terminology": "5.2.16",
|
|
64
64
|
"textlint-rule-write-good": "2.0.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@commitlint/cli": "21.2.
|
|
67
|
+
"@commitlint/cli": "21.2.1",
|
|
68
68
|
"@commitlint/config-conventional": "21.2.0",
|
|
69
|
-
"@ladamczyk/qoq-cli": "5.
|
|
70
|
-
"@ladamczyk/qoq-eslint-v9-ts": "5.
|
|
71
|
-
"@ladamczyk/qoq-jscpd": "5.
|
|
72
|
-
"@ladamczyk/qoq-knip": "5.
|
|
73
|
-
"@ladamczyk/qoq-prettier-with-json-sort": "5.
|
|
74
|
-
"@rollup/plugin-commonjs": "29.0.3",
|
|
75
|
-
"@rollup/plugin-json": "6.1.0",
|
|
76
|
-
"@rollup/plugin-node-resolve": "16.0.3",
|
|
77
|
-
"@rollup/plugin-terser": "1.0.0",
|
|
78
|
-
"@rollup/plugin-typescript": "12.3.0",
|
|
69
|
+
"@ladamczyk/qoq-cli": "5.3.1",
|
|
70
|
+
"@ladamczyk/qoq-eslint-v9-ts": "5.3.1",
|
|
71
|
+
"@ladamczyk/qoq-jscpd": "5.3.1",
|
|
72
|
+
"@ladamczyk/qoq-knip": "5.3.1",
|
|
73
|
+
"@ladamczyk/qoq-prettier-with-json-sort": "5.3.1",
|
|
79
74
|
"@types/node": "^22",
|
|
80
75
|
"@vitest/coverage-v8": "4.1.10",
|
|
81
76
|
"dotenv": "17.4.2",
|
|
82
|
-
"esbuild": "0.28.1",
|
|
83
77
|
"husky": "9.1.7",
|
|
84
78
|
"npm-run-all": "4.1.5",
|
|
85
79
|
"rimraf": "6.1.3",
|
|
86
|
-
"
|
|
87
|
-
"rollup-plugin-esbuild": "6.2.1",
|
|
80
|
+
"rolldown": "1.2.4",
|
|
88
81
|
"typescript": "6.0.3",
|
|
89
82
|
"vitest": "4.1.10"
|
|
90
83
|
},
|