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

@moguw/dsh-ghostty

v0.1.2

Published

VSCode-style integrated terminal panel for the dsh web GUI (ghostty-web wasm + node-pty)

Readme

dsh-ghostty

VSCode 风格的内置终端面板,基于 ghostty-web(Ghostty VT 引擎的 WASM 构建,浏览器端)+ node-pty(宿主端)。它是一个独立的 dsh 插件包,宿主端与浏览器端各占一半:

  • 宿主端src/index.ts + src/host/manager.ts):在 ctx.webServer 上注册 /terminal WebSocket upgrade 路由,用 node-pty 为每个终端会话拉起一个真实 shell(Windows 默认 powershell.exe,其他平台默认 bash),把终端的输入/输出/尺寸变化在 WebSocket 上双向转发。
  • 浏览器端src/client/*):通过槽位系统在会话页下方挂一个可拖拽调高的面板,标题栏参考 VSCode,提供终端标题、下拉切换、新建/关闭当前/关闭面板;在输入栏「上下文」按钮旁(conversation.input.right)加一个拉起/收起按钮,并绑定 `Ctrl+`` 快捷键。

功能

  • `Ctrl+`` 在会话内拉起/收起终端面板。
  • 面板位于会话页下方(composer 下方),拖动顶部分隔线调整高度。
  • 标题栏:终端标题下拉切换、新建终端、关闭当前终端、关闭面板。
  • 输入栏右侧新增终端切换按钮(与「上下文」按钮同处工具行)。
  • 渲染层是 Ghostty 的 VT 引擎(WASM,ghostty-web),支持 xterm.js 兼容 API;多终端切换保留各终端屏幕与滚动历史。

工作原理

  • 浏览器端与宿主端通过单条 WebSocket(/terminal)通信,协议为 JSON 消息:客户端发 create / input / resize / close,宿主回 data / exit / error
  • 终端进程按 WebSocket 生命周期管理:刷新页面或关闭标签页即回收该页全部 shell;显式关闭终端的迟到 exit 帧会被忽略。
  • WASM 二进制内联进 lib/client.js(单文件产物),无需伺服静态资源;运行环境须支持 WebAssembly,若配置了严格 CSP,可能需要允许 wasm-unsafe-eval

构建

pnpm install
pnpm run build

产物:lib/index.js(宿主端)、lib/client.js(浏览器端,内联 ghostty-web 及其 WASM 二进制)。发布包包含 lib/、README、LICENSE 和 package metadata。

安装

方式一:npm 包(推荐)

dsh plugin --profile web add @moguw/dsh-ghostty

安装时可能出现的 peer 依赖提示(node-ptywsreact@deepseek-ai/cordis)由 dsh 宿主环境提供,无需手动安装。

方式二:本地源码 link(开发调试)

# 在本仓库根目录下执行
dsh plugin --profile web add link:/absolute/path/to/dsh-ghostty

挂载进 web 组合

dsh plugin add 只建立依赖,不挂载。在 $DSH_HOME/profiles/web/cordis.patch.yml$DSH_HOME 默认为 ~/.dsh)中加入:

- insert:
    - id: terminal
      name: '@moguw/dsh-ghostty'

启动

dsh web

浏览器打开启动日志打印的地址(默认绑定 loopback)。验证与排障:

  • 打开终端面板后,检查浏览器控制台无 wasm-unsafe-eval 报错(WebView 的 CSP 需允许 WebAssembly)。
  • dsh --profile web --dump-config 可确认 terminal 行已组合进配置树。
  • 修改源码后需重新 pnpm run build 并重启 dsh web 生效(插件加载的是 lib/ 构建产物)。

已知限制

  • 终端进程按浏览器页面存活:刷新页面或关闭标签会结束该页面下的全部终端;切换会话不会自动回收上一会话的终端(v1 简化)。
  • 状态保留仅限面板打开期间:收起面板再打开会重建渲染器,之前的屏幕与滚动历史不保留;面板打开时切换终端则保留各终端状态。
  • 产品文案目前直接写死中文,未接入 ctx.locale 词典。
  • 关闭终端时,宿主日志可能出现 node-pty 的 AttachConsole failed 告警:桌面外壳以无控制台方式启动宿主进程,node-pty 在 Windows 上枚举控制台子进程失败(仅影响外壳内子进程的级联清理,终端本身仍会正常关闭)。这与宿主自带终端工具的行为一致。