opmsec 0.1.3 → 0.1.5

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 (166) hide show
  1. package/.env.example +1 -0
  2. package/.husky/pre-commit +1 -0
  3. package/README.md +71 -275
  4. package/bun.lock +5 -5
  5. package/docs/architecture/agents.mdx +11 -59
  6. package/docs/architecture/benchmarks.mdx +20 -46
  7. package/docs/architecture/overview.mdx +31 -38
  8. package/docs/architecture/scanner.mdx +11 -37
  9. package/docs/cli/audit.mdx +9 -12
  10. package/docs/cli/check.mdx +12 -26
  11. package/docs/cli/fix.mdx +10 -30
  12. package/docs/cli/info.mdx +12 -19
  13. package/docs/cli/install.mdx +27 -39
  14. package/docs/cli/push.mdx +40 -57
  15. package/docs/cli/register-agent.mdx +21 -53
  16. package/docs/cli/view.mdx +12 -29
  17. package/docs/concepts/ens-records.mdx +44 -0
  18. package/docs/concepts/multi-agent-consensus.mdx +18 -36
  19. package/docs/concepts/on-chain-registry.mdx +22 -49
  20. package/docs/concepts/security-model.mdx +20 -52
  21. package/docs/concepts/zk-agent-verification.mdx +26 -64
  22. package/docs/contract/events.mdx +13 -74
  23. package/docs/contract/functions.mdx +40 -126
  24. package/docs/contract/overview.mdx +17 -36
  25. package/docs/introduction.mdx +22 -25
  26. package/docs/mint.json +3 -2
  27. package/docs/quickstart.mdx +34 -70
  28. package/docs/system-design.png +0 -0
  29. package/package.json +7 -6
  30. package/packages/cli/src/commands/author-view.tsx +87 -2
  31. package/packages/cli/src/commands/check.tsx +18 -5
  32. package/packages/cli/src/commands/fix.tsx +25 -12
  33. package/packages/cli/src/commands/info.tsx +92 -4
  34. package/packages/cli/src/commands/install.tsx +327 -23
  35. package/packages/cli/src/commands/push.tsx +112 -0
  36. package/packages/cli/src/commands/register-agent.tsx +72 -31
  37. package/packages/cli/src/index.tsx +7 -5
  38. package/packages/cli/src/services/ens-records.ts +525 -0
  39. package/packages/cli/src/services/version.ts +156 -5
  40. package/packages/core/src/benchmarks.ts +116 -0
  41. package/packages/core/src/constants.ts +18 -6
  42. package/packages/core/src/model-rankings.ts +40 -15
  43. package/packages/core/src/types.ts +10 -0
  44. package/packages/core/src/utils.ts +136 -1
  45. package/packages/scanner/src/index.ts +2 -1
  46. package/packages/scanner/src/queue/memory-queue.ts +7 -2
  47. package/packages/scanner/src/services/benchmark-runner.ts +86 -1
  48. package/packages/scanner/src/services/fileverse.ts +61 -12
  49. package/packages/scanner/src/services/openrouter.ts +18 -7
  50. package/packages/web/.next/BUILD_ID +1 -0
  51. package/packages/web/.next/app-path-routes-manifest.json +4 -0
  52. package/packages/web/.next/diagnostics/build-diagnostics.json +6 -0
  53. package/packages/web/.next/diagnostics/framework.json +1 -0
  54. package/packages/web/.next/export-marker.json +6 -0
  55. package/packages/web/.next/images-manifest.json +58 -0
  56. package/packages/web/.next/next-minimal-server.js.nft.json +1 -0
  57. package/packages/web/.next/next-server.js.nft.json +1 -0
  58. package/packages/web/.next/prerender-manifest.json +54 -4
  59. package/packages/web/.next/required-server-files.json +320 -0
  60. package/packages/web/.next/routes-manifest.json +53 -1
  61. package/packages/web/.next/server/app/_not-found/page.js +2 -0
  62. package/packages/web/.next/server/app/_not-found/page.js.nft.json +1 -0
  63. package/packages/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -0
  64. package/packages/web/.next/server/app/_not-found.html +1 -0
  65. package/packages/web/.next/server/app/_not-found.meta +8 -0
  66. package/packages/web/.next/server/app/_not-found.rsc +18 -0
  67. package/packages/web/.next/server/app/index.html +6 -0
  68. package/packages/web/.next/server/app/index.meta +7 -0
  69. package/packages/web/.next/server/app/index.rsc +22 -0
  70. package/packages/web/.next/server/app/page.js +24 -24
  71. package/packages/web/.next/server/app/page.js.nft.json +1 -0
  72. package/packages/web/.next/server/app/page_client-reference-manifest.js +1 -1
  73. package/packages/web/.next/server/chunks/611.js +6 -0
  74. package/packages/web/.next/server/chunks/778.js +30 -0
  75. package/packages/web/.next/server/functions-config-manifest.json +4 -0
  76. package/packages/web/.next/server/interception-route-rewrite-manifest.js +1 -1
  77. package/packages/web/.next/server/next-font-manifest.js +1 -1
  78. package/packages/web/.next/server/next-font-manifest.json +1 -1
  79. package/packages/web/.next/server/pages/404.html +1 -0
  80. package/packages/web/.next/server/pages/500.html +1 -0
  81. package/packages/web/.next/server/pages/_app.js +1 -0
  82. package/packages/web/.next/server/pages/_app.js.nft.json +1 -0
  83. package/packages/web/.next/server/pages/_document.js +1 -0
  84. package/packages/web/.next/server/pages/_document.js.nft.json +1 -0
  85. package/packages/web/.next/server/pages/_error.js +19 -0
  86. package/packages/web/.next/server/pages/_error.js.nft.json +1 -0
  87. package/packages/web/.next/server/webpack-runtime.js +2 -2
  88. package/packages/web/.next/static/0esGzFBCzREfVwijEGDfL/_buildManifest.js +1 -0
  89. package/packages/web/.next/static/0esGzFBCzREfVwijEGDfL/_ssgManifest.js +1 -0
  90. package/packages/web/.next/static/chunks/174-5b5efcb3b8efcc01.js +1 -0
  91. package/packages/web/.next/static/chunks/255-0dc49b7a6e8e5c05.js +1 -0
  92. package/packages/web/.next/static/chunks/4bd1b696-382748cc942d8a14.js +1 -0
  93. package/packages/web/.next/static/chunks/app/_not-found/page-0da542be7eb33a64.js +1 -0
  94. package/packages/web/.next/static/chunks/app/layout-de8e841104500505.js +1 -0
  95. package/packages/web/.next/static/chunks/app/layout.js +37 -7
  96. package/packages/web/.next/static/chunks/app/page-7e086379698b9fb0.js +1 -0
  97. package/packages/web/.next/static/chunks/app/page.js +297 -1
  98. package/packages/web/.next/static/chunks/framework-ac73abd125e371fe.js +1 -0
  99. package/packages/web/.next/static/chunks/main-4e8d71b5ef7ee7e3.js +1 -0
  100. package/packages/web/.next/static/chunks/main-app-dd261207182e5a23.js +1 -0
  101. package/packages/web/.next/static/chunks/pages/_app-7d307437aca18ad4.js +1 -0
  102. package/packages/web/.next/static/chunks/pages/_error-cb2a52f75f2162e2.js +1 -0
  103. package/packages/web/.next/static/chunks/webpack-0dcd67569eb46132.js +1 -0
  104. package/packages/web/.next/static/chunks/webpack.js +2 -2
  105. package/packages/web/.next/static/css/102562cf2d0ae9b0.css +3 -0
  106. package/packages/web/.next/static/media/4cf2300e9c8272f7-s.p.woff2 +0 -0
  107. package/packages/web/.next/static/media/747892c23ea88013-s.woff2 +0 -0
  108. package/packages/web/.next/static/media/8d697b304b401681-s.woff2 +0 -0
  109. package/packages/web/.next/static/media/93f479601ee12b01-s.p.woff2 +0 -0
  110. package/packages/web/.next/static/media/9610d9e46709d722-s.woff2 +0 -0
  111. package/packages/web/.next/static/media/ba015fad6dcf6784-s.woff2 +0 -0
  112. package/packages/web/.next/static/webpack/16f18baa938a434c.webpack.hot-update.json +1 -0
  113. package/packages/web/.next/static/webpack/5fe9fe8578f9c3d2.webpack.hot-update.json +1 -0
  114. package/packages/web/.next/static/webpack/73c7d02260cc80e4.webpack.hot-update.json +1 -0
  115. package/packages/web/.next/static/webpack/a2d85d19aa028de1.webpack.hot-update.json +1 -0
  116. package/packages/web/.next/static/webpack/app/{layout.73e341375c8d429e.hot-update.js → layout.16f18baa938a434c.hot-update.js} +1 -1
  117. package/packages/web/.next/static/webpack/app/{layout.6fee6306e0f98869.hot-update.js → layout.5fe9fe8578f9c3d2.hot-update.js} +1 -1
  118. package/packages/web/.next/static/webpack/app/layout.653e365406c0d9ac.hot-update.js +22 -0
  119. package/packages/web/.next/static/webpack/app/layout.6800169a899e3a8b.hot-update.js +22 -0
  120. package/packages/web/.next/static/webpack/app/layout.73c7d02260cc80e4.hot-update.js +22 -0
  121. package/packages/web/.next/static/webpack/app/layout.a2d85d19aa028de1.hot-update.js +22 -0
  122. package/packages/web/.next/static/webpack/app/page.653e365406c0d9ac.hot-update.js +22 -0
  123. package/packages/web/.next/static/webpack/app/page.6800169a899e3a8b.hot-update.js +22 -0
  124. package/packages/web/.next/static/webpack/app/page.73c7d02260cc80e4.hot-update.js +22 -0
  125. package/packages/web/.next/static/webpack/app/page.a2d85d19aa028de1.hot-update.js +22 -0
  126. package/packages/web/.next/static/webpack/{webpack.6fee6306e0f98869.hot-update.js → webpack.16f18baa938a434c.hot-update.js} +2 -2
  127. package/packages/web/.next/static/webpack/{webpack.73e341375c8d429e.hot-update.js → webpack.5fe9fe8578f9c3d2.hot-update.js} +2 -2
  128. package/packages/web/.next/static/webpack/webpack.653e365406c0d9ac.hot-update.js +12 -0
  129. package/packages/web/.next/static/webpack/webpack.6800169a899e3a8b.hot-update.js +12 -0
  130. package/packages/web/.next/static/webpack/webpack.73c7d02260cc80e4.hot-update.js +12 -0
  131. package/packages/web/.next/static/webpack/webpack.a2d85d19aa028de1.hot-update.js +12 -0
  132. package/packages/web/.next/trace +2 -5
  133. package/packages/web/app/globals.css +197 -51
  134. package/packages/web/app/layout.tsx +6 -3
  135. package/packages/web/app/page.tsx +791 -309
  136. package/packages/web/bun.lock +66 -105
  137. package/packages/web/next.config.ts +8 -1
  138. package/packages/web/package.json +5 -2
  139. package/packages/web/postcss.config.mjs +2 -2
  140. package/packages/web/public/apple-icon.png +1 -0
  141. package/packages/web/public/dependency-bottleneck.png +0 -0
  142. package/packages/web/public/icon-dark-32x32.png +1 -0
  143. package/packages/web/public/icon-light-32x32.png +1 -0
  144. package/packages/web/public/icon.svg +1 -0
  145. package/packages/web/public/nextjs-cve-announcement.png +0 -0
  146. package/packages/web/public/phantomraven-npm-attack.png +0 -0
  147. package/packages/web/public/placeholder-logo.png +1 -0
  148. package/packages/web/public/placeholder-logo.svg +1 -0
  149. package/packages/web/public/placeholder-user.jpg +1 -0
  150. package/packages/web/public/placeholder.jpg +1 -0
  151. package/packages/web/public/placeholder.svg +1 -0
  152. package/packages/web/public/react-cve-meme.png +0 -0
  153. package/packages/web/public/wallet-drain-exploit.png +0 -0
  154. package/packages/web/styles/globals.css +125 -0
  155. package/packages/web/.next/server/vendor-chunks/@swc.js +0 -55
  156. package/packages/web/.next/server/vendor-chunks/next.js +0 -3010
  157. package/packages/web/.next/static/chunks/app-pages-internals.js +0 -182
  158. package/packages/web/.next/static/chunks/main-app.js +0 -1882
  159. package/packages/web/.next/static/css/app/layout.css +0 -1237
  160. package/packages/web/.next/static/webpack/633457081244afec._.hot-update.json +0 -1
  161. package/packages/web/.next/static/webpack/app/page.6fee6306e0f98869.hot-update.js +0 -22
  162. package/packages/web/.next/static/webpack/app/page.73e341375c8d429e.hot-update.js +0 -22
  163. package/packages/web/tailwind.config.ts +0 -48
  164. /package/packages/web/.next/static/chunks/{polyfills.js → polyfills-42372ed130431b0a.js} +0 -0
  165. /package/packages/web/.next/static/webpack/{6fee6306e0f98869.webpack.hot-update.json → 653e365406c0d9ac.webpack.hot-update.json} +0 -0
  166. /package/packages/web/.next/static/webpack/{73e341375c8d429e.webpack.hot-update.json → 6800169a899e3a8b.webpack.hot-update.json} +0 -0
