lintobot 0.2.1 → 0.2.2

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.
Files changed (3) hide show
  1. package/README.md +32 -1
  2. package/dist/cli.js +105 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -312,7 +312,7 @@ Other variables: `LINTOBOT_ERROR`, `LINTOBOT_WARNING`, `LINTOBOT_PART_LINES`, `L
312
312
 
313
313
  ```
314
314
  lintobot [files...] files, folders or globs; everything in lintobot.yml when omitted
315
- --format pretty|json|jsonl pretty on a terminal, jsonl when piped
315
+ --format pretty|json|jsonl|markdown pretty on a terminal, jsonl when piped
316
316
  -o, --output <file>
317
317
  --files <path> relative to the project; repeatable
318
318
  --rule <id or sentence> a rule or an info item; repeatable
@@ -344,6 +344,37 @@ Naming a folder or file narrows the run to the files in it that the config's pat
344
344
 
345
345
  Exit codes: `0` clean · `1` errors · `2` bad usage or config · `3` model unreachable or checks skipped.
346
346
 
347
+ ### Markdown report
348
+
349
+ `--format markdown` writes a report for a pull request comment or a CI job summary. Each file is one collapsed line with the mark of its worst result; opening it shows a table of its checks. Files with problems come first.
350
+
351
+ ```bash
352
+ lintobot --diff origin/main --format markdown -o lintobot.md
353
+ ```
354
+
355
+ ```markdown
356
+ ### ❌ lintobot: 3 files · 1 error · 2 warnings
357
+
358
+ <details>
359
+ <summary>❌ <code>src/config/load.ts</code> — 1 error, 1 warning · 491 lines</summary>
360
+
361
+ *Reads or writes files on disk*
362
+
363
+ | | Check | Confidence | Lines |
364
+ | --- | --- | ---: | --- |
365
+ | ✅ | no secret values exposed | 4–5% | |
366
+ | ❌ | **no magic numbers** | 97% | 1–491 |
367
+ | ⚠️ | **no global state polluted** | 71% | 295–491 |
368
+
369
+ </details>
370
+
371
+ <details>
372
+ <summary>✅ <code>src/engine/pool.ts</code> — 7 rules</summary>
373
+ ...
374
+ ```
375
+
376
+ With `--quiet`, clean files and passed checks are left out. In GitHub Actions, `lintobot --format markdown >> "$GITHUB_STEP_SUMMARY"` puts it on the run's page.
377
+
347
378
  ### Changed code only
348
379
 
