逗号与问号
A Comma and a Question Mark

原始链接: https://www.thetypicalset.com/blog/a-comma-and-a-question-mark

在积累了二十年终端命令的肌肉记忆后,作者厌倦了死记硬背各种标志和语法。通过将本地大模型(Qwen 27B)集成到 Zsh shell 中,他们开发了一套系统,架起了自然语言与终端执行之间的桥梁。 该系统通过两个简单的触发器改变了命令行体验: * **逗号(`,`):** 接收自然语言描述,并返回一系列建议的命令及其解释,随后放置在提示符行供用户查看并手动执行。 * **问号(`?`):** 连接到一个配备了文件读取和网络搜索工具的本地智能体(“Pi”),通过 Markdown 在终端内直接回答问题。 至关重要的是,该系统侧重于建议而非自动执行,让用户始终拥有完全的控制权。通过利用 JSON 模式和本地模型,作者创建了一个私密、离线的工具,在不牺牲安全性的前提下显著提高了终端效率。这突显了向“计算机辅助”交互的转变,即机器作为智能助手,优化了我们与 Shell 沟通的方式。

``` Hacker News 最新 | 过往 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 逗号与问号 (thetypicalset.com) 10 分,由 eigenBasis 发布于 3 小时前 | 隐藏 | 过往 | 收藏 | 1 条评论 帮助 z3ugma 38 分钟前 [–] 你愿意分享这个脚本吗?使用 pi /share 命令,它会将其发布到 GitHub 的 Gist 上。 回复 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索: ```
相关文章

原文

I’ve been using a terminal for more than two decades now, building muscle memory for find flags and git commands. I’m not sure how it happened, but reaching for --help has become less and less natural. Instead of typing the command I would start typing the sentence: “find the 5 largest files”, “show me the last 3 commits”.

command not found

kept reminding me: computers can’t talk. Or can’t they? In the glorious age of slop, any(one)(thing) can talk. And sure it did; all it took was about a hundred lines of code to stitch together zsh, llama-server, Qwen3.6, Pi and three commands:

  • A comma for “give me a command”
  • A question mark for “answer my question”

It was fun, easy, and only cost $7k for a M5 Max MBP with 128GB of unified memory.

The comma

Now I can type a comma followed by plain English, a description of what I want to do. A few seconds later I get a short list of commands, each with a one-line explanation. I pick one, it drops onto my prompt line. I read it, maybe edit it, and press Enter myself.

Of course, being the CEO of the Structured Outputs Company™, I had to use a few tricks: JSON Schema to get a list of {command, note}, and some grammar fun to force the command prefixes (ls, git, etc.).

The thing answering my commas is a 27B parameter model running locally through llama.cpp. It is not a frontier model and it doesn’t have to be. I’m not asking it to be brilliant; I’m asking it to propose four ways to list large files. Pinning the shape and a local model is more than enough, so is my laptop.

The question mark

The question mark does a different job, so it gets a different tool.

A question might be answered from what the model already knows, or it might need to read a file on my disk, or check something current on the web. So the question mark hands the prompt to a small local agent instead (the Amazing Pi). I’ve given it a deliberately narrow toolset: it can read files and it can search the web, and nothing else. No writing, no editing, no running shell commands. I want it to look things up, not erase my hard drive. The answer comes back rendered as markdown, right there in the terminal.

It’s not about what it can do

The comma never executes anything. It proposes; I dispose. The model is good enough to draft git log --oneline --graph and nowhere near trusted enough to run it unseen, so the command lands on my prompt line and waits for me to hit enter. One keystroke between “here’s a candidate” and “yes, do that”, full safety.

The two exclamation marks that act on instructions instead of suggesting commands are still cooking. Handing an agent permission to do things in my shell, rather than just look things up, is a different kind of evening, and I’m in no rush. That’s a post for later.

An evening well spent

I enjoyed implementing this a lot more than I’d like to admit. The whole thing runs with the wifi off, does not ask for a credit card. I still can’t type a sentence into a shell and have it happen safely, but I am real close. Close enough. Computer still can’t talk, but mine got a little better at helping me talk to it.

联系我们 contact @ memedata.com