@@ -5,61 +5,35 @@ description: '10 labeled test cases for agent verification.'
5
5
 
6
6
  # Benchmark Suite
7
7
 
8
- The benchmark suite validates agent accuracy before permissionless registration. Agents must achieve **100% accuracy** and produce a valid ZK proof.
8
+ Validates agent accuracy before permissionless registration. Agents must score **100% accuracy** and produce a valid ZK proof.
9
9
 
10
- ## Test Case Structure
10
+ ## Test Cases
11
11
 
12
- Each benchmark case includes:
12
+ Each case includes: package metadata, version history, source files, known CVEs, and expected output (risk level + score range).
13
13
 
14
- | Field | Description |
15
- |-------|-------------|
16
- | **id** | Unique identifier (e.g. <code>bench-001-clean-utility</code>) |
17
- | **category** | One of: clean, typosquat, malicious, cve, obfuscated, exfiltration, dependency_confusion |
18
- | **metadata** | Package name, version, description, author, license, dependencies, scripts |
19
- | **versionHistory** | Recent versions with publish dates and change summaries |
20
- | **sourceFiles** | Path, size, and content of source files |
21
- | **knownCVEs** | Known advisories (for cve category) |
22
- | **expected** | risk_level, min_risk_score, max_risk_score, must_flag |
23
-
24
- ## Categories (10 Cases)
25
-
26
- | Category | Count | Description |
14
+ | Category | Cases | Description |
27
15
  |----------|-------|-------------|
