Home Business & Finance Sem: New primitive for code understanding – not LSPs,...
Business & Finance

Sem: New primitive for code understanding – not LSPs, but entities on top of Git

Key Points

Semantic understanding on top of Git. Diff, blame, impact, log. Functions, not lines.

Semantic understanding on top of Git. Diff, blame, impact, log. Functions, not lines. Left: what git shows you. Right: what actually happened. diff --git a/src/auth/login.ts b/src/auth/login.ts @@ -12,6 +12,18 @@ +export function validateToken(token: string) { + const decoded = jwt.verify(token, SECRET); + if (!decoded.exp || decoded.exp < Date.now()) { + throw new TokenExpiredError(); + } + return decoded; +} + @@ -24,8 +36,10 @@ export async function authenticateUser( - const user = await db.findUser(email); - if (!user) return null; + const user = await db.findUser(email); + if (!user) throw new UserNotFoundError(); + await rateLimiter.check(email); @@ -45,12 +59,0 @@ -export function legacyAuth(user, pass) { - return db.query('SELECT * FROM users - WHERE email = ? AND password = ?', - [user, pass]); -} ┌─ src/auth/login.ts ──────────────── │ │ ⊕ function validateToken [added] │ ∆ function authenticateUser [modified] │ ⊖ function legacyAuth [deleted] │ └──────────────────────────────────── 3 entities changed across 1 file AI agents are 2.3x more accurate when given sem output vs raw line diffs. See the benchmark. Everything works in any Git repo. No config. No plugins. sem diff │ ⊕ function validateToken [added] │ ∆ function authenticateUser [modified] │ ⊖ function legacyAuth [deleted] sem blame │ ⊕ render_inline_diff a1a6fbf Rohan 04-03 │ ⊕ format_terminal a1a6fbf Rohan 04-03 sem impact ⊕ function authenticateUser → depends on: db.findUser, rateLimiter ← used by: loginRoute, authMiddleware ! 42 entities transitively affected sem log │ ae576ab Rohan 02-05 added │ a105183 Rohan 02-08 modified (logic) │ a1a6fbf Rohan 04-03 modified (logic) sem entities entities: src/auth/login.ts function validateToken (L12:24) function authenticateUser (L26:45) interface AuthConfig (L47:52) sem context context for authenticateUser (budget: 8000) target: ~705 tokens dependencies: ~256 tokens dependents: ~812 tokens All commands support --json for machine-readable output. Full reference. 26 languages. 5 data formats. One binary. $ brew install sem-cli $ sem setup ✓ Created wrapper script ✓ Set git config --global diff.external = sem ✓ Pre-commit hook installed Done! Running git diff in any repo will now use sem. To revert, run: sem unsetup One command. Every git diff becomes a sem diff . No config files. Also: cargo install --git https://github.com/Ataraxy-Labs/sem sem-cli
Git Semantic (ORG) --git (PERSON) src/auth (ORG) src/auth/login.ts @@ -12,6 (ORG) jwt.verify(token (PERSON) TokenExpiredError (ORG) src/auth/login.ts (ORG) │ ⊕ (ORG) AI (ORG) Git (PERSON) sem diff │ ⊕ (ORG) Rohan (PERSON) sem unsetup One command (ORG)
Originally published by Hacker News Read original →