@ladamczyk/skillslint 4.1.1 → 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 CHANGED
@@ -1,2 +1,7 @@
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 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();
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
- 'use strict';
2
-
3
- var agentSkillsCli = require('agent-skills-cli');
4
- var c = require('picocolors');
5
- var textlint = require('textlint');
6
- var promises = require('fs/promises');
7
- var path = require('path');
8
- var qoqUtils = require('@ladamczyk/qoq-utils');
9
- var fs = require('fs');
10
-
11
- const PACKAGE_NAME = '@ladamczyk/skillslint';
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
- try {
14
- const { rootPath } = qoqUtils.getPackageInfo(PACKAGE_NAME) ?? {};
15
- return rootPath;
16
- }
17
- catch {
18
- // this is for npx
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) => qoqUtils.getRelativePath(resolveCliPackagePath(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 = 'TextlintFileSearchError';
47
+ const NO_TARGET_FILES_ERROR = "TextlintFileSearchError";
27
48
  const runTextlint = async (target, fix) => {
28
- const descriptor = await textlint.loadTextlintrc({
29
- configFilePath: resolveCliRelativePath('/.textlintrc.json'),
30
- });
31
- const linter = textlint.createLinter({ descriptor });
32
- try {
33
- if (!fix) {
34
- return await linter.lintFiles([target]);
35
- }
36
- const results = await linter.fixFiles([target]);
37
- // fixFiles only computes the fixed output; persist it the way the textlint CLI does.
38
- await Promise.all(results.map((result) => promises.writeFile(result.filePath, result.output, 'utf-8')));
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) => ('remainingMessages' in result ? result.remainingMessages : result.messages).some((message) => message.severity === ERROR_SEVERITY));
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 = ['overall', 'structure', 'clarity', 'specificity', 'advanced'];
65
+ const DIMENSIONS = [
66
+ "overall",
67
+ "structure",
68
+ "clarity",
69
+ "specificity",
70
+ "advanced"
71
+ ];
53
72
  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);
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
- * Renders an {@link ILintResult} into a console-ready, colorized string
63
- * (textlint findings, per-skill score bars and the summary verdict).
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
- 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;
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
- const { threshold: optionsThreshold, overall, structure, clarity, specificity, advanced, } = options;
94
- const threshold = {};
95
- if (overall) {
96
- threshold.overall = overall;
97
- }
98
- if (structure) {
99
- threshold.structure = structure;
100
- }
101
- if (clarity) {
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
- scores.structure < (threshold.structure ?? 0) ||
117
- scores.clarity < (threshold.clarity ?? 0) ||
118
- scores.specificity < (threshold.specificity ?? 0) ||
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
- const { fix = false, path: optionsPath, ignored } = options;
124
- const path = `/${optionsPath ?? DEFAULT_PATH}`;
125
- const threshold = buildThreshold(options);
126
- const skillsPath = qoqUtils.resolveCwdRelativePath(path);
127
- const textlint = await runTextlint(qoqUtils.resolveCwdRelativePath(`${path}/**/*.md`), fix);
128
- const skillNames = fs.readdirSync(skillsPath, { withFileTypes: true })
129
- .filter((entry) => entry.isDirectory() && !(ignored ?? []).includes(entry.name))
130
- .map(({ name }) => name);
131
- const skills = await Promise.all(skillNames.map(async (name) => {
132
- const { overall, structure, clarity, specificity, advanced } = await agentSkillsCli.assessQuality(`${skillsPath}/${name}`);
133
- const scores = { overall, structure, clarity, specificity, advanced };
134
- return { name, scores, passed: !failsThreshold(scores, threshold) };
135
- }));
136
- const passed = !hasTextlintErrors(textlint) && skills.every((skill) => skill.passed);
137
- return { textlint, fixed: fix, skills, passed };
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 { getScoreColor, formatScoreBar, assessQuality } from 'agent-skills-cli';
2
- import c from 'picocolors';
3
- import { loadTextlintrc, createLinter, loadFixerFormatter, loadLinterFormatter } from 'textlint';
4
- import { writeFile } from 'fs/promises';
5
- import { resolve } from 'path';
6
- import { getRelativePath, getPackageInfo, resolveCwdRelativePath } from '@ladamczyk/qoq-utils';
7
- import { readdirSync } from 'fs';
8
-
9
- const PACKAGE_NAME = '@ladamczyk/skillslint';
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
- try {
12
- const { rootPath } = getPackageInfo(PACKAGE_NAME) ?? {};
13
- return rootPath;
14
- }
15
- catch {
16
- // this is for npx
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 = 'TextlintFileSearchError';
23
+ const NO_TARGET_FILES_ERROR = "TextlintFileSearchError";
25
24
  const runTextlint = async (target, fix) => {
26
- const descriptor = await loadTextlintrc({
27
- configFilePath: resolveCliRelativePath('/.textlintrc.json'),
28
- });
29
- const linter = createLinter({ descriptor });
30
- try {
31
- if (!fix) {
32
- return await linter.lintFiles([target]);
33
- }
34
- const results = await linter.fixFiles([target]);
35
- // fixFiles only computes the fixed output; persist it the way the textlint CLI does.
36
- await Promise.all(results.map((result) => writeFile(result.filePath, result.output, 'utf-8')));
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) => ('remainingMessages' in result ? result.remainingMessages : result.messages).some((message) => message.severity === ERROR_SEVERITY));
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 = ['overall', 'structure', 'clarity', 'specificity', 'advanced'];
41
+ const DIMENSIONS = [
42
+ "overall",
43
+ "structure",
44
+ "clarity",
45
+ "specificity",
46
+ "advanced"
47
+ ];
51
48
  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);
49
+ if (fixed) return (await loadFixerFormatter({ formatterName: "stylish" })).format(textlint);
50
+ return (await loadLinterFormatter({ formatterName: "stylish" })).format(textlint);
58
51
  };
59
52
  /**
60
- * Renders an {@link ILintResult} into a console-ready, colorized string
61
- * (textlint findings, per-skill score bars and the summary verdict).
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
- 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;
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
- const { threshold: optionsThreshold, overall, structure, clarity, specificity, advanced, } = options;
92
- const threshold = {};
93
- if (overall) {
94
- threshold.overall = overall;
95
- }
96
- if (structure) {
97
- threshold.structure = structure;
98
- }
99
- if (clarity) {
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
- scores.structure < (threshold.structure ?? 0) ||
115
- scores.clarity < (threshold.clarity ?? 0) ||
116
- scores.specificity < (threshold.specificity ?? 0) ||
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
- const { fix = false, path: optionsPath, ignored } = options;
122
- const path = `/${optionsPath ?? DEFAULT_PATH}`;
123
- const threshold = buildThreshold(options);
124
- const skillsPath = resolveCwdRelativePath(path);
125
- const textlint = await runTextlint(resolveCwdRelativePath(`${path}/**/*.md`), fix);
126
- const skillNames = readdirSync(skillsPath, { withFileTypes: true })
127
- .filter((entry) => entry.isDirectory() && !(ignored ?? []).includes(entry.name))
128
- .map(({ name }) => name);
129
- const skills = await Promise.all(skillNames.map(async (name) => {
130
- const { overall, structure, clarity, specificity, advanced } = await assessQuality(`${skillsPath}/${name}`);
131
- const scores = { overall, structure, clarity, specificity, advanced };
132
- return { name, scores, passed: !failsThreshold(scores, threshold) };
133
- }));
134
- const passed = !hasTextlintErrors(textlint) && skills.every((skill) => skill.passed);
135
- return { textlint, fixed: fix, skills, passed };
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 };
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ladamczyk/skillslint",
3
- "version": "4.1.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 && rollup -c rollup.bin.js --silent && rollup -c --silent && chmod +x ./bin/cli.js",
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,41 +52,34 @@
52
52
  "test:coverage": "npm run test -- --coverage"
53
53
  },
54
54
  "dependencies": {
55
- "@ladamczyk/qoq-utils": "4.3.5",
56
- "@textlint/textlint-plugin-markdown": "15.7.1",
57
- "@textlint/textlint-plugin-text": "15.7.1",
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.7.1",
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.0.2",
68
- "@commitlint/config-conventional": "21.0.2",
69
- "@ladamczyk/qoq-cli": "4.3.5",
70
- "@ladamczyk/qoq-eslint-v9-ts": "4.3.5",
71
- "@ladamczyk/qoq-jscpd": "4.3.5",
72
- "@ladamczyk/qoq-knip": "4.3.5",
73
- "@ladamczyk/qoq-prettier-with-json-sort": "4.3.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",
67
+ "@commitlint/cli": "21.2.1",
68
+ "@commitlint/config-conventional": "21.2.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
- "@vitest/coverage-v8": "4.1.9",
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
- "rollup": "4.62.2",
87
- "rollup-plugin-esbuild": "6.2.1",
80
+ "rolldown": "1.2.4",
88
81
  "typescript": "6.0.3",
89
- "vitest": "4.1.9"
82
+ "vitest": "4.1.10"
90
83
  },
91
84
  "engines": {
92
85
  "node": ">=22.13.1"