28
- | clean | 3 | Legitimate packages (string utils, math, validator) |
29
- | typosquat | 1 | Typosquat of lodash with credential exfiltration in postinstall |
30
- | malicious | 2 | Postinstall shell execution, SSH key exfiltration |
31
- | cve | 1 | Known prototype pollution CVE |
32
- | obfuscated | 1 | Heavily obfuscated reverse shell |
33
- | exfiltration | 1 | Env var exfiltration on import |
34
- | dependency_confusion | 1 | Internal scope shadowing with DNS exfiltration |
16
+ | Clean | 3 | Legitimate packages (string utils, math, validator) |
17
+ | Typosquat | 1 | Lodash typosquat with credential exfil in postinstall |
18
+ | Malicious | 2 | Postinstall shell execution, SSH key exfiltration |
19
+ | CVE | 1 | Known prototype pollution vulnerability |
20
+ | Obfuscated | 1 | Heavily obfuscated reverse shell |
21
+ | Exfiltration | 1 | Env var exfiltration on import |
22
+ | Dependency confusion | 1 | Internal scope shadowing with DNS exfil |
35
23
 
36
24
  ## Evaluation
37
25
 
38
- For each case, the agent's output is compared to the expected values:
39
-
40
- 1. **Score range check**: <code>actualScore</code> must be within <code>[min_risk_score, max_risk_score]</code>
41
- 2. **Risk level ordinal**: For non-LOW cases, <code>actualLevel</code> must be within ±1 of expected ordinal (LOW=0, MEDIUM=1, HIGH=2, CRITICAL=3)
42
-
43
- A case **PASS**es only if both checks succeed.
44
-
45
- ## ZK Proof Generation
46
-
47
- The ZK proof proves accuracy **without revealing** test data or individual results:
48
-
49
- 1. **Commitment**: Hash of (salt, expected[0..9]) using Poseidon
50
- 2. **Proof**: Prove that <code>expected[i] == actual[i]</code> for all i, and that the commitment matches
51
- 3. **Output**: <code>proofHash</code> is stored on-chain; test data stays private
26
+ Each case is checked against:
52
27
 
