
Product
PHP and Composer Support Is Now in Beta
Socket’s PHP and Composer support is now in Beta for all customers, with PHP reachability analysis generally available.
Munich Hacking Legal Challenge — an AI agent platform for the BMW Group legal department. Lex coordinates specialized AI agents (contract review, compliance, research, risk) and returns structured, traceable, source-cited deliverables to human lawyers.
Built on the Pi coding-agent runtime and adapted for BMW legal workflows.
# One-line install (clones into ~/.local/share/lex)
curl -fsSL https://raw.githubusercontent.com/itsamirkhon/lex/main/install.sh | bash
# OR via npm
npm install -g bmw-lex
lex auth # paste your OpenRouter API key (sk-or-v1-...)
Get a key at openrouter.ai/keys. Lex uses Claude Sonnet 4.5 by default.
lex # interactive REPL
lex contract-review samples/acme-supplier-nda-draft.md --jurisdiction de
lex compliance-check "Acme GmbH" --check-type sanctions,lksg
lex legal-research "force majeure pandemic" --jurisdiction de,uk
lex-web # web UI on http://localhost:3000
Name conflict on Linux? A system tool
/usr/bin/lex(a lexer generator) may shadow ours. Fix withexport PATH="$HOME/.local/bin:$PATH"or use thebmw-lexalias.
A corporate legal department handles thousands of recurring tasks: reviewing supplier contracts, checking entities against sanctions lists, researching jurisdictional differences, drafting from templates. Lex automates the decomposable parts while keeping a human lawyer in the loop for judgment calls.
Every workflow:
outputs/.plans/<slug>.md.provenance.md sidecar with full audit trail┌─────────────────────────────────────────────────────────────┐
│ CLI / Web UI │
│ bin/lex.js • bin/lex-web.js (Next.js on :3000) │
└────────────────────────────┬────────────────────────────────┘
│
┌──────────────▼───────────────┐
│ Lex Orchestrator │
│ .lex/SYSTEM.md │
│ Pi runtime + extensions │
└──────────────┬───────────────┘
│
┌─────────────────────┼─────────────────────┐
│ │ │
┌───▼────┐ ┌──────▼──────┐ ┌──────▼─────┐
│Workflow│ │ Subagents │ │ Tools │
│Prompts │ │ .lex/agents│ │ extensions/│
└────────┘ └─────────────┘ └────────────┘
File-based handoff via outputs/.plans, outputs/.drafts
| Agent | Role | Output |
|---|---|---|
contract-agent | Clause-by-clause review, redlines, BMW-template comparison | contract-analysis.md |
compliance-agent | OFAC/EU sanctions, LkSG, ESG, GDPR checks | compliance-report.md |
research-agent | Statute & case law (DE / US / UK / FR / EU) | legal-research.md |
risk-agent | Risk register with CRITICAL/HIGH/MEDIUM/LOW grading | risk-assessment.md |
negotiation-agent | BATNA, position tiers (preferred → walk-away), redlines | negotiation-brief.md |
knowledge-agent | Internal precedent / template / memo search | kb-results.md |
qa-agent | Citation verification, jurisdiction completeness | qa-report.md |
| Command | Description |
|---|---|
/contract-review <file> [--jurisdiction <de|us|uk|fr>] | Risk-grade a contract clause-by-clause |
/compliance-check <topic> [--check-type sanctions|lksg|esg|gdpr|all] | Multi-framework compliance assessment |
/legal-research <question> [--jurisdiction <de|us|uk|fr|all>] | Cross-jurisdiction statutory + case law research |
/risk-assessment <file-or-topic> | Comprehensive legal risk register |
/contract-draft <nda|supply|service> [--jurisdiction <de>] | Draft from BMW standard templates |
Registered as Pi tools, available to all agents:
legal_web_search — pre-filtered for gesetze-im-internet.de, eur-lex.europa.eu, bailii.org, etc.sanctions_check — searches OFAC SDN, EU Consolidated, UN Security Council listseurlex_search — EU regulations, directives, decisionsdocument_parse — PDF/DOCX → plaintext for contract analysisdocument_upload — copies files into a matter workspace.
├── bin/ # CLI entry points (lex, lex-web)
├── dist/ # Compiled TypeScript (cli, paths, runtime, setup)
├── extensions/
│ ├── legal-tools.ts # Pi extension entry
│ └── legal-tools/ # Sub-modules (search, document, matter, header)
├── prompts/ # Workflow templates (slash commands)
│ ├── contract-review.md
│ ├── compliance-check.md
│ ├── legal-research.md
│ ├── risk-assessment.md
│ └── contract-draft.md
├── .lex/
│ ├── SYSTEM.md # Orchestrator system prompt
│ ├── settings.json # Pi packages config
│ └── agents/ # 7 specialized subagent definitions
├── knowledge-base/ # BMW internal legal corpus (mock)
│ ├── policies/ # Primary BMW policy sources (Code of Conduct)
│ ├── templates/ # Standard NDA, supply, service agreements
│ ├── precedents/ # Approved clause language
│ └── memos/ # LkSG checklist, sanctions procedure
├── samples/ # Demo contracts for testing
├── web/ # Next.js 15 web UI
│ └── app/
│ ├── page.tsx # Main UI (slash-command input + artifact viewer)
│ └── api/ # task / status / upload / artifacts routes
├── scripts/
│ └── patch-embedded-pi.mjs # Runtime patches to embedded Pi (tool name filter, etc.)
├── outputs/ # Generated at runtime
│ ├── .plans/<slug>.md # Matter plans (orchestrator scratch)
│ ├── .drafts/<slug>-*.md # Subagent intermediate artifacts
│ └── matters/<id>/ # Final deliverables + provenance
├── install.sh # One-line installer
└── package.json
Every final deliverable is paired with a .provenance.md sidecar:
- Matter ID: bmw-acme-nda-review
- Date: 2026-04-25
- Jurisdiction(s): DE
- Governing Law: BGB / GeschGehG
- Task Type: contract-review
- Agents used: contract-agent, risk-agent, knowledge-agent, qa-agent
- Sources consulted: 14 | Sources verified: 12
- QA result: PASS WITH NOTES
- QA MAJOR findings: Liability cap §8.2 references unverified market norm
- Human review gate: APPROVED
- Privilege status: PRIVILEGED
This enables full audit trails for regulatory inquiries, BAFA reporting, and internal governance.
lex contract-review samples/acme-supplier-nda-draft.md --jurisdiction de
The sample NDA contains 5 intentional defects. Expected output:
knowledge-base/templates/bmw-nda-standard.mdlex compliance-check "supply chain partnership XYZ Corp China" --check-type sanctions,lksg
lex legal-research "force majeure pandemic clause enforceability" --jurisdiction de,uk
Comparative table with BGH and English High Court citations. All URLs verified by qa-agent.
lex-web
# open http://localhost:3000
Drag-and-drop contract upload, live agent activity log, artifact viewer with markdown rendering, provenance panel.
@mariozechner/pi-coding-agent) on Node.js 20+tsx at runtime)outputs/, ~/.lex/agent/For legal work, the audit trail of intermediate artifacts is a feature, not a workaround. Plans, drafts, QA reports, and provenance sidecars all sit on disk in human-readable Markdown — making the system fully auditable, resumable across sessions, and easy to inspect without a database.
git clone https://github.com/itsamirkhon/lex.git
cd lex
npm install
lex --version
# Run from source
node bin/lex.js --help
.lex/agents/your-agent.md with YAML frontmatter (name, description, tools, output)prompts/Edit extensions/legal-tools/your-tool.ts, register via pi.registerTool(), and re-export from
extensions/legal-tools.ts.
knowledge-agent currently uses grep, fine for MVPMIT — built for the Munich Hacking Legal Challenge by BMW Group.
FAQs
Lex — BMW Legal AI Agent Platform built on Pi
We found that bmw-lex demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Product
Socket’s PHP and Composer support is now in Beta for all customers, with PHP reachability analysis generally available.

Product
Socket is bringing experimental protection to Firefox, scanning 97,000+ extensions in Mozilla's official directory for malware and risky updates.

Research
/Security News
Three compromised Rust crates pulled in a malicious dependency that downloaded and executed cross-platform malware during Cargo builds.