You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: verify_package tool — registry existence check before cargo add / bun add (anti-slopsquatting) #144
New ReadOnly tool verify_package: verifies that a package name actually exists on crates.io / npm before the model runs cargo add / bun add — the slopsquatting defense. (Research: 43% of hallucinated package names recur across runs — detectable; 13% differ by one character from a real package — typo-squat bait.)
exact=true (default): registry GET — crates.io /api/v1/crates/{name} (200 → {exists:true, newest_version}, 404 → {exists:false}); npm https://registry.npmjs.org/{name} (200/404). 429/5xx → {status:"rate_limited"} — never reported as "does not exist" (an honest unknown must not look like a verdict).
exact=false or exists=false: nearest candidates via the search endpoints (crates.io /api/v1/crates?q=, npm /-/v1/search); any candidate within edit distance 1 is flagged as a possible typo-squat.
Name validation: charset allowlist, reject leading -, reject ..; scoped npm names @scope/pkg supported (URL-encode per segment).
ReadOnly risk: always callable, zero approval friction — mirrors the gh.rs read-ops discipline. Zero new deps: ureq 3 + json feature already in the workspace (openai.rs precedent).
System prompt gains one line: verify a package with verify_package before any install command; run_command description mentions the same.
Why (the problem you're solving)
Slopsquatting is the newest supply-chain class in the agentic era: models hallucinate package names, attackers pre-register them, agents install malware. tole is positioned as the trust-first harness; shipping this check as a first-class ReadOnly tool makes the safe path the cheap path, without blocking installs via approval gates (which would just push the model to route around). Live-verified 2026-10-01: both registries' exists/search endpoints respond as designed.
Testing (how you verified this works)
Unit with a mock HTTP server (pattern: openai.rs tests): exists / not-found + candidates / rate-limited / malformed name (leading dash, .., bad charset) / scoped npm name.
Spec truth: the tool's spec() advertises exactly what execute reads (scan-3 lesson).
Live E2E: verify_package(serde) → exists with version; verify_package(<hallucinated>) → not-found with candidates. Mission-level: a prompt asking to add a nonexistent crate → transcript shows the model verifying first.
Activity