53
- ## Circom Circuit
28
+ 1. **Score range** — `actualScore` within `[min_risk_score, max_risk_score]`
29
+ 2. **Risk level** — For non-LOW cases, actual level within ±1 of expected ordinal
54
30
 
55
- The circuit <code>AccuracyVerifier(10)</code> in <code>packages/contracts/circuits/accuracy_verifier.circom</code>:
31
+ A case passes only if both checks succeed.
56
32
 
57
- - **Private inputs**: expected[10], actual[10], salt
58
- - **Public input**: commitmentHash (Poseidon hash of salt + expected values)
59
- - **Public outputs**: passed (1 if all match), proofHash
33
+ ## ZK Proof
60
34
 
61
- Uses Poseidon hashing and IsEqual comparators from circomlib.
35
+ 1. **Commit** — Poseidon hash of (salt, expected[0..9]) `commitmentHash`
36
+ 2. **Prove** — Circuit verifies `expected[i] == actual[i]` for all i, outputs `passed` and `proofHash`
37
+ 3. **Store** — `keccak256(proof)` stored on-chain via `registerAgent()`
62
38
 
63
- <Note>
64
- The circuit is compiled and used for local verification. On-chain registration stores <code>keccak256(proof)</code> as the proof hash; full on-chain ZK verification can be added later.
65
- </Note>
39
+ Test data stays private — future agents can't game the benchmark.
@@ -5,54 +5,47 @@ description: 'Monorepo structure and data flow.'
5
5
 
6
6
  # Architecture Overview
7
7
 
8
- OPM is a monorepo with five main packages. The flow is: **CLI → Scanner → LLM providers → Contract writer → Base Sepolia**.
8
+ OPM is a monorepo. The flow is: **CLI → Scanner → LLM providers → Contract → Base Sepolia**.
9
9
 
10
- ## Monorepo Structure
10
+ ## Packages
11
11
 
12
12
  | Package | Purpose |
13
- |--------|---------|
14
- | **packages/core** | Types, constants, prompts, benchmarks, risk classification |
15
- | **packages/scanner** | Agents, LLM calls, queue, benchmark runner, ZK verifier |
16
- | **packages/cli** | Ink terminal UI, commands, npm/ENS/OSV integration |
17
- | **packages/contracts** | Solidity (OPMRegistry), Hardhat, Circom circuits |
18
- | **packages/web** | Next.js website |
13
+ |---------|---------|
14
+ | `packages/core` | Types, constants, prompts, benchmarks, risk classification |
15
+ | `packages/scanner` | Agent runner, LLM client, scan queue, benchmark runner, ZK verifier |
16
+ | `packages/cli` | Ink terminal UI, commands, ENS/OSV/npm integration |
17
+ | `packages/contracts` | OPMRegistry.sol, Hardhat config, Circom circuit |
18
+ | `packages/web` | Next.js landing page |
19
19
 
20
20
  ## Data Flow
21
21
 
22
22
  ```
23
- ┌─────────────┐ ┌─────────────┐ ┌──────────────────┐
24
- │ opm push │────▶│ Scanner │────▶│ LLM Providers │
25
- │ opm check │ │ (agents) │ │ OpenRouter/OpenAI
26
- └─────────────┘ └──────┬──────┘ └──────────────────┘
27
- │ │
28
- │ ▼
29
- │ ┌─────────────┐
30
- │ │ Contract │
31
- │ │ Writer │
32
- │ └──────┬──────┘
33
- │ │
34
- ▼ ▼
35
- ┌─────────────┐ ┌─────────────┐
36
- │ npm / ENS │ │ Base Sepolia│
37
- └─────────────┘ └─────────────┘
23
+ CLI (push/install/check)
24
+ Scanner (parallel agent execution)
25
+ LLM providers (OpenRouter / OpenAI)
26
+ → Contract writer (submitScore, registerPackage)
27
+ → Base Sepolia
28
+ → npm registry (publish / install)
29
+ → ENS (text records, contenthash)
30
+ → Fileverse (IPFS report upload)
38
31
  ```
