Objlab
← News
Linguaggi e compilatori

Sem: una nuova struttura di base per la comprensione del codice – non si tratta di LSP, ma di entità che si sovrappongono a Git

Sintesi redazionale: URL dell'articolo: https://ataraxy-labs.github.io/sem/ URL dei commenti: https://news.ycombinator.com/item?id=48428475 Punti: 34 # Commenti: 17. Fonte originale: https://ataraxy-labs.github.io/sem/

<p>Semantic understanding on top of Git.</p><p>Diff, blame, impact, log. Functions, not lines.</p><p>Left: what git shows you. Right: what actually happened.</p><p>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 &lt; 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(&#x27;SELECT * FROM users - WHERE email = ? AND password = ?&#x27;, - [user, pass]); -}</p><p>┌─ src/auth/login.ts ──────────────── │ │ ⊕ function validateToken [added] │ ∆ function authenticateUser [modified] │ ⊖ function legacyAuth [deleted] │ └──────────────────────────────────── 3 entities changed across 1 file</p><p>AI agents are 2.3x more accurate when given sem output vs raw line diffs. See the benchmark.</p><p>Everything works in any Git repo. No config. No plugins.</p><p>`sem diff`</p><p>│ ⊕ function validateToken [added] │ ∆ function authenticateUser [modified] │ ⊖ function legacyAuth [deleted]</p><p>`sem blame`</p><p>│ ⊕ render_inline_diff a1a6fbf Rohan 04-03 │ ⊕ format_terminal a1a6fbf Rohan 04-03</p><p>`sem impact`</p><p>⊕ function authenticateUser → depends on: db.findUser, rateLimiter ← used by: loginRoute, authMiddleware ! 42 entities transitively affected</p><p>`sem log`</p><p>│ ae576ab Rohan 02-05 added │ a105183 Rohan 02-08 modified (logic) │ a1a6fbf Rohan 04-03 modified (logic)</p><p>`sem entities`</p><p>entities: src/auth/login.ts function validateToken (L12:24) function authenticateUser (L26:45) interface AuthConfig (L47:52)</p><p>`sem context`</p><p>context for authenticateUser (budget: 8000) target: ~705 tokens dependencies: ~256 tokens dependents: ~812 tokens</p><p>All commands support `--json`</p><p>for machine-readable output.<br>Full reference.</p><p>26 languages. 5 data formats. One binary.</p><p>$ 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</p><p>One command. Every `git diff`</p><p>becomes a `sem diff`</p><p>. No config files.</p><p>Also:<br>cargo install --git https://github.com/Ataraxy-Labs/sem sem-cli</p>