349
380
  ```bash
package/dist/cli.js CHANGED
@@ -7,7 +7,7 @@ import { Command, CommanderError } from "commander";
7
7
  // package.json
8
8
  var package_default = {
9
9
  name: "lintobot",
10
- version: "0.2.1",
10
+ version: "0.2.2",
11
11
  description: "AI code linter: rules are plain-language sentences answered by a decision model (Jev)",
12
12
  keywords: [
13
13
  "lint",
@@ -1797,13 +1797,116 @@ function range(min, max) {
1797
1797
  return low === Math.round(max * 100) ? `${low}%` : `${low}–${percent(max)}`;
1798
1798
  }
1799
1799
 
1800
+ // src/report/markdown.ts
1801
+ var ICON = { error: "❌", warning: "⚠️", skipped: "⏭️", ok: "✅" };
1802
+ var ORDER = ["error", "warning", "skipped", "ok"];
1803
+ var html = (text) => text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
1804
+ var plain = (text) => html(text).replace(/([\\`*_[\]#|~])/g, "\\$1").replace(/@(?=\w)/g, "@​");
1805
+ var markOf = (record) => record.type === "info" ? record.skipped ? "skipped" : "ok" : record.severity;
1806
+ var where = (areas) => areas?.length ? areas.map(span).join(", ") : "";
1807
+ var named = (text, id) => id ? `${plain(text)} (${plain(id)})` : plain(text);
1808
+ var code = (formula) => formula ? `\`${formula.replace(/\|/g, "\\|")}\`` : "";
1809
+ function check(record) {
1810
+ const label = named(record.rule, record.id);
1811
+ if (record.severity === "skipped")
1812
+ return ["⏭️", label, `skipped: ${plain(record.reason ?? "")}`, ""];
1813
+ if (record.severity === "ok")
1814
+ return ["✅", label, record.min === undefined ? percent(record.confidence) : range(record.min, record.max ?? record.min), ""];
1815
+ return [ICON[record.severity], `**${label}**`, record.confidence === undefined ? code(record.formula) : percent(record.confidence), where(record.areas)];
1816
+ }
1817
+ function composition2(record) {
1818
+ if (record.severity === "skipped" || !record.share)
1819
+ return ["⏭️", named(record.rule, record.id), `skipped: ${plain(record.reason ?? "")}`, ""];
1820
+ const { share } = record;
1821
+ const names = Object.keys(share);
1822
+ const top = names.reduce((best, name) => share[name] > share[best] ? name : best);
1823
+ const meaning = record.categories?.[top];
1824
+ const title = meaning && !(top === OTHER && meaning === OTHER_DESCRIPTION) ? meaning : top;
1825
+ const shares = names.filter((name) => name !== top).map((name) => `${plain(name)} ${percent(share[name])}`).join(", ");
1826
+ const text = `${named(title, record.id)} (${percent(share[top])})${shares && ` · ${shares}`}`;
1827
+ if (record.severity === "ok")
1828
+ return ["✅", text, "", ""];
1829
+ const why = reasons(record.formula, share);
1830
+ const said = why.length ? why.map((reason) => reason.text).join(", ") : code(record.formula);
1831
+ const places = why.filter((reason) => reason.over && record.areas?.[reason.category]?.length).map((reason) => where(record.areas[reason.category]));
1832
+ return [ICON[record.severity], `**${text}**`, said, places.length === 1 ? places[0] : ""];
1833
+ }
1834
+ function table(rows) {
1835
+ const cells = rows.some((row) => row[3]) ? rows : rows.map((row) => row.slice(0, 3));
1836
+ const head = ["", "Check", "Confidence", "Lines"].slice(0, cells[0].length);
1837
+ const align = ["---", "---", "---:", "---"].slice(0, head.length);
1838
+ return [head, align, ...cells].map((row) => `| ${row.join(" | ")} |`).join(`
1839
+ `);
1840
+ }
1841
+ function markdownReporter(write, options = {}) {
1842
+ const files = [];
1843
+ function block({ file, lines: total, parts, added, records }) {
1844
+ const marks = records.map(markOf);
1845
+ const mark = ORDER.find((candidate) => marks.includes(candidate)) ?? "ok";
1846
+ if (options.quiet && mark === "ok")
1847
+ return;
1848
+ const count = (wanted, word) => {
1849
+ const n = records.filter((record) => record.type !== "info" && record.severity === wanted).length;
1850
+ return n ? [plural(n, word)] : [];
1851
+ };
1852
+ const skipped = marks.filter((item) => item === "skipped").length;
1853
+ const rules = records.filter((record) => record.type !== "info").length;
1854
+ const found = [...count("error", "error"), ...count("warning", "warning"), ...skipped ? [`${skipped} skipped`] : []];
1855
+ const size = added !== undefined ? plural(added, "added line") : parts === undefined || parts > 1 ? `${total} lines` : "";
1856
+ const tail = [found.length ? found.join(", ") : plural(rules, "rule"), ...size ? [size] : []].join(" · ");
1857
+ const info = records.filter((record) => record.type === "info");
1858
+ const notes = options.quiet ? "" : info.filter((record) => record.shown && !record.skipped).map((record) => named(record.statement, record.id)).join(", ");
1859
+ const rows = [
1860
+ ...records.filter((record) => record.type === "check").map((record) => ({ record, text: check(record) })),
1861
+ ...records.filter((record) => record.type === "composition").map((record) => ({ record, text: composition2(record) })),
1862
+ ...info.filter((record) => record.skipped).map((record) => ({ record, text: ["⏭️", named(record.statement, record.id), `skipped: ${plain(record.reason ?? "")}`, ""] }))
1863
+ ].filter(({ record }) => !options.quiet || markOf(record) !== "ok");
1864
+ const body = [...notes ? [`*${notes[0].toUpperCase()}${notes.slice(1)}*`] : [], ...rows.length ? [table(rows.map((row) => row.text))] : []];
1865
+ const summary = `<summary>${ICON[mark]} <code>${html(file)}</code> — ${tail}</summary>`;
1866
+ files.push({ mark, text: `<details>
1867
+ ${summary}
1868
+
1869
+ ${body.join(`
1870
+
1871
+ `)}
1872
+
1873
+ </details>
1874
+ ` });
1875
+ }
1876
+ return {
1877
+ file: block,
1878
+ end(summary) {
1879
+ const worst = summary.errors ? "error" : summary.warnings ? "warning" : summary.skipped ? "skipped" : "ok";
1880
+ const totals = [
1881
+ plural(summary.files, "file"),
1882
+ plural(summary.errors, "error"),
1883
+ plural(summary.warnings, "warning"),
1884
+ ...summary.notes ? [plural(summary.notes, "note")] : [],
1885
+ ...summary.skipped ? [`${summary.skipped} skipped`] : []
1886
+ ];
1887
+ const spent = [plural(summary.calls, "call"), `${tokens(summary.tokens)} tokens`, ...summary.cost === undefined ? [] : [`$${summary.cost.toFixed(4)}`], `${(summary.ms / 1000).toFixed(1)}s`];
1888
+ write(`### ${ICON[worst]} lintobot: ${totals.join(" · ")}
1889
+
1890
+ `);
1891
+ for (const mark of ORDER)
1892
+ for (const file of files.filter((item) => item.mark === mark))
1893
+ write(`${file.text}
1894
+ `);
1895
+ write(`<sub>${spent.join(" · ")}</sub>
1896
+ `);
1897
+ }
1898
+ };
1899
+ }
1900
+
1800
1901
  // src/report/index.ts
1801
- var FORMATS = ["pretty", "json", "jsonl"];
1902
+ var FORMATS = ["pretty", "json", "jsonl", "markdown"];
1802
1903
  function createReporter(format, write, options) {
1803
1904
  if (format === "json")
1804
1905
  return jsonReporter(write, options);
1805
1906
  if (format === "jsonl")
1806
1907
  return jsonlReporter(write, options);
1908
+ if (format === "markdown")
1909
+ return markdownReporter(write, options);
1807
1910
  return prettyReporter(write, options);
1808
1911
  }
1809
1912
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lintobot",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "AI code linter: rules are plain-language sentences answered by a decision model (Jev)",
5
5
  "keywords": [
6
6
  "lint",