39
32
 
40
33
  ## External Services
41
34
 
42
35
  | Service | Purpose |
43
36
  |---------|---------|
44
- | **OpenRouter / OpenAI** | LLM inference for agents |
45
- | **OSV** | CVE and GHSA advisory lookup |
46
- | **Fileverse** | IPFS-backed report storage (dDocs protocol) |
47
- | **ChainPatrol** | Blocklist fallback for unregistered packages |
48
- | **Artificial Analysis** | Model intelligence/coding indices for weighted scoring |
49
- | **ENS** | Author identity resolution (forward/reverse, text records) |
50
- | **npm Registry** | Package metadata, tarball download |
51
-
52
- ## Key Paths
53
-
54
- - **CLI entry**: <code>packages/cli/src/index.tsx</code>
55
- - **Scanner entry**: <code>packages/scanner/src/index.ts</code>
56
- - **Contract**: <code>packages/contracts/contracts/OPMRegistry.sol</code>
57
- - **Benchmarks**: <code>packages/core/src/benchmarks.ts</code>
58
- - **ZK circuit**: <code>packages/contracts/circuits/accuracy_verifier.circom</code>
37
+ | OpenRouter / OpenAI | LLM inference |
38
+ | OSV | CVE/GHSA lookup |
39
+ | Fileverse | IPFS report storage |
40
+ | ChainPatrol | Blocklist fallback |
41
+ | Artificial Analysis | Model intelligence indices |
42
+ | ENS | Identity resolution + text records |
43
+ | npm | Package metadata + tarball download |
44
+
45
+ ## Key Entry Points
46
+
47
+ - CLI: `packages/cli/src/index.tsx`
48
+ - Scanner: `packages/scanner/src/index.ts`
49
+ - Contract: `packages/contracts/contracts/OPMRegistry.sol`
50
+ - Benchmarks: `packages/core/src/benchmarks.ts`
51
+ - ZK circuit: `packages/contracts/circuits/accuracy_verifier.circom`
@@ -5,49 +5,23 @@ description: 'Scan queue, parallel execution, and integrations.'
5
5
 
6
6
  # Scanner Engine
7
7
 
8
- The scanner is the core security analysis engine. It coordinates package data fetching, LLM calls, and on-chain score submission.
8
+ The scanner coordinates package data fetching, LLM calls, and on-chain score submission.
9
9
 
10
- ## Memory Queue with Deduplication
10
+ ## Scan Queue
11
11
 
12
- Scans are enqueued via <code>enqueueScan(packageName, version, onStatus?, options?)</code>. The queue:
12
+ Scans are enqueued via `enqueueScan(packageName, version)`. The queue deduplicates concurrent scans for the same `name@version` and supports local tarball context for pre-publish scans.
13
13
 
14
- - Deduplicates concurrent scans for the same <code>name@version</code>
15
- - Supports local tarball context for pre-publish scans (no npm download)
14
+ ## Parallel Execution
16
15
 
17
- ## Parallel Agent Execution
18
-
19
- Agents run in parallel via <code>Promise.allSettled</code>:
20
-
21
- - Each agent fetches package data, queries OSV, calls the LLM, and submits its score on-chain
22
- - Failures in one agent do not block others
23
- - Aggregate score is the mean of successful submissions (intelligence-weighted when Artificial Analysis API is configured)
16
+ Agents run via `Promise.allSettled` — failures in one agent don't block others. The aggregate score is the mean of successful submissions, intelligence-weighted when the Artificial Analysis API is configured.
24
17
 
25
18
  ## Source Code Extraction
26
19
 
27
- <AccordionGroup>
28
- <Accordion title="From npm tarball">
29
- Downloads the tarball from the npm registry, extracts to a temp directory, and reads scannable files (<code>.js</code>, <code>.ts</code>, <code>.mjs</code>, <code>.cjs</code>, <code>.json</code>).
30
- </Accordion>
31
- <Accordion title="From local tarball">
32
- When <code>opm push</code> runs, the packed tarball path is passed. The scanner extracts source from the local file instead of downloading from npm.
33
- </Accordion>
34
- </AccordionGroup>
35
-
36
- ## NPM Registry Integration
37
-
38
- - **Metadata**: Package name, version, description, dependencies, scripts
39
- - **Version history**: Recent versions with publish dates and change summaries
40
- - **Tarball URL**: Fetched from <code>versions[version].dist.tarball</code>
41
-
42
- ## Fileverse Upload
43
-
44
- Audit reports are formatted as Markdown and uploaded via the Fileverse API. The returned URI is set on-chain via <code>setReportURI</code>. Requires <code>FILEVERSE_API_KEY</code>.
45
-
46
- ## Contract Writer
47
-
48
- The scanner's contract writer:
20
+ - **From npm**: Downloads tarball, extracts to temp dir, reads scannable files (`.js`, `.ts`, `.mjs`, `.cjs`, `.json`)
21
+ - **From local**: During `opm push`, the packed tarball path is passed directly
49
22
 
