@wipcomputer/wip-license-hook 1.0.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.
package/LICENSE ADDED
@@ -0,0 +1,52 @@
1
+ Dual License: MIT + AGPLv3
2
+
3
+ Copyright (c) 2026 WIP Computer, Inc.
4
+
5
+
6
+ 1. MIT License (local and personal use)
7
+ ---------------------------------------
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
26
+
27
+
28
+ 2. GNU Affero General Public License v3.0 (commercial and cloud use)
29
+ --------------------------------------------------------------------
30
+
31
+ If you run this software as part of a hosted service, cloud platform,
32
+ marketplace listing, or any network-accessible offering for commercial
33
+ purposes, the AGPLv3 terms apply. You must either:
34
+
35
+ a) Release your complete source code under AGPLv3, or
36
+ b) Obtain a commercial license.
37
+
38
+ This program is free software: you can redistribute it and/or modify
39
+ it under the terms of the GNU Affero General Public License as published
40
+ by the Free Software Foundation, either version 3 of the License, or
41
+ (at your option) any later version.
42
+
43
+ This program is distributed in the hope that it will be useful,
44
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
45
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46
+ GNU Affero General Public License for more details.
47
+
48
+ You should have received a copy of the GNU Affero General Public License
49
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
50
+
51
+
52
+ AGPLv3 for personal use is free. Commercial licenses available.
package/README.md ADDED
@@ -0,0 +1,200 @@
1
+ ###### WIP Computer
2
+
3
+ [![npm](https://img.shields.io/npm/v/@wipcomputer/wip-license-hook)](https://www.npmjs.com/package/@wipcomputer/wip-license-hook) [![CLI / TUI](https://img.shields.io/badge/interface-CLI_/_TUI-black)](https://github.com/wipcomputer/wip-ai-devops-toolbox/blob/main/tools/wip-license-hook/cli.js) [![MCP Server](https://img.shields.io/badge/interface-MCP_Server-black)](https://github.com/wipcomputer/wip-ai-devops-toolbox/blob/main/tools/wip-license-hook/mcp-server.mjs) [![Claude Code Skill](https://img.shields.io/badge/interface-Claude_Code_Skill-black)](https://github.com/wipcomputer/wip-ai-devops-toolbox/blob/main/tools/wip-license-hook/SKILL.md) [![Universal Interface Spec](https://img.shields.io/badge/Universal_Interface_Spec-black?style=flat&color=black)](https://github.com/wipcomputer/wip-ai-devops-toolbox/blob/main/tools/wip-universal-installer/SPEC.md)
4
+
5
+ # wip-license-hook
6
+
7
+ License rug-pull detection and dependency license compliance for open source projects.
8
+
9
+ ## The Problem
10
+
11
+ You fork an MIT project. You build on it. Six months later, the upstream quietly changes to BSL or proprietary. You pull the update without checking. Now your project is poisoned.
12
+
13
+ This has happened. It will happen again.
14
+
15
+ ## The Solution
16
+
17
+ A pre-merge hook + daily scanner + public dashboard that:
18
+
19
+ 1. **Maintains a license ledger** of every dependency and fork at time of adoption
20
+ 2. **Gates all upstream merges** — if the license changed, the merge is blocked
21
+ 3. **Scans daily** — catches license drift before it reaches your codebase
22
+ 4. **Publishes a dashboard** — public proof of license health for anyone using your forks
23
+
24
+ ## How It Works
25
+
26
+ ### Git Hooks (Always On)
27
+
28
+ **Two mandatory hooks. No bypass.**
29
+
30
+ **Pre-pull** — before pulling anything from upstream:
31
+ ```
32
+ git pull upstream main
33
+ → hook fires FIRST
34
+ → fetch without merge
35
+ → check LICENSE, package.json, SPDX headers
36
+ → compare against ledger
37
+ → SAME? → pull proceeds
38
+ → CHANGED? → BLOCK. Flag. Document. Notify. Do NOT pull.
39
+ ```
40
+
41
+ **Pre-push** — before pushing any commit to our branch:
42
+ ```
43
+ git push origin main
44
+ → hook fires FIRST
45
+ → check upstream license status
46
+ → compare against ledger
47
+ → SAME? → push proceeds
48
+ → CHANGED? → ALERT. Warn that upstream has drifted. Push still allowed (it's our code) but we know.
49
+ ```
50
+
51
+ Pre-pull = hard gate (blocks).
52
+ Pre-push = alert (warns, doesn't block our own work).
53
+
54
+ ### License Ledger
55
+
56
+ `LICENSE-LEDGER.json` tracks every dependency:
57
+
58
+ ```json
59
+ {
60
+ "dependencies": [
61
+ {
62
+ "name": "openclaw",
63
+ "source": "github:openclaw/openclaw",
64
+ "type": "fork",
65
+ "license_at_adoption": "MIT",
66
+ "license_current": "MIT",
67
+ "adopted_date": "2026-02-05",
68
+ "last_checked": "2026-02-15",
69
+ "commit_at_adoption": "abc123",
70
+ "status": "clean"
71
+ }
72
+ ],
73
+ "last_full_scan": "2026-02-15T08:00:00Z",
74
+ "alerts": []
75
+ }
76
+ ```
77
+
78
+ Status values: `clean` | `changed` | `removed` | `unknown`
79
+
80
+ ### LICENSE Snapshots
81
+
82
+ Physical copies of LICENSE files at adoption. Not just metadata. Proof that survives git history rewrites.
83
+
84
+ ```
85
+ ledger/
86
+ snapshots/
87
+ openclaw/
88
+ LICENSE-2026-02-05.txt ← what it was when we forked
89
+ LICENSE-2026-02-15.txt ← latest check
90
+ ```
91
+
92
+ If they rug-pull and rewrite history, we have the receipt on disk.
93
+
94
+ ### Daily Cron Scan
95
+
96
+ Runs every morning:
97
+
98
+ 1. For each fork: `git fetch upstream` (no merge), check LICENSE file
99
+ 2. For each npm/pip dependency: check registry for current license metadata
100
+ 3. Compare everything against the ledger
101
+ 4. Generate report
102
+ 5. If anything changed: alert immediately (message, email, or both)
103
+
104
+ ### Public Dashboard
105
+
106
+ Static site (GitHub Pages or similar) generated from the ledger:
107
+
108
+ - List of all dependencies and forks
109
+ - License at adoption vs current license
110
+ - Last checked date
111
+ - Health status (green/yellow/red)
112
+ - Proof links (commit hashes, archived LICENSE files)
113
+
114
+ Anyone using our forks can verify: "WIP Computer adopted this when it was MIT, and it's still MIT."
115
+
116
+ ## Detection Methods
117
+
118
+ ### For Forks (git repos)
119
+ - Check `LICENSE` / `LICENSE.md` / `COPYING` file content
120
+ - Parse `package.json` license field
121
+ - Check for SPDX headers in source files
122
+ - Compare against known license text fingerprints
123
+
124
+ ### For npm Dependencies
125
+ - `npm view <package> license`
126
+ - Compare against ledger
127
+
128
+ ### For Python Dependencies
129
+ - `pip show <package>` license field
130
+ - PyPI API metadata
131
+
132
+ ## Installation
133
+
134
+ ### As an OpenClaw Skill
135
+ ```bash
136
+ clawhub install wip-license-hook
137
+ ```
138
+
139
+ ### As a Git Hook
140
+ ```bash
141
+ wip-license-hook install --repo .
142
+ ```
143
+
144
+ ### As a Cron Job
145
+ ```bash
146
+ wip-license-hook scan --all --report
147
+ ```
148
+
149
+ ## Architecture
150
+
151
+ ```
152
+ core/
153
+ scanner.ts — license detection logic
154
+ ledger.ts — ledger read/write/compare
155
+ detector.ts — license text fingerprinting
156
+ reporter.ts — generate reports and alerts
157
+ cli/
158
+ index.ts — CLI wrapper
159
+ skill/
160
+ SKILL.md — OpenClaw/agent skill definition
161
+ dashboard/
162
+ index.html — static dashboard generator
163
+ hooks/
164
+ pre-merge.sh — git hook script
165
+ ```
166
+
167
+ ## Commands
168
+
169
+ ```bash
170
+ wip-license-hook init # Initialize ledger for current project
171
+ wip-license-hook scan # Scan all deps, update ledger
172
+ wip-license-hook check <dep> # Check specific dependency
173
+ wip-license-hook gate # Pre-merge license gate (for hooks)
174
+ wip-license-hook report # Generate report
175
+ wip-license-hook dashboard # Generate static dashboard
176
+ wip-license-hook alert # Send alerts for any changes
177
+ ```
178
+
179
+ ## Why This Matters
180
+
181
+ > "Been dubious of MIT open source. Seen too many pull it or hide non-MIT bins for it all to work."
182
+
183
+ This tool is the guardrail. The receipt. The proof.
184
+
185
+ If your dependency gets rug-pulled, you have:
186
+ - The exact commit where the license was what you agreed to
187
+ - Documentation of when and what changed
188
+ - A clean fork point to fall back to
189
+ - Public proof for anyone downstream of you
190
+
191
+ ## License
192
+
193
+ ```
194
+ CLI, MCP server, skills MIT (use anywhere, no restrictions)
195
+ Hosted or cloud service use AGPL (network service distribution)
196
+ ```
197
+
198
+ AGPL for personal use is free.
199
+
200
+ Built by Parker Todd Brooks, Lēsa (OpenClaw, Claude Opus 4.6), Claude Code (Claude Opus 4.6).
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * wip-license-hook CLI
4
+ *
5
+ * Commands:
6
+ * init Initialize ledger for current project
7
+ * scan Scan all deps, update ledger
8
+ * check <dep> Check specific dependency
9
+ * gate Pre-merge license gate (for hooks)
10
+ * report Print ledger report
11
+ * dashboard Generate static dashboard HTML
12
+ * alert Print current alerts
13
+ * install Install git hooks in current repo
14
+ */
15
+ export {};
@@ -0,0 +1,170 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * wip-license-hook CLI
4
+ *
5
+ * Commands:
6
+ * init Initialize ledger for current project
7
+ * scan Scan all deps, update ledger
8
+ * check <dep> Check specific dependency
9
+ * gate Pre-merge license gate (for hooks)
10
+ * report Print ledger report
11
+ * dashboard Generate static dashboard HTML
12
+ * alert Print current alerts
13
+ * install Install git hooks in current repo
14
+ */
15
+ import { resolve } from "node:path";
16
+ import { existsSync, mkdirSync, copyFileSync } from "node:fs";
17
+ import { readLedger, writeLedger, createEmptyLedger, findEntry, scanAndUpdate, gateCheck, formatScanReport, formatGateOutput, formatLedgerReport, writeDashboard, generateBadgeUrl, } from "../core/index.js";
18
+ const args = process.argv.slice(2);
19
+ const command = args[0];
20
+ const flags = new Set(args.filter((a) => a.startsWith("--")));
21
+ const positional = args.filter((a) => !a.startsWith("--")).slice(1);
22
+ const repoRoot = resolve(process.cwd());
23
+ const offline = flags.has("--offline");
24
+ const verbose = flags.has("--verbose");
25
+ function help() {
26
+ console.log(`
27
+ wip-license-hook — License rug-pull detection
28
+
29
+ Usage: wip-license-hook <command> [options]
30
+
31
+ Commands:
32
+ init Initialize LICENSE-LEDGER.json
33
+ scan Scan all dependencies, update ledger
34
+ check <name> Check a specific dependency
35
+ gate Pre-merge license gate (exit 1 if changed)
36
+ report Print ledger status
37
+ dashboard Generate static HTML dashboard
38
+ alert Show current alerts
39
+ install Install git hooks in .git/hooks/
40
+ badge Print shields.io badge URL
41
+
42
+ Options:
43
+ --offline Skip network calls (use cached data only)
44
+ --verbose Verbose output
45
+ --help Show this help
46
+ `);
47
+ }
48
+ async function main() {
49
+ if (!command || command === "--help" || flags.has("--help")) {
50
+ help();
51
+ return;
52
+ }
53
+ switch (command) {
54
+ case "init": {
55
+ const ledgerPath = resolve(repoRoot, "LICENSE-LEDGER.json");
56
+ if (existsSync(ledgerPath)) {
57
+ console.log("⚠️ LICENSE-LEDGER.json already exists. Use 'scan' to update.");
58
+ return;
59
+ }
60
+ writeLedger(repoRoot, createEmptyLedger());
61
+ mkdirSync(resolve(repoRoot, "ledger/snapshots"), { recursive: true });
62
+ console.log("✅ Initialized LICENSE-LEDGER.json and ledger/snapshots/");
63
+ console.log(" Run 'wip-license-hook scan' to populate.");
64
+ break;
65
+ }
66
+ case "scan": {
67
+ console.log(offline ? "📡 Scanning (offline mode)..." : "📡 Scanning dependencies...");
68
+ const results = scanAndUpdate({ repoRoot, offline, verbose });
69
+ console.log(formatScanReport(results));
70
+ break;
71
+ }
72
+ case "check": {
73
+ const name = positional[0];
74
+ if (!name) {
75
+ console.error("Usage: wip-license-hook check <dependency-name>");
76
+ process.exit(1);
77
+ }
78
+ const ledger = readLedger(repoRoot);
79
+ const entry = findEntry(ledger, name);
80
+ if (!entry) {
81
+ console.log(`❓ ${name} not found in ledger. Run 'scan' first.`);
82
+ process.exit(1);
83
+ }
84
+ console.log(`\n ${entry.status === "clean" ? "✅" : "🚫"} ${entry.name}`);
85
+ console.log(` Type: ${entry.type}`);
86
+ console.log(` Source: ${entry.source}`);
87
+ console.log(` Adopted: ${entry.license_at_adoption} on ${entry.adopted_date}`);
88
+ console.log(` Current: ${entry.license_current} (checked ${entry.last_checked})`);
89
+ console.log(` Status: ${entry.status}\n`);
90
+ break;
91
+ }
92
+ case "gate": {
93
+ if (offline) {
94
+ console.log("⚠️ Offline mode — skipping license gate (cannot verify upstream).");
95
+ console.log(" Your push will proceed, but licenses were NOT checked.");
96
+ process.exit(0);
97
+ }
98
+ const { safe, alerts } = gateCheck(repoRoot, offline);
99
+ console.log(formatGateOutput(safe, alerts));
100
+ if (!safe)
101
+ process.exit(1);
102
+ break;
103
+ }
104
+ case "report": {
105
+ const ledger = readLedger(repoRoot);
106
+ console.log(formatLedgerReport(ledger));
107
+ break;
108
+ }
109
+ case "dashboard": {
110
+ const outPath = writeDashboard(repoRoot);
111
+ console.log(`✅ Dashboard written to ${outPath}`);
112
+ break;
113
+ }
114
+ case "alert": {
115
+ const ledger = readLedger(repoRoot);
116
+ if (ledger.alerts.length === 0) {
117
+ console.log("✅ No active alerts.");
118
+ }
119
+ else {
120
+ console.log(`\n⚠️ ${ledger.alerts.length} alert(s):\n`);
121
+ for (const a of ledger.alerts) {
122
+ console.log(` ${a.message}`);
123
+ console.log(` Detected: ${a.detected}\n`);
124
+ }
125
+ }
126
+ break;
127
+ }
128
+ case "install": {
129
+ const hooksDir = resolve(repoRoot, ".git/hooks");
130
+ if (!existsSync(resolve(repoRoot, ".git"))) {
131
+ console.error("❌ Not a git repository. Run from a git repo root.");
132
+ process.exit(1);
133
+ }
134
+ mkdirSync(hooksDir, { recursive: true });
135
+ // Find hooks relative to the package
136
+ const pkgRoot = resolve(new URL(".", import.meta.url).pathname, "../../..");
137
+ const prePullSrc = resolve(pkgRoot, "hooks/pre-pull.sh");
138
+ const preCommitSrc = resolve(pkgRoot, "hooks/pre-push.sh");
139
+ for (const [src, dest] of [
140
+ [prePullSrc, resolve(hooksDir, "pre-merge-commit")],
141
+ [preCommitSrc, resolve(hooksDir, "pre-push")],
142
+ ]) {
143
+ if (existsSync(src)) {
144
+ copyFileSync(src, dest);
145
+ const { chmodSync } = await import("node:fs");
146
+ chmodSync(dest, 0o755);
147
+ console.log(`✅ Installed ${dest}`);
148
+ }
149
+ else {
150
+ console.log(`⚠️ Hook source not found: ${src}`);
151
+ }
152
+ }
153
+ break;
154
+ }
155
+ case "badge": {
156
+ const ledger = readLedger(repoRoot);
157
+ console.log(generateBadgeUrl(ledger));
158
+ break;
159
+ }
160
+ default:
161
+ console.error(`Unknown command: ${command}`);
162
+ help();
163
+ process.exit(1);
164
+ }
165
+ }
166
+ main().catch((err) => {
167
+ console.error("Fatal error:", err.message);
168
+ process.exit(1);
169
+ });
170
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAiB,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EACL,UAAU,EAAE,WAAW,EAAE,iBAAiB,EAAE,SAAS,EACrD,aAAa,EAAE,SAAS,EACxB,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,EACtD,cAAc,EAAE,gBAAgB,GACjC,MAAM,kBAAkB,CAAC;AAE1B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,OAAO,GAAG,IAAI,CAAC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+ export type LicenseId = "MIT" | "Apache-2.0" | "BSD-2-Clause" | "BSD-3-Clause" | "GPL-2.0" | "GPL-3.0" | "LGPL-2.1" | "LGPL-3.0" | "MPL-2.0" | "ISC" | "BSL-1.1" | "SSPL-1.0" | "Unlicense" | "AGPL-3.0" | "UNKNOWN";
5
+ /**
6
+ * Detect license type from raw license file text.
7
+ */
8
+ export declare function detectLicenseFromText(text: string): LicenseId;
9
+ /**
10
+ * Normalize a license SPDX identifier from package metadata.
11
+ */
12
+ export declare function normalizeSpdx(raw: string): LicenseId;
@@ -0,0 +1,104 @@
1
+ /**
2
+ * License text fingerprinting — identifies license type from file content.
3
+ */
4
+ const FINGERPRINTS = [
5
+ {
6
+ id: "MIT",
7
+ markers: ["permission is hereby granted, free of charge", "the software is provided \"as is\""],
8
+ antiMarkers: ["apache", "gnu general public"],
9
+ },
10
+ {
11
+ id: "Apache-2.0",
12
+ markers: ["apache license", "version 2.0"],
13
+ },
14
+ {
15
+ id: "GPL-3.0",
16
+ markers: ["gnu general public license", "version 3"],
17
+ antiMarkers: ["lesser general public"],
18
+ },
19
+ {
20
+ id: "GPL-2.0",
21
+ markers: ["gnu general public license", "version 2"],
22
+ antiMarkers: ["lesser general public", "version 3"],
23
+ },
24
+ {
25
+ id: "LGPL-3.0",
26
+ markers: ["gnu lesser general public license", "version 3"],
27
+ },
28
+ {
29
+ id: "LGPL-2.1",
30
+ markers: ["gnu lesser general public license", "version 2.1"],
31
+ },
32
+ {
33
+ id: "AGPL-3.0",
34
+ markers: ["gnu affero general public license", "version 3"],
35
+ },
36
+ {
37
+ id: "BSD-3-Clause",
38
+ markers: ["redistribution and use in source and binary forms", "neither the name"],
39
+ },
40
+ {
41
+ id: "BSD-2-Clause",
42
+ markers: ["redistribution and use in source and binary forms"],
43
+ antiMarkers: ["neither the name"],
44
+ },
45
+ {
46
+ id: "MPL-2.0",
47
+ markers: ["mozilla public license", "version 2.0"],
48
+ },
49
+ {
50
+ id: "ISC",
51
+ markers: ["isc license", "permission to use, copy, modify"],
52
+ },
53
+ {
54
+ id: "BSL-1.1",
55
+ markers: ["business source license", "1.1"],
56
+ },
57
+ {
58
+ id: "SSPL-1.0",
59
+ markers: ["server side public license"],
60
+ },
61
+ {
62
+ id: "Unlicense",
63
+ markers: ["this is free and unencumbered software released into the public domain"],
64
+ },
65
+ ];
66
+ /**
67
+ * Detect license type from raw license file text.
68
+ */
69
+ export function detectLicenseFromText(text) {
70
+ const lower = text.toLowerCase();
71
+ for (const fp of FINGERPRINTS) {
72
+ const allMatch = fp.markers.every((m) => lower.includes(m));
73
+ const anyAnti = fp.antiMarkers?.some((m) => lower.includes(m)) ?? false;
74
+ if (allMatch && !anyAnti)
75
+ return fp.id;
76
+ }
77
+ return "UNKNOWN";
78
+ }
79
+ /**
80
+ * Normalize a license SPDX identifier from package metadata.
81
+ */
82
+ export function normalizeSpdx(raw) {
83
+ const map = {
84
+ mit: "MIT",
85
+ "apache-2.0": "Apache-2.0",
86
+ apache2: "Apache-2.0",
87
+ "bsd-2-clause": "BSD-2-Clause",
88
+ "bsd-3-clause": "BSD-3-Clause",
89
+ "gpl-2.0": "GPL-2.0",
90
+ "gpl-3.0": "GPL-3.0",
91
+ "gpl-3.0-only": "GPL-3.0",
92
+ "lgpl-2.1": "LGPL-2.1",
93
+ "lgpl-3.0": "LGPL-3.0",
94
+ "mpl-2.0": "MPL-2.0",
95
+ isc: "ISC",
96
+ "bsl-1.1": "BSL-1.1",
97
+ "sspl-1.0": "SSPL-1.0",
98
+ unlicense: "Unlicense",
99
+ "agpl-3.0": "AGPL-3.0",
100
+ "agpl-3.0-only": "AGPL-3.0",
101
+ };
102
+ return map[raw.toLowerCase().trim()] ?? "UNKNOWN";
103
+ }
104
+ //# sourceMappingURL=detector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detector.js","sourceRoot":"","sources":["../../src/core/detector.ts"],"names":[],"mappings":"AAAA;;GAEG;AAyBH,MAAM,YAAY,GAAkB;IAClC;QACE,EAAE,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AS,CAAC;AACpD,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { detectLicenseFromText, normalizeSpdx, type LicenseId } from "./detector.js";
2
+ export { readLedger, writeLedger, createEmptyLedger, findEntry, upsertEntry, archiveSnapshot, hasLicenseChanged, addAlert, type Ledger, type LedgerEntry, type Alert, type DependencyType, type DependencyStatus } from "./ledger.js";
3
+ export { scanAll, scanAndUpdate, gateCheck, findLicenseFile, readLicenseFromDir, type ScanResult } from "./scanner.js";
4
+ export { formatScanReport, formatGateOutput, formatLedgerReport, generateDashboardHtml, generateBadgeUrl, writeDashboard } from "./reporter.js";
@@ -0,0 +1,5 @@
1
+ export { detectLicenseFromText, normalizeSpdx } from "./detector.js";
2
+ export { readLedger, writeLedger, createEmptyLedger, findEntry, upsertEntry, archiveSnapshot, hasLicenseChanged, addAlert } from "./ledger.js";
3
+ export { scanAll, scanAndUpdate, gateCheck, findLicenseFile, readLicenseFromDir } from "./scanner.js";
4
+ export { formatScanReport, formatGateOutput, formatLedgerReport, generateDashboardHtml, generateBadgeUrl, writeDashboard } from "./reporter.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAkB,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,iBAAiB,EAAE,QAAQ,EAAyF,MAAM,aAAa,CAAC;AACtO,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,kBAAkB,EAAmB,MAAM,cAAc,CAAC;AACvH,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * License ledger — read/write/compare LICENSE-LEDGER.json + snapshot archiving.
3
+ */
4
+ import type { LicenseId } from "./detector.js";
5
+ export type DependencyStatus = "clean" | "changed" | "removed" | "unknown";
6
+ export type DependencyType = "fork" | "npm" | "pip" | "cargo" | "go";
7
+ export interface LedgerEntry {
8
+ name: string;
9
+ source: string;
10
+ type: DependencyType;
11
+ license_at_adoption: LicenseId;
12
+ license_current: LicenseId;
13
+ adopted_date: string;
14
+ last_checked: string;
15
+ commit_at_adoption?: string;
16
+ status: DependencyStatus;
17
+ }
18
+ export interface Alert {
19
+ dependency: string;
20
+ from: LicenseId;
21
+ to: LicenseId;
22
+ detected: string;
23
+ message: string;
24
+ }
25
+ export interface Ledger {
26
+ version: 1;
27
+ dependencies: LedgerEntry[];
28
+ last_full_scan: string | null;
29
+ alerts: Alert[];
30
+ }
31
+ export declare function ledgerPath(repoRoot: string): string;
32
+ export declare function createEmptyLedger(): Ledger;
33
+ export declare function readLedger(repoRoot: string): Ledger;
34
+ export declare function writeLedger(repoRoot: string, ledger: Ledger): void;
35
+ export declare function findEntry(ledger: Ledger, name: string): LedgerEntry | undefined;
36
+ export declare function upsertEntry(ledger: Ledger, entry: LedgerEntry): void;
37
+ /**
38
+ * Archive a LICENSE file snapshot for a dependency.
39
+ */
40
+ export declare function archiveSnapshot(repoRoot: string, depName: string, licenseContent: string, date?: string): string;
41
+ /**
42
+ * Compare an entry's current license against its adoption license.
43
+ * Returns true if changed.
44
+ */
45
+ export declare function hasLicenseChanged(entry: LedgerEntry): boolean;
46
+ /**
47
+ * Add an alert to the ledger.
48
+ */
49
+ export declare function addAlert(ledger: Ledger, dep: string, from: LicenseId, to: LicenseId): void;