skill-preflight 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 SkillPreflight contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,132 @@
1
+ # SkillPreflight
2
+
3
+ SkillPreflight is a pre-install safety, token, and maintainability scorecard for AI agent skills.
4
+
5
+ It helps users decide whether a Codex, Claude Code, Cursor, Gemini CLI, or other agent skill is safe and lightweight enough to install.
6
+
7
+ ## Quick Start
8
+
9
+ Run without installing:
10
+
11
+ ```bash
12
+ npx skill-preflight scan ./my-skill
13
+ ```
14
+
15
+ Scan a GitHub repository before installing it:
16
+
17
+ ```bash
18
+ npx skill-preflight scan https://github.com/user/some-skill
19
+ ```
20
+
21
+ Scan common local skill directories:
22
+
23
+ ```bash
24
+ npx skill-preflight scan --installed
25
+ ```
26
+
27
+ ## Local Development
28
+
29
+ ```bash
30
+ npm install
31
+ npm run build
32
+ npm test
33
+ npm run dev -- scan examples/risky-skill
34
+ ```
35
+
36
+ ## Score Model
37
+
38
+ SkillPreflight uses a 100-point score:
39
+
40
+ | Category | Points | What it checks |
41
+ | --- | ---: | --- |
42
+ | Security | 35 | Dangerous commands, secret access, exfiltration, prompt injection, remote script execution |
43
+ | Permission restraint | 15 | Over-broad activation, unnecessary shell/network/file access |
44
+ | Token efficiency | 15 | Oversized `SKILL.md`, repeated content, poor progressive disclosure |
45
+ | Lightweight footprint | 10 | File count, total size, dependencies, large assets |
46
+ | Maintainability | 10 | README, license, frontmatter, examples, documentation hygiene |
47
+ | Reliability | 10 | Tests, fixtures, deterministic workflow, error handling |
48
+ | Compatibility | 5 | Hardcoded local paths, OS-specific assumptions, fragile shell usage |
49
+
50
+ ## CLI
51
+
52
+ ```bash
53
+ skill-preflight scan <target>
54
+ ```
55
+
56
+ Options:
57
+
58
+ ```text
59
+ --installed Scan common installed skill directories.
60
+ --format <format> text, json, markdown, html, or sarif. Default: text.
61
+ --out <file> Write report to a file.
62
+ --fail-below <score> Exit with code 1 if any scanned skill is below this score.
63
+ --keep-temp Keep temporary clones for debugging.
64
+ ```
65
+
66
+ Generate Shields-compatible badge JSON:
67
+
68
+ ```bash
69
+ skill-preflight badge ./my-skill --out skill-preflight-badge.json
70
+ ```
71
+
72
+ The badge payload can be served through a static endpoint or GitHub Pages:
73
+
74
+ ```json
75
+ {
76
+ "schemaVersion": 1,
77
+ "label": "SkillPreflight",
78
+ "message": "91/100 A",
79
+ "color": "brightgreen"
80
+ }
81
+ ```
82
+
83
+ ## GitHub Action
84
+
85
+ After the package is published to npm and the repository is tagged, skill authors can scan every PR:
86
+
87
+ ```yaml
88
+ name: SkillPreflight
89
+
90
+ on: [pull_request, push]
91
+
92
+ jobs:
93
+ scan:
94
+ runs-on: ubuntu-latest
95
+ steps:
96
+ - uses: actions/checkout@v4
97
+ - uses: agent-contracts/skill-preflight@v1
98
+ with:
99
+ target: "."
100
+ fail-below: "70"
101
+ ```
102
+
103
+ For GitHub code scanning, emit SARIF:
104
+
105
+ ```bash
106
+ skill-preflight scan . --format sarif --out skill-preflight.sarif
107
+ ```
108
+
109
+ See `docs/github-action.md` for the full workflow.
110
+
111
+ ## Safety Principle
112
+
113
+ SkillPreflight does not execute scripts inside scanned skills. It only reads files and performs static analysis.
114
+
115
+ ## Example Output
116
+
117
+ ```text
118
+ shell-super-agent: 35/100 (F) - High risk, do not install blindly
119
+
120
+ Top findings:
121
+ - [CRITICAL] Remote script execution pattern (SKILL.md:15)
122
+ - [HIGH] Prompt injection language (SKILL.md:8)
123
+ - [HIGH] Potential secret or credential access (SKILL.md:10)
124
+ ```
125
+
126
+ ## Rule Catalog
127
+
128
+ See `docs/rules.md` for the current static analysis rule catalog, including dependency, install-script, MCP config, token, and compatibility checks.
129
+
130
+ ## Publishing
131
+
132
+ See `docs/release.md` for the first npm and GitHub release checklist.
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function runCli(argv: string[]): Promise<void>;
package/dist/cli.js ADDED
@@ -0,0 +1,109 @@
1
+ import { writeFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { Command } from "commander";
4
+ import { scan } from "./core/scan.js";
5
+ import { parseFormat, renderReport } from "./report/render.js";
6
+ export async function runCli(argv) {
7
+ const program = new Command();
8
+ program
9
+ .name("skill-preflight")
10
+ .description("Pre-install safety, token, and maintainability scorecard for AI agent skills.")
11
+ .version("0.1.0");
12
+ program
13
+ .command("scan")
14
+ .argument("[target]", "Local skill path or GitHub repository URL")
15
+ .option("--installed", "Scan common installed skill directories")
16
+ .option("--format <format>", "Report format: text, json, markdown, html, sarif", "text")
17
+ .option("--out <file>", "Write report to a file")
18
+ .option("--fail-below <score>", "Exit with code 1 if any skill score is below this threshold")
19
+ .option("--keep-temp", "Keep temporary GitHub clones for debugging")
20
+ .action(async (target, options) => {
21
+ const format = parseFormat(options.format ?? "text");
22
+ const report = await scan({
23
+ target,
24
+ installed: options.installed,
25
+ keepTemp: options.keepTemp
26
+ });
27
+ const rendered = renderReport(report, format);
28
+ if (options.out) {
29
+ const outPath = path.resolve(options.out);
30
+ await writeFile(outPath, rendered, "utf8");
31
+ process.stdout.write(`Wrote ${format} report to ${outPath}\n`);
32
+ }
33
+ else {
34
+ process.stdout.write(rendered);
35
+ }
36
+ if (options.failBelow !== undefined) {
37
+ const threshold = Number(options.failBelow);
38
+ if (!Number.isFinite(threshold)) {
39
+ throw new Error(`Invalid --fail-below value: ${options.failBelow}`);
40
+ }
41
+ const failed = report.reports.some((skill) => skill.score < threshold);
42
+ if (failed) {
43
+ process.exitCode = 1;
44
+ }
45
+ }
46
+ });
47
+ program
48
+ .command("badge")
49
+ .argument("[target]", "Local skill path or GitHub repository URL")
50
+ .option("--installed", "Scan common installed skill directories")
51
+ .option("--out <file>", "Write Shields endpoint JSON to a file")
52
+ .option("--keep-temp", "Keep temporary GitHub clones for debugging")
53
+ .action(async (target, options) => {
54
+ const report = await scan({
55
+ target,
56
+ installed: options.installed,
57
+ keepTemp: options.keepTemp
58
+ });
59
+ const badge = renderBadge(report.summary.averageScore, report.summary.highRiskCount);
60
+ const rendered = `${JSON.stringify(badge, null, 2)}\n`;
61
+ if (options.out) {
62
+ const outPath = path.resolve(options.out);
63
+ await writeFile(outPath, rendered, "utf8");
64
+ process.stdout.write(`Wrote badge JSON to ${outPath}\n`);
65
+ }
66
+ else {
67
+ process.stdout.write(rendered);
68
+ }
69
+ });
70
+ program.showHelpAfterError();
71
+ try {
72
+ await program.parseAsync(argv);
73
+ }
74
+ catch (error) {
75
+ process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
76
+ process.exitCode = 1;
77
+ }
78
+ }
79
+ function renderBadge(score, highRiskCount) {
80
+ return {
81
+ schemaVersion: 1,
82
+ label: "SkillPreflight",
83
+ message: `${score}/100 ${badgeGrade(score)}`,
84
+ color: highRiskCount > 0 ? "red" : badgeColor(score)
85
+ };
86
+ }
87
+ function badgeGrade(score) {
88
+ if (score >= 90)
89
+ return "A";
90
+ if (score >= 80)
91
+ return "B";
92
+ if (score >= 70)
93
+ return "C";
94
+ if (score >= 60)
95
+ return "D";
96
+ return "F";
97
+ }
98
+ function badgeColor(score) {
99
+ if (score >= 90)
100
+ return "brightgreen";
101
+ if (score >= 80)
102
+ return "green";
103
+ if (score >= 70)
104
+ return "yellowgreen";
105
+ if (score >= 60)
106
+ return "orange";
107
+ return "red";
108
+ }
109
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAgB/D,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAc;IACzC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAE9B,OAAO;SACJ,IAAI,CAAC,iBAAiB,CAAC;SACvB,WAAW,CAAC,+EAA+E,CAAC;SAC5F,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpB,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,QAAQ,CAAC,UAAU,EAAE,2CAA2C,CAAC;SACjE,MAAM,CAAC,aAAa,EAAE,yCAAyC,CAAC;SAChE,MAAM,CAAC,mBAAmB,EAAE,kDAAkD,EAAE,MAAM,CAAC;SACvF,MAAM,CAAC,cAAc,EAAE,wBAAwB,CAAC;SAChD,MAAM,CAAC,sBAAsB,EAAE,6DAA6D,CAAC;SAC7F,MAAM,CAAC,aAAa,EAAE,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O,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,KAAa,EAAE,aAAqB;IAMvD,OAAO;QACL,aAAa,EAAE,CAAC;QAChB,KAAK,EAAE,gBAAgB;QACvB,OAAO,EAAE,GAAG,KAAK,QAAQ,UAAU,CAAC,KAAK,CAAC,EAAE;QAC5C,KAAK,EAAE,aAAa,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC;KACrD,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,KAAK,IAAI,EAAE;QAAE,OAAO,GAAG,CAAC;IAC5B,IAAI,KAAK,IAAI,EAAE;QAAE,OAAO,GAAG,CAAC;IAC5B,IAAI,KAAK,IAAI,EAAE;QAAE,OAAO,GAAG,CAAC;IAC5B,IAAI,KAAK,IAAI,EAAE;QAAE,OAAO,GAAG,CAAC;IAC5B,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,KAAK,IAAI,EAAE;QAAE,OAAO,aAAa,CAAC;IACtC,IAAI,KAAK,IAAI,EAAE;QAAE,OAAO,OAAO,CAAC;IAChC,IAAI,KAAK,IAAI,EAAE;QAAE,OAAO,aAAa,CAAC;IACtC,IAAI,KAAK,IAAI,EAAE;QAAE,OAAO,QAAQ,CAAC;IACjC,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { CategoryDefinition } from "./types.js";
2
+ export declare const CATEGORIES: CategoryDefinition[];
3
+ export declare const MAX_SCORE: number;
@@ -0,0 +1,11 @@
1
+ export const CATEGORIES = [
2
+ { id: "security", label: "Security", maxScore: 35 },
3
+ { id: "permissions", label: "Permission restraint", maxScore: 15 },
4
+ { id: "token", label: "Token efficiency", maxScore: 15 },
5
+ { id: "footprint", label: "Lightweight footprint", maxScore: 10 },
6
+ { id: "maintainability", label: "Maintainability", maxScore: 10 },
7
+ { id: "reliability", label: "Reliability", maxScore: 10 },
8
+ { id: "compatibility", label: "Compatibility", maxScore: 5 }
9
+ ];
10
+ export const MAX_SCORE = CATEGORIES.reduce((sum, category) => sum + category.maxScore, 0);
11
+ //# sourceMappingURL=categories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"categories.js","sourceRoot":"","sources":["../../src/core/categories.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,UAAU,GAAyB;IAC9C,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE;IACnD,EAAE,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,sBAAsB,EAAE,QAAQ,EAAE,EAAE,EAAE;IAClE,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,EAAE,EAAE;IACxD,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,uBAAuB,EAAE,QAAQ,EAAE,EAAE,EAAE;IACjE,EAAE,EAAE,EAAE,iBAAiB,EAAE,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,EAAE,EAAE;IACjE,EAAE,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,EAAE,EAAE;IACzD,EAAE,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,EAAE;CAC7D,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,GAAG,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { ResolvedTarget, ScannedFile, TextFile } from "./types.js";
2
+ export declare function resolveTarget(target: string, keepTemp?: boolean): Promise<ResolvedTarget>;
3
+ export declare function isGitHubUrl(value: string): boolean;
4
+ export declare function discoverSkillRoots(rootPath: string): Promise<string[]>;
5
+ export declare function readSkillFiles(rootPath: string): Promise<{
6
+ files: ScannedFile[];
7
+ textFiles: TextFile[];
8
+ }>;
9
+ export declare function commonInstalledSkillDirs(): string[];
@@ -0,0 +1,115 @@
1
+ import { readdir, readFile, rm } from "node:fs/promises";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { randomUUID } from "node:crypto";
5
+ import { execFile } from "node:child_process";
6
+ import { promisify } from "node:util";
7
+ import { isProbablyText, pathExists, toPosixPath } from "./utils.js";
8
+ const execFileAsync = promisify(execFile);
9
+ const IGNORED_DIRS = new Set([
10
+ ".git",
11
+ "node_modules",
12
+ "dist",
13
+ "build",
14
+ "coverage",
15
+ ".next",
16
+ ".nuxt",
17
+ ".turbo",
18
+ ".cache",
19
+ "__pycache__"
20
+ ]);
21
+ const MAX_TEXT_FILE_BYTES = 1024 * 1024;
22
+ export async function resolveTarget(target, keepTemp = false) {
23
+ if (isGitHubUrl(target)) {
24
+ const tempRoot = path.join(os.tmpdir(), `skill-preflight-${randomUUID()}`);
25
+ await execFileAsync("git", ["clone", "--depth", "1", target, tempRoot], {
26
+ timeout: 120000,
27
+ windowsHide: true
28
+ });
29
+ return {
30
+ displayTarget: target,
31
+ localPath: tempRoot,
32
+ cleanup: keepTemp
33
+ ? undefined
34
+ : async () => {
35
+ await rm(tempRoot, { recursive: true, force: true });
36
+ }
37
+ };
38
+ }
39
+ const localPath = path.resolve(target);
40
+ if (!(await pathExists(localPath))) {
41
+ throw new Error(`Target does not exist: ${target}`);
42
+ }
43
+ return {
44
+ displayTarget: target,
45
+ localPath
46
+ };
47
+ }
48
+ export function isGitHubUrl(value) {
49
+ return /^https:\/\/github\.com\/[^/]+\/[^/]+\/?$/.test(value.trim());
50
+ }
51
+ export async function discoverSkillRoots(rootPath) {
52
+ const directSkill = path.join(rootPath, "SKILL.md");
53
+ if (await pathExists(directSkill)) {
54
+ return [rootPath];
55
+ }
56
+ const roots = [];
57
+ await walk(rootPath, async (filePath) => {
58
+ if (path.basename(filePath).toLowerCase() === "skill.md") {
59
+ roots.push(path.dirname(filePath));
60
+ }
61
+ });
62
+ return [...new Set(roots)].sort();
63
+ }
64
+ export async function readSkillFiles(rootPath) {
65
+ const files = [];
66
+ const textFiles = [];
67
+ await walk(rootPath, async (absolutePath) => {
68
+ const buffer = await readFile(absolutePath);
69
+ const relativePath = toPosixPath(path.relative(rootPath, absolutePath));
70
+ const isText = buffer.length <= MAX_TEXT_FILE_BYTES && isProbablyText(buffer);
71
+ files.push({
72
+ path: relativePath,
73
+ absolutePath,
74
+ bytes: buffer.length,
75
+ isText
76
+ });
77
+ if (isText) {
78
+ const content = buffer.toString("utf8");
79
+ textFiles.push({
80
+ path: relativePath,
81
+ absolutePath,
82
+ bytes: buffer.length,
83
+ content,
84
+ lines: content.split(/\r?\n/)
85
+ });
86
+ }
87
+ });
88
+ return { files, textFiles };
89
+ }
90
+ async function walk(rootPath, onFile) {
91
+ const entries = await readdir(rootPath, { withFileTypes: true });
92
+ for (const entry of entries) {
93
+ const absolutePath = path.join(rootPath, entry.name);
94
+ if (entry.isDirectory()) {
95
+ if (!IGNORED_DIRS.has(entry.name)) {
96
+ await walk(absolutePath, onFile);
97
+ }
98
+ continue;
99
+ }
100
+ if (entry.isFile()) {
101
+ await onFile(absolutePath);
102
+ }
103
+ }
104
+ }
105
+ export function commonInstalledSkillDirs() {
106
+ const home = os.homedir();
107
+ const cwd = process.cwd();
108
+ return [
109
+ path.join(home, ".codex", "skills"),
110
+ path.join(home, ".claude", "skills"),
111
+ path.join(cwd, ".codex", "skills"),
112
+ path.join(cwd, ".claude", "skills")
113
+ ];
114
+ }
115
+ //# sour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