npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tui2cli

v0.1.0

Published

把对话式 coding agent TUI 包装成可编程接口 / scriptable wrapper around the Claude Code TUI

Readme

tui2cli (t2c)

把对话式 coding agent TUI(目前是 Claude Code)包装成可编程 CLI,但走的是 TUI 订阅价,不消耗 claude -p / Agent SDK 的按量计费配额。

🌐 English


为什么用 t2c

claude -p 是脚本化调用 Claude 的标准方式。但从 2026 年 6 月 15 日起,Anthropic 把 Pro/Max 订阅用户的 -p / Agent SDK 调用切到一个独立的 Agent SDK credit 预算,跟交互式订阅额度分开计费。

交互式 TUI(claude 裸跑)还是走订阅 flat fee。t2c 把这个 TUI 包成脚本可调的接口,但底层在 TUI 会话里干活,用的是订阅配额。

另外,对于具有tui但是没有暴露非交互式命令的coding agent,或者,你想程序化的跨厂商进行agent互相交互这个仓库提供了一种将其包装 成可编程cli的方式.


安装

npm install -g tui2cli

快速开始

因为目前只支持claude code,所以t2ctui2cliclaude-tui,都指向同一个 CLI

# 第一次调用 — t2c 自动生成 session_id (写到 stderr)
$ t2c "用 TypeScript 写个 hello.ts"

然后等待回复即可.

# 续上同一个对话 (resume)
$ t2c --session abc-1234-... "改成 ESM"

# 长 prompt 从文件喂 (stdin)
$ cat task.md | t2c

# 第一次在某个新 cwd 跑, 加 --auto-trust 让 t2c 自动写 ~/.claude.json 的
# trust 记录; 不加的话 t2c 会拒跑并提示你手动 claude 一下确认
$ t2c --auto-trust "你好"

命令参考

t2c [--session <id>] [--auto-trust] "<prompt>"
t2c [...options]  < prompt.txt           # prompt 从 stdin 读
t2c --help | --version                   # 打印帮助 / 版本号到 stdout

| Flag | 默认 | 说明 | |---|------------|---| | --session <id> | (不传则开启新会话) | 复用 session, 等价于 claude -r <session-id> | | --auto-trust | (不自动信任) | 显式 opt-in: 跑前自动把当前 cwd 加进 ~/.claude.json 的 trust 列表; 不加的话 t2c 在没 trust 的 cwd 里会拒跑并提示你二选一 (手动 claude 或加这个 flag) | | -h, --help | — | — | | -V, --version | — | — |

位置参数: <prompt> — 必填,除非用 stdin 喂(或使用 --help / --version)。

工作原理

t2c "<prompt>"
   │
   ├─ 检查 cwd 是否已在 ~/.claude.json 的 trust 列表里
   │  ├─ 已 trusted             → 继续
   │  ├─ 未 trusted + --auto-trust → 写入 trust 记录 (会持久化, 不会回滚)
   │  └─ 未 trusted + 没传 flag    → 拒跑, 提示二选一
   │
   ├─ 在 node-pty 伪终端里 spawn `claude --plugin-dir <内置> --session-id|--resume <id>`
   │  (不依赖 tmux)
   │
   ├─ 内置 plugin 注册 hook (SessionStart / Stop / ...), 每个 hook 触发时
   │  把 payload 转发到本次调用专用的 events.jsonl 文件
   │
   ├─ 等 SessionStart payload → claude TUI ready
   ├─ 通过 PTY 写入 prompt
   ├─ 等 Stop payload → claude 这一轮处理完
   └─ 输出 last_assistant_message, 退出

贡献

欢迎提 issue 和 PR。


协议

MIT (见 LICENSE)。