@fungi.computer/lantern

中文文档
0.4.2发布于 2026/11/08MITTypeScriptES Module近 30 天下载 5276

Shared Fungi terminal wordmarks, Clack interaction and progress

原始使用文档
文档目录7 节
  1. Install or set up
  2. Quick start
  3. Core concepts
  4. API reference
  5. Examples and checks
  6. Limits and errors
  7. Contribute and license

Lantern (@fungi.computer/lantern)

Lantern provides terminal wordmarks, prompts and progress. Most people want Oyster to run Apps or Shiitake to run Agents.

Lantern gives Fungi command-line tools shared wordmarks, prompts, and progress messages, so every command looks and feels the same without rebuilding terminal presentation from scratch. It handles terminal presentation. Each command owns its own work, credentials, persistence, and conversation state.

Install or set up

Use Node 24 or newer.

npm install @fungi.computer/lantern

The package ships ESM only and depends on @clack/core, @clack/prompts, and Stipe for terminal colors, all installed automatically. Import @fungi.computer/lantern for Node command-line tools, or @fungi.computer/lantern/banner to render a banner without importing Clack prompts or Node streams.

Quick start

This illustrative example uses a noninteractive CLI so progress and checklist messages go to the supplied output stream:

import { Cli } from "@fungi.computer/lantern";

const cli = new Cli({ brand: "vishnu", interactive: false });
cli.welcome("Build a game");
await cli.task("Building", async (update) => {
  update("Checking the project");
  return "ready";
});
cli.checklist()("project", true, "ready");

The terminal tests exercise banner rendering, piped input behavior, and noninteractive task output in test/terminal.test.ts.

Core concepts

Cli detects interactivity from TTY input and output unless the caller passes interactive. It accepts optional input, output, and terminal width so a host can control where prompts and messages go. welcome, info, step, outro, cancel, task, and checklist provide shared presentation. A task stops its spinner on success. A failed task rethrows the original error. When a spinner is active, it displays a generic failure message without error details.

In noninteractive mode, ordinary messages are written as text and confirm returns false. text, password, select, and search throw because they require an interactive terminal. task reports progress as plain lines instead of animating a spinner.

search accepts ordered choices with labels, descriptions and optional group names. It displays group headings and can collapse one group behind a counted disclosure row. Typing searches every choice, including collapsed choices. Enter expands the disclosure or selects a choice. Callers own the catalog and group membership. Clack owns input, navigation and cancellation.

renderBanner is the browser-safe rendering entrypoint. It chooses a brand's wide or compact art for interactive terminals, and a plain brand label for piped or no-color output. Widths below 60 columns use compact art where available; Computer omits its art at narrow widths. Set rawPty: true when writing directly to a raw pseudo-terminal to receive CRLF line endings.

API reference

See the generated Lantern API reference and the banner reference. The ./banner entrypoint exports renderBanner and the art strings.

Examples and checks

The existing terminal tests cover banner width and color behavior, raw PTY line endings, prompt refusal for piped input, and noninteractive task/checklist messages. Run them with:

pnpm --filter @fungi.computer/lantern test

Limits and errors

Lantern does not run commands or decide whether work succeeds. The caller provides the task and owns its result. A noninteractive task prints no failure line when it throws. Noninteractive confirmation always declines, and prompt methods that could consume piped input refuse to run. Use explicit command options for automation.

The banner renderer selects existing art and wraps it with Stipe's semantic palette. It does not start a shell or own terminal greeting timing or reconnection behavior.

Contribute and license

Lantern is MIT licensed. See LICENSE.

版本与发布记录

@fungi.computer/lantern 共发布 8 个版本,首次发布于 2026/10/17;过去 12 个月发布了 8 个版本。

版本发布日期距今
0.4.2latest2026/11/087 天前
0.4.12026/11/079 天前
0.4.02026/11/0510 天前
0.3.12026/10/2818 天前
0.3.02026/10/2323 天前
0.2.02026/10/1729 天前

关于 @fungi.computer/lantern 的常见问题

@fungi.computer/lantern 是什么?

Shared Fungi terminal wordmarks, Clack interaction and progress

如何安装 @fungi.computer/lantern?

在项目目录运行 npm install @fungi.computer/lantern,或使用 pnpm add / yarn add / bun add。

@fungi.computer/lantern 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fungi.computer/lantern 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@fungi.computer/lantern 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=24.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@fungi.computer/lantern 可以商用吗?

@fungi.computer/lantern 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fungi.computer/lantern 的下载量有多少?

根据 npm 官方下载统计,@fungi.computer/lantern 在 2026/10/16 – 2026/11/14 这 30 天内被下载 5,276 次,日均约 176 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fungi.computer/lantern 还在维护吗?

最新版本 0.4.2 发布于 2026/11/08(7 天前);至今共发布 8 个版本,其中过去 12 个月发布了 8 个;首次发布于 2026/10/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。