惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
CXSECURITY Database RSS Feed - CXSecurity.com
A
About on SuperTechFans
H
Help Net Security
Engineering at Meta
Engineering at Meta
G
Google Developers Blog
aimingoo的专栏
aimingoo的专栏
The Register - Security
The Register - Security
WordPress大学
WordPress大学
MongoDB | Blog
MongoDB | Blog
Hugging Face - Blog
Hugging Face - Blog
爱范儿
爱范儿
C
Check Point Blog
人人都是产品经理
人人都是产品经理
云风的 BLOG
云风的 BLOG
N
Netflix TechBlog - Medium
酷 壳 – CoolShell
酷 壳 – CoolShell
雷峰网
雷峰网
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - Franky
I
InfoQ
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The GitHub Blog
The GitHub Blog
Last Week in AI
Last Week in AI
D
Docker
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 叶小钗
Jina AI
Jina AI
F
Fortinet All Blogs
宝玉的分享
宝玉的分享
小众软件
小众软件
有赞技术团队
有赞技术团队
F
Full Disclosure
月光博客
月光博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Recorded Future
Recorded Future
Apple Machine Learning Research
Apple Machine Learning Research
P
Proofpoint News Feed
量子位
U
Unit 42
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
V
V2EX
O
OpenAI News
S
Secure Thoughts
罗磊的独立博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Google Online Security Blog
Google Online Security Blog
Cloudbric
Cloudbric
W
WeLiveSecurity
IT之家
IT之家

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Agentp: Turn OpenCode Into a Headless AI Engine for Your Editor, Terminal, and Telegram
Joan Miquel Torres · 2026-06-18 · via DEV Community

I've always felt out of step with the prevailing trends.

Before the AI explosion, the mantra was "ship fast" — the Minimum Viable Product. If you weren't first, you were nobody. Quality, testing, documentation? Nice-to-haves. I could never stomach shipping "human slop" just to be first.

Now we're in the AI era, and suddenly everyone is alarmed about "AI slop." And I find myself out of step again — because from where I stand, the AI helps me produce the opposite.

Just as an example, I have a personal side project called SmarkForm and very little time to invest in it (but I keep pushing). Before AI it had a few "not-to-break-again" tests and a bare "just-the-docs" Jekyll site on GitHub Pages with often outdated code snippets and only a separate Examples section (which still exists) as the sole real demo.

