Skip to content

Instantly share code, notes, and snippets.

View monperrus's full-sized avatar

Martin Monperrus monperrus

View GitHub Profile
@monperrus
monperrus / composition.atif.json
Created October 30, 2026 18:59
lean-agent: six live Lean-only theorem-verification trajectories (ATIF)
{
"schema_version": "ATIF-v1.7",
"session_id": "9a79a8a7177f",
"agent": {
"name": "lean-agent",
"version": "0.1.0",
"model_name": "deepseek-v4-flash"
},
"notes": "Live theorem verification: Trajectory.composition. Actual Lean calls and observations; environment prompts and hidden reasoning omitted. The theorem concerns the pure transition model, not arbitrary native IO.",
"steps": [
@monperrus
monperrus / 390d0d04-sed-excerpt.md
Created October 20, 2026 08:55
Knowledge as Code (Monperrus 2026), trajectory 390d0d04 excerpt: encoding POSIX basic regular expressions in a sed model

Trajectory 390d0d04 (excerpt): encoding POSIX basic regular expressions in a sed model

user (2026-10-17T15:53:33)

add support for 'sed -i'

assistant (2026-10-17T15:53:47)

Adding sed -i support to the line-provenance index. When the agent runs sed -i on a file, its s/// substitutions are applied to the lines already attributed to the agent for that file, and the lines inserted by a, i and c are attributed to the agent.

@monperrus
monperrus / b8ea8c89-telegram-excerpt.md
Created October 20, 2026 08:55
Knowledge as Code (Monperrus 2026), trajectory b8ea8c89 excerpt: learning the shape of a Telegram API response by execution

Trajectory b8ea8c89 (excerpt): learning the shape of a Telegram API response by execution

user (2026-09-09T09:28:30)

tg.py only does send/contacts/read/whoami add support for group creation

tool call: Bash (2026-09-09T09:28:42)

grep -n "cmd_whoami\|^def main\|sub.add_parser\|args.command ==\|^from telethon\|^\"\"\"\|^  tg.py" tg.py
@monperrus
monperrus / post.md
Last active October 14, 2026 18:29
Why Claude Code cannot sudo (and how to fix it)

Why Claude Code cannot sudo (and how to fix it)

TL;DR: If your account has an empty password and no NOPASSWD rule, sudo -n fails with a password is required, while plain sudo works with no terminal at all.

Agents love sudo -n, so they conclude "sudo doesn't work".

Fix: drop -n, or add a NOPASSWD rule.

@monperrus
monperrus / post.md
Created October 3, 2026 03:47
How long does a prompt cache live? Measured TTLs for 11 LLM endpoints

How long does a prompt cache live? Measured TTLs for 11 LLM endpoints

Every major LLM API now caches prompt prefixes: send the same beginning twice and the second call is cheaper and faster. What vendors rarely say is how long a cached prefix survives. Anthropic documents it (5 min, or 1 h on request); OpenAI gives a range ("5 to 10 minutes of inactivity, up to an hour", 24 h on opt-in); DeepSeek says "hours to days". Z.ai, Moonshot (Kimi) and Mistral publish nothing. I could not find a page that measures it.

So I measured it.

@monperrus
monperrus / gist.md
Created September 21, 2026 08:00
Copy-paste from a remote tmux to your local clipboard (OSC 52)

Copy-paste from a remote tmux to your local clipboard

Three layers must all cooperate. Any one of them broken and copy silently does nothing — no error, no clipboard. 🧩

[ remote app / tmux copy-mode ]  →  OSC 52 escape  →  [ ssh ]  →  [ local terminal ]  →  clipboard

Layer 1 — the terminal emulator must speak OSC 52 📋

@monperrus
monperrus / native-grammar-decoding.md
Last active September 6, 2026 06:45
Native support of grammar-based Decoding in inference servers

Native support of grammar-based Decoding in inference servers

This note distinguishes server-side constrained decoding from prompt-only formatting. In constrained decoding, the inference server masks invalid next tokens while generating; it does not merely ask the model to follow a format and parse the finished text.

Constraint interfaces

Interface Expressive power Typical use
JSON Schema Structured JSON objects and arrays API responses, function arguments
Regex Regular languages IDs, dates, fixed records
@monperrus
monperrus / run.superwebapp-tab.json
Created August 26, 2026 06:20
Martin's Super Webapp tab: Run
{
"1": {
"tab": {
"id": "run",
"label": "Run",
"html": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\">\n<title>Run Pace</title>\n<style>\n html, body { margin: 0; height: 100%; background: #0d1117; color: #c9d1d9;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }\n * { box-sizing: border-box; }\n \n .app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; padding: 12px; gap: 8px; }\n \n .header { display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }\n .header h1 { margin: 0; font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 6px; }\n .status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }\n .status-dot.idle { background: #8b949e; }\n .status-dot.running { background: #3fb950; box-shadow: 0 0 12px rg
@monperrus
monperrus / paint.superwebapp-tab.json
Created August 25, 2026 18:34
Martin's Super Webapp tab: Paint
{
"1": {
"tab": {
"id": "paint",
"label": "Paint",
"html": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\">\n<title>Paint</title>\n<style>\n html, body {\n margin: 0; height: 100%;\n background: #0d1117; color: #c9d1d9;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n overflow: hidden;\n -webkit-user-select: none; user-select: none;\n }\n #app { display: flex; flex-direction: column; height: 100%; }\n\n /* Top bar */\n header {\n display: flex; align-items: center; gap: 6px;\n padding: 8px 10px;\n background: #161b22; border-bottom: 1px solid #30363d;\n flex-shrink: 0;\n }\n header h1 {\n font-size: 16px; margin: 0 8px 0 0; font-weight: 600; color: #58a6ff;\n flex-shrink: 0;\n }\n .hbtn {\n min-width: 44px; height: 44px;\n display: flex; align-items: center; justify-conte
@monperrus
monperrus / jmap-email.superwebapp-tab.json
Last active August 25, 2026 17:48
Martin's Super Webapp tab: Email
{
"1": {
"tab": {
"id": "jmap-email",
"label": "Email",
"html": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<title>JMAP Email</title>\n<style>\n html, body { margin: 0; height: 100%; background: #0d1117; color: #c9d1d9;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }\n * { box-sizing: border-box; }\n .app { display: flex; flex-direction: column; height: 100%; max-width: 600px; margin: 0 auto; }\n .header { padding: 12px 16px; border-bottom: 1px solid #30363d; background: #161b22;\n display: flex; align-items: center; gap: 8px; min-height: 52px; }\n .header h1 { margin: 0; font-size: 18px; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;\n cursor: pointer; -webkit-user-select: none; user-select: none; }\n .header h1:active { opacity: .7; }\n .header .back-btn { background: none; border: none;