lintsure 0.3.19 → 0.3.21

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 CHANGED
@@ -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.
@@ -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).
@@ -3,6 +3,7 @@
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";
@@ -137,6 +138,31 @@ export async function setup(root, agents, apply, scope = "") {
137
138
  console.log("For guards that run while the agent works, add the plugin: lintsure plugin");
138
139
  return 0;
139
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
+ }
140
166
  /** Readiness check. Never prints secret values. Exit 2 only when the config has problems a scan would refuse. */
141
167
  export async function status(root) {
142
168
  let todo = 0;
@@ -156,7 +182,7 @@ export async function status(root) {
156
182
  if (!used)
157
183
  continue;
158
184
  const p = await plan(root, a);
159
- line(p.skip === "already set up", `${a.name}: Lintsure MCP server in ${a.file}`, p.skip && p.skip !== "already set up" ? p.skip : `Run: lintsure setup --agents ${a.id}`);
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}`);
160
186
  }
161
187
  // Skills: are the ones in this project the ones this version ships? An older or edited copy teaches the agent old habits.
162
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) => {
@@ -196,7 +197,8 @@ lintsure setup [path] Add the Lintsure MCP server to this project's agent con
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,6 +207,10 @@ 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;
@@ -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 eight frameworks)", "Let me pick"]);
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) {
@@ -691,11 +710,16 @@ async function main(argv) {
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);
@@ -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.
@@ -857,6 +882,52 @@ async function main(argv) {
857
882
  }
858
883
  return code;
859
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
+ }
860
931
  if (cmd === "init" || cmd === "info")
861
932
  return (cmd === "init" ? init : info)(resolve(raw.find((a) => !a.startsWith("--")) ?? "."));
862
933
  // The start screen is for a person at a terminal. Piped output and CI logs stay exactly as they were.
@@ -1076,7 +1147,7 @@ async function main(argv) {
1076
1147
  for (const f of items) {
1077
1148
  if (f.file !== file) {
1078
1149
  file = f.file;
1079
- console.log(`\n ${paint("38;2;98;137;254", file)}`);
1150
+ console.log(`\n ${paint("38;2;98;137;254", vis(file))}`);
1080
1151
  }
1081
1152
  const status = f.accepted && !f.accepted.expired ? "accepted" : f.status;
1082
1153
  const badge = status === "gap" ? paint("1;31", "GAP ") : status === "partial" ? paint("33", "PARTIAL ") : paint("2", "ACCEPTED");
@@ -1093,7 +1164,7 @@ async function main(argv) {
1093
1164
  const fold = (t, pad) => t.replace(new RegExp(`(.{1,${width - pad.length - 2}})(\\s+|$)`, "g"), `$1\n${pad}`).trimEnd();
1094
1165
  const reportFile = resolve("lintsure-report.md");
1095
1166
  // A request a person can paste into any coding agent, connected or not: it names the finding and where the proposal is.
1096
- 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.`;
1097
1168
  if (pretty) {
1098
1169
  // One line that fits the outcome, so the result is clear before any detail. It reports what the rules found and
1099
1170
  // never calls a project safe: "nothing found" is said in those words.
@@ -1109,7 +1180,7 @@ async function main(argv) {
1109
1180
  group("Repo hygiene: housekeeping, not flaws in the code", listed.filter(isHygiene));
1110
1181
  if (first.length) {
1111
1182
  console.log(ruled(`Start here (${first.length} of ${inCode.length})`));
1112
- 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, " ")}`));
1113
1184
  if (inCode.length > first.length)
1114
1185
  console.log(`\n ${paint("2", `The fix for every finding is in ${resolve("lintsure-report.md")}`)}`);
1115
1186
  }
@@ -1117,12 +1188,18 @@ async function main(argv) {
1117
1188
  }
1118
1189
  else
1119
1190
  for (const f of listed)
1120
- 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)" : ""}`);
1121
1192
  if (rest.includes("--github"))
1122
1193
  for (const f of open) {
1123
1194
  const msg = `${f.title}. Proposed change, needs your approval: ${f.proposal.what}`.replace(/%/g, "%25").replace(/\r?\n/g, " ");
1124
- 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}`);
1125
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
+ }
1126
1203
  console.log(`Report saved to ${pretty ? resolve("lintsure-report.md") : "lintsure-report.md"}`);
1127
1204
  if (rest.includes("--report"))
1128
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.");
@@ -1143,7 +1220,7 @@ async function main(argv) {
1143
1220
  const showFix = async () => {
1144
1221
  const list = [...ranked, ...open.filter(isHygiene)].slice(0, 15);
1145
1222
  console.log(`\nWhich finding?${open.length > list.length ? ` (the first ${list.length} of ${open.length}; the rest are in the report)` : ""}`);
1146
- 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);
1147
1224
  if (pick === null || pick >= list.length)
1148
1225
  return;
1149
1226
  const f = list[pick], row = (name, text) => console.log(` ${paint(GOLD, name.padEnd(8))}${fold(text, " ")}`);
@@ -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")}`);
@@ -1,4 +1,4 @@
1
- export declare const PLUGIN_TAG = "v0.3.10";
1
+ export declare const PLUGIN_TAG = "v0.3.11";
2
2
  export interface GuardAgent {
3
3
  id: string;
4
4
  name: string;
@@ -13,7 +13,7 @@ import { homedir } from "node:os";
13
13
  import { dirname, join } from "node:path";
14
14
  import { writeJson } from "./agents.js";
15
15
  // The plugin release that pairs with this engine. Pinned: a moving branch here would be what the supply-chain rules flag.
16
- export const PLUGIN_TAG = "v0.3.10";
16
+ export const PLUGIN_TAG = "v0.3.11";
17
17
  const REPO = "https://github.com/lintsure/plugin.git";
18
18
  export const GUARD_AGENTS = [
19
19
  { id: "claude", name: "Claude Code", marker: ".claude" },
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)
@@ -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[]>;
@@ -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,54 +1,69 @@
1
- {
2
- "name": "lintsure",
3
- "version": "0.3.19",
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
- "license": "Apache-2.0",
6
- "type": "module",
7
- "bin": {
8
- "lintsure": "dist/src/index.js"
9
- },
10
- "files": [
11
- "dist/src",
12
- "skills",
13
- "README.md",
14
- "LICENSE"
15
- ],
16
- "dependencies": {
17
- "@lintsure/core": "0.3.19"
18
- },
19
- "author": "Lintsure <hello@lintsure.com>",
20
- "homepage": "https://lintsure.com/docs",
21
- "repository": {
22
- "type": "git",
23
- "url": "git+https://github.com/lintsure/lintsure.git"
24
- },
25
- "bugs": {
26
- "url": "https://github.com/lintsure/lintsure/issues",
27
- "email": "support@lintsure.com"
28
- },
29
- "engines": {
30
- "node": ">=22"
31
- },
32
- "publishConfig": {
33
- "access": "public"
34
- },
35
- "keywords": [
36
- "ai-agents",
37
- "claude-code",
38
- "grok-build",
39
- "codex",
40
- "coding-agent",
41
- "guardrails",
42
- "security",
43
- "secrets",
44
- "supabase",
45
- "owasp",
46
- "gdpr",
47
- "eu-ai-act",
48
- "mcp",
49
- "static-analysis"
50
- ],
51
- "scripts": {
52
- "prepublishOnly": "cd ../.. && npm test"
53
- }
54
- }
1
+ {
2
+ "name": "lintsure",
3
+ "version": "0.3.21",
4
+ "description": "Keep your AI coding agents on track and in context: holds Claude Code, Grok Build, Codex and Gemini CLI to your project rules, and checks the code they write for secrets, open databases and unsafe patterns, mapped to OWASP, CWE, GDPR and the EU AI Act. Runs locally. Not an audit or legal advice.",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "bin": {
8
+ "lintsure": "dist/src/index.js"
9
+ },
10
+ "files": [
11
+ "dist/src",
12
+ "skills",
13
+ "README.md",
14
+ "LICENSE"
15
+ ],
16
+ "dependencies": {
17
+ "@lintsure/core": "0.3.21"
18
+ },
19
+ "author": "Lintsure <hello@lintsure.com>",
20
+ "homepage": "https://lintsure.com/docs",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/lintsure/lintsure.git"
24
+ },
25
+ "bugs": {
26
+ "url": "https://github.com/lintsure/lintsure/issues",
27
+ "email": "support@lintsure.com"
28
+ },
29
+ "engines": {
30
+ "node": ">=22"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "keywords": [
36
+ "ai-agents",
37
+ "ai-coding-agents",
38
+ "ai-agent-rules",
39
+ "agent-rules",
40
+ "agent-context",
41
+ "agent-monitoring",
42
+ "claude-code",
43
+ "grok-build",
44
+ "codex",
45
+ "gemini-cli",
46
+ "coding-agent",
47
+ "guardrails",
48
+ "code-checker",
49
+ "code-check",
50
+ "lint",
51
+ "linter",
52
+ "code-security",
53
+ "security",
54
+ "secrets",
55
+ "sast",
56
+ "static-analysis",
57
+ "ai-generated-code",
58
+ "supabase",
59
+ "owasp",
60
+ "cwe",
61
+ "gdpr",
62
+ "eu-ai-act",
63
+ "mcp",
64
+ "cli"
65
+ ],
66
+ "scripts": {
67
+ "prepublishOnly": "cd ../.. && npm test"
68
+ }
69
+ }