Nowadays almost every code snippet in the documentation is a working example of a SmarkForm-powered form whose source code can be edited in place. The test suite has been fully migrated to Playwright, covering up to 5 platforms and including a suite of co-located tests that ensure every example in the documentation keeps working. Moreover, the most recent inline examples are AI-authored (in Copilot's words: "SmarkForm's clean, declarative API makes it a natural fit for AI-assisted development"). The last "AI-free" bastion in the repository was the actual source code of the library, but nowadays I use AI there too — just with a more thorough review and a test-first approach.

Put simply: my documentation is better. I write more tests than I could have imagined before. The code is cleaner. Even the worst AI-generated test is harmless: the most it can do is be useless. Unlike buggy production code rushed out to win a race, it won't break anything — an occasional garbage-collection pass is all you need.

The same goes for tooling. Every few years — sometimes months — a new IDE becomes the baseline, and if you haven't switched you're suddenly irrelevant. I use Neovim and tmux. Not because they're trendy, but because I spent years evolving a workflow that works across physical terminals, remote servers, and whatever machine I happen to be sitting at. And, more importantly, it lets me focus on what I'm doing rather than how to do it. I'm not about to throw that away for a shinier editor.

That's the mindset behind the agentp trio. It started with just agentp, a simple CLI tool that pipes a prompt to an OpenCode server and returns the final answer while you see what's going on in a spare monitor (when you have it). Then came ocmux, a project manager that manages a tmux session labeled as "Opencode" and keeps a dedicated OpenCode server and TUI for each project in a separate window. Finally, tgagentp is a Telegram bot that lets me talk to my projects (and even send and receive files) while away from the keyboard — and so much more.

Agentp grew from there — piece by piece, idea by idea — into a set of three zero-dependency Node.js CLI tools. It's heavily AI-assisted, including the tests. I review every stage before shipping, but the real test is using it every day. Bugs happen; I value a working feature more than a flawless one.

In summary, now I can:

  • Pipe a prompt straight from Vim and replace my selection with the answer.
  • See what's going on in an Opencode TUI that automatically switches to the right project.
  • Get notified in Telegram when the answer is ready.
  • Talk to the agent in charge of my project from Telegram while away from the keyboard.
  • Handle multiple projects and servers simultaneously from a Telegram group with topics.
  • Queue messages while a server is busy and get threaded replies.
  • Leave private comments and public (for the agent awareness) notes in my telegram conversation.
  • Send files to the agent and ask the agent to send files to me through Telegram.
  • Record a Telegram conversation and inject it as context into the next agentp response.
  • Threaded replies, permission request handling, and more...

The Three Tools

agentp — The Pipe

Stdin in, answer out. That's the core loop.

When you get used to writing text in Vim, all other text input methods feel clunky — and OpenCode TUI's editor is no exception. Its /editor command lets you edit prompts in an external editor, but the whole TUI screen blanks out during the edit, which means a complete loss of context.

My solution: I open the OpenCode TUI in a dedicated tmux session that I can maximize on a spare vertical monitor or just switch back and forth when working from a laptop. Then I write my prompts directly in Vim, visually select them, and send them to OpenCode by filtering them through agentp. I can either ask for a code snippet and get the answer in place, or use the --qa modifier to keep my prompt together with the answer. The latter lets me maintain a kind of logbook of prompts and answers so I can go back to review, copy chunks of code (or former prompts), etc.

Basic usage:

printf "Summarize this file" | agentp
cat prompt.txt | agentp

# Target a specific session by name (partial match works)
cat prompt.txt | agentp --session "My Task"
cat prompt.txt | agentp --session "New Task" --new   # create if not found

# Pull the last N answers without sending a new prompt
agentp --getLast 5
agentp --getLast 3 --qa    # full QA pairs with rulers

Real magic from Vim/Neovim:

:'<,'>!agentp --qa

This replaces your visual selection with the answer. The optional --qa modifier preserves the prompt + answer with labels, so you keep the full context.

🚀 Spoiler:

Passing the output of ocmux (without arguments) ensures the prompt goes to the right server and automatically switches the TUI in your spare monitor (or wherever) to the right project, instantly.

:'<,'>!agentp --qa $(ocmux)

ocmux — The Project Manager

Each project gets its own tmux window with a dedicated opencode serve + TUI pane. Auto-restarts dead panes, pins window names, stores state in .ocmux.json (discovered upward like .git).

Having the OpenCode TUI aside while you send work to it and receive answers in place is great. But what if you want to switch to another project while the agent is processing?

  • Open another OpenCode Server + TUI in a new tmux window.
  • Remember the port of each server.
  • Manually switch to the right TUI pane and zoom it.
  • Pass the correct port to agentp every time you call it from a different directory…

None of this is a big deal on its own. But by the time you finish working on the second project, the first one has probably finished — and you'd want to switch back.

Ocmux handles all of that. With no arguments, it switches the Opencode tmux session to the window for the current project (based on the working directory) and prints the server URL.

Combine it with agentp as agentp $(ocmux) or agentp --qa $(ocmux) and you not only send the prompt to the right server and get the answer back — at the same time, OpenCode automatically switches to the right TUI window for that project. It feels like magic when you're juggling multiple projects.

ocmux serve ~/projects/myapp        # create (new window)
ocmux serve --print-logs ~/projects/myapp  # also print server logs to terminal
ocmux list                          # list all
ocmux list -l                       # list with full URLs
ocmux ~/projects/myapp              # switch (shows url)
ocmux                               # same as ocmux $(pwd)
ocmux kill ~/projects/myapp         # remove
ocmux kill                          # same as ocmux $(pwd)

ocmux also supports --git and --GIT flags for git base directory resolution: --git matches with either worktrees or repository roots, while --GIT requires an actual repository root (not a worktree).

ocmux --last prints the URL of the active tmux window — useful when calling agentp from outside the project directory.

When an opencode server crashes, ocmux resurrect reads .ocmux.json, kills the stale tmux window, and starts a fresh server + TUI in the same directory. Works even with a dead tmux window (stale state file).

tgagentp — The Telegram Bridge

A Telegram bot that routes messages to your OpenCode servers. Multi-chat, multi-server, slash-commands for everything.

Ever wanted to work on a project while away from the keyboard? Writing notes is fine, but you get no feedback — you can't see or explore the project environment. What if you could send a prompt to an agent handling your project and get the answer back in Telegram? Queue messages while the server is busy and get threaded replies? Send files to the agent, or — even better — ask the agent to send files to you?

That's tgagentp. And way more: handle multiple servers simultaneously (with a Telegram group using topics), "record" your messages so the next agentp --qa prepends the conversation as context… And vice versa: get prompts and responses from agentp --qa delivered to Telegram so you can follow the conversation from anywhere — or just go grab a coffee and get notified when the agent finishes.

tgagentp                                  # default port 4096
tgagentp --think                          # start with thinking forwarding enabled
tgagentp --dev                            # enable /shutdown for remote restart
TGAGENTP_ROOT=/srv/projects tgagentp      # enable /serve and /new commands
TGAGENTP_ALLOWED_CHAT_IDS="123,-456" tgagentp  # restrict to specific chats

Slash commands:

Command What it does
/help Show available commands
/status Show current server, session, agent, and health
/servers List/switch between ocmux projects
/sessions List/switch/create/rename sessions
/agents List/switch active agent
/models List providers and models
/serve <path> Start a server in an existing project (requires TGAGENTP_ROOT)
/new <path> Create a directory, init git, and start a server (requires TGAGENTP_ROOT)
/allow Approve a tool permission once
/reject Deny a tool permission
/always Approve a permission and remember the choice
/answer <number> Respond to a structured question from the AI
/markdown Send original markdown response as .md file (reply to get that specific one)
//<command> Send a raw TUI command (e.g., //init, //clear) — answer or confirmation forwarded
/queue <msg> Queue message when busy — auto-sent after current task finishes (replies chain!)
/record Record / pause / retrofill conversation for agentp context
/flush Clear all queued messages (manual or auto-queued)
/note <text> Forward context for agent awareness (agent replies "Ack", info informs future responses)
/comment <text> Save a comment in chat (not forwarded to agent — context via reply quoting)
/think Toggle real-time thinking message forwarding
/cancel Abort the running prompt
/disconnect Disconnect from current server, clear ownership and connection file
/force-switch <server> Switch server bypassing ownership check (two-phase matching)
/resurrect Restart a crashed server and reconnect the chat to the new instance

Permission prompts from OpenCode (tool access requests) are forwarded automatically — respond with /allow, /reject, or /always directly in the chat.

When the AI asks a structured question (e.g., tool configuration), tgagentp forwards it as a numbered multiple-choice poll — respond with /answer <number>. If the command produces a quick answer, it arrives immediately; otherwise a confirmation (✅ /init submitted.) is sent.

File sharing: Ask the agent to send you a file and it will know how. Send a file to the chat and the agent will be notified and can download it on demand.

!! wildcard: Use !! in any command to reference the previous user message. For example, /queue !! queues your last message, /note !! sends it as a note.

On formatting: The agent produces Markdown, but Telegram only supports a limited subset (bold, italic, code, pre). tgagentp converts Markdown to Telegram's HTML automatically, which works great for prose, lists, and code — but complex tables, nested formatting, or raw HTML may not survive the trip. If something looks mangled, use /markdown to download the original response as a .md file and read it comfortably in any Markdown viewer or editor.


agentp and ocmux together

Combine both tools and you never need to think about ports or URLs again. agentp $(ocmux) sends your prompt to the right server for the current project AND switches the TUI to show that project — all in one command. From Vim:

:'<,'>!agentp --qa $(ocmux)

Note: You may think you can just run ocmux once and pass the URL as a
literal to agentp — the command is recorded in your Vim command history, after all.

But calling ocmux every time also automatically switches the TUI to the
right project in the "Opencode" tmux session.
That's the real value.


The Agentp Gateway

The killer integration: agentp and tgagentp talk to each other through a tiny HTTP gateway.

  • agentp --tg — forwards the answer to your Telegram chat after every pipe (hard error if tgagentp not running).
  • agentp --no-tg — explicitly disable Telegram forwarding (overrides auto-detection in --qa mode).
  • agentp --qa — auto-detects tgagentp and sends the full QA pair (rulers + prompt + answer) if tgagentp is running.
  • /record — buffers the Telegram conversation. On the next agentp call, the gateway returns the buffer, and --qa prepends it to stdout with rulers — so OpenCode sees the full Telegram thread as context. Retroactively buffer past messages with /record N.
  • agentp --flush — clears the buffer without prepending.
  • agentp --getLast 5 — retrieves the last 5 assistant answers from session history (or QA pairs with --getLast 5 --qa).
  • Exclusive ownership — each server belongs to at most one chat. New chats start disconnected. /servers switch <name> --force takes over and notifies the previous owner.
  • Auto-queue — when a server is unreachable, messages are automatically queued and delivered when it comes back. /flush clears the queue.
  • Server health detection — tgagentp periodically checks server connectivity. Dead servers are shown as ❌ unreachable in /status.
  • Multi-chat — each Telegram chat or forum thread has independent server, session, and recorder state. Perfect for teams sharing one bot.
  • Auto tmux switch — every message or /note from any chat/topic automatically selects and zooms the corresponding server's tmux window, so the TUI follows the conversation across topics.
  • Message splitting — long answers are split at 4096 characters (respecting newlines) to stay within Telegram limits.
  • State persistence — chat-to-server directory mappings survive restarts via /tmp/tgagentp-connections.json. On reboot, tgagentp re-discovers the live server URL from .ocmux.json and reconnects automatically. /shutdown clear wipes the saved state.
  • Remote resurrect/resurrect restarts a crashed server from Telegram: calls resurrectServer() from the library, then transfers session state (serverOwners, active session/agent) to the new URL.
:'<,'>!agentp --qa --tg          " answer in editor + Telegram (hard error if no tgagentp)
:'<,'>!agentp --qa               " same + Telegram only if tgagentp detected
:'<,'>!agentp --qa --flush       " flush /record buffer
:'<,'>!agentp                    " only replaces. Useful for simple snippets.
:'<,'>!agentp --no-tg            " same as above, explicitly skip Telegram

Environment variables:

Variable Required Default Description
TELEGRAM_BOT_TOKEN Yes Bot token from @botfather
TGAGENTP_ALLOWED_CHAT_IDS No all Comma-separated chat IDs to allow (e.g. "123456,-789012")
TGAGENTP_ROOT No Root directory for /serve and /new commands (must be writable)
TGAGENTP_PORT No random Port for the agentp gateway (agentp --tg discovers it automatically)
TGAGENTP_DEBOUNCE_MS No 5000 Debounce interval for queued-agentp Telegram notifications (ms)
OPENCODE_SERVER_PASSWORD No Password for authenticated OpenCode servers

All of this with zero npm dependencies — just Node.js 18+ stdlib.


Why This Setup Works

  1. Always-visible TUI, hands-free — The dedicated TUI lives on a spare monitor, a virtual desktop, or a tmux window. You work elsewhere. The TUI shows the full picture without you touching it.
  2. Multi-project agility — Each project gets its own server and TUI. Switch projects with a single ocmux command (or automatically via ocmux with no args), and the displayed TUI follows. The same auto-switch works from Telegram: every message or /note selects the right tmux window, so the TUI follows you across topics. Start a task in project A, switch to project B while A runs.
  3. Editor ↔ terminal ↔ Telegram loop — Pipe from Vim with agentp, get the answer inline. Enable --tg (implicit with --qa) and the result also lands in Telegram — so even if you moved to another device or context, you know when it's done.
  4. Remote awareness — tgagentp monitors progress, forwards permission prompts, and queues follow-ups from anywhere. /record recovers Telegram conversation context for your next agentp call. Notifications pop the moment a piped task finishes or needs input.
  5. Graceful degradation--tg in auto mode silently skips Telegram if tgagentp isn't running. Explicit --tg errors pre-send, warns post-send.
  6. Async processing — tgagentp never blocks the polling loop. Commands stay responsive even while a prompt runs.

Quick Start

npm install -g agentp

# Start a project server
ocmux serve ~/projects/myapp

# Pipe a prompt
printf "Explain this codebase" | agentp

# With Telegram (set up a bot with @BotFather first)
export TELEGRAM_BOT_TOKEN="your-token"
export OPENCODE_SERVER_PASSWORD="your-password"   # optional but recommended
tgagentp --think


Links


Feedback? Issues? PRs welcome.