proof-of-commitment 1.3.0 → 1.5.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 (3) hide show
  1. package/README.md +261 -55
  2. package/index.js +148 -10
  3. package/package.json +9 -3
package/README.md CHANGED
@@ -1,63 +1,55 @@
1
- # proof-of-commitment
1
+ # Proof of Commitment
2
2
 
3
- > Supply chain risk scorer for npm and PyPI packages. Behavioral signals that can't be faked.
3
+ [![Commitment Score](https://poc-backend.amdal-dev.workers.dev/badge/npm/proof-of-commitment)](https://getcommit.dev/audit?packages=proof-of-commitment)
4
4
 
5
- ```
6
- npx proof-of-commitment axios zod chalk
7
- ```
5
+ > **Stars lie. Behavioral signals don't.**
8
6
 
9
- ```
10
- ──────────────────────────────────────────────────────────────────────────
11
- Package Risk Score Maintainers Downloads Age
12
- ──────────────────────────────────────────────────────────────────────────
13
- axios 🔴 CRITICAL 89 1 102.0M/wk 11.6y
14
- └ longevity=25 momentum=25 releases=20 maintainers=4 github=15
15
- zod 🔴 CRITICAL 83 1 154.0M/wk 6.1y
16
- └ longevity=25 momentum=25 releases=18 maintainers=4 github=11
17
- chalk 🔴 CRITICAL 75 1 414.6M/wk 12.7y
18
- └ longevity=25 momentum=22 releases=13 maintainers=4 github=11
19
- ──────────────────────────────────────────────────────────────────────────
20
-
21
- ⚠ 3 CRITICAL packages found.
22
- CRITICAL = sole maintainer + >10M weekly downloads (high-value attack target)
23
- Full breakdown: https://getcommit.dev/audit?packages=axios,zod,chalk
24
- ```
7
+ An MCP server and web tool that scores npm packages, PyPI packages, Rust crates, and GitHub repos on **behavioral commitment** — signals that are harder to fake than stars, READMEs, or download counts.
25
8
 
26
- ## What this does
9
+ ## The supply chain problem
27
10
 
28
- `npm audit` finds *known* CVEs vulnerabilities already catalogued in a database. This scores *structural risk before it becomes a CVE*.
11
+ 26 of the 91 npm packages with >10M weekly downloads have a **single npm publisher**. Together they account for over 3 billion downloads per week. `npm audit` doesn't surface this. Stars don't either.
29
12
 
30
- The axios attack on April 1st, 2026: `npm audit` showed zero issues beforehand. Proof of Commitment flagged axios as CRITICAL (1 maintainer, 96M downloads/week) — the exact profile that made it a high-value target.
13
+ Four packages in a typical Node.js project are CRITICAL right now:
14
+ - **chalk** — 413M downloads/week, **1 npm publisher**
15
+ - **zod** — 163M downloads/week, **1 npm publisher** (30+ GitHub contributors)
16
+ - **lodash** — 145M downloads/week, **1 npm publisher**
17
+ - **axios** — 99M downloads/week, **1 npm publisher** (attacked March 30, 2026)
31
18
 
32
- **Score dimensions:**
33
- - **Longevity** (25 pts) years in production
34
- - **Download Momentum** (25 pts) weekly download trend
35
- - **Release Consistency** (20 pts) days since last release
36
- - **Maintainer Depth** (15 pts) — team size
37
- - **GitHub Backing** (15 pts) — organization/team support
19
+ They won't appear in your `package.json` either — but these are in almost every project:
20
+ - **minimatch** 562M downloads/week, **1 npm publisher**
21
+ - **glob** 333M downloads/week, **1 npm publisher**
22
+ - **cross-spawn** 190M downloads/week, **1 npm publisher**
38
23
 
39
- **CRITICAL** = sole maintainer + >10M weekly downloads (high-value attack target)
24
+ Behavioral signals surface this. Stars and READMEs don't.
40
25
 
41
- ## Usage
26
+ ## Try it now
42
27
 
28
+ **Terminal (zero install):**
43
29
  ```bash
44
- # Score npm packages
45
- npx proof-of-commitment axios zod chalk lodash express
46
-
47
- # Score PyPI packages
48
- npx proof-of-commitment --pypi litellm langchain requests numpy
49
-
50
- # Auto-detect from package.json or requirements.txt
30
+ npx proof-of-commitment axios zod chalk
31
+ # scan your own project:
51
32
  npx proof-of-commitment --file package.json
52
- npx proof-of-commitment --file requirements.txt
53
-
54
- # Short alias
55
- npx poc axios zod chalk
33
+ # scan ALL transitive dependencies via lock file (finds the hidden CRITICAL packages):
34
+ npx proof-of-commitment --file package-lock.json # npm
35
+ npx proof-of-commitment --file yarn.lock # yarn
36
+ npx proof-of-commitment --file pnpm-lock.yaml # pnpm
37
+ # pnpm monorepo — scans all workspace packages, deduplicates:
38
+ npx proof-of-commitment --file pnpm-workspace.yaml # pnpm workspaces
39
+ # JSON output for CI/CD pipelines (exits 1 if CRITICAL found):
40
+ npx proof-of-commitment --file package-lock.json --json | jq '.criticalCount'
41
+ # PyPI too:
42
+ npx proof-of-commitment --pypi litellm langchain requests
43
+ # Cargo (Rust) via API:
44
+ curl -s https://poc-backend.amdal-dev.workers.dev/api/audit \
45
+ -X POST -H "Content-Type: application/json" \
46
+ -d '{"packages":["serde","tokio","reqwest"],"ecosystem":"cargo"}'
56
47
  ```
57
48
 
58
- ## Zero-install MCP server (for Claude, Cursor, Windsurf)
49
+ **Web demo (no install):** [getcommit.dev/audit](https://getcommit.dev/audit) paste your packages, see risk scores in seconds.
50
+
51
+ **MCP server (zero install):**
59
52
 
60
- Add to your AI tool's config:
61
53
  ```json
62
54
  {
63
55
  "mcpServers": {
@@ -69,20 +61,234 @@ Add to your AI tool's config:
69
61
  }
70
62
  ```
71
63
 
72
- Then ask: *"Audit the dependencies in my package.json"* or *"What's the risk profile of vercel/ai?"*
64
+ Add to Claude Desktop, Cursor, Windsurf, or any MCP-compatible AI tool. Then ask:
65
+
66
+ > "Audit my package.json for supply chain risk"
67
+ > "Score axios, zod, chalk, lodash — which is highest risk?"
68
+ > "Is vercel/ai actively maintained?"
73
69
 
74
70
  ## GitHub Action
75
71
 
76
- Posts audit results directly on your PR:
72
+ Add supply chain auditing to any CI pipeline in 30 seconds — auto-detects packages from `package.json` or `requirements.txt`, **posts results as a PR comment**, writes to GitHub Step Summary, and optionally fails on CRITICAL packages.
73
+
74
+ Use the dedicated action at [piiiico/commit-action](https://github.com/piiiico/commit-action):
75
+
77
76
  ```yaml
78
- - uses: piiiico/proof-of-commitment@main
79
- with:
80
- fail-on-critical: false
81
- comment-on-pr: true
77
+ # .github/workflows/supply-chain.yml
78
+ name: Supply Chain Audit
79
+ on:
80
+ pull_request:
81
+ paths: ['package.json', 'package-lock.json', 'bun.lock']
82
+
83
+ jobs:
84
+ audit:
85
+ runs-on: ubuntu-latest
86
+ permissions:
87
+ pull-requests: write
88
+ steps:
89
+ - uses: actions/checkout@v4
90
+ - uses: piiiico/commit-action@v1
91
+ with:
92
+ fail-on-critical: true # blocks merges on CRITICAL packages
93
+ comment-on-pr: true # posts results as a PR comment
94
+ ```
95
+
96
+ When `comment-on-pr: true` (default), the action automatically posts the audit table as a comment on the pull request — and **updates the same comment** on re-run, so you don't get comment spam. Reviewers see the risk table without leaving the PR.
97
+
98
+ **Inputs:**
99
+
100
+ | Input | Default | Description |
101
+ |-------|---------|-------------|
102
+ | `packages` | _(auto)_ | Comma-separated package names (auto-detected from `package.json`/`requirements.txt` if not set) |
103
+ | `packages-file` | _(auto)_ | Path to `package.json` or `requirements.txt` (default: auto-detect in workspace root) |
104
+ | `fail-on-critical` | `true` | Fail the workflow if CRITICAL packages are found |
105
+ | `max-packages` | `20` | Max packages to audit when auto-detecting |
106
+ | `include-dev-dependencies` | `false` | Include `devDependencies` from `package.json` |
107
+ | `comment-on-pr` | `true` | Post audit results as a PR comment (requires `pull-requests: write` permission) |
108
+ | `api-key` | _(none)_ | [Commit Pro](https://getcommit.dev/pricing) API key — enables batch requests and 10K requests/month |
109
+ | `api-url` | _(prod)_ | Override API endpoint (useful for self-hosting) |
110
+
111
+ **Outputs:** `has-critical`, `critical-count`, `audit-summary` (markdown table, also written to Step Summary).
112
+
113
+ **Free vs Pro:** Without an API key, packages are audited one at a time (with delays to respect rate limits). With a Pro API key, all packages are audited in a single batch request — faster and with higher monthly limits.
114
+
115
+ Example PR comment / Step Summary output:
116
+
117
+ ```
118
+ | Package | Risk | Score | Publishers | Downloads/wk | Age |
119
+ |---------|-------------|-------|------------|--------------|-------|
120
+ | chalk | 🔴 CRITICAL | 75 | 1 | 380M | 12.7y |
121
+ | zod | 🔴 CRITICAL | 83 | 1 | 133M | 6.1y |
122
+ | axios | 🔴 CRITICAL | 89 | 1 | 93M | 11.6y |
123
+ ```
124
+
125
+ ## README Badges
126
+
127
+ Add a Commit Trust badge to any npm package you maintain or depend on:
128
+
129
+ ```markdown
130
+ ![Commit Trust](https://poc-backend.amdal-dev.workers.dev/badge/YOUR-PACKAGE)
131
+ ```
132
+
133
+ Examples:
134
+
135
+ | Package | Badge URL |
136
+ |---------|-----------|
137
+ | chalk | `![Commit Trust](https://poc-backend.amdal-dev.workers.dev/badge/chalk)` |
138
+ | react | `![Commit Trust](https://poc-backend.amdal-dev.workers.dev/badge/react)` |
139
+ | express | `![Commit Trust](https://poc-backend.amdal-dev.workers.dev/badge/express)` |
140
+ | @babel/core | `![Commit Trust](https://poc-backend.amdal-dev.workers.dev/badge/@babel/core)` |
141
+
142
+ Grades: 🟢 OK (75+) · 🟠 WARNING (40–74) · 🔴 CRITICAL (<40 or sole npm publisher with 10M+ weekly downloads)
143
+
144
+ Badges are cached 1 hour. No API key needed.
145
+
146
+ Also supports PyPI, Cargo, and the full ecosystem-specific format:
147
+
148
+ ```markdown
149
+ ![commit score](https://poc-backend.amdal-dev.workers.dev/api/badge/npm/YOUR-PACKAGE)
150
+ ![commit score](https://poc-backend.amdal-dev.workers.dev/api/badge/pypi/YOUR-PACKAGE)
151
+ ![commit score](https://poc-backend.amdal-dev.workers.dev/api/badge/cargo/YOUR-CRATE)
152
+ ```
153
+
154
+ ## REST API
155
+
156
+ No API key. No install.
157
+
158
+ ```bash
159
+ curl https://poc-backend.amdal-dev.workers.dev/api/audit \
160
+ -X POST \
161
+ -H "Content-Type: application/json" \
162
+ -d '{"packages": ["axios", "zod", "chalk", "lodash", "express"]}'
82
163
  ```
83
164
 
84
- ## Links
165
+ ```json
166
+ {
167
+ "count": 5,
168
+ "results": [
169
+ {
170
+ "name": "chalk",
171
+ "ecosystem": "npm",
172
+ "score": 75,
173
+ "maintainers": 1,
174
+ "weeklyDownloads": 398397580,
175
+ "ageYears": 12.7,
176
+ "trend": "stable",
177
+ "riskFlags": ["CRITICAL"],
178
+ "scorecardScore": 3.6, // null if no GitHub repo
179
+ "hasDangerousWorkflow": false // null if no Scorecard data
180
+ },
181
+ ...
182
+ ]
183
+ }
184
+ ```
185
+
186
+ ## 8 MCP tools
187
+
188
+ | Tool | Description |
189
+ |------|-------------|
190
+ | `audit_dependencies` | Batch risk audit for up to 20 npm/PyPI/Cargo packages |
191
+ | `lookup_npm_package` | Single npm package behavioral profile |
192
+ | `lookup_pypi_package` | Single PyPI package behavioral profile |
193
+ | `lookup_cargo_crate` | Single Rust crate behavioral profile (crates.io) |
194
+ | `lookup_github_repo` | GitHub repo commitment score (longevity, commit frequency, contributor depth) |
195
+ | `lookup_business` | Norwegian business register — operating years, employees, financials |
196
+ | `lookup_business_by_org` | Same, by org number |
197
+ | `query_commitment` | Browser extension behavioral data (unique verified visitors, repeat rate) |
198
+
199
+ ## What the score measures
200
+
201
+ Each package is scored 0–100 across:
202
+
203
+ - **Longevity** — How long has the package existed? Abandoned packages get reactivated for attacks.
204
+ - **Publisher depth** — Single npm publisher + millions of weekly downloads = the attack surface LiteLLM exploited. (Publisher = person with npm publish access, distinct from GitHub contributors.)
205
+ - **Release consistency** — Regular releases signal active oversight. Long gaps = vulnerability accumulation.
206
+ - **Download trend** — Growing packages attract more scrutiny (and attacks). Stable = lower profile.
207
+ - **OpenSSF Scorecard** — Process security (code review enforcement, branch protection, CI/CD safety). Separate from behavioral signals. High Scorecard ≠ safe from credential theft attacks.
208
+
209
+ > Both axios (8.1/10 Scorecard) and chalk (3.6/10 Scorecard) score CRITICAL on behavioral signals. They measure different attack surfaces — Scorecard catches process gaps, behavioral signals catch publisher concentration.
210
+
211
+ **Risk flags:**
212
+ - `CRITICAL` — single npm publisher + >10M weekly downloads (exact LiteLLM/axios attack profile)
213
+ - `HIGH` — package <1yr old + rapid adoption
214
+ - `WARN` — no release in 12+ months
215
+
216
+ ## Real data points
217
+
218
+ ```
219
+ # packages you know about:
220
+ chalk — score 75, 1 publisher, 413M/week ⚑ CRITICAL
221
+ zod — score 86, 1 publisher, 163M/week ⚑ CRITICAL (30+ GitHub contributors)
222
+ lodash — score 81, 1 publisher, 145M/week ⚑ CRITICAL
223
+ axios — score 86, 1 publisher, 99M/week ⚑ CRITICAL (attacked Mar 30 2026)
224
+ express — score 90, 5 publishers, 95M/week
225
+
226
+ # packages probably not in your package.json, definitely in your lock file:
227
+ minimatch — score 78, 1 publisher, 562M/week ⚑ CRITICAL
228
+ glob — score 80, 1 publisher, 333M/week ⚑ CRITICAL
229
+ cross-spawn — score 72, 1 publisher, 190M/week ⚑ CRITICAL
230
+
231
+ # post-attack:
232
+ litellm — score 74, 1 publisher ⚑ CRITICAL (supply chain attack Mar 2026)
233
+
234
+ # Rust crates (new in v1.3.0):
235
+ serde — score 78, 1 owner, 13M/week ⚑ CRITICAL (dtolnay sole owner)
236
+ tokio — score 89, 2 owners, 10M/week
237
+ reqwest — score 85, 1 owner, 8M/week ⚑ HIGH
238
+ ```
239
+
240
+ ## Why behavioral signals
241
+
242
+ The LiteLLM attack (March 2026) and axios attack (March 30, 2026) followed the same pattern: stolen credentials → malicious package pushed → 97M+ machines exposed. Both packages scored CRITICAL by these metrics *before* the attacks.
85
243
 
86
- - **Web demo:** https://getcommit.dev/audit
87
- - **Live watchlist:** https://getcommit.dev/watchlist (top 25 npm packages by structural risk)
88
- - **GitHub:** https://github.com/piiiico/proof-of-commitment
244
+ Declarative signals (stars, README quality, CI badges) don't capture this risk. Behavioral commitment does.
245
+
246
+ ## Stack
247
+
248
+ | Layer | Technology |
249
+ |-------|-----------|
250
+ | Backend | Cloudflare Workers + D1 |
251
+ | MCP | Model Context Protocol SDK |
252
+ | Data | npm registry, PyPI, crates.io, GitHub API, Brønnøysund (NO) |
253
+ | Landing | Astro + Cloudflare Pages |
254
+
255
+ ## Roadmap
256
+
257
+ Planned, not promised. The project is early-stage — contributions welcome on any of these.
258
+
259
+ | Feature | Status | Notes |
260
+ |---------|--------|-------|
261
+ | **Cargo (Rust) registry support** | ✅ Live | MCP tool, REST API, badge endpoint — `ecosystem: "cargo"` |
262
+ | **Go modules support** | Planned | pkg.go.dev API + GitHub backing score |
263
+ | **Score breakdown visualization** | Planned | Chart component for the 5 dimensions on getcommit.dev/audit |
264
+ | **`--json` flag for CLI** | ✅ Live | `npx proof-of-commitment --file package-lock.json --json \| jq '.criticalCount'` |
265
+ | **pnpm workspace monorepo support** | ✅ Live | `--file pnpm-workspace.yaml` or auto-detected from `pnpm-lock.yaml` |
266
+ | **Historical score tracking** | Planned | Trend charts — was this package getting riskier over time? |
267
+ | **Org-level dashboards** | Planned | Aggregate risk view across all repos in a GitHub org |
268
+
269
+ See [open issues](https://github.com/piiiico/proof-of-commitment/issues) for things you can help with today.
270
+
271
+ ## The broader vision
272
+
273
+ Supply chain auditing is the first tool. The underlying primitive is a **commitment graph** — behavioral signals that replace content-based trust across any domain.
274
+
275
+ When content is free to fake (reviews, stars, READMEs), commitment becomes the signal. A publisher who has shipped 847 releases over 12 years is a different kind of commitment than one who published once in 2023.
276
+
277
+ The same logic applies to websites, businesses, and AI agents. Two card networks have independently named this gap: Mastercard Verifiable Intent §9.2 explicitly lists behavioral trust as "not covered." Visa TAP identifies agents without answering whether to trust them.
278
+
279
+ Proof of Commitment is the trust layer they're pointing at.
280
+
281
+ → [getcommit.dev](https://getcommit.dev)
282
+
283
+ ## Run locally
284
+
285
+ ```bash
286
+ bun install
287
+ bun run dev:backend # local server with SQLite
288
+ bun run test:e2e # E2E test with mock World ID
289
+ ```
290
+
291
+ Deploy:
292
+ ```bash
293
+ bun run deploy # deploys to Cloudflare Workers
294
+ ```
package/index.js CHANGED
@@ -65,7 +65,7 @@ function printTable(results, { totalScanned, totalCritical, lockfile } = {}) {
65
65
  padEnd(clr(c.bold, 'Package'), COL.name),
66
66
  padEnd(clr(c.bold, 'Risk'), COL.risk),
67
67
  padEnd(clr(c.bold, 'Score'), COL.score),
68
- padEnd(clr(c.bold, 'Maintainers'), COL.maintainers),
68
+ padEnd(clr(c.bold, 'Publishers'), COL.maintainers),
69
69
  padEnd(clr(c.bold, 'Downloads'), COL.downloads),
70
70
  padEnd(clr(c.bold, 'Age'), COL.age),
71
71
  ].join(' ');
@@ -98,12 +98,18 @@ function printTable(results, { totalScanned, totalCritical, lockfile } = {}) {
98
98
 
99
99
  console.log(row);
100
100
 
101
+ // Show GitHub contributor context for CRITICAL packages with active communities
102
+ if (pkg.riskFlags && pkg.riskFlags.includes('CRITICAL') && pkg.githubContributors && pkg.githubContributors > 1) {
103
+ const ghCount = pkg.githubContributors === 35 ? '30+' : pkg.githubContributors;
104
+ console.log(clr(c.dim, ` ↳ ${ghCount} GitHub contributors — publish-access concentration risk despite active community`));
105
+ }
106
+
101
107
  // Score breakdown if available
102
108
  if (pkg.scoreBreakdown) {
103
109
  const b = pkg.scoreBreakdown;
104
110
  const breakdown = clr(c.dim,
105
111
  ` └ longevity=${b.longevity} momentum=${b.downloadMomentum} ` +
106
- `releases=${b.releaseConsistency} maintainers=${b.maintainerDepth} github=${b.githubBacking}`
112
+ `releases=${b.releaseConsistency} publishers=${b.maintainerDepth} github=${b.githubBacking}`
107
113
  );
108
114
  console.log(breakdown);
109
115
  }
@@ -115,7 +121,7 @@ function printTable(results, { totalScanned, totalCritical, lockfile } = {}) {
115
121
  if (effectiveCritical > 0) {
116
122
  const suffix = totalScanned ? ` (in ${totalScanned} packages scanned)` : '';
117
123
  console.log('\n' + clr(c.red + c.bold, `⚠ ${effectiveCritical} CRITICAL package${effectiveCritical > 1 ? 's' : ''} found${suffix}.`));
118
- console.log(clr(c.dim, ' CRITICAL = sole maintainer + >10M weekly downloads (high-value attack target)'));
124
+ console.log(clr(c.dim, ' CRITICAL = sole npm publisher + >10M weekly downloads (publish-access concentration risk)'));
119
125
  } else {
120
126
  const suffix = totalScanned ? ` (${totalScanned} packages scanned)` : '';
121
127
  console.log('\n' + clr(c.green, `✓ No CRITICAL packages found${suffix}.`));
@@ -138,12 +144,13 @@ ${clr(c.bold, 'Usage:')}
138
144
  npx proof-of-commitment --file package-lock.json Audit ALL dependencies (lock file)
139
145
  npx proof-of-commitment --file yarn.lock Audit from yarn lock file
140
146
  npx proof-of-commitment --file pnpm-lock.yaml Audit from pnpm lock file
147
+ npx proof-of-commitment --file pnpm-workspace.yaml Audit entire pnpm monorepo
141
148
  npx proof-of-commitment --file requirements.txt Audit Python packages
142
149
 
143
150
  ${clr(c.bold, 'Options:')}
144
151
  --json Output results as JSON (exits 1 if any CRITICAL found — useful in CI)
145
152
  --pypi Score PyPI packages instead of npm
146
- --file, -f Read packages from package.json, lock file, or requirements.txt
153
+ --file, -f Read packages from package.json, lock file, pnpm-workspace.yaml, or requirements.txt
147
154
 
148
155
  ${clr(c.bold, 'Examples:')}
149
156
  npx proof-of-commitment axios zod chalk
@@ -153,13 +160,13 @@ ${clr(c.bold, 'Examples:')}
153
160
  npx proof-of-commitment axios chalk --json | jq '.criticalCount'
154
161
 
155
162
  ${clr(c.bold, 'Score meaning:')}
156
- 🔴 CRITICAL Sole maintainer + >10M downloads/wk (high-value attack target)
163
+ 🔴 CRITICAL Sole npm publisher + >10M downloads/wk (publish-access concentration risk)
157
164
  🟠 HIGH Score < 40
158
165
  🟡 MODERATE Score 40–59
159
166
  🟡 GOOD Score 60–74
160
167
  🟢 HEALTHY Score 75+
161
168
 
162
- ${clr(c.bold, 'Score dimensions:')} longevity · download momentum · release consistency · maintainer depth · GitHub backing
169
+ ${clr(c.bold, 'Score dimensions:')} longevity · download momentum · release consistency · publisher depth · GitHub backing
163
170
 
164
171
  ${clr(c.bold, 'Web:')} ${WEB}
165
172
  ${clr(c.bold, 'MCP:')} ${clr(c.dim, 'Add to Claude Desktop / Cursor for AI-assisted auditing')}
@@ -223,12 +230,124 @@ function parseLockPnpm(content) {
223
230
  return [...pkgs];
224
231
  }
225
232
 
226
- async function readPackagesFromFile(filePath) {
233
+ /**
234
+ * Parse pnpm-workspace.yaml and resolve all workspace package dependencies.
235
+ * Reads package.json from each workspace, merges deps, deduplicates.
236
+ * Internal workspace packages are excluded from the audit list.
237
+ */
238
+ async function parsePnpmWorkspace(filePath) {
227
239
  const fs = await import('fs');
228
240
  const path = await import('path');
229
241
  const content = fs.readFileSync(filePath, 'utf-8');
242
+ const dir = path.dirname(path.resolve(filePath));
243
+
244
+ // Parse packages list from YAML
245
+ // Format: "packages:\n - 'apps/*'\n - 'packages/*'"
246
+ const patterns = [];
247
+ const lines = content.split('\n');
248
+ let inPackages = false;
249
+ for (const line of lines) {
250
+ if (/^packages\s*:/.test(line)) { inPackages = true; continue; }
251
+ if (inPackages) {
252
+ if (/^\s+-/.test(line)) {
253
+ const pattern = line.replace(/^\s+-\s*/, '').replace(/['"]/g, '').trim();
254
+ if (pattern) patterns.push(pattern);
255
+ } else if (/^\S/.test(line) && line.trim()) {
256
+ inPackages = false;
257
+ }
258
+ }
259
+ }
260
+
261
+ if (patterns.length === 0) {
262
+ throw new Error('No workspace packages found in pnpm-workspace.yaml');
263
+ }
264
+
265
+ // Split into includes and excludes
266
+ const excludes = patterns.filter(p => p.startsWith('!')).map(p => p.slice(1));
267
+ const includes = patterns.filter(p => !p.startsWith('!'));
268
+
269
+ // Resolve patterns to directories containing package.json
270
+ const workspaceDirs = [];
271
+ for (const pattern of includes) {
272
+ if (pattern.endsWith('/*') || pattern.endsWith('/**')) {
273
+ // Glob: 'apps/*' -> list all subdirectories of apps/
274
+ const parentDir = path.join(dir, pattern.replace(/\/\*\*?$/, ''));
275
+ try {
276
+ const entries = fs.readdirSync(parentDir, { withFileTypes: true });
277
+ for (const entry of entries) {
278
+ if (entry.isDirectory()) {
279
+ const fullPath = path.join(parentDir, entry.name);
280
+ const isExcluded = excludes.some(ex => fullPath.includes(ex) || entry.name === ex);
281
+ if (!isExcluded) workspaceDirs.push(fullPath);
282
+ }
283
+ }
284
+ } catch { /* directory doesn't exist — skip */ }
285
+ } else {
286
+ // Direct path: 'packages/shared'
287
+ const fullPath = path.join(dir, pattern);
288
+ try {
289
+ fs.statSync(fullPath);
290
+ workspaceDirs.push(fullPath);
291
+ } catch { /* doesn't exist — skip */ }
292
+ }
293
+ }
294
+
295
+ // Collect workspace package names (to exclude from audit — they're internal)
296
+ const workspacePackageNames = new Set();
297
+ for (const wsDir of workspaceDirs) {
298
+ try {
299
+ const pkg = JSON.parse(fs.readFileSync(path.join(wsDir, 'package.json'), 'utf-8'));
300
+ if (pkg.name) workspacePackageNames.add(pkg.name);
301
+ } catch { /* no package.json — skip */ }
302
+ }
303
+
304
+ // Read root package.json + all workspace package.json files, merge deps
305
+ const allDeps = new Set();
306
+ let workspaceCount = 0;
307
+
308
+ // Root
309
+ try {
310
+ const rootPkg = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf-8'));
311
+ if (rootPkg.dependencies) Object.keys(rootPkg.dependencies).forEach(d => allDeps.add(d));
312
+ if (rootPkg.devDependencies) Object.keys(rootPkg.devDependencies).forEach(d => allDeps.add(d));
313
+ } catch { /* no root package.json */ }
314
+
315
+ // Workspaces
316
+ for (const wsDir of workspaceDirs) {
317
+ try {
318
+ const pkg = JSON.parse(fs.readFileSync(path.join(wsDir, 'package.json'), 'utf-8'));
319
+ if (pkg.dependencies) Object.keys(pkg.dependencies).forEach(d => allDeps.add(d));
320
+ if (pkg.devDependencies) Object.keys(pkg.devDependencies).forEach(d => allDeps.add(d));
321
+ workspaceCount++;
322
+ } catch { /* no package.json in workspace dir */ }
323
+ }
324
+
325
+ // Remove internal workspace packages from audit list
326
+ for (const name of workspacePackageNames) {
327
+ allDeps.delete(name);
328
+ }
329
+
330
+ return {
331
+ packages: [...allDeps],
332
+ ecosystem: 'npm',
333
+ lockfile: false,
334
+ totalInFile: allDeps.size,
335
+ workspaceCount,
336
+ };
337
+ }
338
+
339
+ async function readPackagesFromFile(filePath) {
340
+ const fs = await import('fs');
341
+ const path = await import('path');
230
342
  const basename = path.basename(filePath).toLowerCase();
231
343
 
344
+ // pnpm-workspace.yaml — monorepo workspace scanner
345
+ if (basename === 'pnpm-workspace.yaml' || basename === 'pnpm-workspace.yml') {
346
+ return parsePnpmWorkspace(filePath);
347
+ }
348
+
349
+ const content = fs.readFileSync(filePath, 'utf-8');
350
+
232
351
  // package-lock.json
233
352
  if (basename === 'package-lock.json') {
234
353
  const pkgs = parseLockNpm(content);
@@ -241,8 +360,20 @@ async function readPackagesFromFile(filePath) {
241
360
  return { packages: pkgs, ecosystem: 'npm', lockfile: true, totalInFile: pkgs.length };
242
361
  }
243
362
 
244
- // pnpm-lock.yaml
363
+ // pnpm-lock.yaml — also check for workspace file to give better detection
245
364
  if (basename === 'pnpm-lock.yaml' || basename === 'pnpm-lock.yml') {
365
+ const dir = path.dirname(path.resolve(filePath));
366
+ const workspaceFile = path.join(dir, 'pnpm-workspace.yaml');
367
+ let hasWorkspace = false;
368
+ try { fs.statSync(workspaceFile); hasWorkspace = true; } catch {}
369
+
370
+ if (hasWorkspace) {
371
+ // Monorepo detected — use workspace-aware parsing
372
+ const result = await parsePnpmWorkspace(workspaceFile);
373
+ result.monorepoDetected = true;
374
+ return result;
375
+ }
376
+
246
377
  const pkgs = parseLockPnpm(content);
247
378
  return { packages: pkgs, ecosystem: 'npm', lockfile: true, totalInFile: pkgs.length };
248
379
  }
@@ -268,7 +399,7 @@ async function readPackagesFromFile(filePath) {
268
399
  return { packages: pkgs, ecosystem: 'pypi', lockfile: false };
269
400
  }
270
401
 
271
- throw new Error(`Unsupported file: ${basename}. Supported: package.json, package-lock.json, yarn.lock, pnpm-lock.yaml, requirements.txt`);
402
+ throw new Error(`Unsupported file: ${basename}. Supported: package.json, package-lock.json, yarn.lock, pnpm-lock.yaml, pnpm-workspace.yaml, requirements.txt`);
272
403
  }
273
404
 
274
405
  /**
@@ -353,7 +484,14 @@ async function main() {
353
484
  ecosystem = result.ecosystem;
354
485
  isLockfile = result.lockfile || false;
355
486
  totalInFile = result.totalInFile || packages.length;
356
- if (!jsonOutput) console.log(clr(c.dim, `Detected ${totalInFile} packages from ${filePath} (${ecosystem})`));
487
+ if (result.workspaceCount) {
488
+ if (!jsonOutput) console.log(clr(c.dim, `Monorepo: ${result.workspaceCount} workspace${result.workspaceCount > 1 ? 's' : ''} → ${totalInFile} unique external dependencies (${ecosystem})`));
489
+ if (result.monorepoDetected && !jsonOutput) {
490
+ console.log(clr(c.dim, ` (auto-detected pnpm-workspace.yaml next to ${filePath})`));
491
+ }
492
+ } else {
493
+ if (!jsonOutput) console.log(clr(c.dim, `Detected ${totalInFile} packages from ${filePath} (${ecosystem})`));
494
+ }
357
495
  } catch (err) {
358
496
  console.error(`Error reading ${filePath}: ${err.message}`);
359
497
  process.exit(1);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "proof-of-commitment",
3
- "version": "1.3.0",
4
- "description": "Supply chain risk scorer for npm and PyPI packages — behavioral signals that can't be faked",
3
+ "version": "1.5.0",
4
+ "description": "Supply chain risk scorer for npm, PyPI, and Cargo packages — behavioral signals that can't be faked",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "proof-of-commitment": "./index.js",
@@ -17,12 +17,18 @@
17
17
  "security",
18
18
  "npm",
19
19
  "pypi",
20
+ "cargo",
21
+ "rust",
22
+ "pnpm",
23
+ "monorepo",
24
+ "workspace",
20
25
  "dependencies",
21
26
  "audit",
22
27
  "risk",
23
28
  "behavioral",
24
29
  "commitment",
25
- "maintainer"
30
+ "maintainer",
31
+ "publisher"
26
32
  ],
27
33
  "author": "piiiico",
28
34
  "license": "MIT",