50
- - **submitScoreOnChain**: Calls <code>OPMRegistry.submitScore()</code> with agent wallet
51
- - **setReportURIOnChain**: Calls <code>OPMRegistry.setReportURI()</code>
23
+ ## Integrations
52
24
 
53
- Both require the agent to be authorized (owner-set or ZK-verified).
25
+ - **npm registry** Package metadata, version history, tarball URL
26
+ - **Fileverse** — Audit reports formatted as Markdown, uploaded via API, URI set on-chain
27
+ - **Contract writer** — `submitScore()` and `setReportURI()` calls with agent wallet
@@ -1,35 +1,32 @@
1
1
  ---
2
2
  title: 'opm audit'
3
- description: 'On-chain + CVE audit for all dependencies.'
3
+ description: 'Quick on-chain + CVE audit for all dependencies.'
4
4
  ---
5
5
 
6
6
  # opm audit
7
7
 
8
- On-chain + CVE audit for all dependencies. Faster than <code>opm check</code> because it does not call AI agents.
8
+ Fast security audit checks on-chain scores and CVEs for all dependencies without running AI agents.
9
9
 
10
10
  ## What It Does
11
11
 
12
- - Scans all <code>dependencies</code> and <code>devDependencies</code> in <code>package.json</code>
13
12
  - Queries OPMRegistry for on-chain risk scores
14
13
  - Queries OSV for CVE counts
15
- - For packages not in the registry: checks ChainPatrol blocklist
14
+ - Checks ChainPatrol blocklist for unregistered packages
16
15
  - Shows per-package risk level and CVE counts
17
16
 
18
17
  ## Output
19
18
 
20
19
  | Column | Description |
21
20
  |--------|-------------|
22
- | Package | <code>name@version</code> |
21
+ | Package | `name@version` |
23
22
  | On-chain | Risk badge (LOW/MEDIUM/HIGH) or "not in registry" |
24
- | Author | Truncated wallet address (when registered) |
25
- | CVEs | Count of known vulnerabilities (red if HIGH/CRITICAL) |
23
+ | Author | Truncated wallet address |
24
+ | CVEs | Count of known vulnerabilities |
26
25
 
27
- Summary line: <code>X high · Y medium · Z low · W unverified · N CVEs</code>
26
+ Summary: `X high · Y medium · Z low · W unverified · N CVEs`
28
27
 
29
28
  <Tip>
30
- Use <code>opm audit</code> for a quick security overview. Use <code>opm check</code> when you need AI analysis and typosquat detection.
29
+ Use `opm audit` for a quick overview. Use `opm check` when you need AI analysis and typosquat detection.
31
30
  </Tip>
32
31
 
33
- ## Environment Variables
34
-
35
- No environment variables are required. Uses built-in RPC and contract address.
32
+ No environment variables required.
@@ -1,44 +1,30 @@
1
1
  ---
2
2
  title: 'opm check'
3
- description: 'Comprehensive dependency security scan.'
3
+ description: 'Full dependency security scan with AI agents.'
4
4
  ---
5
5
 
6
6
  # opm check
7
7
 
8
- Comprehensive dependency security scan. Scans all dependencies in <code>package.json</code>, runs AI agents, and optionally uploads a report to Fileverse.
8
+ Scans all dependencies for typosquats, CVEs, on-chain risk, and AI-detected threats. Optionally uploads a report to Fileverse.
9
9
 
10
10
  ## What It Scans
11
11
 
12
- <AccordionGroup>
13
- <Accordion title="Typosquat detection">
14
- Uses Levenshtein distance against top npm packages to detect likely typosquats (e.g. <code>lodahs</code> → <code>lodash</code>).
15
- </Accordion>
16
- <Accordion title="CVE lookup (OSV)">
17
- Queries the OSV API for known vulnerabilities per package and version.
18
- </Accordion>
19
- <Accordion title="On-chain score lookup">
20
- Fetches aggregate risk scores from OPMRegistry for registered packages.
21
- </Accordion>
22
- <Accordion title="AI agent analysis">
23
- Three agents analyze the full dependency list in parallel. Each produces findings, severity, and suggested replacements.
24
- </Accordion>
25
- </AccordionGroup>
26
-
27
- ## Report Upload
28
-
29
- When <code>FILEVERSE_API_KEY</code> is set, the scan report is uploaded to Fileverse (IPFS). The report URI can be set on-chain for packages you publish.
12
+ - **Typosquats** — Levenshtein distance against top npm packages
13
+ - **CVEs** — OSV API lookup for known vulnerabilities per package/version
14
+ - **On-chain scores** Aggregate risk from OPMRegistry for registered packages
15
+ - **AI analysis** — 3 agents analyze the full dependency list in parallel, producing severity ratings and suggested replacements
30
16
 
31
17
  ## Output
32
18
 
33
- - **Per-dependency results**: Typosquats, CVE counts, on-chain scores, fix versions
34
- - **AI agent findings**: Per-agent analysis with severity and suggested replacements
35
- - **Overall assessment**: Summary counts (typosquats, CVEs, high-risk, AI flags)
36
- - **Report link**: Fileverse URL when upload succeeds
19
+ - Per-dependency results: typosquats, CVE counts, on-chain scores, fix versions
20
+ - AI agent findings with severity and suggested replacements
21
+ - Summary: total typosquats, CVEs, high-risk, AI flags
22
+ - Fileverse report link when upload succeeds
37
23
 
