lintsure 0.3.18 → 0.3.20
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/README.md +3 -1
- package/dist/src/agents.d.ts +3 -0
- package/dist/src/agents.js +34 -5
- package/dist/src/index.js +106 -26
- package/dist/src/menu.d.ts +3 -0
- package/dist/src/menu.js +3 -0
- package/dist/src/plugin.d.ts +2 -1
- package/dist/src/plugin.js +13 -4
- package/dist/src/send.js +1 -1
- package/dist/src/skills.d.ts +4 -0
- package/dist/src/skills.js +24 -0
- package/package.json +4 -4
- package/skills/lintsure-rules/SKILL.md +5 -3
- package/skills/lintsure-rules/agents.mjs +66 -21
- package/skills/lintsure-rules/lib.mjs +2 -1
- package/skills/lintsure-rules/rules.mjs +217 -215
- package/skills/lintsure-setup/SKILL.md +34 -34
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# lintsure
|
|
2
2
|
|
|
3
|
-
**Keep your AI coding agents on track and in context.** Lintsure checks the code Claude Code,
|
|
3
|
+
**Keep your AI coding agents on track and in context.** Lintsure checks the code Claude Code, Grok Build, Codex and other agents write, and holds them to your project's rules. It finds secrets in source, databases left open, unsafe agent settings, request data reaching a query or a shell, and more, and maps each finding to OWASP, GDPR and the EU AI Act. It runs on your machine and never uploads your code.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
npx lintsure scan # check the project in this folder
|
|
@@ -25,6 +25,8 @@ Every finding shows the file and line, a suggested fix, a plain note on why it m
|
|
|
25
25
|
|
|
26
26
|
In Claude Code, the [plugin](https://github.com/lintsure/plugin) adds guards that work while the agent edits: Drift Guard, Danger Guard, Secret Guard and Loop Guard.
|
|
27
27
|
|
|
28
|
+
You set Lintsure up once and it stays on: `setup`, `skills`, `plugin` and `hook` each write files that stay, so there is nothing to turn on for a new session. Run `lintsure setup` again after an update, and `lintsure status` to see what is in place.
|
|
29
|
+
|
|
28
30
|
With Docker: `docker run --rm -v "$PWD:/work" -w /work node:22-slim npx -y lintsure scan`
|
|
29
31
|
|
|
30
32
|
> **Lintsure is a readiness tool, not an audit, a certification or legal advice.** It checks code only, against our reading of the publicly available text of each framework. Work outside code still has to be done, and a qualified person should review the results before any audit or decision.
|
package/dist/src/agents.d.ts
CHANGED
|
@@ -34,6 +34,9 @@ export declare function callingAgent(env?: Record<string, string | undefined>):
|
|
|
34
34
|
/** Agents to set up: the ones named, or the ones whose folder exists, with Claude Code as the default. */
|
|
35
35
|
export declare function pick(root: string, names?: string[]): Promise<Agent[] | string>;
|
|
36
36
|
export declare function setup(root: string, agents: Agent[], apply: boolean, scope?: string): Promise<number>;
|
|
37
|
+
/** Agents whose Lintsure MCP entry names another version than this CLI, as "Name (version)". Reads this project's
|
|
38
|
+
* files and the entries made for every project in the user's own agent settings. Never changes a file. */
|
|
39
|
+
export declare function staleMcp(root: string, home?: string): Promise<string[]>;
|
|
37
40
|
/** Readiness check. Never prints secret values. Exit 2 only when the config has problems a scan would refuse. */
|
|
38
41
|
export declare function status(root: string): Promise<number>;
|
|
39
42
|
/** Takes Lintsure's own entry back out, leaving everything else in the file as it is now (later edits included).
|
package/dist/src/agents.js
CHANGED
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
// downloaded or sent; the agent itself starts the server later with npx.
|
|
4
4
|
import { access, chmod, copyFile, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
5
5
|
import { constants } from "node:fs";
|
|
6
|
+
import { homedir } from "node:os";
|
|
6
7
|
import { dirname, join } from "node:path";
|
|
7
8
|
import { RULES_VERSION, readConfig } from "@lintsure/core";
|
|
8
9
|
import { installSkills, skills } from "./skills.js";
|
|
9
10
|
/** Project-level MCP config files. `marker` is the folder that shows the project uses that agent. */
|
|
10
11
|
export const AGENTS = [
|
|
11
12
|
{ id: "claude", name: "Claude Code", file: ".mcp.json", key: "mcpServers", marker: ".claude" },
|
|
12
|
-
|
|
13
|
+
// Grok Build reads the same .mcp.json as Claude Code, so it shares that entry.
|
|
14
|
+
{ id: "grok", name: "Grok Build", file: ".mcp.json", key: "mcpServers", marker: ".grok" },
|
|
13
15
|
{ id: "vscode", name: "VS Code (Copilot)", file: ".vscode/mcp.json", key: "servers", marker: ".vscode" },
|
|
14
16
|
{ id: "gemini", name: "Gemini CLI", file: ".gemini/settings.json", key: "mcpServers", marker: ".gemini" },
|
|
15
17
|
// Codex keeps its config as TOML, one table per server. It reads a project's file only for projects marked as trusted.
|
|
@@ -65,19 +67,21 @@ export async function detected(root) {
|
|
|
65
67
|
export const CONNECT_NOTE = "Connecting adds one entry to the agent's config file in this project. It tells the agent how to start\nLintsure, so the agent can check code and explain findings itself. Installing the lintsure command does not\ndo this: an agent only knows Lintsure once it is connected.";
|
|
66
68
|
/** The agent running this command, from the environment it sets, so setup connects the one that asked. */
|
|
67
69
|
export function callingAgent(env = process.env) {
|
|
68
|
-
const id = env.CLAUDECODE ? "claude" : env.GEMINI_CLI ? "gemini" : env.
|
|
70
|
+
const id = env.CLAUDECODE ? "claude" : env.GEMINI_CLI ? "gemini" : env.GROK_SESSION_ID || env.GROK_WORKSPACE_ROOT ? "grok" : Object.keys(env).some((k) => k.startsWith("CODEX_")) ? "codex" : undefined;
|
|
69
71
|
return AGENTS.find((a) => a.id === id);
|
|
70
72
|
}
|
|
73
|
+
/** One step per config file: Claude Code and Grok Build share .mcp.json, so it is written once. */
|
|
74
|
+
const oneEach = (list) => list.filter((a, i) => list.findIndex((b) => b.file === a.file) === i);
|
|
71
75
|
/** Agents to set up: the ones named, or the ones whose folder exists, with Claude Code as the default. */
|
|
72
76
|
export async function pick(root, names) {
|
|
73
77
|
if (names) {
|
|
74
78
|
const bad = names.filter((n) => !AGENTS.some((a) => a.id === n));
|
|
75
|
-
return bad.length ? `Unknown agent: ${bad.join(", ")}. Use ${AGENTS.map((a) => a.id).join(", ")}.` : AGENTS.filter((a) => names.includes(a.id));
|
|
79
|
+
return bad.length ? `Unknown agent: ${bad.join(", ")}. Use ${AGENTS.map((a) => a.id).join(", ")}.` : oneEach(AGENTS.filter((a) => names.includes(a.id)));
|
|
76
80
|
}
|
|
77
81
|
const found = await detected(root), me = callingAgent();
|
|
78
82
|
if (me && !found.includes(me))
|
|
79
83
|
found.push(me);
|
|
80
|
-
return found.length ? found : [AGENTS[0]];
|
|
84
|
+
return found.length ? oneEach(found) : [AGENTS[0]];
|
|
81
85
|
}
|
|
82
86
|
export async function setup(root, agents, apply, scope = "") {
|
|
83
87
|
const plans = await Promise.all(agents.map((a) => plan(root, a)));
|
|
@@ -134,6 +138,31 @@ export async function setup(root, agents, apply, scope = "") {
|
|
|
134
138
|
console.log("For guards that run while the agent works, add the plugin: lintsure plugin");
|
|
135
139
|
return 0;
|
|
136
140
|
}
|
|
141
|
+
/** Agents whose Lintsure MCP entry names another version than this CLI, as "Name (version)". Reads this project's
|
|
142
|
+
* files and the entries made for every project in the user's own agent settings. Never changes a file. */
|
|
143
|
+
export async function staleMcp(root, home = homedir()) {
|
|
144
|
+
const read = (p) => readFile(p, "utf8").catch(() => "");
|
|
145
|
+
const old = (text) => { const v = /@lintsure\/mcp@([\w.-]+)/.exec(text)?.[1]; return v && v !== RULES_VERSION ? v : null; };
|
|
146
|
+
const out = [];
|
|
147
|
+
for (const a of AGENTS) {
|
|
148
|
+
const v = old(await read(join(root, a.file)));
|
|
149
|
+
if (v)
|
|
150
|
+
out.push(`${a.name} (${v})`);
|
|
151
|
+
}
|
|
152
|
+
// Claude Code keeps its own entry at the top of ~/.claude.json, next to per-project ones that are not ours to judge.
|
|
153
|
+
let claude = "";
|
|
154
|
+
try {
|
|
155
|
+
claude = JSON.stringify(JSON.parse(await read(join(home, ".claude.json"))).mcpServers?.lintsure ?? "");
|
|
156
|
+
}
|
|
157
|
+
catch { /* no file, or not JSON */ }
|
|
158
|
+
const mine = [["Claude Code", claude], ["Gemini CLI", await read(join(home, ".gemini/settings.json"))], ["Codex", await read(join(home, ".codex/config.toml"))]];
|
|
159
|
+
for (const [name, text] of mine) {
|
|
160
|
+
const v = old(text);
|
|
161
|
+
if (v)
|
|
162
|
+
out.push(`${name}, set up for every project (${v})`);
|
|
163
|
+
}
|
|
164
|
+
return out;
|
|
165
|
+
}
|
|
137
166
|
/** Readiness check. Never prints secret values. Exit 2 only when the config has problems a scan would refuse. */
|
|
138
167
|
export async function status(root) {
|
|
139
168
|
let todo = 0;
|
|
@@ -153,7 +182,7 @@ export async function status(root) {
|
|
|
153
182
|
if (!used)
|
|
154
183
|
continue;
|
|
155
184
|
const p = await plan(root, a);
|
|
156
|
-
line(p.skip === "already set up", `${a.name}: Lintsure MCP server in ${a.file}`, p.skip && p.skip !== "already set up" ? p.skip :
|
|
185
|
+
line(p.skip === "already set up", `${a.name}: Lintsure MCP server in ${a.file}`, p.skip && p.skip !== "already set up" ? p.skip : `${p.existed && p.text?.includes("lintsure") ? "Missing, or from another Lintsure version. " : ""}Run: lintsure setup --agents ${a.id}`);
|
|
157
186
|
}
|
|
158
187
|
// Skills: are the ones in this project the ones this version ships? An older or edited copy teaches the agent old habits.
|
|
159
188
|
const steps = await installSkills(root, skills(), false), here = steps.filter((s) => s.state !== "add"), stale = here.filter((s) => s.state === "update");
|
package/dist/src/index.js
CHANGED
|
@@ -8,12 +8,12 @@ import { homedir } from "node:os";
|
|
|
8
8
|
import { access, copyFile, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
9
9
|
import { basename, dirname, join, resolve } from "node:path";
|
|
10
10
|
import { createInterface } from "node:readline/promises";
|
|
11
|
-
import { AGENTS, CONNECT_NOTE, MANUAL, callingAgent, detected, status, pick, plan, setup, undo } from "./agents.js";
|
|
11
|
+
import { AGENTS, CONNECT_NOTE, MANUAL, callingAgent, detected, status, pick, plan, setup, undo, staleMcp } from "./agents.js";
|
|
12
12
|
import { parseActivity, toOtlp } from "./otel.js";
|
|
13
13
|
import { sendRun } from "./send.js";
|
|
14
|
-
import { ALL_FRAMEWORKS, BASELINE_FILE, DISCLAIMER, RULES_VERSION, classify, isHygiene, isNonShipping, isOpen, nextSteps, readConfig, scan, toAssessmentHtml, toBaseline, toMarkdown, toSarif } from "@lintsure/core";
|
|
15
|
-
import { choose, chooseMany } from "./menu.js";
|
|
16
|
-
import { installSkills, removeSkills, skillFolders, skills } from "./skills.js";
|
|
14
|
+
import { ALL_FRAMEWORKS, BASELINE_FILE, DISCLAIMER, QUESTIONS, RULES_VERSION, classify, classifyAnswer, explainFramework, explainRule, getKnowledge, planAnswer, rules, isHygiene, isNonShipping, isOpen, nextSteps, readConfig, scan, toAssessmentHtml, toBaseline, toMarkdown, toSarif } from "@lintsure/core";
|
|
15
|
+
import { choose, chooseMany, vis } from "./menu.js";
|
|
16
|
+
import { installSkills, recordSkills, removeSkills, skillFolders, skills } from "./skills.js";
|
|
17
17
|
import { advisories, pinned } from "./deps.js";
|
|
18
18
|
import { GUARD_AGENTS, PLUGIN_TAG, claudeCli, installGuards, pluginHome, planGuards, removeGuards } from "./plugin.js";
|
|
19
19
|
// The old Windows console can't draw block, line or diamond characters reliably, so it gets plain ones.
|
|
@@ -129,6 +129,7 @@ const START = [
|
|
|
129
129
|
{ label: "Connect your coding agent", run: ["setup"] },
|
|
130
130
|
{ label: "Give your agent skills", run: ["skills"] },
|
|
131
131
|
{ label: "Add the Lintsure plugin", run: ["plugin"] },
|
|
132
|
+
{ label: "Which standards apply to me?", run: ["classify"] },
|
|
132
133
|
{ label: "Is everything set up?", run: ["status"] },
|
|
133
134
|
{ label: "Every command and option", run: ["--help"] },
|
|
134
135
|
{ label: "Quit", run: null },
|
|
@@ -167,7 +168,7 @@ async function offer(rows, color) {
|
|
|
167
168
|
return main(run);
|
|
168
169
|
}
|
|
169
170
|
}
|
|
170
|
-
const COMMANDS = ["scan", "baseline", "init", "info", "setup", "skills", "plugin", "hook", "fix", "deps", "history", "status", "export"];
|
|
171
|
+
const COMMANDS = ["scan", "baseline", "init", "info", "setup", "skills", "plugin", "hook", "fix", "deps", "history", "status", "export", "explain", "classify", "plan"];
|
|
171
172
|
/** The command someone most likely meant: the same word without dashes, or one within two typing slips. Pure. */
|
|
172
173
|
function nearest(word) {
|
|
173
174
|
const slips = (a, b) => {
|
|
@@ -191,12 +192,13 @@ lintsure setup [path] Add the Lintsure MCP server to this project's agent con
|
|
|
191
192
|
(with no path it asks: --everywhere for every project on this
|
|
192
193
|
machine, --here for this folder;
|
|
193
194
|
shows the change; --yes writes it; --undo takes it out;
|
|
194
|
-
--agents claude,
|
|
195
|
+
--agents claude,grok,vscode,gemini,codex;
|
|
195
196
|
--manual for an agent set up in its own settings)
|
|
196
197
|
lintsure skills [path] Add Lintsure's skills to this project: short instruction files that
|
|
197
198
|
tell your agent when to check code and how to handle findings
|
|
198
199
|
(at a terminal you pick which; --yes adds all; --only a,b;
|
|
199
|
-
--undo takes them out
|
|
200
|
+
--undo takes them out; --record saves a fingerprint of every
|
|
201
|
+
skill file, so a scan reports one that changes later)
|
|
200
202
|
lintsure fix [path] [F-001 ...] Apply the change for findings whose rule knows the exact one
|
|
201
203
|
(shows it first; --all includes held-back findings; --yes writes it,
|
|
202
204
|
backs the file up, scans again,
|
|
@@ -205,13 +207,17 @@ lintsure fix [path] [F-001 ...] Apply the change for findings whose rule knows
|
|
|
205
207
|
lintsure deps [path] Look up the project's pinned packages for known vulnerabilities.
|
|
206
208
|
The only command that uses the network: it says what it will send
|
|
207
209
|
(package names and versions, never code) and sends it with --yes
|
|
210
|
+
lintsure explain <id> A rule or a framework in plain words, for example: lintsure explain pii.logged
|
|
211
|
+
lintsure plan "<feature>" The checks a feature is likely to meet, before you write it
|
|
212
|
+
lintsure classify [answers] Which frameworks may apply. Alone, it lists the questions.
|
|
213
|
+
Answer like this: lintsure classify euUsers=yes usesAI=no
|
|
208
214
|
lintsure history [path] List the records saved with scan --save-record, oldest first
|
|
209
215
|
lintsure hook [path] Check the lines you commit: adds a git pre-commit hook that runs
|
|
210
216
|
lintsure scan --staged --fail-on gap (shows it first; --yes writes it;
|
|
211
217
|
--undo removes it; an existing hook of your own is left alone)
|
|
212
218
|
lintsure plugin [path] Install the guards that run while your agent works: the full plugin
|
|
213
|
-
for Claude Code, and hooks files for
|
|
214
|
-
(shows the plan first; --agents claude,
|
|
219
|
+
for Claude Code and Grok Build, and hooks files for Codex and Gemini CLI
|
|
220
|
+
(shows the plan first; --agents claude,grok,codex,gemini;
|
|
215
221
|
--yes installs; --undo takes them out)
|
|
216
222
|
lintsure status [path] Check that this project is ready: Node, config, rules, agents
|
|
217
223
|
lintsure export --otlp-json [path] Write .lintsure/activity.jsonl as an OpenTelemetry
|
|
@@ -243,6 +249,19 @@ scan options:
|
|
|
243
249
|
--save-record Also save this run's readiness check record to
|
|
244
250
|
.lintsure/records/<id>.json, building a dated history (no code inside)
|
|
245
251
|
|
|
252
|
+
every command:
|
|
253
|
+
--help This text
|
|
254
|
+
--version, -v The installed version
|
|
255
|
+
Exit codes 0 done. 1 --fail-on found something, or a step failed. 2 the command
|
|
256
|
+
or one of its options was wrong
|
|
257
|
+
NO_COLOR=1 Turns colour off
|
|
258
|
+
LINTSURE_API_KEY, LINTSURE_URL Read only by scan --send
|
|
259
|
+
|
|
260
|
+
set up once:
|
|
261
|
+
setup, skills, plugin and hook each write files that stay. You don't turn Lintsure on
|
|
262
|
+
again for a new session. Run lintsure status to see what is in place, and run
|
|
263
|
+
lintsure setup again after you update Lintsure, so your agent gets the new rules.
|
|
264
|
+
|
|
246
265
|
baseline:
|
|
247
266
|
Saves the current open findings to .lintsure/baseline.json in the scanned folder.
|
|
248
267
|
Later scans show what is new, fixed or unchanged. The file holds rule ids, file
|
|
@@ -275,7 +294,7 @@ export function parseDiff(text) {
|
|
|
275
294
|
}
|
|
276
295
|
return out;
|
|
277
296
|
}
|
|
278
|
-
const FRAMEWORK_NAMES = { "owasp-top10": "OWASP Top 10", "cwe-top25": "CWE Top 25", gdpr: "GDPR", "eu-ai-act": "EU AI Act", "owasp-llm": "OWASP Top 10 for LLM apps", "owasp-ast": "OWASP Agentic Skills Top 10", "owasp-api": "OWASP API Security Top 10", cra: "EU Cyber Resilience Act" };
|
|
297
|
+
const FRAMEWORK_NAMES = { "owasp-agentic": "OWASP Top 10 for Agentic Applications", "owasp-top10": "OWASP Top 10", "cwe-top25": "CWE Top 25", gdpr: "GDPR", "eu-ai-act": "EU AI Act", "owasp-llm": "OWASP Top 10 for LLM apps", "owasp-ast": "OWASP Agentic Skills Top 10", "owasp-api": "OWASP API Security Top 10", cra: "EU Cyber Resilience Act" };
|
|
279
298
|
/** First-run setup: three questions, saved once, never asked in CI. */
|
|
280
299
|
async function init(path) {
|
|
281
300
|
const file = join(path, "lintsure.config.yaml");
|
|
@@ -299,7 +318,7 @@ async function init(path) {
|
|
|
299
318
|
}
|
|
300
319
|
};
|
|
301
320
|
console.log("Lintsure setup: 3 questions. Press Enter for the first answer.");
|
|
302
|
-
const what = await pick("1. What should Lintsure check?", ["Security only (OWASP Top 10, CWE Top 25)", "Security and privacy (adds GDPR)", "Everything (all
|
|
321
|
+
const what = await pick("1. What should Lintsure check?", ["Security only (OWASP Top 10, CWE Top 25)", "Security and privacy (adds GDPR)", "Everything (all nine frameworks)", "Let me pick"]);
|
|
303
322
|
let chosen = what === 1 ? ["owasp-top10", "cwe-top25"] : what === 2 ? ["owasp-top10", "cwe-top25", "gdpr"] : [...ALL_FRAMEWORKS];
|
|
304
323
|
if (what === 4) {
|
|
305
324
|
console.log("\nType the numbers you want, separated by commas, or press Enter for all:");
|
|
@@ -451,7 +470,7 @@ async function main(argv) {
|
|
|
451
470
|
return 0;
|
|
452
471
|
}
|
|
453
472
|
for (const f of exact)
|
|
454
|
-
console.log(`${f.id} ${f.title}\n ${f.file}:${f.patch.line}\n${f.patch.old != null ? ` - ${f.patch.old.trim()}\n` : ""}${f.patch.text.replace(/\n$/, "").split("\n").map((t) => ` + ${t.trim()}`).join("\n")}\n`);
|
|
473
|
+
console.log(`${f.id} ${f.title}\n ${vis(f.file)}:${f.patch.line}\n${f.patch.old != null ? ` - ${vis(f.patch.old.trim())}\n` : ""}${f.patch.text.replace(/\n$/, "").split("\n").map((t) => ` + ${vis(t.trim())}`).join("\n")}\n`);
|
|
455
474
|
if (!raw.includes("--yes")) {
|
|
456
475
|
console.log(`Nothing changed yet. To apply ${exact.length === 1 ? "it" : `these ${exact.length}`}, run: lintsure fix${ids.length ? " " + ids.join(" ") : ""}${raw.includes("--all") ? " --all" : ""} --yes\nEach file is backed up first (<file>.lintsure-backup).${rest ? `\n${rest} other finding${rest === 1 ? " needs" : "s need"} a person or a coding agent.` : ""}`);
|
|
457
476
|
if (viaMenu && process.stdin.isTTY && process.stdout.isTTY) {
|
|
@@ -660,7 +679,7 @@ async function main(argv) {
|
|
|
660
679
|
showFolder("Project", root);
|
|
661
680
|
if (picking) {
|
|
662
681
|
step("Which agents should get the guards?");
|
|
663
|
-
const picked = await chooseMany(GUARD_AGENTS.map((a) => `${a.name.padEnd(14)}${a.file ? `guards through ${a.file}` : "the full plugin, through Claude Code's own installer"}${used.includes(a) ? " used in this project" : ""}`), (n) => (n ? `Install for the ${n} selected` : "Install (none selected yet)"), " Up and Down to move, Enter to select or de-select, a for all, q to quit", !process.env.NO_COLOR && process.env.TERM !== "dumb");
|
|
682
|
+
const picked = await chooseMany(GUARD_AGENTS.map((a) => `${a.name.padEnd(14)}${a.manual ? "the Claude Code plugin, which it loads itself" : a.file ? `guards through ${a.file}` : "the full plugin, through Claude Code's own installer"}${used.includes(a) ? " used in this project" : ""}`), (n) => (n ? `Install for the ${n} selected` : "Install (none selected yet)"), " Up and Down to move, Enter to select or de-select, a for all, q to quit", !process.env.NO_COLOR && process.env.TERM !== "dumb");
|
|
664
683
|
if (!picked?.length) {
|
|
665
684
|
console.log("Nothing installed. Come back any time: lintsure plugin");
|
|
666
685
|
return 0;
|
|
@@ -679,23 +698,28 @@ async function main(argv) {
|
|
|
679
698
|
// Before the download there is nothing to read the hooks from, so the preview names the files and the source.
|
|
680
699
|
const fetched = existsSync(join(dir, "hooks"));
|
|
681
700
|
if (!apply) {
|
|
682
|
-
const lines = fetched ? (await planGuards(root, agents, dir)).map((s) => `${s.agent.name}: ${s.note}`) : agents.map((a) => `${a.name}: ${a.file ? `write the guards' hooks to ${a.file}` : "claude plugin marketplace add lintsure/plugin, then claude plugin install lintsure@lintsure"}`);
|
|
701
|
+
const lines = fetched ? (await planGuards(root, agents, dir)).map((s) => `${s.agent.name}: ${s.note}`) : agents.map((a) => `${a.name}: ${a.manual ? a.manual : a.file ? `write the guards' hooks to ${a.file}` : "claude plugin marketplace add lintsure/plugin, then claude plugin install lintsure@lintsure"}`);
|
|
683
702
|
step(`Would install the guards for ${agents.length} agent${agents.length === 1 ? "" : "s"}`, [...lines, ...(needsFiles && !fetched ? [tint("2", `Downloads the plugin ${PLUGIN_TAG} from github.com/lintsure/plugin into your home folder first.`)] : [])]);
|
|
684
703
|
console.log(`Nothing installed yet. To apply, run: lintsure plugin${names ? ` --agents ${names.join(",")}` : ""} --yes`);
|
|
685
704
|
return 0;
|
|
686
705
|
}
|
|
687
706
|
const said = await installGuards(root, await planGuards(root, agents, dir));
|
|
688
707
|
step(tint("32", "Done!"), said.flatMap((s) => s.split("\n")));
|
|
689
|
-
console.log("The guards for
|
|
708
|
+
console.log("The guards for Grok Build, Codex and Gemini CLI are new: tell us if one misbehaves. Take them out with: lintsure plugin --undo");
|
|
690
709
|
return 0;
|
|
691
710
|
}
|
|
692
711
|
if (cmd === "skills") {
|
|
693
712
|
const root = resolve(raw.find((a, i) => !a.startsWith("--") && raw[i - 1] !== "--only") ?? ".");
|
|
694
|
-
const bad = raw.find((a) => a.startsWith("--") && !["--yes", "--undo", "--only", "--here"].includes(a));
|
|
713
|
+
const bad = raw.find((a) => a.startsWith("--") && !["--yes", "--undo", "--only", "--here", "--record"].includes(a));
|
|
695
714
|
if (bad) {
|
|
696
|
-
console.error(`Unknown option: ${bad}. Use --yes, --only <names>, --here or --undo.`);
|
|
715
|
+
console.error(`Unknown option: ${bad}. Use --yes, --only <names>, --here, --record or --undo.`);
|
|
697
716
|
return 2;
|
|
698
717
|
}
|
|
718
|
+
if (raw.includes("--record")) {
|
|
719
|
+
const n = await recordSkills(root);
|
|
720
|
+
console.log(n ? `Recorded ${n} skill file${n === 1 ? "" : "s"} in .lintsure/skills.json. A scan now reports any that change or appear after this. Commit the file so your team shares it.` : "No skill files found in this project, so there is nothing to record yet.");
|
|
721
|
+
return 0;
|
|
722
|
+
}
|
|
699
723
|
const lost = wrongPlace("skills", raw, "--only");
|
|
700
724
|
if (lost) {
|
|
701
725
|
console.error(lost);
|
|
@@ -721,7 +745,7 @@ async function main(argv) {
|
|
|
721
745
|
console.log("");
|
|
722
746
|
step(tint(BADGE, " Lintsure skills "), ["A skill is a short instruction file. It tells your coding agent when to use Lintsure and what", "to do with what it finds. Connecting gives the agent the tools; skills give it the habit."]);
|
|
723
747
|
showFolder("Project", root);
|
|
724
|
-
step("Where they go", folders.map((f) => `${tint(BLUE, f)} ${tint("2", f.startsWith(".agents") ? "read by Codex,
|
|
748
|
+
step("Where they go", folders.map((f) => `${tint(BLUE, f)} ${tint("2", f.startsWith(".agents") ? "read by Codex, Grok Build, Gemini CLI and many others" : "read by Claude Code")}`));
|
|
725
749
|
if (picking) {
|
|
726
750
|
step(`Found ${all.length} skills. Which do you want?`);
|
|
727
751
|
const width = Math.max(...all.map((s) => s.name.length)) + 2;
|
|
@@ -741,6 +765,7 @@ async function main(argv) {
|
|
|
741
765
|
console.log(`Nothing written yet. To apply, run: lintsure skills ${names ? `--only ${names.join(",")} ` : ""}--yes`);
|
|
742
766
|
return 0;
|
|
743
767
|
}
|
|
768
|
+
await recordSkills(root, true);
|
|
744
769
|
step(tint("32", `Done! Installed ${chosen.length} skill${chosen.length === 1 ? "" : "s"}`), lines);
|
|
745
770
|
console.log("Restart the agent so it reads them. Take them out any time with: lintsure skills --undo");
|
|
746
771
|
// Renamed in 0.3.16: an older install still has the folder under its first name.
|
|
@@ -774,7 +799,8 @@ async function main(argv) {
|
|
|
774
799
|
return 0;
|
|
775
800
|
}
|
|
776
801
|
if (everywhere) {
|
|
777
|
-
// The user's own agent settings, in their home folder.
|
|
802
|
+
// The user's own agent settings, in their home folder. Gemini CLI and Codex keep them at the same path as in a project;
|
|
803
|
+
// Grok Build reads Claude Code's own settings.
|
|
778
804
|
const home = homedir(), i = raw.indexOf("--agents"), apply = raw.includes("--yes"), undoIt = raw.includes("--undo");
|
|
779
805
|
const picked = i >= 0 ? await pick(home, raw[i + 1]?.split(",").map((s) => s.trim())) : AGENTS.filter((a) => existsSync(join(home, a.marker)));
|
|
780
806
|
if (typeof picked === "string") {
|
|
@@ -790,6 +816,8 @@ async function main(argv) {
|
|
|
790
816
|
for (const a of picked) {
|
|
791
817
|
if (a.id === "vscode")
|
|
792
818
|
console.log(`- ${a.name}: its own settings are set from inside VS Code. Run "MCP: Open User Configuration" there and add the entry shown by: lintsure setup --manual`);
|
|
819
|
+
if (a.id === "grok")
|
|
820
|
+
console.log(`- ${a.name}: it reads Claude Code's settings, so connecting Claude Code for every project covers it. Without Claude Code, add the server in Grok Build under /mcps (values: lintsure setup --manual)`);
|
|
793
821
|
if (a.id !== "claude")
|
|
794
822
|
continue;
|
|
795
823
|
if (!apply && !undoIt) {
|
|
@@ -804,7 +832,7 @@ async function main(argv) {
|
|
|
804
832
|
console.log(`- ${a.name}: the claude command didn't do it. Run it yourself:\n claude ${(undoIt ? ["mcp", "remove", "--scope", "user", "lintsure"] : add).join(" ")}`);
|
|
805
833
|
}
|
|
806
834
|
}
|
|
807
|
-
const files = picked.filter((a) => ["
|
|
835
|
+
const files = picked.filter((a) => ["gemini", "codex"].includes(a.id));
|
|
808
836
|
if (undoIt)
|
|
809
837
|
return undo(home, files);
|
|
810
838
|
if (files.length)
|
|
@@ -854,6 +882,52 @@ async function main(argv) {
|
|
|
854
882
|
}
|
|
855
883
|
return code;
|
|
856
884
|
}
|
|
885
|
+
// The MCP server's tools as plain commands, for an agent that has a terminal and no MCP. Same text as the tools.
|
|
886
|
+
if (cmd === "explain" || cmd === "plan" || cmd === "classify") {
|
|
887
|
+
const arg = raw.filter((a) => !a.startsWith("--")).join(" ").trim();
|
|
888
|
+
let text;
|
|
889
|
+
if (cmd === "explain") {
|
|
890
|
+
const known = getKnowledge(arg) ? explainFramework(arg) : rules.some((r) => r.id === arg) ? explainRule(arg) : null;
|
|
891
|
+
if (!known) {
|
|
892
|
+
console.error(arg ? `No rule or framework named ${arg}. Rule ids look like "pii.logged"; frameworks: ${ALL_FRAMEWORKS.join(", ")}.` : "Use: lintsure explain <rule id or framework>, for example lintsure explain pii.logged");
|
|
893
|
+
return 2;
|
|
894
|
+
}
|
|
895
|
+
text = known;
|
|
896
|
+
}
|
|
897
|
+
else if (cmd === "plan") {
|
|
898
|
+
if (arg.length < 3) {
|
|
899
|
+
console.error('Use: lintsure plan "<the feature in plain words>", for example lintsure plan "users upload a profile picture"');
|
|
900
|
+
return 2;
|
|
901
|
+
}
|
|
902
|
+
text = planAnswer(arg.slice(0, 2000));
|
|
903
|
+
}
|
|
904
|
+
else {
|
|
905
|
+
// Answers as one JSON object, the same names the MCP tool takes. With none, the questions come back.
|
|
906
|
+
let answers = {};
|
|
907
|
+
// Pairs first: Windows PowerShell strips the double quotes from a JSON argument before it reaches Node.
|
|
908
|
+
if (arg.startsWith("{")) {
|
|
909
|
+
try {
|
|
910
|
+
answers = JSON.parse(arg);
|
|
911
|
+
}
|
|
912
|
+
catch {
|
|
913
|
+
answers = [];
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
else
|
|
917
|
+
for (const pair of arg.split(/[\s,]+/).filter(Boolean)) {
|
|
918
|
+
const [q, v = ""] = pair.split("=");
|
|
919
|
+
answers[q] = /^(true|yes)$/i.test(v) ? true : /^(false|no)$/i.test(v) ? false : v;
|
|
920
|
+
}
|
|
921
|
+
const bad = Array.isArray(answers) || typeof answers !== "object" || answers === null ? "not an object" : Object.entries(answers).find(([q, v]) => !(q in QUESTIONS) || (q === "decisionArea" ? typeof v !== "string" : typeof v !== "boolean"))?.[0];
|
|
922
|
+
if (bad) {
|
|
923
|
+
console.error(`Use: lintsure classify euUsers=yes usesAI=no. Answers are yes or no (decisionArea is a word). One JSON object works too. Problem: ${bad}. Run lintsure classify alone to see the questions.`);
|
|
924
|
+
return 2;
|
|
925
|
+
}
|
|
926
|
+
text = classifyAnswer(answers);
|
|
927
|
+
}
|
|
928
|
+
console.log(`${text}\n\n---\n${DISCLAIMER}`);
|
|
929
|
+
return 0;
|
|
930
|
+
}
|
|
857
931
|
if (cmd === "init" || cmd === "info")
|
|
858
932
|
return (cmd === "init" ? init : info)(resolve(raw.find((a) => !a.startsWith("--")) ?? "."));
|
|
859
933
|
// The start screen is for a person at a terminal. Piped output and CI logs stay exactly as they were.
|
|
@@ -1073,7 +1147,7 @@ async function main(argv) {
|
|
|
1073
1147
|
for (const f of items) {
|
|
1074
1148
|
if (f.file !== file) {
|
|
1075
1149
|
file = f.file;
|
|
1076
|
-
console.log(`\n ${paint("38;2;98;137;254", file)}`);
|
|
1150
|
+
console.log(`\n ${paint("38;2;98;137;254", vis(file))}`);
|
|
1077
1151
|
}
|
|
1078
1152
|
const status = f.accepted && !f.accepted.expired ? "accepted" : f.status;
|
|
1079
1153
|
const badge = status === "gap" ? paint("1;31", "GAP ") : status === "partial" ? paint("33", "PARTIAL ") : paint("2", "ACCEPTED");
|
|
@@ -1090,7 +1164,7 @@ async function main(argv) {
|
|
|
1090
1164
|
const fold = (t, pad) => t.replace(new RegExp(`(.{1,${width - pad.length - 2}})(\\s+|$)`, "g"), `$1\n${pad}`).trimEnd();
|
|
1091
1165
|
const reportFile = resolve("lintsure-report.md");
|
|
1092
1166
|
// A request a person can paste into any coding agent, connected or not: it names the finding and where the proposal is.
|
|
1093
|
-
const request = (fs) => `Fix ${fs.length === 1 ? "this Lintsure finding" : "these Lintsure findings, one at a time"}: ${fs.map((f) => `${f.id} "${f.title}" at ${f.file}:${f.line}`).join("; ")}. The proposal for ${fs.length === 1 ? "it" : "each"} is in ${reportFile}. Show me ${fs.length === 1 ? "the" : "each"} change before you apply it, then check the file with Lintsure again.`;
|
|
1167
|
+
const request = (fs) => `Fix ${fs.length === 1 ? "this Lintsure finding" : "these Lintsure findings, one at a time"}: ${fs.map((f) => `${f.id} "${f.title}" at ${vis(f.file)}:${f.line}`).join("; ")}. The proposal for ${fs.length === 1 ? "it" : "each"} is in ${reportFile}. Show me ${fs.length === 1 ? "the" : "each"} change before you apply it, then check the file with Lintsure again.`;
|
|
1094
1168
|
if (pretty) {
|
|
1095
1169
|
// One line that fits the outcome, so the result is clear before any detail. It reports what the rules found and
|
|
1096
1170
|
// never calls a project safe: "nothing found" is said in those words.
|
|
@@ -1106,7 +1180,7 @@ async function main(argv) {
|
|
|
1106
1180
|
group("Repo hygiene: housekeeping, not flaws in the code", listed.filter(isHygiene));
|
|
1107
1181
|
if (first.length) {
|
|
1108
1182
|
console.log(ruled(`Start here (${first.length} of ${inCode.length})`));
|
|
1109
|
-
first.forEach((f, i) => console.log(`\n ${i + 1}. ${f.title}\n ${paint("2", `${f.file}:${f.line}`)}\n ${paint("36", "Fix:")} ${fold(f.fix, " ")}`));
|
|
1183
|
+
first.forEach((f, i) => console.log(`\n ${i + 1}. ${f.title}\n ${paint("2", `${vis(f.file)}:${f.line}`)}\n ${paint("36", "Fix:")} ${fold(f.fix, " ")}`));
|
|
1110
1184
|
if (inCode.length > first.length)
|
|
1111
1185
|
console.log(`\n ${paint("2", `The fix for every finding is in ${resolve("lintsure-report.md")}`)}`);
|
|
1112
1186
|
}
|
|
@@ -1114,12 +1188,18 @@ async function main(argv) {
|
|
|
1114
1188
|
}
|
|
1115
1189
|
else
|
|
1116
1190
|
for (const f of listed)
|
|
1117
|
-
console.log(`${f === listed.find(isHygiene) ? "Repo hygiene (housekeeping, not flaws in the code):\n" : ""}${(f.accepted && !f.accepted.expired ? "accepted" : f.status).padEnd(8)} ${f.file}:${f.line} ${f.title}${f.change === "new" ? " (new)" : ""}`);
|
|
1191
|
+
console.log(`${f === listed.find(isHygiene) ? "Repo hygiene (housekeeping, not flaws in the code):\n" : ""}${(f.accepted && !f.accepted.expired ? "accepted" : f.status).padEnd(8)} ${vis(f.file)}:${f.line} ${f.title}${f.change === "new" ? " (new)" : ""}`);
|
|
1118
1192
|
if (rest.includes("--github"))
|
|
1119
1193
|
for (const f of open) {
|
|
1120
1194
|
const msg = `${f.title}. Proposed change, needs your approval: ${f.proposal.what}`.replace(/%/g, "%25").replace(/\r?\n/g, " ");
|
|
1121
|
-
console.log(`::${f.status === "gap" ? "error" : "warning"} file=${f.file},line=${f.line},title=Lintsure ${f.ruleId}::${msg}`);
|
|
1195
|
+
console.log(`::${f.status === "gap" ? "error" : "warning"} file=${f.file.replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A").replace(/:/g, "%3A").replace(/,/g, "%2C")},line=${f.line},title=Lintsure ${f.ruleId}::${msg}`);
|
|
1122
1196
|
}
|
|
1197
|
+
// Setup is done once, so nothing else would tell the user that the agent still starts an older server.
|
|
1198
|
+
if (pretty) {
|
|
1199
|
+
const old = await staleMcp(path);
|
|
1200
|
+
if (old.length)
|
|
1201
|
+
console.log(`Your agent starts an older Lintsure: ${old.join(", ")}. This is ${RULES_VERSION}. Update it with: lintsure setup --yes${old.some((o) => o.includes("every project")) ? " (and lintsure setup --everywhere --yes)" : ""}`);
|
|
1202
|
+
}
|
|
1123
1203
|
console.log(`Report saved to ${pretty ? resolve("lintsure-report.md") : "lintsure-report.md"}`);
|
|
1124
1204
|
if (rest.includes("--report"))
|
|
1125
1205
|
console.log("Assessment saved to lintsure-assessment.html (open it in a browser to read, print or save as PDF). It is a draft until a qualified person reviews and signs it.");
|
|
@@ -1140,7 +1220,7 @@ async function main(argv) {
|
|
|
1140
1220
|
const showFix = async () => {
|
|
1141
1221
|
const list = [...ranked, ...open.filter(isHygiene)].slice(0, 15);
|
|
1142
1222
|
console.log(`\nWhich finding?${open.length > list.length ? ` (the first ${list.length} of ${open.length}; the rest are in the report)` : ""}`);
|
|
1143
|
-
const pick = await choose([...list.map((f) => `${f.id} ${f.title} ${f.file}:${f.line}`.slice(0, width - 6)), "Back"], HINT, color);
|
|
1223
|
+
const pick = await choose([...list.map((f) => `${f.id} ${f.title} ${vis(f.file)}:${f.line}`.slice(0, width - 6)), "Back"], HINT, color);
|
|
1144
1224
|
if (pick === null || pick >= list.length)
|
|
1145
1225
|
return;
|
|
1146
1226
|
const f = list[pick], row = (name, text) => console.log(` ${paint(GOLD, name.padEnd(8))}${fold(text, " ")}`);
|
package/dist/src/menu.d.ts
CHANGED
|
@@ -13,3 +13,6 @@ export declare function choose(rows: string[], hint: string, color: boolean): Pr
|
|
|
13
13
|
* Under the rows come a row that finishes, named by `finish` from the number picked, and Quit. Resolves with the
|
|
14
14
|
* picked row numbers (it may be empty), or null for Quit, q, Esc or Ctrl+C. Only call this at a terminal. */
|
|
15
15
|
export declare function chooseMany(rows: string[], finish: (picked: number) => string, hint: string, color: boolean): Promise<number[] | null>;
|
|
16
|
+
/** Text from the scanned project (a file name, a line of code) with control characters made visible, so it can't
|
|
17
|
+
* move the cursor, recolour the terminal or start a new line. */
|
|
18
|
+
export declare const vis: (s: string) => string;
|
package/dist/src/menu.js
CHANGED
|
@@ -87,3 +87,6 @@ export function chooseMany(rows, finish, hint, color) {
|
|
|
87
87
|
picked.add(at);
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
|
+
/** Text from the scanned project (a file name, a line of code) with control characters made visible, so it can't
|
|
91
|
+
* move the cursor, recolour the terminal or start a new line. */
|
|
92
|
+
export const vis = (s) => s.replace(/[\x00-\x08\x0a-\x1f\x7f-\x9f]/g, (c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, "0")}`);
|
package/dist/src/plugin.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export declare const PLUGIN_TAG = "v0.3.
|
|
1
|
+
export declare const PLUGIN_TAG = "v0.3.10";
|
|
2
2
|
export interface GuardAgent {
|
|
3
3
|
id: string;
|
|
4
4
|
name: string;
|
|
5
5
|
marker: string;
|
|
6
6
|
file?: string;
|
|
7
7
|
from?: string;
|
|
8
|
+
manual?: string;
|
|
8
9
|
}
|
|
9
10
|
export declare const GUARD_AGENTS: GuardAgent[];
|
|
10
11
|
/** The folder that holds the plugin's hooks, fetching it once per version. LINTSURE_PLUGIN_SRC names a local copy
|
package/dist/src/plugin.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// (Drift, Danger, Loop and Threat Guard, and one check at the end of a task), which a skill can't do: a skill is only
|
|
3
3
|
// read when the agent decides to read it.
|
|
4
4
|
// Claude Code: its own plugin system does the install, through the `claude` command.
|
|
5
|
-
//
|
|
5
|
+
// Grok Build: it loads the Claude Code plugin itself, so this only says how to add it there.
|
|
6
|
+
// Codex, Gemini CLI: the plugin is fetched once into the user's home folder and a hooks file is written into
|
|
6
7
|
// the project that points at it. An existing hooks file of the user's own is never changed.
|
|
7
8
|
// Getting the plugin is a download from GitHub, so nothing happens until the user has seen the plan and agreed.
|
|
8
9
|
import { execFileSync } from "node:child_process";
|
|
@@ -12,11 +13,11 @@ import { homedir } from "node:os";
|
|
|
12
13
|
import { dirname, join } from "node:path";
|
|
13
14
|
import { writeJson } from "./agents.js";
|
|
14
15
|
// The plugin release that pairs with this engine. Pinned: a moving branch here would be what the supply-chain rules flag.
|
|
15
|
-
export const PLUGIN_TAG = "v0.3.
|
|
16
|
+
export const PLUGIN_TAG = "v0.3.10";
|
|
16
17
|
const REPO = "https://github.com/lintsure/plugin.git";
|
|
17
18
|
export const GUARD_AGENTS = [
|
|
18
19
|
{ id: "claude", name: "Claude Code", marker: ".claude" },
|
|
19
|
-
{ id: "
|
|
20
|
+
{ id: "grok", name: "Grok Build", marker: ".grok", manual: "Grok Build runs the Claude Code plugin as it is. If it is installed for Claude Code, Grok Build already has the guards; if not, open /marketplace in Grok Build, add lintsure/plugin and install Lintsure" },
|
|
20
21
|
{ id: "codex", name: "Codex", marker: ".codex", file: ".codex/hooks.json", from: "codex/hooks.json" },
|
|
21
22
|
{ id: "gemini", name: "Gemini CLI", marker: ".gemini", file: ".gemini/settings.json", from: "gemini/hooks.json" },
|
|
22
23
|
];
|
|
@@ -47,7 +48,7 @@ export function pluginHome(fetchIt) {
|
|
|
47
48
|
export function hooksFor(template, dir) {
|
|
48
49
|
const at = dir.replace(/\\/g, "/");
|
|
49
50
|
const fix = (v) => typeof v === "string"
|
|
50
|
-
? v.replace(/\$\{(CLAUDE_PLUGIN_ROOT|
|
|
51
|
+
? v.replace(/\$\{(CLAUDE_PLUGIN_ROOT|extensionPath)\}/g, at).replace(/^node hooks\//, `node "${at}/hooks/`).replace(/^(node "[^"]*\/hooks\/[\w.-]+)( |$)/, (m, a, b) => (a.endsWith('"') ? m : `${a}"${b}`))
|
|
51
52
|
: Array.isArray(v) ? v.map(fix) : v && typeof v === "object" ? Object.fromEntries(Object.entries(v).map(([k, x]) => [k, fix(x)])) : v;
|
|
52
53
|
return fix(template);
|
|
53
54
|
}
|
|
@@ -55,6 +56,10 @@ export function hooksFor(template, dir) {
|
|
|
55
56
|
export async function planGuards(root, agents, dir) {
|
|
56
57
|
const steps = [];
|
|
57
58
|
for (const a of agents) {
|
|
59
|
+
if (a.manual) {
|
|
60
|
+
steps.push({ agent: a, does: "skip", note: a.manual });
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
58
63
|
if (!a.file) {
|
|
59
64
|
steps.push({ agent: a, does: "claude", note: "claude plugin marketplace add lintsure/plugin, then claude plugin install lintsure@lintsure" });
|
|
60
65
|
continue;
|
|
@@ -136,6 +141,10 @@ export async function removeGuards(root, agents) {
|
|
|
136
141
|
}
|
|
137
142
|
catch { /* nothing recorded */ }
|
|
138
143
|
for (const a of agents) {
|
|
144
|
+
if (a.manual) {
|
|
145
|
+
said.push(`${a.name}: remove it from /plugins in Grok Build (or uninstall it from Claude Code)`);
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
139
148
|
if (!a.file) {
|
|
140
149
|
try {
|
|
141
150
|
claudeCli(["plugin", "uninstall", "lintsure@lintsure"]);
|
package/dist/src/send.js
CHANGED
|
@@ -35,7 +35,7 @@ export async function sendRun(report, path, project) {
|
|
|
35
35
|
const branch = process.env.GITHUB_HEAD_REF || process.env.GITHUB_REF_NAME || git(path, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
36
36
|
const body = runPayload(report, { project: project || basename(path), source: ci ? "ci" : "agent", commit: process.env.GITHUB_SHA || git(path, ["rev-parse", "HEAD"]), branch: branch === "HEAD" ? "" : branch });
|
|
37
37
|
try {
|
|
38
|
-
const r = await fetch(`${api}/api/v1/runs`, { method: "POST", headers: { authorization: `Bearer ${key}`, "content-type": "application/json", "user-agent": `lintsure-cli/${RULES_VERSION}` }, body: JSON.stringify(body), signal: AbortSignal.timeout(15000) });
|
|
38
|
+
const r = await fetch(`${api}/api/v1/runs`, { method: "POST", headers: { authorization: `Bearer ${key}`, "content-type": "application/json", "user-agent": `lintsure-cli/${RULES_VERSION}` }, body: JSON.stringify(body), redirect: "error", signal: AbortSignal.timeout(15000) });
|
|
39
39
|
if (r.status === 401)
|
|
40
40
|
return { ok: false, say: "Lintsure didn't accept that API key. Nothing was sent." };
|
|
41
41
|
if (!r.ok)
|
package/dist/src/skills.d.ts
CHANGED
|
@@ -14,5 +14,9 @@ export type SkillStep = {
|
|
|
14
14
|
/** What installing would do, skill by skill. With `apply` it also does it. A file that differs from ours (an older
|
|
15
15
|
* version, or one the user edited) is kept beside the new one as <file>.lintsure-backup. */
|
|
16
16
|
export declare function installSkills(root: string, chosen: Skill[], apply: boolean): Promise<SkillStep[]>;
|
|
17
|
+
/** Writes the fingerprint of every skill file to .lintsure/skills.json, so a scan can report one that changes later.
|
|
18
|
+
* With `own` it only brings Lintsure's own skills up to date in a record that already exists (after an install),
|
|
19
|
+
* so installing never marks someone else's changed skill as reviewed. Returns how many files the record holds. */
|
|
20
|
+
export declare function recordSkills(root: string, own?: boolean): Promise<number | null>;
|
|
17
21
|
/** Takes Lintsure's skills back out. A file that was edited since is left where it is. Folders left empty are removed. */
|
|
18
22
|
export declare function removeSkills(root: string): Promise<string[]>;
|
package/dist/src/skills.js
CHANGED
|
@@ -5,6 +5,8 @@ import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
|
5
5
|
import { copyFile, mkdir, readFile, readdir, rm, rmdir, writeFile } from "node:fs/promises";
|
|
6
6
|
import { dirname, join } from "node:path";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
|
+
import { relative, sep } from "node:path";
|
|
9
|
+
import { listFiles, parseSkillRecord, SKILL_TREE, skillHash, SKILLS_RECORD } from "@lintsure/core";
|
|
8
10
|
// The build copies the repository's skills folder next to dist, so the published package carries it.
|
|
9
11
|
const SOURCE = fileURLToPath(new URL("../../skills/", import.meta.url));
|
|
10
12
|
// One line a person reads when choosing, in the order a new user needs them. The description inside each skill is
|
|
@@ -53,6 +55,28 @@ export async function installSkills(root, chosen, apply) {
|
|
|
53
55
|
}
|
|
54
56
|
return steps;
|
|
55
57
|
}
|
|
58
|
+
/** Writes the fingerprint of every skill file to .lintsure/skills.json, so a scan can report one that changes later.
|
|
59
|
+
* With `own` it only brings Lintsure's own skills up to date in a record that already exists (after an install),
|
|
60
|
+
* so installing never marks someone else's changed skill as reviewed. Returns how many files the record holds. */
|
|
61
|
+
export async function recordSkills(root, own = false) {
|
|
62
|
+
const path = join(root, SKILLS_RECORD), old = own ? parseSkillRecord(await readFile(path, "utf8").catch(() => null)) : {};
|
|
63
|
+
if (!old)
|
|
64
|
+
return null;
|
|
65
|
+
const mine = new RegExp(`/skills/(${readdirSync(SOURCE).join("|")})/`), files = { ...old };
|
|
66
|
+
for (const abs of await listFiles(root)) {
|
|
67
|
+
const rel = relative(root, abs).split(sep).join("/");
|
|
68
|
+
if (!SKILL_TREE.test(rel) || rel.endsWith(".lintsure-backup") || (own && !mine.test(rel)))
|
|
69
|
+
continue;
|
|
70
|
+
const text = await readFile(abs, "utf8").catch(() => null);
|
|
71
|
+
if (text !== null)
|
|
72
|
+
files[rel] = skillHash(text);
|
|
73
|
+
}
|
|
74
|
+
if (!Object.keys(files).length)
|
|
75
|
+
return 0;
|
|
76
|
+
await mkdir(dirname(path), { recursive: true });
|
|
77
|
+
await writeFile(path, JSON.stringify({ v: 1, files: Object.fromEntries(Object.entries(files).sort(([a], [b]) => a.localeCompare(b))) }, null, 2) + "\n");
|
|
78
|
+
return Object.keys(files).length;
|
|
79
|
+
}
|
|
56
80
|
/** Takes Lintsure's skills back out. A file that was edited since is left where it is. Folders left empty are removed. */
|
|
57
81
|
export async function removeSkills(root) {
|
|
58
82
|
const said = [];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lintsure",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "Keep your AI coding agents on track: checks the code Claude Code,
|
|
3
|
+
"version": "0.3.20",
|
|
4
|
+
"description": "Keep your AI coding agents on track: checks the code Claude Code, Grok Build and Codex write for secrets, open databases and unsafe patterns, mapped to OWASP, GDPR and the EU AI Act. Runs locally. Not an audit or legal advice.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"LICENSE"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@lintsure/core": "0.3.
|
|
17
|
+
"@lintsure/core": "0.3.20"
|
|
18
18
|
},
|
|
19
19
|
"author": "Lintsure <hello@lintsure.com>",
|
|
20
20
|
"homepage": "https://lintsure.com/docs",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"keywords": [
|
|
36
36
|
"ai-agents",
|
|
37
37
|
"claude-code",
|
|
38
|
-
"
|
|
38
|
+
"grok-build",
|
|
39
39
|
"codex",
|
|
40
40
|
"coding-agent",
|
|
41
41
|
"guardrails",
|