@ladamczyk/skillslint 4.1.0 → 4.1.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.
- package/bin/cli.js +1 -1
- package/lib/index.cjs +45 -3
- package/lib/index.mjs +46 -5
- package/lib/src/format.d.ts +6 -0
- package/lib/src/index.d.ts +1 -0
- package/package.json +12 -12
package/bin/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{getRelativePath as t,getPackageInfo as e,resolveCwdRelativePath as r,EExitCode as i}from"@ladamczyk/qoq-utils";import{
|
|
2
|
+
import{getRelativePath as t,getPackageInfo as e,resolveCwdRelativePath as r,EExitCode as i}from"@ladamczyk/qoq-utils";import s from"cac";import{getScoreColor as a,formatScoreBar as o,assessQuality as l}from"agent-skills-cli";import n from"picocolors";import{loadTextlintrc as c,createLinter as d,loadFixerFormatter as p,loadLinterFormatter as f}from"textlint";import{writeFile as h}from"fs/promises";import{resolve as m}from"path";import{readdirSync as u}from"fs";const y=t=>m(`${(()=>{try{const{rootPath:t}=e("@ladamczyk/skillslint")??{};return t}catch{return process.cwd()}})()}${t}`),v=t=>t.some(t=>("remainingMessages"in t?t.remainingMessages:t.messages).some(t=>2===t.severity)),g=["overall","structure","clarity","specificity","advanced"],w=async t=>{let e="";const r=await(async(t,e)=>{if(e)return(await p({formatterName:"stylish"})).format(t);return(await f({formatterName:"stylish"})).format(t)})(t.textlint,t.fixed);return r.trim()&&(e+=`${r}\n`),t.fixed&&v(t.textlint)&&(e+=n.red("Can't perform automatic fix!\n\n")),t.skills.forEach(({name:t,scores:r})=>{e+=n.gray(`\n/${t}\n`),g.forEach(t=>{const i=`${t[0]?.toUpperCase()}${t.slice(1)}:`.padEnd(13),s=n[a(r[t])];e+=s(`${i}${o(r[t],25)}\n`)})}),t.skills.some(t=>!t.passed)&&(e+=n.red("At least one skill doesn't meet required threshold!\n")),t.passed&&(e+=n.green("\nAll good!\n")),e},x=(t,e)=>t.overall<(e.overall??0)||t.structure<(e.structure??0)||t.clarity<(e.clarity??0)||t.specificity<(e.specificity??0)||t.advanced<(e.advanced??0),k="./skills",$=async(e={})=>{const{fix:i=!1,path:s,ignored:a}=e,o=`/${s??k}`,n=(t=>{const{threshold:e,overall:r,structure:i,clarity:s,specificity:a,advanced:o}=t,l={};return r&&(l.overall=r),i&&(l.structure=i),s&&(l.clarity=s),a&&(l.specificity=a),o&&(l.advanced=o),0===Object.keys(l).length&&(l.overall=e??70),l})(e),p=r(o),f=await(async(e,r)=>{const i=await c({configFilePath:(s="/.textlintrc.json",t(y(s)))});var s;const a=d({descriptor:i});try{if(!r)return await a.lintFiles([e]);const t=await a.fixFiles([e]);return await Promise.all(t.map(t=>h(t.filePath,t.output,"utf-8"))),t}catch(t){if(t instanceof Error&&"TextlintFileSearchError"===t.name)return[];throw t}})(r(`${o}/**/*.md`),i),m=u(p,{withFileTypes:!0}).filter(t=>t.isDirectory()&&!(a??[]).includes(t.name)).map(({name:t})=>t),g=await Promise.all(m.map(async t=>{const{overall:e,structure:r,clarity:i,specificity:s,advanced:a}=await l(`${p}/${t}`),o={overall:e,structure:r,clarity:i,specificity:s,advanced:a};return{name:t,scores:o,passed:!x(o,n)}})),w=!v(f)&&g.every(t=>t.passed);return{textlint:f,fixed:i,skills:g,passed:w}},q=s("skillslint");q.command("","Linter for agents skills").option("-p,--path <path>","Lint path",{default:k}).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=>{const e=await $(t);process.stdout.write(await w(e)),process.exit(e.passed?i.OK:i.ERROR)}),q.help(),q.parse();
|
package/lib/index.cjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var fs = require('fs');
|
|
4
|
-
var qoqUtils = require('@ladamczyk/qoq-utils');
|
|
5
3
|
var agentSkillsCli = require('agent-skills-cli');
|
|
6
|
-
var
|
|
4
|
+
var c = require('picocolors');
|
|
7
5
|
var textlint = require('textlint');
|
|
6
|
+
var promises = require('fs/promises');
|
|
8
7
|
var path = require('path');
|
|
8
|
+
var qoqUtils = require('@ladamczyk/qoq-utils');
|
|
9
|
+
var fs = require('fs');
|
|
9
10
|
|
|
10
11
|
const PACKAGE_NAME = '@ladamczyk/skillslint';
|
|
11
12
|
const getCliPackagePath = () => {
|
|
@@ -47,6 +48,46 @@ const runTextlint = async (target, fix) => {
|
|
|
47
48
|
};
|
|
48
49
|
const hasTextlintErrors = (results) => results.some((result) => ('remainingMessages' in result ? result.remainingMessages : result.messages).some((message) => message.severity === ERROR_SEVERITY));
|
|
49
50
|
|
|
51
|
+
const BAR_WIDTH = 25;
|
|
52
|
+
const DIMENSIONS = ['overall', 'structure', 'clarity', 'specificity', 'advanced'];
|
|
53
|
+
const formatTextlint = async (textlint$1, fixed) => {
|
|
54
|
+
if (fixed) {
|
|
55
|
+
const formatter = await textlint.loadFixerFormatter({ formatterName: 'stylish' });
|
|
56
|
+
return formatter.format(textlint$1);
|
|
57
|
+
}
|
|
58
|
+
const formatter = await textlint.loadLinterFormatter({ formatterName: 'stylish' });
|
|
59
|
+
return formatter.format(textlint$1);
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Renders an {@link ILintResult} into a console-ready, colorized string
|
|
63
|
+
* (textlint findings, per-skill score bars and the summary verdict).
|
|
64
|
+
*/
|
|
65
|
+
const format = async (result) => {
|
|
66
|
+
let output = '';
|
|
67
|
+
const textlint = await formatTextlint(result.textlint, result.fixed);
|
|
68
|
+
if (textlint.trim()) {
|
|
69
|
+
output += `${textlint}\n`;
|
|
70
|
+
}
|
|
71
|
+
if (result.fixed && hasTextlintErrors(result.textlint)) {
|
|
72
|
+
output += c.red("Can't perform automatic fix!\n\n");
|
|
73
|
+
}
|
|
74
|
+
result.skills.forEach(({ name, scores }) => {
|
|
75
|
+
output += c.gray(`\n/${name}\n`);
|
|
76
|
+
DIMENSIONS.forEach((dimension) => {
|
|
77
|
+
const label = `${dimension[0]?.toUpperCase()}${dimension.slice(1)}:`.padEnd(13);
|
|
78
|
+
const color = c[agentSkillsCli.getScoreColor(scores[dimension])];
|
|
79
|
+
output += color(`${label}${agentSkillsCli.formatScoreBar(scores[dimension], BAR_WIDTH)}\n`);
|
|
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;
|
|
89
|
+
};
|
|
90
|
+
|
|
50
91
|
const DEFAULT_THRESHOLD = 70;
|
|
51
92
|
const buildThreshold = (options) => {
|
|
52
93
|
const { threshold: optionsThreshold, overall, structure, clarity, specificity, advanced, } = options;
|
|
@@ -100,6 +141,7 @@ exports.DEFAULT_PATH = DEFAULT_PATH;
|
|
|
100
141
|
exports.DEFAULT_THRESHOLD = DEFAULT_THRESHOLD;
|
|
101
142
|
exports.buildThreshold = buildThreshold;
|
|
102
143
|
exports.failsThreshold = failsThreshold;
|
|
144
|
+
exports.format = format;
|
|
103
145
|
exports.hasTextlintErrors = hasTextlintErrors;
|
|
104
146
|
exports.lint = lint;
|
|
105
147
|
exports.runTextlint = runTextlint;
|
package/lib/index.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import { getScoreColor, formatScoreBar, assessQuality } from 'agent-skills-cli';
|
|
2
|
+
import c from 'picocolors';
|
|
3
|
+
import { loadTextlintrc, createLinter, loadFixerFormatter, loadLinterFormatter } from 'textlint';
|
|
4
4
|
import { writeFile } from 'fs/promises';
|
|
5
|
-
import { loadTextlintrc, createLinter } from 'textlint';
|
|
6
5
|
import { resolve } from 'path';
|
|
6
|
+
import { getRelativePath, getPackageInfo, resolveCwdRelativePath } from '@ladamczyk/qoq-utils';
|
|
7
|
+
import { readdirSync } from 'fs';
|
|
7
8
|
|
|
8
9
|
const PACKAGE_NAME = '@ladamczyk/skillslint';
|
|
9
10
|
const getCliPackagePath = () => {
|
|
@@ -45,6 +46,46 @@ const runTextlint = async (target, fix) => {
|
|
|
45
46
|
};
|
|
46
47
|
const hasTextlintErrors = (results) => results.some((result) => ('remainingMessages' in result ? result.remainingMessages : result.messages).some((message) => message.severity === ERROR_SEVERITY));
|
|
47
48
|
|
|
49
|
+
const BAR_WIDTH = 25;
|
|
50
|
+
const DIMENSIONS = ['overall', 'structure', 'clarity', 'specificity', 'advanced'];
|
|
51
|
+
const formatTextlint = async (textlint, fixed) => {
|
|
52
|
+
if (fixed) {
|
|
53
|
+
const formatter = await loadFixerFormatter({ formatterName: 'stylish' });
|
|
54
|
+
return formatter.format(textlint);
|
|
55
|
+
}
|
|
56
|
+
const formatter = await loadLinterFormatter({ formatterName: 'stylish' });
|
|
57
|
+
return formatter.format(textlint);
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Renders an {@link ILintResult} into a console-ready, colorized string
|
|
61
|
+
* (textlint findings, per-skill score bars and the summary verdict).
|
|
62
|
+
*/
|
|
63
|
+
const format = async (result) => {
|
|
64
|
+
let output = '';
|
|
65
|
+
const textlint = await formatTextlint(result.textlint, result.fixed);
|
|
66
|
+
if (textlint.trim()) {
|
|
67
|
+
output += `${textlint}\n`;
|
|
68
|
+
}
|
|
69
|
+
if (result.fixed && hasTextlintErrors(result.textlint)) {
|
|
70
|
+
output += c.red("Can't perform automatic fix!\n\n");
|
|
71
|
+
}
|
|
72
|
+
result.skills.forEach(({ name, scores }) => {
|
|
73
|
+
output += c.gray(`\n/${name}\n`);
|
|
74
|
+
DIMENSIONS.forEach((dimension) => {
|
|
75
|
+
const label = `${dimension[0]?.toUpperCase()}${dimension.slice(1)}:`.padEnd(13);
|
|
76
|
+
const color = c[getScoreColor(scores[dimension])];
|
|
77
|
+
output += color(`${label}${formatScoreBar(scores[dimension], BAR_WIDTH)}\n`);
|
|
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;
|
|
87
|
+
};
|
|
88
|
+
|
|
48
89
|
const DEFAULT_THRESHOLD = 70;
|
|
49
90
|
const buildThreshold = (options) => {
|
|
50
91
|
const { threshold: optionsThreshold, overall, structure, clarity, specificity, advanced, } = options;
|
|
@@ -94,4 +135,4 @@ const lint = async (options = {}) => {
|
|
|
94
135
|
return { textlint, fixed: fix, skills, passed };
|
|
95
136
|
};
|
|
96
137
|
|
|
97
|
-
export { DEFAULT_PATH, DEFAULT_THRESHOLD, buildThreshold, failsThreshold, hasTextlintErrors, lint, runTextlint };
|
|
138
|
+
export { DEFAULT_PATH, DEFAULT_THRESHOLD, buildThreshold, failsThreshold, format, hasTextlintErrors, lint, runTextlint };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ILintResult } from './types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Renders an {@link ILintResult} into a console-ready, colorized string
|
|
4
|
+
* (textlint findings, per-skill score bars and the summary verdict).
|
|
5
|
+
*/
|
|
6
|
+
export declare const format: (result: ILintResult) => Promise<string>;
|
package/lib/src/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ladamczyk/skillslint",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.2",
|
|
4
4
|
"description": "Linter for agents skills",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"test:coverage": "npm run test -- --coverage"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@ladamczyk/qoq-utils": "
|
|
55
|
+
"@ladamczyk/qoq-utils": "5.2.3",
|
|
56
56
|
"@textlint/textlint-plugin-markdown": "15.7.1",
|
|
57
57
|
"@textlint/textlint-plugin-text": "15.7.1",
|
|
58
58
|
"agent-skills-cli": "1.1.9",
|
|
@@ -64,29 +64,29 @@
|
|
|
64
64
|
"textlint-rule-write-good": "2.0.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@commitlint/cli": "21.0
|
|
68
|
-
"@commitlint/config-conventional": "21.0
|
|
69
|
-
"@ladamczyk/qoq-cli": "
|
|
70
|
-
"@ladamczyk/qoq-eslint-v9-ts": "
|
|
71
|
-
"@ladamczyk/qoq-jscpd": "
|
|
72
|
-
"@ladamczyk/qoq-knip": "
|
|
73
|
-
"@ladamczyk/qoq-prettier-with-json-sort": "
|
|
67
|
+
"@commitlint/cli": "21.2.0",
|
|
68
|
+
"@commitlint/config-conventional": "21.2.0",
|
|
69
|
+
"@ladamczyk/qoq-cli": "5.2.3",
|
|
70
|
+
"@ladamczyk/qoq-eslint-v9-ts": "5.2.3",
|
|
71
|
+
"@ladamczyk/qoq-jscpd": "5.2.3",
|
|
72
|
+
"@ladamczyk/qoq-knip": "5.2.3",
|
|
73
|
+
"@ladamczyk/qoq-prettier-with-json-sort": "5.2.3",
|
|
74
74
|
"@rollup/plugin-commonjs": "29.0.3",
|
|
75
75
|
"@rollup/plugin-json": "6.1.0",
|
|
76
76
|
"@rollup/plugin-node-resolve": "16.0.3",
|
|
77
77
|
"@rollup/plugin-terser": "1.0.0",
|
|
78
78
|
"@rollup/plugin-typescript": "12.3.0",
|
|
79
79
|
"@types/node": "^22",
|
|
80
|
-
"@vitest/coverage-v8": "4.1.
|
|
80
|
+
"@vitest/coverage-v8": "4.1.10",
|
|
81
81
|
"dotenv": "17.4.2",
|
|
82
82
|
"esbuild": "0.28.1",
|
|
83
83
|
"husky": "9.1.7",
|
|
84
84
|
"npm-run-all": "4.1.5",
|
|
85
85
|
"rimraf": "6.1.3",
|
|
86
|
-
"rollup": "4.62.
|
|
86
|
+
"rollup": "4.62.3",
|
|
87
87
|
"rollup-plugin-esbuild": "6.2.1",
|
|
88
88
|
"typescript": "6.0.3",
|
|
89
|
-
"vitest": "4.1.
|
|
89
|
+
"vitest": "4.1.10"
|
|
90
90
|
},
|
|
91
91
|
"engines": {
|
|
92
92
|
"node": ">=22.13.1"
|