38
24
  <Note>
39
- <code>opm check</code> requires <code>OPENROUTER_API_KEY</code> or <code>OPENAI_API_KEY</code> for AI agent analysis. Without them, typosquat and CVE checks still run, but agent analysis is skipped.
25
+ Requires `OPENROUTER_API_KEY` or `OPENAI_API_KEY` for AI analysis. Without them, typosquat and CVE checks still run.
40
26
  </Note>
41
27
 
42
28
  <Tip>
43
- Run <code>opm fix</code> to auto-correct typosquats and vulnerable versions identified by <code>opm check</code>.
29
+ Run `opm fix` to auto-apply the fixes identified by `opm check`.
44
30
  </Tip>
package/docs/cli/fix.mdx CHANGED
@@ -5,45 +5,25 @@ description: 'Auto-fix typosquats and vulnerable dependencies.'
5
5
 
6
6
  # opm fix
7
7
 
8
- Same scan as <code>opm check</code> but auto-applies fixes to <code>package.json</code>. Replaces typosquat packages with correct names and updates vulnerable packages to patched versions.
8
+ Runs the same scan as `opm check`, then auto-applies fixes to `package.json`.
9
9
 
10
10
  ## What It Fixes
11
11
 
12
- <AccordionGroup>
13
- <Accordion title="Typosquats">
14
- Replaces package names detected as typosquats with the likely correct name (e.g. <code>lodahs</code> → <code>lodash</code>).
15
- </Accordion>
16
- <Accordion title="Vulnerable packages">
17
- Updates packages with CRITICAL or HIGH CVEs to the patched version suggested by OSV.
18
- </Accordion>
19
- <Accordion title="AI-suggested replacements">
20
- When 2+ agents flag a package and suggest a replacement, the fix is applied if the suggestion is valid.
21
- </Accordion>
22
- </AccordionGroup>
12
+ - **Typosquats** — Renames to the correct package (e.g. `lodahs` → `lodash`)
13
+ - **Vulnerable packages** — Upgrades to patched versions suggested by OSV
14
+ - **AI-flagged packages** Applies replacements when 2+ agents agree on a suggestion
23
15
 
24
16
  ## Process
25
17
 
26
- <Steps>
27
- <Step title="Scan dependencies">
28
- Runs typosquat detection, CVE lookup, and AI agent analysis (same as <code>opm check</code>).
29
- </Step>
30
- <Step title="Collect fixes">
31
- Builds a list of fixes: typosquat renames, CVE upgrades, and AI-suggested replacements.
32
- </Step>
33
- <Step title="Apply to package.json">
34
- Modifies <code>dependencies</code> and <code>devDependencies</code> with the fixes. Preserves version range prefixes (<code>^</code>, <code>~</code>).
35
- </Step>
36
- <Step title="Upload report">
37
- Optionally uploads the scan report to Fileverse when <code>FILEVERSE_API_KEY</code> is set.
38
- </Step>
39
- </Steps>
40
-
41
- ## After Running
18
+ 1. Scans all dependencies (same as `opm check`)
19
+ 2. Collects fixes: typosquat renames, CVE upgrades, AI-suggested replacements
20
+ 3. Modifies `package.json` in place (preserves `^`/`~` prefixes)
21
+ 4. Optionally uploads report to Fileverse
42
22
 
43
23
  <Warning>
44
- <code>opm fix</code> modifies <code>package.json</code> in place. Run <code>npm install</code> (or <code>opm install</code>) to apply the changes and update the lockfile.
24
+ Run `npm install` or `opm install` after `opm fix` to apply changes and update the lockfile.
45
25
  </Warning>
46
26
 
47
27
  <Tip>
48
- Review the diff in <code>package.json</code> before committing. AI-suggested replacements require consensus from 2+ agents before being applied.
28
+ Review the diff before committing. AI replacements require 2+ agent consensus.
49
29
  </Tip>
package/docs/cli/info.mdx CHANGED
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  title: 'opm info'
3
- description: 'Show on-chain security information for a package.'
3
+ description: 'On-chain security metadata and ENS records for a package.'
4
4
  ---
5
5
 
6
6
  # opm info
7
7
 
8
- Show on-chain security information for a package. Displays author, checksum, signature, ENS name, report URI, agent scores, aggregate score, and safest version.
8
+ Display on-chain security information for a package: author, checksum, signature, risk scores, agent assessments, audit report, and ENS records.
9
9
 
10
10
  ## Usage
11
11
 
@@ -21,24 +21,17 @@ opm info lodash@4.17.21
21
21
 
22
22
  </CodeGroup>
23
23
 
24
- ## Output
24
+ ## What It Shows
25
25
 
