@lintsure/core 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Lintsure
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
package/README.md CHANGED
@@ -1,3 +1,12 @@
1
- # Temporary Holding Version
1
+ # @lintsure/core
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The Lintsure engine: rules, framework knowledge, scanning and report writers. Used by the [`lintsure`](https://www.npmjs.com/package/lintsure) CLI and [`@lintsure/mcp`](https://www.npmjs.com/package/@lintsure/mcp). No network code.
4
+
5
+ > **Lintsure is a readiness tool, not an audit, a certification or legal advice.** Results cover code only; a qualified person should review them.
6
+
7
+ ```js
8
+ import { scan, toMarkdown, toAssessmentHtml } from "@lintsure/core";
9
+ const report = await scan("./my-app", ["gdpr", "soc2"]);
10
+ ```
11
+
12
+ Docs: https://lintsure.com/docs · Source: https://github.com/lintsure/lintsure · Apache-2.0
@@ -0,0 +1,8 @@
1
+ import type { Report } from "./types.js";
2
+ export interface AssessmentOptions {
3
+ /** Shown on the cover. Defaults to "Your project". */
4
+ project?: string;
5
+ /** Date the report was produced, as YYYY-MM-DD. Passed in so the same input gives the same file. */
6
+ date: string;
7
+ }
8
+ export declare function toAssessmentHtml(r: Report, opts: AssessmentOptions): string;
@@ -0,0 +1,116 @@
1
+ // The assessment report: one self-contained HTML file, laid out in print pages, so a person can
2
+ // read it, annotate it, print it or save it as a PDF from any browser. It is a draft until a
3
+ // qualified person reviews it and fills in the sign-off page.
4
+ import { DISCLAIMER, NOT_A_VERDICT, nextSteps } from "./index.js";
5
+ import { knowledge } from "./knowledge/index.js";
6
+ const esc = (s) => s.replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c]);
7
+ const NAME = { "eu-ai-act": "EU AI Act", gdpr: "GDPR", soc2: "SOC 2", "iso-27001": "ISO/IEC 27001" };
8
+ const STATUS = { gap: "Gap", partial: "Partial", met: "Met", outside: "Outside code" };
9
+ const SEV = ["high", "medium", "low"];
10
+ const SKIPPED = "node_modules, .git, dist, build, out, .output, .next, .nuxt, .svelte-kit, .astro, .vercel, .netlify, .wrangler, .turbo, .cache, venv, .venv, __pycache__, coverage";
11
+ function page(title, body, n, total, project) {
12
+ return `<section class="page"><header><span>Lintsure readiness assessment · ${esc(project)}</span><span>Draft until reviewed by a person</span></header>
13
+ <h2>${esc(title)}</h2>${body}<footer><span>Not an audit, a certification or legal advice.</span><span>Section ${n} of ${total}</span></footer></section>`;
14
+ }
15
+ function findingCard(f, i) {
16
+ return `<article class="finding ${f.status}">
17
+ <p class="meta"><b class="st">${STATUS[f.status]}</b> · ${f.severity} severity · <code>${esc(f.ruleId)}</code></p>
18
+ <h3>${i}. ${esc(f.title)}</h3>
19
+ <p class="where"><code>${esc(f.file)}:${f.line}</code></p>
20
+ <dl>
21
+ <dt>Rules it may affect</dt><dd>${f.controls.map((c) => `${NAME[c.framework]} ${esc(c.id)} (${esc(c.title)})`).join("<br>")}</dd>
22
+ <dt>Why it matters</dt><dd>${esc(f.note)}</dd>
23
+ <dt>Possible fix</dt><dd>${esc(f.fix)} Review the change before it is made.</dd>
24
+ </dl>
25
+ <p class="decide"><b>Reviewer decision:</b> ☐ Fix &nbsp; ☐ Accept the risk (record why) &nbsp; ☐ Not applicable (record why) &nbsp; Initials ______ &nbsp; Date ______</p>
26
+ </article>`;
27
+ }
28
+ export function toAssessmentHtml(r, opts) {
29
+ const project = opts.project?.trim() || "Your project";
30
+ const n = (s) => r.findings.filter((f) => f.status === s).length;
31
+ const fws = r.frameworks;
32
+ const sorted = [...r.findings].sort((a, b) => SEV.indexOf(a.severity) - SEV.indexOf(b.severity));
33
+ const cover = `<section class="page cover">
34
+ <p class="brand">Lintsure</p>
35
+ <h1>Readiness assessment</h1>
36
+ <p class="sub">${esc(project)}</p>
37
+ <table class="facts">
38
+ <tr><th>Date produced</th><td>${esc(opts.date)}</td></tr>
39
+ <tr><th>Frameworks checked</th><td>${fws.map((f) => NAME[f]).join(", ") || "None"}</td></tr>
40
+ <tr><th>Files checked</th><td>${r.filesChecked}</td></tr>
41
+ <tr><th>Rules version</th><td>${esc(r.rulesVersion)}</td></tr>
42
+ <tr><th>Status of this report</th><td><b>Draft.</b> Not complete until a qualified person reviews it and signs the review page.</td></tr>
43
+ </table>
44
+ <div class="callout"><b>Read this first.</b> ${esc(DISCLAIMER)}</div>
45
+ </section>`;
46
+ const summary = `<p>This report shows where your code may not meet the code-related parts of the frameworks above, what could be done about it, and what still has to happen outside code. It is a starting point for a person to review, not a conclusion.</p>
47
+ <table class="counts"><tr><th>Gap</th><th>Partial</th><th>Rules with no finding (Met)</th><th>Outside code</th></tr>
48
+ <tr><td>${n("gap")}</td><td>${n("partial")}</td><td>${r.met.length}</td><td>${r.outside.length}</td></tr></table>
49
+ <h3>By framework</h3>
50
+ <table><tr><th>Framework</th><th>Gaps</th><th>Partial</th><th>Rules with no finding</th><th>Outside-code items</th></tr>
51
+ ${fws.map((f) => `<tr><td>${NAME[f]}</td><td>${r.findings.filter((x) => x.status === "gap" && x.controls.some((c) => c.framework === f)).length}</td><td>${r.findings.filter((x) => x.status === "partial" && x.controls.some((c) => c.framework === f)).length}</td><td>${r.met.filter((m) => m.controls.some((c) => c.framework === f)).length}</td><td>${r.outside.filter((o) => o.framework === f).length}</td></tr>`).join("")}</table>
52
+ <div class="callout"><b>What this summary does not mean.</b> ${esc(NOT_A_VERDICT)}</div>`;
53
+ const method = `<h3>What was checked</h3>
54
+ <p>Lintsure read ${r.filesChecked} files in the project folder on the computer or CI runner where it ran. Nothing was uploaded. It skipped these folders: ${SKIPPED}, any paths listed under ignore in lintsure.config.yaml, minified files, and any file over 1 MB or binary.</p>
55
+ <h3>How results are produced</h3>
56
+ <ul><li>A fixed set of rules (version ${esc(r.rulesVersion)}) looks for known patterns, line by line or file by file. It does not use a language model to decide results, so the same code gives the same findings.</li>
57
+ <li><b>Gap</b>: a rule found code that may break a control. <b>Partial</b>: a likely problem that depends on context only you can confirm. <b>Met</b>: the rule ran and found nothing in the files it read. <b>Outside code</b>: work that code cannot show.</li>
58
+ <li>Rules reflect our reading of the publicly available text of each framework. They are in Beta: their mappings to framework controls await review by a qualified compliance professional.</li></ul>
59
+ <h3>Known limits</h3>
60
+ <ul><li>Rules can miss real problems and can flag code that is fine.</li><li>They do not follow data across files or functions.</li><li>They mainly cover JavaScript, TypeScript and Python.</li><li>They cannot see infrastructure, cloud settings, or anything outside the folder that was scanned.</li></ul>`;
61
+ const findingsBody = sorted.length
62
+ ? `<p>${sorted.length} possible issue${sorted.length === 1 ? "" : "s"}, most severe first. For each one, a reviewer records a decision.</p>${sorted.map((f, i) => findingCard(f, i + 1)).join("")}`
63
+ : `<p>The current rules found no possible issues in the files they read. That is not the same as having none: rules have limits (see "Scope and method"), and the outside-code work still applies.</p>`;
64
+ const byFramework = fws.map((f) => {
65
+ const k = knowledge.find((x) => x.id === f);
66
+ const hits = r.findings.filter((x) => x.controls.some((c) => c.framework === f));
67
+ const rows = (k?.obligations ?? []).map((o) => {
68
+ const related = hits.filter((h) => o.rules?.includes(h.ruleId));
69
+ const result = o.inCode === "no" ? "Outside code: needs evidence" : related.length ? `${related.length} finding${related.length === 1 ? "" : "s"} to review` : o.inCode === "partly" ? "No finding from the rules; code shows only part of this" : "No finding from the rules";
70
+ return `<tr><td><code>${esc(o.ref)}</code></td><td><b>${esc(o.title)}.</b> ${esc(o.plain)}</td><td>${result}</td></tr>`;
71
+ }).join("");
72
+ return `<h3>${NAME[f]}</h3>${k ? `<p>${esc(k.summary)}</p>` : ""}<table><tr><th>Ref</th><th>What it asks</th><th>What Lintsure saw</th></tr>${rows}</table>`;
73
+ }).join("");
74
+ const outside = r.outside.length
75
+ ? `<p>Code cannot show these. They still need to be done before a full review. Assign an owner to each.</p><table><tr><th>Framework</th><th>Item</th><th>Evidence an auditor may ask for</th><th>Owner</th><th>Done</th></tr>
76
+ ${r.outside.map((o) => `<tr><td>${NAME[o.framework]} <code>${esc(o.control)}</code></td><td>${esc(o.title)}</td><td>${esc(o.evidence)}</td><td></td><td>☐</td></tr>`).join("")}</table>`
77
+ : `<p>No outside-code items for the frameworks checked.</p>`;
78
+ const next = `<ol>${nextSteps(r).map((s) => `<li>${esc(s)}</li>`).join("")}</ol>
79
+ <p>Lintsure suggests; people decide. Re-run Lintsure after changes, and keep each signed report with the rules version it was produced with.</p>`;
80
+ const signoff = `<div class="callout"><b>Human review is required.</b> This report is a draft produced by software. It must be reviewed by a qualified person, such as a compliance professional, before anyone relies on it for an audit, a certification, a customer answer or a business decision.</div>
81
+ <table class="sign">
82
+ <tr><th>Reviewer name</th><td></td></tr><tr><th>Role and qualification</th><td></td></tr><tr><th>Date of review</th><td></td></tr>
83
+ <tr><th>Scope reviewed</th><td>☐ All findings &nbsp; ☐ Outside-code items &nbsp; ☐ Framework applicability</td></tr>
84
+ <tr><th>Overall notes</th><td class="tall"></td></tr><tr><th>Signature</th><td class="tall"></td></tr></table>
85
+ <p class="small">By signing, the reviewer confirms they reviewed this report. Signing does not turn it into an audit or certification.</p>`;
86
+ const pages = [
87
+ ["Summary", summary], ["Scope and method", method], ["Possible issues and fixes", findingsBody],
88
+ ["Framework by framework", byFramework || "<p>No frameworks were checked.</p>"], ["Work outside code", outside],
89
+ ["What to do next", next], ["Human review and sign-off", signoff], ["Disclaimer", `<p>${esc(DISCLAIMER)}</p><p>${esc(NOT_A_VERDICT)}</p><p>Lintsure does not decide whether a framework applies to you or whether you meet it. A person makes the final call. Full disclaimer: https://lintsure.com/disclaimer</p>`],
90
+ ];
91
+ const total = pages.length + 1;
92
+ return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
93
+ <title>Lintsure readiness assessment · ${esc(project)} · ${esc(opts.date)}</title>
94
+ <style>
95
+ :root{--ink:#141413;--muted:#5E5D59;--line:#E4E2DD;--sunken:#F5F4F1;--gap:#B42318;--partial:#8A5A00;--met:#0B6E4F}
96
+ *{box-sizing:border-box}body{margin:0;background:#ECEAE5;color:var(--ink);font:14px/1.55 -apple-system,"Segoe UI",Helvetica,Arial,sans-serif}
97
+ .page{background:#fff;width:210mm;min-height:297mm;margin:16px auto;padding:18mm 18mm 22mm;position:relative;box-shadow:0 2px 12px #0002}
98
+ header,footer{display:flex;justify-content:space-between;font-size:10px;color:var(--muted)}header{border-bottom:1px solid var(--line);padding-bottom:6px;margin-bottom:18px}
99
+ footer{position:absolute;left:18mm;right:18mm;bottom:10mm;border-top:1px solid var(--line);padding-top:6px}
100
+ h1{font-size:40px;letter-spacing:-.03em;margin:40mm 0 4px}h2{font-size:24px;letter-spacing:-.02em;margin:0 0 12px}h3{font-size:16px;margin:20px 0 6px}
101
+ .brand{font-weight:700;letter-spacing:-.02em;font-size:18px}.sub{font-size:18px;color:var(--muted);margin:0 0 24px}
102
+ table{width:100%;border-collapse:collapse;margin:8px 0 12px;font-size:12.5px}th,td{border:1px solid var(--line);padding:6px 8px;text-align:left;vertical-align:top}th{background:var(--sunken);font-weight:600}
103
+ .counts td{font-size:22px;font-weight:600;text-align:center}.facts th{width:38%}
104
+ .callout{border:1px solid var(--ink);border-radius:8px;padding:10px 12px;margin:14px 0;font-size:13px}
105
+ code{font:12px ui-monospace,Menlo,Consolas,monospace;background:var(--sunken);padding:1px 4px;border-radius:4px}
106
+ .finding{border:1px solid var(--line);border-radius:8px;padding:10px 12px;margin:10px 0;break-inside:avoid}.finding h3{margin:4px 0 2px}
107
+ .finding .meta{margin:0;font-size:12px;color:var(--muted)}.gap .st{color:var(--gap)}.partial .st{color:var(--partial)}
108
+ .where{margin:0 0 6px}dl{margin:0;display:grid;grid-template-columns:150px 1fr;gap:4px 10px;font-size:12.5px}dt{color:var(--muted)}dd{margin:0}
109
+ .decide{font-size:12px;margin:8px 0 0;padding-top:6px;border-top:1px dashed var(--line)}
110
+ .sign td{height:28px}.sign .tall{height:70px}.small{font-size:11.5px;color:var(--muted)}
111
+ @page{size:A4;margin:0}@media print{body{background:#fff}.page{margin:0;box-shadow:none;break-after:page}}
112
+ </style></head><body>
113
+ ${cover}
114
+ ${pages.map(([t, b], i) => page(t, b, i + 2, total, project)).join("\n")}
115
+ </body></html>`;
116
+ }
@@ -0,0 +1,3 @@
1
+ export declare const AGENT_GUIDANCE = "You are using Lintsure, a readiness tool that checks code against compliance frameworks.\n\nWhen you report Lintsure results:\n- Never say or imply the user is compliant, certified, approved, audit-ready, \"good to go\", or that they passed. Lintsure cannot decide that.\n- Never make a decision for the user. Present findings and options; the user chooses what to do.\n- Always ask for confirmation before changing any file, and before treating a framework as applicable.\n- Say that results cover code only, against Lintsure's reading of the publicly available text of each framework.\n- Always mention the items outside code (policies, training, contracts, evidence) that still need to be done before a full review.\n- Recommend that a qualified person review the results before any audit, certification or business decision.\n- A control marked Met only means Lintsure's rules found no problem in the files they read. Say so if you mention Met.";
2
+ /** Phrases that read as a verdict. Lintsure's own output must never claim these. */
3
+ export declare const FORBIDDEN_CLAIMS: RegExp[];
@@ -0,0 +1,18 @@
1
+ // How any agent should talk about Lintsure results. Sent to MCP clients as server instructions
2
+ // and tested: the report text must never contain the phrases in FORBIDDEN_CLAIMS.
3
+ export const AGENT_GUIDANCE = `You are using Lintsure, a readiness tool that checks code against compliance frameworks.
4
+
5
+ When you report Lintsure results:
6
+ - Never say or imply the user is compliant, certified, approved, audit-ready, "good to go", or that they passed. Lintsure cannot decide that.
7
+ - Never make a decision for the user. Present findings and options; the user chooses what to do.
8
+ - Always ask for confirmation before changing any file, and before treating a framework as applicable.
9
+ - Say that results cover code only, against Lintsure's reading of the publicly available text of each framework.
10
+ - Always mention the items outside code (policies, training, contracts, evidence) that still need to be done before a full review.
11
+ - Recommend that a qualified person review the results before any audit, certification or business decision.
12
+ - A control marked Met only means Lintsure's rules found no problem in the files they read. Say so if you mention Met.`;
13
+ /** Phrases that read as a verdict. Lintsure's own output must never claim these. */
14
+ export const FORBIDDEN_CLAIMS = [
15
+ /\byou(?:'re| are) (?:now )?(?:fully )?(?:compliant|certified|audit[- ]ready|ready for (?:an |the )?audit)\b/i,
16
+ /\b(?:good to go|all clear|you passed|passed the audit|guaranteed?)\b/i,
17
+ /\bis (?:now )?(?:fully )?(?:compliant|certified)\b/i,
18
+ ];
@@ -0,0 +1,31 @@
1
+ import { rules } from "./rules/index.js";
2
+ import type { FrameworkId, Report } from "./types.js";
3
+ export * from "./types.js";
4
+ export { rules };
5
+ export * from "./guidance.js";
6
+ export { toAssessmentHtml } from "./assessment.js";
7
+ export * from "./knowledge/index.js";
8
+ export declare const RULES_VERSION = "0.1.1";
9
+ /** Shown with every result, in every interface. Lintsure prepares; people decide. */
10
+ export declare const DISCLAIMER: string;
11
+ /** What a report must never be read as. Used in the report and by the MCP server. */
12
+ export declare const NOT_A_VERDICT: string;
13
+ /** Plain next steps, so a report always ends with what a person still needs to do. */
14
+ export declare function nextSteps(r: Report): string[];
15
+ export declare const ALL_FRAMEWORKS: FrameworkId[];
16
+ /** Reads the frameworks list from lintsure.config.yaml in the repo root, if there is one.
17
+ * Only the simple list form is supported:
18
+ * frameworks:
19
+ * - gdpr
20
+ * Ids Lintsure doesn't check yet (for example "hipaa") are returned in `skipped`.
21
+ * An `ignore:` list of paths (relative to the root, for example tests/ or fixtures/) is skipped by scan(). */
22
+ export declare function readConfig(root: string): Promise<{
23
+ frameworks: FrameworkId[] | null;
24
+ skipped: string[];
25
+ ignore: string[];
26
+ }>;
27
+ export declare const SKIP_DIRS: string[];
28
+ /** Scout: list files to check, sorted so output order never depends on the file system. */
29
+ export declare function listFiles(root: string, ignore?: string[]): Promise<string[]>;
30
+ export declare function scan(root: string, frameworks?: FrameworkId[]): Promise<Report>;
31
+ export declare function toMarkdown(r: Report): string;
@@ -0,0 +1,168 @@
1
+ // Scout (file walk) + Checker (rules) + Auditor (dedupe, sort) + Officer (outside code).
2
+ // No network calls anywhere in this package: a test enforces it.
3
+ import { readdir, readFile } from "node:fs/promises";
4
+ import { extname, join, relative, sep } from "node:path";
5
+ import { outsideFor } from "./knowledge/index.js";
6
+ import { rules } from "./rules/index.js";
7
+ export * from "./types.js";
8
+ export { rules };
9
+ export * from "./guidance.js";
10
+ export { toAssessmentHtml } from "./assessment.js";
11
+ export * from "./knowledge/index.js";
12
+ export const RULES_VERSION = "0.1.1";
13
+ /** Shown with every result, in every interface. Lintsure prepares; people decide. */
14
+ export const DISCLAIMER = "Lintsure is a readiness tool, not an audit, a certification or legal advice. " +
15
+ "Its rules reflect our reading of the publicly available text of each framework, and they check code only. " +
16
+ "Work outside code, such as policies, training, contracts and evidence, still has to be done. " +
17
+ "Have a qualified person review the results before any audit, certification or decision.";
18
+ /** What a report must never be read as. Used in the report and by the MCP server. */
19
+ export const NOT_A_VERDICT = "These results do not mean you are compliant, certified or ready for an audit. A control marked Met means only that " +
20
+ "Lintsure's rules found no problem in the files they read.";
21
+ /** Plain next steps, so a report always ends with what a person still needs to do. */
22
+ export function nextSteps(r) {
23
+ const gaps = r.findings.filter((f) => f.status === "gap").length;
24
+ const partial = r.findings.filter((f) => f.status === "partial").length;
25
+ return [
26
+ gaps ? `Review the ${gaps} gap${gaps === 1 ? "" : "s"} and decide how to fix each one. Approve any change before it is made.` : "No gaps were found by the current rules. Keep checking as the code changes.",
27
+ partial ? `Check the ${partial} partial finding${partial === 1 ? "" : "s"}: each depends on context only you can confirm.` : "",
28
+ `Work through the ${r.outside.length} item${r.outside.length === 1 ? "" : "s"} that live outside code. Code checks alone are not enough for a full review.`,
29
+ "Ask a qualified compliance professional to review the results before you rely on them.",
30
+ ].filter(Boolean);
31
+ }
32
+ export const ALL_FRAMEWORKS = ["gdpr", "soc2", "iso-27001", "eu-ai-act"];
33
+ /** Reads the frameworks list from lintsure.config.yaml in the repo root, if there is one.
34
+ * Only the simple list form is supported:
35
+ * frameworks:
36
+ * - gdpr
37
+ * Ids Lintsure doesn't check yet (for example "hipaa") are returned in `skipped`.
38
+ * An `ignore:` list of paths (relative to the root, for example tests/ or fixtures/) is skipped by scan(). */
39
+ export async function readConfig(root) {
40
+ let text;
41
+ try {
42
+ text = await readFile(join(root, "lintsure.config.yaml"), "utf8");
43
+ }
44
+ catch {
45
+ return { frameworks: null, skipped: [], ignore: [] };
46
+ }
47
+ const lists = { frameworks: [], ignore: [] };
48
+ let key = "";
49
+ let emptyFw = false;
50
+ for (const raw of text.split(/\r?\n/)) {
51
+ const line = raw.replace(/#.*$/, "").trimEnd();
52
+ if (/^frameworks\s*:\s*\[\s*\]\s*$/.test(line)) {
53
+ emptyFw = true;
54
+ key = "";
55
+ continue;
56
+ }
57
+ const head = line.match(/^(frameworks|ignore)\s*:\s*$/);
58
+ if (head) {
59
+ key = head[1];
60
+ continue;
61
+ }
62
+ if (key) {
63
+ const m = line.match(/^\s+-\s*["']?([^"'\s]+)["']?\s*$/);
64
+ if (m)
65
+ lists[key].push(m[1]);
66
+ else if (line.trim())
67
+ key = "";
68
+ }
69
+ }
70
+ const ignore = lists.ignore.map((p) => p.replace(/\\/g, "/").replace(/^\.?\//, "").replace(/\/+$/, ""));
71
+ if (emptyFw)
72
+ return { frameworks: [], skipped: [], ignore };
73
+ const ids = lists.frameworks;
74
+ if (!ids.length)
75
+ return { frameworks: null, skipped: [], ignore };
76
+ const known = ids.filter((i) => ALL_FRAMEWORKS.includes(i));
77
+ return { frameworks: known, skipped: ids.filter((i) => !known.includes(i)), ignore };
78
+ }
79
+ // Dependencies, build output and caches: generated code, not code you wrote.
80
+ export const SKIP_DIRS = ["node_modules", ".git", "dist", "build", "out", ".output", ".next", ".nuxt", ".svelte-kit", ".astro", ".vercel", ".netlify", ".wrangler", ".turbo", ".cache", "venv", ".venv", "__pycache__", "coverage"];
81
+ const SKIP = new Set(SKIP_DIRS);
82
+ const MAX_LINE = 1000; // a line this long means minified or generated code
83
+ const MAX_BYTES = 1_000_000;
84
+ /** Scout: list files to check, sorted so output order never depends on the file system. */
85
+ export async function listFiles(root, ignore = []) {
86
+ const out = [];
87
+ const ignored = (p) => { const r = relative(root, p).split(sep).join("/"); return ignore.some((i) => r === i || r.startsWith(i + "/")); };
88
+ async function walk(dir) {
89
+ for (const e of await readdir(dir, { withFileTypes: true })) {
90
+ if (SKIP.has(e.name) || /\.min\.(js|css)$/.test(e.name))
91
+ continue;
92
+ const p = join(dir, e.name);
93
+ if (ignored(p))
94
+ continue;
95
+ if (e.isDirectory())
96
+ await walk(p);
97
+ else if (e.isFile())
98
+ out.push(p);
99
+ }
100
+ }
101
+ await walk(root);
102
+ return out.sort();
103
+ }
104
+ export async function scan(root, frameworks = ALL_FRAMEWORKS) {
105
+ const active = rules.filter((r) => r.controls.some((c) => frameworks.includes(c.framework)));
106
+ const findings = [];
107
+ let filesChecked = 0;
108
+ for (const abs of await listFiles(root, (await readConfig(root)).ignore)) {
109
+ const ext = extname(abs) || (abs.endsWith(".env") ? ".env" : "");
110
+ const relevant = active.filter((r) => r.extensions.includes(ext));
111
+ if (!relevant.length)
112
+ continue;
113
+ const buf = await readFile(abs);
114
+ if (buf.length > MAX_BYTES || buf.includes(0))
115
+ continue; // skip big or binary files
116
+ const file = relative(root, abs).split(sep).join("/");
117
+ const lines = buf.toString("utf8").split(/\r?\n/);
118
+ if (lines.some((l) => l.length > MAX_LINE))
119
+ continue; // minified or generated
120
+ filesChecked++;
121
+ const add = (r, line) => findings.push({
122
+ ruleId: r.id, file, line, status: r.status, severity: r.severity, title: r.title,
123
+ controls: r.controls.filter((c) => frameworks.includes(c.framework)), fix: r.fix, note: r.note,
124
+ });
125
+ for (const r of relevant) {
126
+ if (r.test)
127
+ lines.forEach((text, i) => { if (r.test(text))
128
+ add(r, i + 1); });
129
+ if (r.fileTest)
130
+ for (const n of r.fileTest(lines))
131
+ add(r, n);
132
+ }
133
+ }
134
+ // Auditor: one finding per rule per line; stable order.
135
+ const seen = new Set();
136
+ const deduped = findings.filter((f) => { const k = `${f.ruleId}|${f.file}|${f.line}`; return seen.has(k) ? false : (seen.add(k), true); })
137
+ .sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line || a.ruleId.localeCompare(b.ruleId));
138
+ const hit = new Set(deduped.map((f) => f.ruleId));
139
+ return {
140
+ rulesVersion: RULES_VERSION,
141
+ frameworks: [...frameworks].sort(),
142
+ findings: deduped,
143
+ // Only the Checker sets Met: a rule that ran and found nothing.
144
+ met: active.filter((r) => !hit.has(r.id)).map((r) => ({ ruleId: r.id, title: r.title, controls: r.controls.filter((c) => frameworks.includes(c.framework)) })),
145
+ outside: outsideFor(frameworks),
146
+ filesChecked,
147
+ disclaimer: DISCLAIMER,
148
+ };
149
+ }
150
+ const LABEL = { gap: "Gap", partial: "Partial", met: "Met", outside: "Outside code" };
151
+ const ctl = (c) => c.map((x) => `${x.framework.toUpperCase()} ${x.id}`).join(" · ");
152
+ export function toMarkdown(r) {
153
+ const lines = [
154
+ "# Lintsure report", "",
155
+ `Frameworks: ${r.frameworks.join(", ")} · Rules v${r.rulesVersion}`, "",
156
+ `> ${DISCLAIMER}`, "",
157
+ `## Findings (${r.findings.length})`, "",
158
+ ];
159
+ if (!r.findings.length)
160
+ lines.push("No issues found by the current rules.", "");
161
+ for (const f of r.findings)
162
+ lines.push(`### ${LABEL[f.status]} · \`${f.file}:${f.line}\``, `**${f.title}** (${f.severity})`, "", `- Rules: ${ctl(f.controls)}`, `- Fix: ${f.fix}`, `- Auditor note: ${f.note}`, "");
163
+ lines.push(`## Met (${r.met.length})`, "", ...r.met.map((m) => `- ${m.title} · ${ctl(m.controls)}`), "");
164
+ lines.push(`## Outside code (${r.outside.length})`, "", "Code can't prove these. They still need to be done before a full review.", "", ...r.outside.map((o) => `- ${o.framework.toUpperCase()} ${o.control} · ${o.title}: ${o.evidence}`), "");
165
+ lines.push("## What to do next", "", ...nextSteps(r).map((s, i) => `${i + 1}. ${s}`), "");
166
+ lines.push("## What this report is not", "", NOT_A_VERDICT, "");
167
+ return lines.join("\n");
168
+ }
@@ -0,0 +1,2 @@
1
+ import type { FrameworkKnowledge } from "./types.js";
2
+ export declare const euAiAct: FrameworkKnowledge;