@ladamczyk/skillslint 4.1.3 → 4.2.0
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/AGENTS.md +30 -2
- package/bin/cli.js +8 -3
- package/lib/index.cjs +22 -2
- package/lib/index.mjs +24 -3
- package/lib/src/helpers/stats.d.ts +2 -0
- package/lib/src/helpers/stats.test.d.ts +1 -0
- package/lib/src/helpers/threshold.d.ts +1 -1
- package/lib/src/lint.d.ts +1 -1
- package/lib/src/types.d.ts +1 -0
- package/package.json +9 -9
package/AGENTS.md
CHANGED
|
@@ -29,7 +29,13 @@ The package also exports a JavaScript API (ESM). The `lint` function runs the sa
|
|
|
29
29
|
```js
|
|
30
30
|
import { lint } from '@ladamczyk/skillslint';
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
// `stats` is required — see "Anonymous usage stats" below.
|
|
33
|
+
const result = await lint({
|
|
34
|
+
path: './skills',
|
|
35
|
+
threshold: 70,
|
|
36
|
+
ignored: ['wip-skill'],
|
|
37
|
+
stats: false,
|
|
38
|
+
});
|
|
33
39
|
|
|
34
40
|
result.passed; // boolean — every skill met its threshold and textlint found no errors
|
|
35
41
|
result.fixed; // boolean — whether `fix` was requested (fixes are written to disk)
|
|
@@ -37,7 +43,29 @@ result.skills; // Array<{ name, scores: { overall, structure, clarity, specifici
|
|
|
37
43
|
result.textlint; // raw textlint results for the linted markdown files
|
|
38
44
|
```
|
|
39
45
|
|
|
40
|
-
`lint(options)` accepts the same options as the CLI flags (`path`, `fix`, `ignored`, `threshold`, `overall`, `structure`, `clarity`, `specificity`, `advanced`). Additional named exports: `DEFAULT_PATH`, `DEFAULT_THRESHOLD`, `buildThreshold`, `failsThreshold`, `runTextlint`, `hasTextlintErrors`, and the TypeScript types (`ILintOptions`, `ILintResult`, `IScores`, `ISkillScore`, `IThreshold`).
|
|
46
|
+
`lint(options)` accepts the same options as the CLI flags (`path`, `fix`, `ignored`, `threshold`, `overall`, `structure`, `clarity`, `specificity`, `advanced`), all optional, plus the required `stats: boolean` (see below). Additional named exports: `DEFAULT_PATH`, `DEFAULT_THRESHOLD`, `buildThreshold`, `failsThreshold`, `runTextlint`, `hasTextlintErrors`, and the TypeScript types (`ILintOptions`, `ILintResult`, `IScores`, `ISkillScore`, `IThreshold`).
|
|
47
|
+
|
|
48
|
+
## Anonymous usage stats
|
|
49
|
+
|
|
50
|
+
Opt-in, off until a human says yes. A counted run posts one constant to `https://stats.adamczyk.ovh` and nothing else — every run, every flag combination, byte for byte the same body:
|
|
51
|
+
|
|
52
|
+
```jsonc
|
|
53
|
+
{ "tool": "skillslint", "options": [] } // `options` is always empty
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
So the only thing a send carries is that a run happened. Never sent: skills, file names, paths, scores, findings, thresholds, the flags you typed, project or package names, or anything identifying the user or machine. Sends are fire-and-forget with a 2s timeout; a failure is swallowed and never affects the exit code.
|
|
57
|
+
|
|
58
|
+
- **CLI** — asks the user, once, the first time it runs with a TTY on both stdin and stdout, and stores the answer in `$XDG_CONFIG_HOME/skillslint.json` (`~/.config/skillslint.json` by default):
|
|
59
|
+
|
|
60
|
+
| File state | Meaning | Effect |
|
|
61
|
+
| -------------------- | ----------- | --------------------------------------------- |
|
|
62
|
+
| `{ "stats": true }` | allowed | one POST per run |
|
|
63
|
+
| `{ "stats": false }` | denied | nothing sent, never asked again |
|
|
64
|
+
| no key / no file | never asked | nothing sent, asked again on the next TTY run |
|
|
65
|
+
|
|
66
|
+
Edit or delete the file to change the answer; deleting it returns to "never asked". Non-interactive runs — `CI=true`, a pipe, a subprocess — are never prompted, never counted, and write nothing, so they leave the question open rather than answering it for the user.
|
|
67
|
+
|
|
68
|
+
- **API** — never prompts, never reads that file, and has no default. `stats: boolean` is a **required** option on `lint()`: the caller holds its own user's consent, so it must pass `true` or `false` outright. `false` sends nothing.
|
|
41
69
|
|
|
42
70
|
## Skills directory structure
|
|
43
71
|
|
package/bin/cli.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
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
|
|
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{dirname as m,join as h,resolve as g}from"path";import{mkdirSync as _,readFileSync as v,readdirSync as y,writeFileSync as b}from"fs";import{homedir as x}from"os";import{createInterface as S}from"readline/promises";const C=()=>{try{let{rootPath:e}=t(`@ladamczyk/skillslint`)??{};return e}catch{return process.cwd()}},w=e=>g(`${C()}${e}`),T=e=>n(w(e)),E=async(e,t)=>{let n=await f({configFilePath:T(`/.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}},D=e=>e.some(e=>(`remainingMessages`in e?e.remainingMessages:e.messages).some(e=>e.severity===2)),O=[`overall`,`structure`,`clarity`,`specificity`,`advanced`],k=async(e,t)=>t?(await u({formatterName:`stylish`})).format(e):(await d({formatterName:`stylish`})).format(e),A=async e=>{let t=``,n=await k(e.textlint,e.fixed);return n.trim()&&(t+=`${n}\n`),e.fixed&&D(e.textlint)&&(t+=c.red(`Can't perform automatic fix!
|
|
3
3
|
|
|
4
|
-
`)),e.skills.forEach(({name:e,scores:n})=>{t+=c.gray(`\n/${e}\n`),
|
|
4
|
+
`)),e.skills.forEach(({name:e,scores:n})=>{t+=c.gray(`\n/${e}\n`),O.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
5
|
`)),e.passed&&(t+=c.green(`
|
|
6
6
|
All good!
|
|
7
|
-
`)),t},
|
|
7
|
+
`)),t},j=`https://stats.adamczyk.ovh`,M=h(process.env.XDG_CONFIG_HOME??h(x(),`.config`),`skillslint.json`),N=e=>{try{let t=JSON.parse(v(e,`utf8`));return typeof t==`object`&&t?t:{}}catch{return{}}},P=(e,t)=>{try{_(m(e),{recursive:!0}),b(e,`${JSON.stringify({...N(e),stats:t},null,2)}\n`)}catch{}},F=async()=>{process.stdout.write([c.bold(`
|
|
8
|
+
Skillslint usage stats
|
|
9
|
+
`),`Send a count of skillslint runs to ${j}? Each run posts one thing:\n`,` • the tool name — always the literal ${c.cyan(`"skillslint"`)}\n`,c.gray(`Never sent: your skills, file names, paths, scores, findings, thresholds,
|
|
10
|
+
the flags you typed, project or package names, and nothing identifying
|
|
11
|
+
you or your machine.
|
|
12
|
+
`),c.gray(`Stored as \`stats: true|false\` in ${M} — edit it any time.\n\n`)].join(``));let e=S({input:process.stdin,output:process.stdout});try{return(await e.question(`Send anonymous usage stats? [y/N] `)).trim().toLowerCase()===`y`}finally{e.close()}},I=async(e=M)=>{let t=N(e).stats;if(typeof t==`boolean`)return t;if(process.env.CI===`true`||!process.stdin.isTTY||!process.stdout.isTTY)return;let n=await F();return P(e,n),n},L=async()=>{try{await fetch(j,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({tool:`skillslint`,options:[]}),signal:AbortSignal.timeout(2e3)})}catch{}},R=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},z=(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),B=async e=>{let{fix:t=!1,path:n,ignored:i,stats:o}=e;o&&L();let s=`/${n??`./skills`}`,c=R(e),l=r(s),u=await E(r(`${s}/**/*.md`),t),d=y(l,{withFileTypes:!0}).filter(e=>e.isDirectory()&&!(i??[]).includes(e.name)).map(({name:e})=>e),f=await Promise.all(d.map(async e=>{let{overall:t,structure:n,clarity:r,specificity:i,advanced:o}=await a(`${l}/${e}`),s={overall:t,structure:n,clarity:r,specificity:i,advanced:o};return{name:e,scores:s,passed:!z(s,c)}}));return{textlint:u,fixed:t,skills:f,passed:!D(u)&&f.every(e=>e.passed)}},V=i(`skillslint`);V.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 B({...t,stats:await I()??!1});process.stdout.write(await A(n)),process.exit(n.passed?e.OK:e.ERROR)}),V.help(),V.parse();
|
package/lib/index.cjs
CHANGED
|
@@ -29,6 +29,7 @@ let fs_promises = require("fs/promises");
|
|
|
29
29
|
let path = require("path");
|
|
30
30
|
let _ladamczyk_qoq_utils = require("@ladamczyk/qoq-utils");
|
|
31
31
|
let fs = require("fs");
|
|
32
|
+
let os = require("os");
|
|
32
33
|
//#region src/helpers/paths.ts
|
|
33
34
|
const PACKAGE_NAME = "@ladamczyk/skillslint";
|
|
34
35
|
const getCliPackagePath = () => {
|
|
@@ -95,6 +96,24 @@ const format = async (result) => {
|
|
|
95
96
|
return output;
|
|
96
97
|
};
|
|
97
98
|
//#endregion
|
|
99
|
+
//#region src/helpers/stats.ts
|
|
100
|
+
const STATS_URL = "https://stats.adamczyk.ovh";
|
|
101
|
+
const STATS_TIMEOUT_MS = 2e3;
|
|
102
|
+
(0, path.join)(process.env.XDG_CONFIG_HOME ?? (0, path.join)((0, os.homedir)(), ".config"), "skillslint.json");
|
|
103
|
+
const sendStats = async () => {
|
|
104
|
+
try {
|
|
105
|
+
await fetch(STATS_URL, {
|
|
106
|
+
method: "POST",
|
|
107
|
+
headers: { "content-type": "application/json" },
|
|
108
|
+
body: JSON.stringify({
|
|
109
|
+
tool: "skillslint",
|
|
110
|
+
options: []
|
|
111
|
+
}),
|
|
112
|
+
signal: AbortSignal.timeout(STATS_TIMEOUT_MS)
|
|
113
|
+
});
|
|
114
|
+
} catch {}
|
|
115
|
+
};
|
|
116
|
+
//#endregion
|
|
98
117
|
//#region src/helpers/threshold.ts
|
|
99
118
|
const DEFAULT_THRESHOLD = 70;
|
|
100
119
|
const buildThreshold = (options) => {
|
|
@@ -112,8 +131,9 @@ const failsThreshold = (scores, threshold) => scores.overall < (threshold.overal
|
|
|
112
131
|
//#endregion
|
|
113
132
|
//#region src/lint.ts
|
|
114
133
|
const DEFAULT_PATH = "./skills";
|
|
115
|
-
const lint = async (options
|
|
116
|
-
const { fix = false, path: optionsPath, ignored } = options;
|
|
134
|
+
const lint = async (options) => {
|
|
135
|
+
const { fix = false, path: optionsPath, ignored, stats } = options;
|
|
136
|
+
if (stats) sendStats();
|
|
117
137
|
const path = `/${optionsPath ?? "./skills"}`;
|
|
118
138
|
const threshold = buildThreshold(options);
|
|
119
139
|
const skillsPath = (0, _ladamczyk_qoq_utils.resolveCwdRelativePath)(path);
|
package/lib/index.mjs
CHANGED
|
@@ -2,9 +2,11 @@ import { assessQuality, formatScoreBar, getScoreColor } from "agent-skills-cli";
|
|
|
2
2
|
import c from "picocolors";
|
|
3
3
|
import { createLinter, loadFixerFormatter, loadLinterFormatter, loadTextlintrc } from "textlint";
|
|
4
4
|
import { writeFile } from "fs/promises";
|
|
5
|
-
import { resolve } from "path";
|
|
5
|
+
import { join, resolve } from "path";
|
|
6
6
|
import { getPackageInfo, getRelativePath, resolveCwdRelativePath } from "@ladamczyk/qoq-utils";
|
|
7
7
|
import { readdirSync } from "fs";
|
|
8
|
+
import { homedir } from "os";
|
|
9
|
+
import "readline/promises";
|
|
8
10
|
//#region src/helpers/paths.ts
|
|
9
11
|
const PACKAGE_NAME = "@ladamczyk/skillslint";
|
|
10
12
|
const getCliPackagePath = () => {
|
|
@@ -71,6 +73,24 @@ const format = async (result) => {
|
|
|
71
73
|
return output;
|
|
72
74
|
};
|
|
73
75
|
//#endregion
|
|
76
|
+
//#region src/helpers/stats.ts
|
|
77
|
+
const STATS_URL = "https://stats.adamczyk.ovh";
|
|
78
|
+
const STATS_TIMEOUT_MS = 2e3;
|
|
79
|
+
join(process.env.XDG_CONFIG_HOME ?? join(homedir(), ".config"), "skillslint.json");
|
|
80
|
+
const sendStats = async () => {
|
|
81
|
+
try {
|
|
82
|
+
await fetch(STATS_URL, {
|
|
83
|
+
method: "POST",
|
|
84
|
+
headers: { "content-type": "application/json" },
|
|
85
|
+
body: JSON.stringify({
|
|
86
|
+
tool: "skillslint",
|
|
87
|
+
options: []
|
|
88
|
+
}),
|
|
89
|
+
signal: AbortSignal.timeout(STATS_TIMEOUT_MS)
|
|
90
|
+
});
|
|
91
|
+
} catch {}
|
|
92
|
+
};
|
|
93
|
+
//#endregion
|
|
74
94
|
//#region src/helpers/threshold.ts
|
|
75
95
|
const DEFAULT_THRESHOLD = 70;
|
|
76
96
|
const buildThreshold = (options) => {
|
|
@@ -88,8 +108,9 @@ const failsThreshold = (scores, threshold) => scores.overall < (threshold.overal
|
|
|
88
108
|
//#endregion
|
|
89
109
|
//#region src/lint.ts
|
|
90
110
|
const DEFAULT_PATH = "./skills";
|
|
91
|
-
const lint = async (options
|
|
92
|
-
const { fix = false, path: optionsPath, ignored } = options;
|
|
111
|
+
const lint = async (options) => {
|
|
112
|
+
const { fix = false, path: optionsPath, ignored, stats } = options;
|
|
113
|
+
if (stats) sendStats();
|
|
93
114
|
const path = `/${optionsPath ?? "./skills"}`;
|
|
94
115
|
const threshold = buildThreshold(options);
|
|
95
116
|
const skillsPath = resolveCwdRelativePath(path);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ILintOptions, IScores, IThreshold } from '../types.ts';
|
|
2
2
|
export declare const DEFAULT_THRESHOLD = 70;
|
|
3
|
-
export declare const buildThreshold: (options: ILintOptions) => IThreshold;
|
|
3
|
+
export declare const buildThreshold: (options: IThreshold & Pick<ILintOptions, "threshold">) => IThreshold;
|
|
4
4
|
export declare const failsThreshold: (scores: IScores, threshold: IThreshold) => boolean;
|
package/lib/src/lint.d.ts
CHANGED
package/lib/src/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ladamczyk/skillslint",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
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": "6.0.0",
|
|
56
56
|
"@textlint/textlint-plugin-markdown": "15.8.0",
|
|
57
57
|
"@textlint/textlint-plugin-text": "15.8.0",
|
|
58
58
|
"agent-skills-cli": "1.1.9",
|
|
@@ -64,13 +64,13 @@
|
|
|
64
64
|
"textlint-rule-write-good": "2.0.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@commitlint/cli": "21.2.
|
|
68
|
-
"@commitlint/config-conventional": "21.2.
|
|
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.2",
|
|
68
|
+
"@commitlint/config-conventional": "21.2.2",
|
|
69
|
+
"@ladamczyk/qoq-cli": "6.0.0",
|
|
70
|
+
"@ladamczyk/qoq-eslint-v9-ts": "6.0.0",
|
|
71
|
+
"@ladamczyk/qoq-jscpd": "6.0.0",
|
|
72
|
+
"@ladamczyk/qoq-knip": "6.0.0",
|
|
73
|
+
"@ladamczyk/qoq-prettier-with-json-sort": "6.0.0",
|
|
74
74
|
"@types/node": "^22",
|
|
75
75
|
"@vitest/coverage-v8": "4.1.10",
|
|
76
76
|
"dotenv": "17.4.2",
|