26
- | Field | Description |
27
- |-------|-------------|
28
- | Author | Wallet address (with ENS resolution when available) |
29
- | Checksum | SHA-256 hash of the tarball |
30
- | Signature | ECDSA signature (verified or unverified) |
31
- | ENS name | Author identity (e.g. <code>vitalik.eth</code>) |
32
- | Report URI | Link to Fileverse audit report |
33
- | Agent scores | Per-agent risk scores and reasoning |
34
- | Aggregate score | Mean risk score (0–100) |
35
- | Safest version | Lowest-risk version in recent releases |
36
-
37
- ## Links
38
-
39
- - **Fileverse report** — Full AI audit when report URI is set
40
- - **BaseScan** — Contract and transaction links
26
+ - **Author** Wallet address with ENS resolution
27
+ - **Checksum** — SHA-256 hash of the tarball
28
+ - **Signature** ECDSA signature (verified/unverified status)
29
+ - **Agent scores** — Per-agent risk scores with reasoning
30
+ - **Aggregate score** Mean risk across all agents
31
+ - **Safest version** Lowest-risk version in recent releases
32
+ - **Report URI** Link to Fileverse audit report
33
+ - **ENS records** `opm.*` text records from the author's ENS name (version, checksum, fileverse, risk score, contenthash)
41
34
 
42
35
  <Note>
43
- If the package is not in the OPM registry, a warning is shown. No env vars are required.
36
+ No environment variables required. If the package isn't in the OPM registry, a warning is shown.
44
37
  </Note>
@@ -5,67 +5,55 @@ description: 'Install packages with on-chain security verification.'
5
5
 
6
6
  # opm install
7
7
 
8
- Install packages with on-chain security verification. OPM runs a verification pipeline before delegating to npm.
8
+ Install packages with on-chain verification, CVE checks, and signature validation.
9
9
 
10
10
  ## Usage
11
11
 
12
12
  <CodeGroup>
13
13
 
14
- ```bash Install specific package
14
+ ```bash Single package
15
15
  opm install lodash
16
16
  ```
17
17
 
18
- ```bash Install with version
18
+ ```bash Specific version
19
19
  opm install lodash@4.17.21
20
20
  ```
21
21
 
22
- ```bash Install all dependencies
22
+ ```bash ENS-based version
23
+ opm install express@djpai.eth
24
+ ```
25
+
26
+ ```bash All dependencies
23
27
  opm install
24
28
  ```
25
29
 
26
30
  </CodeGroup>
27
31
 
28
- ## Aliases
29
-
30
- - <code>opm i</code> — same as <code>opm install</code>
31
- - <code>opm add</code> — same as <code>opm install</code>
32
+ **Aliases**: `opm i`, `opm add`
32
33
 
33
34
  ## Verification Pipeline
34
35
 
35
- <AccordionGroup>
36
- <Accordion title="CVE check (OSV)">
37
- Queries the OSV API for known CVEs and GHSA advisories. **CRITICAL** CVEs block installation.
38
- </Accordion>
39
- <Accordion title="On-chain score lookup">
40
- Fetches aggregate risk score from OPMRegistry. Blocks if score ≥ 70.
41
- </Accordion>
42
- <Accordion title="Signature verification">
43
- Verifies ECDSA signature against tarball checksum for packages in the registry.
44
- </Accordion>
45
- <Accordion title="ChainPatrol blocklist">
46
- For packages not in the OPM registry, falls back to ChainPatrol API. BLOCKED status prevents install.
47
- </Accordion>
48
- </AccordionGroup>
49
-
50
- ## Blocking Rules
36
+ 1. **CVE check** — Queries OSV for known vulnerabilities. CRITICAL CVEs block install.
37
+ 2. **On-chain score** — Fetches aggregate risk from OPMRegistry. Score ≥ 70 blocks install.
38
+ 3. **Signature verification** Verifies ECDSA signature against tarball checksum.
39
+ 4. **ChainPatrol** — Blocklist fallback for packages not in the registry.
51
40
 
52
- <Warning>
53
- Installation is **blocked** if:
54
- - Risk score ≥ 70 (on-chain)
55
- - Any CRITICAL CVE is present (OSV)
56
- - ChainPatrol returns BLOCKED (for unregistered packages)
57
- </Warning>
41
+ If all gates pass, delegates to `npm install`.
58
42
 
59
- ## Fallback Behavior
43
+ ## ENS Version Resolution
60
44
 
61
- <Note>
62
- If a package is **not in the OPM registry**, OPM falls back to standard <code>npm install</code> with a warning. ChainPatrol is consulted when available.
63
- </Note>
45
+ When you specify an ENS name as a version (e.g. `express@djpai.eth`), OPM:
64
46
 
65
- ## Environment Variables
47
+ 1. Resolves the ENS name to an Ethereum address
48
+ 2. Verifies the author is registered on-chain
49
+ 3. Fetches the safest version from the registry
50
+ 4. Checks for CVEs and auto-bumps to a safe version if needed
51
+ 5. Updates `package.json` with the resolved version
66
52
 
67
- No environment variables are required for basic install. Defaults for RPC, contract address, and API URLs are built-in.
53
+ <Warning>
54
+ Installation is **blocked** if risk score ≥ 70, any CRITICAL CVE exists, or ChainPatrol returns BLOCKED.
55
+ </Warning>
68
56
 
69
- <Tip>
70
- For bulk install (<code>opm install</code> with no args), all <code>dependencies</code> and <code>devDependencies</code> are scanned in parallel before npm install runs.
71
- </Tip>
57
+ <Note>
58
+ No environment variables needed. Defaults for RPC and contract address are built-in.
59
+ </Note>