@nanonets/graft 0.12.1 → 0.15.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.
Files changed (242) hide show
  1. package/README.md +20 -7
  2. package/dist/ai/crux.d.ts.map +1 -1
  3. package/dist/ai/crux.js +22 -1
  4. package/dist/ai/crux.js.map +1 -1
  5. package/dist/ai/llm/factory.d.ts +5 -1
  6. package/dist/ai/llm/factory.d.ts.map +1 -1
  7. package/dist/ai/llm/factory.js +8 -0
  8. package/dist/ai/llm/factory.js.map +1 -1
  9. package/dist/ai/llm/litellm.d.ts +34 -0
  10. package/dist/ai/llm/litellm.d.ts.map +1 -0
  11. package/dist/ai/llm/litellm.js +45 -0
  12. package/dist/ai/llm/litellm.js.map +1 -0
  13. package/dist/ai/llm/openai.d.ts.map +1 -1
  14. package/dist/ai/llm/openai.js +66 -7
  15. package/dist/ai/llm/openai.js.map +1 -1
  16. package/dist/ai/llm/recover-tool.d.ts +19 -0
  17. package/dist/ai/llm/recover-tool.d.ts.map +1 -0
  18. package/dist/ai/llm/recover-tool.js +109 -0
  19. package/dist/ai/llm/recover-tool.js.map +1 -0
  20. package/dist/ai/providers.d.ts.map +1 -1
  21. package/dist/ai/providers.js +2 -0
  22. package/dist/ai/providers.js.map +1 -1
  23. package/dist/ai/synthesize.d.ts.map +1 -1
  24. package/dist/ai/synthesize.js +19 -5
  25. package/dist/ai/synthesize.js.map +1 -1
  26. package/dist/app/checkout.d.ts +28 -0
  27. package/dist/app/checkout.d.ts.map +1 -0
  28. package/dist/app/checkout.js +100 -0
  29. package/dist/app/checkout.js.map +1 -0
  30. package/dist/app/events.d.ts +37 -0
  31. package/dist/app/events.d.ts.map +1 -0
  32. package/dist/app/events.js +59 -0
  33. package/dist/app/events.js.map +1 -0
  34. package/dist/app/identity.d.ts +54 -0
  35. package/dist/app/identity.d.ts.map +1 -0
  36. package/dist/app/identity.js +96 -0
  37. package/dist/app/identity.js.map +1 -0
  38. package/dist/app/main.d.ts +2 -0
  39. package/dist/app/main.d.ts.map +1 -0
  40. package/dist/app/main.js +56 -0
  41. package/dist/app/main.js.map +1 -0
  42. package/dist/app/pages.d.ts +39 -0
  43. package/dist/app/pages.d.ts.map +1 -0
  44. package/dist/app/pages.js +86 -0
  45. package/dist/app/pages.js.map +1 -0
  46. package/dist/app/queue.d.ts +40 -0
  47. package/dist/app/queue.d.ts.map +1 -0
  48. package/dist/app/queue.js +68 -0
  49. package/dist/app/queue.js.map +1 -0
  50. package/dist/app/review.d.ts +23 -0
  51. package/dist/app/review.d.ts.map +1 -0
  52. package/dist/app/review.js +129 -0
  53. package/dist/app/review.js.map +1 -0
  54. package/dist/app/server.d.ts +40 -0
  55. package/dist/app/server.d.ts.map +1 -0
  56. package/dist/app/server.js +117 -0
  57. package/dist/app/server.js.map +1 -0
  58. package/dist/ask/ask.d.ts +42 -0
  59. package/dist/ask/ask.d.ts.map +1 -1
  60. package/dist/ask/ask.js +442 -57
  61. package/dist/ask/ask.js.map +1 -1
  62. package/dist/ask/file-rank.d.ts +72 -0
  63. package/dist/ask/file-rank.d.ts.map +1 -0
  64. package/dist/ask/file-rank.js +160 -0
  65. package/dist/ask/file-rank.js.map +1 -0
  66. package/dist/ask/file-selection.d.ts +22 -0
  67. package/dist/ask/file-selection.d.ts.map +1 -0
  68. package/dist/ask/file-selection.js +66 -0
  69. package/dist/ask/file-selection.js.map +1 -0
  70. package/dist/ask/fuse.d.ts +16 -0
  71. package/dist/ask/fuse.d.ts.map +1 -1
  72. package/dist/ask/fuse.js +21 -4
  73. package/dist/ask/fuse.js.map +1 -1
  74. package/dist/ask/graphrank.d.ts +18 -0
  75. package/dist/ask/graphrank.d.ts.map +1 -1
  76. package/dist/ask/graphrank.js +65 -19
  77. package/dist/ask/graphrank.js.map +1 -1
  78. package/dist/blast/blast-cli.d.ts +5 -0
  79. package/dist/blast/blast-cli.d.ts.map +1 -1
  80. package/dist/blast/blast-cli.js +16 -1
  81. package/dist/blast/blast-cli.js.map +1 -1
  82. package/dist/blast/blast.d.ts +9 -0
  83. package/dist/blast/blast.d.ts.map +1 -1
  84. package/dist/blast/blast.js.map +1 -1
  85. package/dist/blast/evidence.d.ts +51 -0
  86. package/dist/blast/evidence.d.ts.map +1 -0
  87. package/dist/blast/evidence.js +162 -0
  88. package/dist/blast/evidence.js.map +1 -0
  89. package/dist/blast/owners.d.ts +85 -0
  90. package/dist/blast/owners.d.ts.map +1 -0
  91. package/dist/blast/owners.js +272 -0
  92. package/dist/blast/owners.js.map +1 -0
  93. package/dist/blast/render.d.ts +11 -2
  94. package/dist/blast/render.d.ts.map +1 -1
  95. package/dist/blast/render.js +125 -4
  96. package/dist/blast/render.js.map +1 -1
  97. package/dist/blast/viz.d.ts +20 -0
  98. package/dist/blast/viz.d.ts.map +1 -1
  99. package/dist/blast/viz.js +13 -157
  100. package/dist/blast/viz.js.map +1 -1
  101. package/dist/claude/format.js +1 -1
  102. package/dist/claude/format.js.map +1 -1
  103. package/dist/claude/hooks.d.ts.map +1 -1
  104. package/dist/claude/hooks.js +99 -11
  105. package/dist/claude/hooks.js.map +1 -1
  106. package/dist/claude/settings-merge.d.ts +11 -0
  107. package/dist/claude/settings-merge.d.ts.map +1 -1
  108. package/dist/claude/settings-merge.js +24 -10
  109. package/dist/claude/settings-merge.js.map +1 -1
  110. package/dist/claude/state.d.ts +14 -1
  111. package/dist/claude/state.d.ts.map +1 -1
  112. package/dist/claude/state.js +1 -1
  113. package/dist/claude/state.js.map +1 -1
  114. package/dist/claude/stats.d.ts.map +1 -1
  115. package/dist/claude/stats.js +2 -1
  116. package/dist/claude/stats.js.map +1 -1
  117. package/dist/claude/statusline.d.ts +5 -3
  118. package/dist/claude/statusline.d.ts.map +1 -1
  119. package/dist/claude/statusline.js +6 -4
  120. package/dist/claude/statusline.js.map +1 -1
  121. package/dist/claude/sync-run.d.ts.map +1 -1
  122. package/dist/claude/sync-run.js +10 -2
  123. package/dist/claude/sync-run.js.map +1 -1
  124. package/dist/claude/tally.d.ts +23 -0
  125. package/dist/claude/tally.d.ts.map +1 -0
  126. package/dist/claude/tally.js +138 -0
  127. package/dist/claude/tally.js.map +1 -0
  128. package/dist/cli.js +138 -1
  129. package/dist/cli.js.map +1 -1
  130. package/dist/context/build.d.ts.map +1 -1
  131. package/dist/context/build.js +23 -4
  132. package/dist/context/build.js.map +1 -1
  133. package/dist/context/check.d.ts.map +1 -1
  134. package/dist/context/check.js +2 -1
  135. package/dist/context/check.js.map +1 -1
  136. package/dist/context/node-file.d.ts +2 -1
  137. package/dist/context/node-file.d.ts.map +1 -1
  138. package/dist/context/node-file.js +37 -2
  139. package/dist/context/node-file.js.map +1 -1
  140. package/dist/engine.d.ts +2 -0
  141. package/dist/engine.d.ts.map +1 -1
  142. package/dist/engine.js +1 -0
  143. package/dist/engine.js.map +1 -1
  144. package/dist/graph/bindings.d.ts +25 -3
  145. package/dist/graph/bindings.d.ts.map +1 -1
  146. package/dist/graph/bindings.js +168 -2
  147. package/dist/graph/bindings.js.map +1 -1
  148. package/dist/graph/build.d.ts +4 -0
  149. package/dist/graph/build.d.ts.map +1 -1
  150. package/dist/graph/build.js +7 -4
  151. package/dist/graph/build.js.map +1 -1
  152. package/dist/graph/check.d.ts +3 -0
  153. package/dist/graph/check.d.ts.map +1 -1
  154. package/dist/graph/check.js +58 -11
  155. package/dist/graph/check.js.map +1 -1
  156. package/dist/graph/enrich.d.ts.map +1 -1
  157. package/dist/graph/enrich.js +29 -9
  158. package/dist/graph/enrich.js.map +1 -1
  159. package/dist/graph/extract.d.ts +22 -2
  160. package/dist/graph/extract.d.ts.map +1 -1
  161. package/dist/graph/extract.js +1444 -44
  162. package/dist/graph/extract.js.map +1 -1
  163. package/dist/graph/fingerprint.d.ts +6 -1
  164. package/dist/graph/fingerprint.d.ts.map +1 -1
  165. package/dist/graph/fingerprint.js +7 -3
  166. package/dist/graph/fingerprint.js.map +1 -1
  167. package/dist/graph/generic.d.ts.map +1 -1
  168. package/dist/graph/generic.js +39 -7
  169. package/dist/graph/generic.js.map +1 -1
  170. package/dist/graph/invariants.d.ts +3 -2
  171. package/dist/graph/invariants.d.ts.map +1 -1
  172. package/dist/graph/invariants.js +6 -3
  173. package/dist/graph/invariants.js.map +1 -1
  174. package/dist/graph/queries/dart.scm +42 -0
  175. package/dist/graph/queries/lua.scm +36 -0
  176. package/dist/graph/queries/nix.scm +32 -0
  177. package/dist/graph/refresh.d.ts.map +1 -1
  178. package/dist/graph/refresh.js +6 -2
  179. package/dist/graph/refresh.js.map +1 -1
  180. package/dist/graph/resolve.d.ts +1 -1
  181. package/dist/graph/resolve.d.ts.map +1 -1
  182. package/dist/graph/resolve.js +211 -26
  183. package/dist/graph/resolve.js.map +1 -1
  184. package/dist/graph/scopes.d.ts.map +1 -1
  185. package/dist/graph/scopes.js +2 -1
  186. package/dist/graph/scopes.js.map +1 -1
  187. package/dist/graph/source-files.d.ts +7 -2
  188. package/dist/graph/source-files.d.ts.map +1 -1
  189. package/dist/graph/source-files.js +19 -6
  190. package/dist/graph/source-files.js.map +1 -1
  191. package/dist/graph/traverse-cli.d.ts +13 -2
  192. package/dist/graph/traverse-cli.d.ts.map +1 -1
  193. package/dist/graph/traverse-cli.js +25 -4
  194. package/dist/graph/traverse-cli.js.map +1 -1
  195. package/dist/graph/workspace-cli.d.ts +2 -0
  196. package/dist/graph/workspace-cli.d.ts.map +1 -1
  197. package/dist/graph/workspace-cli.js +3 -0
  198. package/dist/graph/workspace-cli.js.map +1 -1
  199. package/dist/graph/workspace.d.ts.map +1 -1
  200. package/dist/graph/workspace.js +26 -2
  201. package/dist/graph/workspace.js.map +1 -1
  202. package/dist/hosts/mcp-config.d.ts +12 -0
  203. package/dist/hosts/mcp-config.d.ts.map +1 -1
  204. package/dist/hosts/mcp-config.js +54 -5
  205. package/dist/hosts/mcp-config.js.map +1 -1
  206. package/dist/hosts/registry.d.ts.map +1 -1
  207. package/dist/hosts/registry.js +20 -0
  208. package/dist/hosts/registry.js.map +1 -1
  209. package/dist/hosts/retract.d.ts +47 -0
  210. package/dist/hosts/retract.d.ts.map +1 -0
  211. package/dist/hosts/retract.js +473 -0
  212. package/dist/hosts/retract.js.map +1 -0
  213. package/dist/ingest/fs.d.ts +19 -5
  214. package/dist/ingest/fs.d.ts.map +1 -1
  215. package/dist/ingest/fs.js +35 -9
  216. package/dist/ingest/fs.js.map +1 -1
  217. package/dist/telemetry/contract.d.ts.map +1 -1
  218. package/dist/telemetry/contract.js +7 -2
  219. package/dist/telemetry/contract.js.map +1 -1
  220. package/dist/telemetry/sessions.d.ts.map +1 -1
  221. package/dist/telemetry/sessions.js +6 -0
  222. package/dist/telemetry/sessions.js.map +1 -1
  223. package/dist/util/state.d.ts +25 -2
  224. package/dist/util/state.d.ts.map +1 -1
  225. package/dist/util/state.js +24 -2
  226. package/dist/util/state.js.map +1 -1
  227. package/dist/viewer/app.js +2 -1
  228. package/dist/viewer/style.css +14 -0
  229. package/dist/viz/assemble.d.ts +17 -0
  230. package/dist/viz/assemble.d.ts.map +1 -1
  231. package/dist/viz/assemble.js.map +1 -1
  232. package/package.json +19 -4
  233. package/scripts/graph-quality.mjs +3 -3
  234. package/scripts/tally-audit.mjs +140 -0
  235. package/dist/ai/llm/claude-cli.d.ts +0 -60
  236. package/dist/ai/llm/claude-cli.d.ts.map +0 -1
  237. package/dist/ai/llm/claude-cli.js +0 -417
  238. package/dist/ai/llm/claude-cli.js.map +0 -1
  239. package/dist/util/num.d.ts +0 -3
  240. package/dist/util/num.d.ts.map +0 -1
  241. package/dist/util/num.js +0 -20
  242. package/dist/util/num.js.map +0 -1
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Turning a report into code a reader can see.
3
+ *
4
+ * `blast` knows which lines changed (git's hunks) and which symbols reach them
5
+ * (the walk), and both the hosted panel and the PR comment want to SHOW that
6
+ * rather than cite a line number the reader has to go and look up. The shaping
7
+ * lives here so the two surfaces quote the same lines: a comment that disagreed
8
+ * with the page it links to would be worse than one that said less.
9
+ */
10
+ import { readFileSync } from "node:fs";
11
+ import { join } from "node:path";
12
+ const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
13
+ /** Symbols given their own snippet per node. Past this the panel is a file listing
14
+ * rather than a summary — the rest are still counted in the headline. */
15
+ export const MAX_EVIDENCE = 4;
16
+ /** Lines shown per snippet before it folds. A handful is a hunk you can read at a
17
+ * glance; a 30-line refactor is a diff view's job, not a panel's. */
18
+ const MAX_LINES = 6;
19
+ /** `L12-L34` → the numbers, so a label is something a reader can type. */
20
+ export function spanRange(span) {
21
+ const m = /^L(\d+)(?:-L(\d+))?$/.exec(span);
22
+ if (!m)
23
+ return null;
24
+ const start = Number(m[1]);
25
+ return { start, end: m[2] === undefined ? start : Number(m[2]) };
26
+ }
27
+ function labelFor(name, path, span) {
28
+ const r = spanRange(span);
29
+ return r ? `${name} · ${path}:${r.start}-${r.end}` : `${name} · ${path}`;
30
+ }
31
+ /** Keep the first {@link MAX_LINES}, and say how many were left. */
32
+ function fold(lines) {
33
+ if (lines.length <= MAX_LINES)
34
+ return { lines };
35
+ return { lines: lines.slice(0, MAX_LINES), more: lines.length - MAX_LINES };
36
+ }
37
+ const asEvidenceLines = (lines) => lines.map((l) => ({ n: l.n, sign: l.sign, text: l.text }));
38
+ /**
39
+ * The hunks of `file` that fall inside `span`.
40
+ *
41
+ * A file's diff is split by symbol rather than shown whole, because two unrelated
42
+ * edits in one file are two answers — a panel that merges them makes the reader do
43
+ * the separating.
44
+ */
45
+ function hunksIn(file, span) {
46
+ const out = [];
47
+ let dropped = 0;
48
+ for (const h of file.hunks) {
49
+ if (span && (h.end < span.start || h.start > span.end))
50
+ continue;
51
+ out.push(...asEvidenceLines(h.lines));
52
+ dropped += h.dropped;
53
+ }
54
+ return { lines: out, dropped };
55
+ }
56
+ /** Evidence for one changed symbol: what this PR did to it. */
57
+ export function seedEvidence(seed, file) {
58
+ if (!file)
59
+ return null;
60
+ const span = seed.wholeFile ? null : spanRange(seed.span);
61
+ const { lines, dropped } = hunksIn(file, span);
62
+ if (lines.length === 0 && dropped === 0)
63
+ return null;
64
+ const folded = fold(lines);
65
+ const more = (folded.more ?? 0) + dropped;
66
+ return {
67
+ label: seed.wholeFile ? seed.path : labelFor(seed.name, seed.path, seed.span),
68
+ note: file.status === "added" ? "new file" : seed.wholeFile ? "outside any symbol" : undefined,
69
+ lines: folded.lines,
70
+ more: more > 0 ? more : undefined,
71
+ };
72
+ }
73
+ const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
74
+ /**
75
+ * The first line inside a span that mentions one of `needles`, with its number.
76
+ *
77
+ * This is the whole trick behind "why is this symbol here": the edge says A calls
78
+ * B, and this finds the line where it does it. Shared so `blast`'s panel, its
79
+ * comment and `graft callers` all quote the same line for the same edge.
80
+ */
81
+ export function referenceLine(path, span, needles, read) {
82
+ const range = spanRange(span);
83
+ const lines = read(path);
84
+ if (!range || !lines)
85
+ return null;
86
+ for (const [i, text] of lines.slice(range.start - 1, range.end).entries()) {
87
+ if (needles.some((re) => re.test(text)))
88
+ return { n: range.start + i, text };
89
+ }
90
+ return null;
91
+ }
92
+ /** A symbol name, matched as a whole word — `export` must not hit `exportViz`. */
93
+ export const wordRe = (name) => new RegExp(`\\b${escapeRe(name)}\\b`);
94
+ /**
95
+ * Evidence for one dependent symbol: the line that reaches the diff.
96
+ *
97
+ * Nothing changed here, so there is no hunk to show — the useful line is the one
98
+ * naming a changed symbol or module, which answers "why am I in this blast radius
99
+ * at all". Found by reading the symbol's span off disk.
100
+ *
101
+ * When no line names the diff, this returns nothing rather than quoting the span's
102
+ * first line: for a file-level dependent that first line is `/**`, and a panel that
103
+ * shows it has spent a code block to say nothing.
104
+ */
105
+ export function impactedEvidence(sym, reach, read) {
106
+ // A changed symbol's own name is the strongest signal; a file-level dependent
107
+ // usually reaches the diff through its import line, which names a MODULE
108
+ // instead, so both are tried in that order.
109
+ const byName = referenceLine(sym.path, sym.span, reach.names.map(wordRe), read);
110
+ if (byName) {
111
+ const hit = reach.names.find((n) => wordRe(n).test(byName.text));
112
+ return {
113
+ label: labelFor(sym.name, sym.path, sym.span),
114
+ note: `${sym.relation} ${hit}`,
115
+ lines: [{ n: byName.n, sign: " ", text: byName.text }],
116
+ };
117
+ }
118
+ const byModule = referenceLine(sym.path, sym.span, reach.modules, read);
119
+ if (byModule) {
120
+ return {
121
+ label: labelFor(sym.name, sym.path, sym.span),
122
+ note: sym.relation,
123
+ lines: [{ n: byModule.n, sign: " ", text: byModule.text }],
124
+ };
125
+ }
126
+ // No line names the diff — an indirect reach (a dynamic import, a re-export),
127
+ // or a symbol whose whole file is the span. Quoting its first line means
128
+ // quoting `/**`, so the block is dropped instead: the path stays in `sources`
129
+ // and the panel simply says less.
130
+ return null;
131
+ }
132
+ export function reachTerms(seeds, changed) {
133
+ const names = [...new Set(seeds.filter((s) => !s.wholeFile).map((s) => s.name))].sort((a, b) => b.length - a.length);
134
+ const stems = [...new Set(changed.map((f) => f.path.replace(/\.[^./]+$/, "").split("/").pop() ?? ""))].filter(Boolean);
135
+ return {
136
+ names,
137
+ modules: stems.map((stem) => new RegExp(`["'\`][^"'\`]*\\b${escapeRe(stem)}(\\.[a-z]+)?["'\`]`)),
138
+ };
139
+ }
140
+ /** Read each file once, and never fail: a snippet is a nicety, and a symbol whose
141
+ * file moved under us must not take the whole page down. */
142
+ export function fileReader(root) {
143
+ const cache = new Map();
144
+ return (path) => {
145
+ if (root === undefined)
146
+ return null;
147
+ const hit = cache.get(path);
148
+ if (hit !== undefined)
149
+ return hit;
150
+ let lines = null;
151
+ try {
152
+ lines = readFileSync(join(root, path), "utf8").split("\n");
153
+ }
154
+ catch {
155
+ // Deleted, renamed under us, or unreadable: no snippet, no failure.
156
+ lines = null;
157
+ }
158
+ cache.set(path, lines);
159
+ return lines;
160
+ };
161
+ }
162
+ //# sourceMappingURL=evidence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evidence.js","sourceRoot":"","sources":["../../src/blast/evidence.ts"],"names":[],"mappings":"AAA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,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACvH,OAAO;QACL,KAAK;QACL,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,oBAAoB,QAAQ,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;KACjG,CAAC;AACJ,CAAC;AAED;4DAC4D;AAC5D,MAAM,UAAU,UAAU,CAAC,IAAwB;IACjD,MAAM,KAAK,GAAG,IAAI,GAAG,EAA2B,CAAC;IACjD,OAAO,CAAC,IAAY,EAAE,EAAE;QACtB,IAAI,IAAI,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC;QACpC,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC5B,IAAI,GAAG,KAAK,SAAS;YAAE,OAAO,GAAG,CAAC;QAClC,IAAI,KAAK,GAAoB,IAAI,CAAC;QAClC,IAAI,CAAC;YACH,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7D,CAAC;QAAC,MAAM,CAAC;YACP,oEAAoE;YACpE,KAAK,GAAG,IAAI,CAAC;QACf,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACvB,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,85 @@
1
+ import type { BlastReport } from "./blast.js";
2
+ /** One person's claim on one area. */
3
+ export interface Owner {
4
+ /** Display name as git reports it, with `.mailmap` already applied. */
5
+ name: string;
6
+ /** GitHub handle, when the commit email carries one. Never guessed. */
7
+ handle?: string;
8
+ /** Commits of theirs that touched this area's files. */
9
+ commits: number;
10
+ /** Recency-weighted weight of those commits — the ranking key. */
11
+ score: number;
12
+ /** Their most recent commit here, ms since the epoch. */
13
+ last: number;
14
+ }
15
+ /** One person's claim across the whole report: what the tag line prints. */
16
+ export interface Reviewer extends Owner {
17
+ /** Area labels they own, heaviest first. */
18
+ areas: string[];
19
+ }
20
+ export interface OwnerOptions {
21
+ /** Logins, names or emails to drop — the PR author, so they are not told to
22
+ * tag themselves. Matched case-insensitively against all three. */
23
+ exclude?: string[];
24
+ /** Clock, so a test can plant history at a fixed distance from "now". */
25
+ now?: number;
26
+ }
27
+ /** Names listed per area, and in the tag line. */
28
+ export declare const MAX_PER_AREA = 2;
29
+ export declare const MAX_REVIEWERS = 3;
30
+ /**
31
+ * A GitHub handle out of a commit email, or null.
32
+ *
33
+ * Both noreply forms are accepted: the modern `12345+name@` and the legacy bare
34
+ * `name@`. The character class is GitHub's own username rule (alphanumerics and
35
+ * interior hyphens, 39 max) so an address that merely ends in the right domain
36
+ * cannot smuggle something unmentionable into a comment body.
37
+ */
38
+ export declare function githubHandle(email: string): string | null;
39
+ /**
40
+ * The people behind `files`, best first.
41
+ *
42
+ * `--no-merges` because a merge commit's author is whoever pressed the button,
43
+ * not whoever wrote the code. `%aN`/`%aE` rather than `%an`/`%ae` so git applies
44
+ * the repository's `.mailmap` for us — which is the supported way to give a
45
+ * contributor whose work address has no handle a noreply one, at no new config
46
+ * cost to graft.
47
+ */
48
+ export declare function ownersFor(root: string, files: string[], opts?: OwnerOptions): Owner[];
49
+ /**
50
+ * Everyone who authored a commit in `base...HEAD` — the people whose work this
51
+ * pull request IS.
52
+ *
53
+ * This is the exclusion that actually fires in CI. The obvious source for "who
54
+ * opened this" is `pull_request.user.email` from the webhook, but GitHub almost
55
+ * never populates it, so excluding on the login alone leaves anyone whose commits
56
+ * carry a work address being suggested as a reviewer of their own PR. The commits
57
+ * in the range carry exactly the name and email git will match on later.
58
+ *
59
+ * Co-authors count too: a pair-programmed commit has two people on it and neither
60
+ * of them is a reviewer of it.
61
+ */
62
+ export declare function diffAuthors(root: string, base: string): string[];
63
+ /**
64
+ * Whoever git would sign a commit as, here and now.
65
+ *
66
+ * The local counterpart of {@link diffAuthors}. `graft blast` with no `--base`
67
+ * compares the working tree against HEAD, so there is no commit range to read
68
+ * authors from — and without this, the one person guaranteed to have written the
69
+ * change being examined is also the top name in its own "who to tag" list.
70
+ */
71
+ export declare function localIdentity(root: string): string[];
72
+ /**
73
+ * Fill in `owners` on every area and module, and rank the report's `reviewers`.
74
+ *
75
+ * Called AFTER `--name`, because a reviewer's reason cites area labels and the
76
+ * naming pass is what gives an area its final label.
77
+ */
78
+ export declare function attachOwners(root: string, report: BlastReport, opts?: OwnerOptions): void;
79
+ /** `9d ago`, `3mo ago` — how a comment says when someone was last in here. */
80
+ export declare function sinceLabel(last: number, now?: number): string;
81
+ /** `@handle`, or the bare name when git carries no handle for them. */
82
+ export declare function mention(o: Owner): string;
83
+ /** ISO day, for an exported page that has to stay truthful when opened later. */
84
+ export declare function isoDay(ms: number): string;
85
+ //# sourceMappingURL=owners.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owners.d.ts","sourceRoot":"","sources":["../../src/blast/owners.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,sCAAsC;AACtC,MAAM,WAAW,KAAK;IACpB,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC;IACd,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;CACd;AAED,4EAA4E;AAC5E,MAAM,WAAW,QAAS,SAAQ,KAAK;IACrC,4CAA4C;IAC5C,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B;uEACmE;IACnE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,yEAAyE;IACzE,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AA4BD,kDAAkD;AAClD,eAAO,MAAM,YAAY,IAAI,CAAC;AAC9B,eAAO,MAAM,aAAa,IAAI,CAAC;AAW/B;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGzD;AAmBD;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,YAAiB,GAAG,KAAK,EAAE,CAuEzF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAiBhE;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAIpD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,GAAE,YAAiB,GAAG,IAAI,CA+B7F;AAED,8EAA8E;AAC9E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAE,MAAmB,GAAG,MAAM,CAOzE;AAED,uEAAuE;AACvE,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,GAAG,MAAM,CAExC;AAED,iFAAiF;AACjF,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAEzC"}
@@ -0,0 +1,272 @@
1
+ /**
2
+ * Who to tag on a pull request: the people whose fingerprints are on the areas
3
+ * this diff changes or can affect.
4
+ *
5
+ * The blast report already answers "what does this reach"; the author's next
6
+ * question is "who do I ask about it", and git has the answer without a single
7
+ * API call. One `git log` per area over that area's OWN files, scored by recency,
8
+ * ranked, capped.
9
+ *
10
+ * Two rules keep the output honest, and both exist because a wrong name here is
11
+ * worse than no name:
12
+ *
13
+ * - A handle is only ever printed when git actually carries one (the GitHub
14
+ * noreply address, which anything merged through the web UI has). With no
15
+ * handle the display name is printed unlinked — a guessed `@mention` pings a
16
+ * stranger, and there is no cheap way to verify a guess.
17
+ * - An owner has to hold {@link MIN_SHARE} of an area's weight to be named. That
18
+ * drops a drive-by typo fix next to a real owner, and keeps it when the
19
+ * drive-by is all the history there is.
20
+ *
21
+ * Everything here is best-effort: no git, no repository, a detached tarball
22
+ * checkout or a shallow clone leaves the report exactly as it was and the comment
23
+ * simply says nothing about people.
24
+ */
25
+ import { spawnSync } from "node:child_process";
26
+ import { resolve } from "node:path";
27
+ /**
28
+ * Recency half-life. A commit from four months ago counts half as much as one
29
+ * from today, so the person who rewrote a module last month outranks the person
30
+ * who created it two years ago and moved on — which is the reviewer an author
31
+ * actually wants.
32
+ */
33
+ const HALF_LIFE_MS = 120 * 24 * 60 * 60 * 1000;
34
+ /**
35
+ * History window and commit cap, per area.
36
+ *
37
+ * Both are bounds on the walk, not on the answer: at 36 months a commit is worth
38
+ * 0.002 of a fresh one, so nothing outside the window could survive the share
39
+ * floor anyway, and the pair keeps one `git log` off a large repo's full history.
40
+ */
41
+ const SINCE = "36.months";
42
+ const MAX_COMMITS = 400;
43
+ /** Files passed to one `git log`. A very wide area is sampled rather than blowing
44
+ * the argument list; the sample is the area's own sorted file list, so it is
45
+ * stable between runs rather than whichever files git happened to yield. */
46
+ const MAX_PATHSPEC = 80;
47
+ /** Share of an area's total weight an owner must hold to be named. */
48
+ const MIN_SHARE = 0.15;
49
+ /** Names listed per area, and in the tag line. */
50
+ export const MAX_PER_AREA = 2;
51
+ export const MAX_REVIEWERS = 3;
52
+ /**
53
+ * Weight of an area a diff only *reaches*, against one it edits.
54
+ *
55
+ * Not zero, because the person whose code your change can break is exactly the
56
+ * reviewer the diff alone would never surface — that is what the blast radius is
57
+ * for. Not one either: the author of the code you edited knows it better.
58
+ */
59
+ const AFFECTED_WEIGHT = 0.6;
60
+ /**
61
+ * A GitHub handle out of a commit email, or null.
62
+ *
63
+ * Both noreply forms are accepted: the modern `12345+name@` and the legacy bare
64
+ * `name@`. The character class is GitHub's own username rule (alphanumerics and
65
+ * interior hyphens, 39 max) so an address that merely ends in the right domain
66
+ * cannot smuggle something unmentionable into a comment body.
67
+ */
68
+ export function githubHandle(email) {
69
+ const m = /^(?:\d+\+)?([A-Za-z0-9](?:-?[A-Za-z0-9]){0,38})@users\.noreply\.github\.com$/i.exec(email.trim());
70
+ return m ? m[1] : null;
71
+ }
72
+ /** Bots write commits and are never reviewers. */
73
+ function isBot(name, email) {
74
+ return /\[bot\]/i.test(name) || /\[bot\]@/i.test(email) || /^(github-actions|dependabot|renovate)(\[bot\])?$/i.test(name.trim());
75
+ }
76
+ /** Run git in `root`, or null when git fails — not a repo, no git, no history. */
77
+ function git(root, args) {
78
+ const res = spawnSync("git", ["-c", "core.quotePath=false", ...args], {
79
+ cwd: root,
80
+ encoding: "utf8",
81
+ stdio: ["ignore", "pipe", "pipe"],
82
+ maxBuffer: 64 * 1024 * 1024,
83
+ });
84
+ if (res.error || res.status !== 0 || typeof res.stdout !== "string")
85
+ return null;
86
+ return res.stdout;
87
+ }
88
+ /**
89
+ * The people behind `files`, best first.
90
+ *
91
+ * `--no-merges` because a merge commit's author is whoever pressed the button,
92
+ * not whoever wrote the code. `%aN`/`%aE` rather than `%an`/`%ae` so git applies
93
+ * the repository's `.mailmap` for us — which is the supported way to give a
94
+ * contributor whose work address has no handle a noreply one, at no new config
95
+ * cost to graft.
96
+ */
97
+ export function ownersFor(root, files, opts = {}) {
98
+ const paths = [...files].sort().slice(0, MAX_PATHSPEC);
99
+ if (paths.length === 0)
100
+ return [];
101
+ const now = opts.now ?? Date.now();
102
+ const out = git(resolve(root), [
103
+ "log",
104
+ "--no-merges",
105
+ `--since=${SINCE}`,
106
+ "-n",
107
+ String(MAX_COMMITS),
108
+ "--format=\x01%H\x02%aI\x02%aN\x02%aE",
109
+ "--name-only",
110
+ "--",
111
+ ...paths,
112
+ ]);
113
+ if (out === null)
114
+ return [];
115
+ const wanted = new Set(paths);
116
+ const people = new Map();
117
+ let commit = null;
118
+ for (const line of out.split("\n")) {
119
+ if (line.startsWith("\x01")) {
120
+ const [hash, iso, name, email] = line.slice(1).split("\x02");
121
+ const at = Date.parse(iso ?? "");
122
+ commit = Number.isFinite(at)
123
+ ? { hash, at, weight: Math.pow(0.5, (now - at) / HALF_LIFE_MS), name: name ?? "", email: email ?? "" }
124
+ : null;
125
+ continue;
126
+ }
127
+ // A pathspec'd `git log --name-only` already lists only matching files, but
128
+ // the set is re-checked here so a future flag change cannot silently start
129
+ // crediting whoever touched an unrelated file in the same commit.
130
+ if (commit === null || !wanted.has(line))
131
+ continue;
132
+ if (isBot(commit.name, commit.email))
133
+ continue;
134
+ const handle = githubHandle(commit.email) ?? undefined;
135
+ const key = (handle ?? commit.email).toLowerCase();
136
+ const prev = people.get(key);
137
+ if (!prev) {
138
+ people.set(key, {
139
+ name: commit.name, handle, commits: 1, score: commit.weight, last: commit.at,
140
+ seen: new Set([commit.hash]),
141
+ });
142
+ continue;
143
+ }
144
+ // One commit touching six files in the area is one commit, not six.
145
+ if (prev.seen.has(commit.hash))
146
+ continue;
147
+ prev.seen.add(commit.hash);
148
+ prev.commits += 1;
149
+ prev.score += commit.weight;
150
+ prev.last = Math.max(prev.last, commit.at);
151
+ }
152
+ const excluded = new Set((opts.exclude ?? []).map((e) => e.trim().toLowerCase()).filter(Boolean));
153
+ const isExcluded = (o, email) => excluded.has(email.toLowerCase()) ||
154
+ excluded.has(o.name.toLowerCase()) ||
155
+ (o.handle !== undefined && excluded.has(o.handle.toLowerCase()));
156
+ const kept = [...people].filter(([email, o]) => !isExcluded(o, email)).map(([, o]) => o);
157
+ // The floor is a SHARE of what is left after the author is dropped, not of the
158
+ // whole area. On a repo where one person wrote everything, their own PR would
159
+ // otherwise leave every remaining contributor under the floor and report nobody.
160
+ const total = kept.reduce((n, o) => n + o.score, 0);
161
+ return kept
162
+ .filter((o) => total === 0 || o.score / total >= MIN_SHARE)
163
+ .sort((a, b) => b.score - a.score || b.commits - a.commits || a.name.localeCompare(b.name))
164
+ .slice(0, MAX_PER_AREA)
165
+ .map(({ name, handle, commits, score, last }) => ({ name, handle, commits, score, last }));
166
+ }
167
+ /**
168
+ * Everyone who authored a commit in `base...HEAD` — the people whose work this
169
+ * pull request IS.
170
+ *
171
+ * This is the exclusion that actually fires in CI. The obvious source for "who
172
+ * opened this" is `pull_request.user.email` from the webhook, but GitHub almost
173
+ * never populates it, so excluding on the login alone leaves anyone whose commits
174
+ * carry a work address being suggested as a reviewer of their own PR. The commits
175
+ * in the range carry exactly the name and email git will match on later.
176
+ *
177
+ * Co-authors count too: a pair-programmed commit has two people on it and neither
178
+ * of them is a reviewer of it.
179
+ */
180
+ export function diffAuthors(root, base) {
181
+ const out = git(resolve(root), ["log", "--format=%aN%n%aE%n%(trailers:key=Co-authored-by,valueonly)", `${base}...HEAD`]);
182
+ if (out === null)
183
+ return [];
184
+ const names = new Set();
185
+ for (const raw of out.split("\n")) {
186
+ const line = raw.trim();
187
+ if (line === "")
188
+ continue;
189
+ // A co-author trailer is `Name <email>`; both halves are worth excluding.
190
+ const m = /^(.*?)\s*<([^>]+)>$/.exec(line);
191
+ if (m) {
192
+ if (m[1])
193
+ names.add(m[1]);
194
+ names.add(m[2]);
195
+ continue;
196
+ }
197
+ names.add(line);
198
+ }
199
+ return [...names];
200
+ }
201
+ /**
202
+ * Whoever git would sign a commit as, here and now.
203
+ *
204
+ * The local counterpart of {@link diffAuthors}. `graft blast` with no `--base`
205
+ * compares the working tree against HEAD, so there is no commit range to read
206
+ * authors from — and without this, the one person guaranteed to have written the
207
+ * change being examined is also the top name in its own "who to tag" list.
208
+ */
209
+ export function localIdentity(root) {
210
+ const dir = resolve(root);
211
+ const out = [git(dir, ["config", "user.name"]), git(dir, ["config", "user.email"])];
212
+ return out.map((v) => v?.trim() ?? "").filter((v) => v !== "");
213
+ }
214
+ /**
215
+ * Fill in `owners` on every area and module, and rank the report's `reviewers`.
216
+ *
217
+ * Called AFTER `--name`, because a reviewer's reason cites area labels and the
218
+ * naming pass is what gives an area its final label.
219
+ */
220
+ export function attachOwners(root, report, opts = {}) {
221
+ const ranked = new Map();
222
+ const visit = (label, files, weight) => {
223
+ const owners = ownersFor(root, files, opts);
224
+ for (const o of owners) {
225
+ const key = (o.handle ?? o.name).toLowerCase();
226
+ const prev = ranked.get(key);
227
+ if (!prev) {
228
+ ranked.set(key, { ...o, areas: [label], weighted: o.score * weight });
229
+ continue;
230
+ }
231
+ prev.areas.push(label);
232
+ prev.commits += o.commits;
233
+ prev.score += o.score;
234
+ prev.weighted += o.score * weight;
235
+ prev.last = Math.max(prev.last, o.last);
236
+ // A handle found on any one area is the handle: a contributor who has some
237
+ // commits from the web UI and some from a laptop should still be taggable.
238
+ if (prev.handle === undefined && o.handle !== undefined)
239
+ prev.handle = o.handle;
240
+ }
241
+ return owners;
242
+ };
243
+ for (const area of report.areas)
244
+ area.owners = visit(area.label, area.files, 1);
245
+ for (const mod of report.modules)
246
+ mod.owners = visit(mod.label, mod.files, AFFECTED_WEIGHT);
247
+ report.reviewers = [...ranked.values()]
248
+ .sort((a, b) => b.weighted - a.weighted || b.commits - a.commits || a.name.localeCompare(b.name))
249
+ .slice(0, MAX_REVIEWERS)
250
+ .map(({ weighted: _weighted, ...r }) => r);
251
+ }
252
+ /** `9d ago`, `3mo ago` — how a comment says when someone was last in here. */
253
+ export function sinceLabel(last, now = Date.now()) {
254
+ const days = Math.max(0, Math.round((now - last) / (24 * 60 * 60 * 1000)));
255
+ if (days < 1)
256
+ return "today";
257
+ if (days === 1)
258
+ return "yesterday";
259
+ if (days < 31)
260
+ return `${days}d ago`;
261
+ const months = Math.round(days / 30);
262
+ return months < 24 ? `${months}mo ago` : `${Math.round(days / 365)}y ago`;
263
+ }
264
+ /** `@handle`, or the bare name when git carries no handle for them. */
265
+ export function mention(o) {
266
+ return o.handle !== undefined ? `@${o.handle}` : o.name;
267
+ }
268
+ /** ISO day, for an exported page that has to stay truthful when opened later. */
269
+ export function isoDay(ms) {
270
+ return new Date(ms).toISOString().slice(0, 10);
271
+ }
272
+ //# sourceMappingURL=owners.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owners.js","sourceRoot":"","sources":["../../src/blast/owners.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA+BpC;;;;;GAKG;AACH,MAAM,YAAY,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,KAAK,GAAG,WAAW,CAAC;AAC1B,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB;;4EAE4E;AAC5E,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB,sEAAsE;AACtE,MAAM,SAAS,GAAG,IAAI,CAAC;AAEvB,kDAAkD;AAClD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC;AAC9B,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,MAAM,CAAC,GAAG,+EAA+E,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7G,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACzB,CAAC;AAED,kDAAkD;AAClD,SAAS,KAAK,CAAC,IAAY,EAAE,KAAa;IACxC,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,mDAAmD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CAAC;IAC7B,IAAI,IAAI,KAAK,CAAC;QAAE,OAAO,WAAW,CAAC;IACnC,IAAI,IAAI,GAAG,EAAE;QAAE,OAAO,GAAG,IAAI,OAAO,CAAC;IACrC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;IACrC,OAAO,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,MAAM,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC;AAC5E,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,OAAO,CAAC,CAAQ;IAC9B,OAAO,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC1D,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,MAAM,CAAC,EAAU;IAC/B,OAAO,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACjD,CAAC"}
@@ -30,8 +30,17 @@ import type { BlastReport } from "./blast.js";
30
30
  * broken renderer, and the caller has a sentence for "no dependents found".
31
31
  */
32
32
  export declare function mermaidDiagram(r: BlastReport): string | null;
33
- /** The PR-comment body: diagram, then one table, then everything else collapsed. */
34
- export declare function markdownReport(r: BlastReport): string;
33
+ /**
34
+ * The PR-comment body: diagram, then one table, then everything else collapsed.
35
+ *
36
+ * `root` is the repository the report was taken in. With it, the collapsed symbol
37
+ * list quotes the line that reaches the diff — the same line the hosted page shows,
38
+ * from the same helper. Without it the list is unchanged, so a caller that has no
39
+ * checkout (a test, a piped report) loses nothing but the snippet.
40
+ */
41
+ export declare function markdownReport(r: BlastReport, opts?: {
42
+ root?: string;
43
+ }): string;
35
44
  /** Terminal report: same content, no markdown scaffolding. */
36
45
  export declare function textReport(r: BlastReport): string;
37
46
  //# sourceMappingURL=render.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/blast/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,YAAY,CAAC;AA8C1D;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAsB5D;AAED,oFAAoF;AACpF,wBAAgB,cAAc,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM,CAiCrD;AA+JD,8DAA8D;AAC9D,wBAAgB,UAAU,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM,CA8BjD"}
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/blast/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,WAAW,EAAqD,MAAM,YAAY,CAAC;AAoDjG;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAsB5D;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,MAAM,CA6CnF;AA0PD,8DAA8D;AAC9D,wBAAgB,UAAU,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM,CAuCjD"}