mcpField
O
opentui

opentui

github.com/pedronauck开发64655 次安装1 周前更新
代码仓库

关于 opentui

opentui 是使用 OpenTUI 构建终端界面的参考技能,面向开发者,帮助选择 Core、React 或 Solid,并查找组件、输入、布局、动画与测试指南。

主要功能

  1. 01框架选择指南
  2. 02Core、React 和 Solid 参考
  3. 03组件与布局文档
  4. 04键盘与动画指南
  5. 05测试与故障排查参考

适用场景

  1. 01为新终端界面选择 OpenTUI 方案
  2. 02实现 TUI 时查找组件指南
  3. 03处理键盘输入、布局或动画
  4. 04测试和调试 OpenTUI 项目

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/pedronauck/skills --skill opentui

安装后在 Claude Code 中输入/opentui确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

references/animation/
REFERENCE.md
references/components/
REFERENCE.md
code-diff.md
containers.md
inputs.md
text-display.md
references/core/
REFERENCE.md
api.md
configuration.md
gotchas.md
patterns.md
references/keyboard/
REFERENCE.md
references/layout/
REFERENCE.md
patterns.md
references/react/
REFERENCE.md
api.md
configuration.md
gotchas.md
patterns.md
references/solid/
REFERENCE.md
api.md
configuration.md
gotchas.md
patterns.md
references/testing/
REFERENCE.md

详细介绍

OpenTUI 平台技能

用于使用 OpenTUI 构建终端用户界面的综合技能。请使用下方的决策树找到合适的框架和组件,然后加载详细参考资料。

关键规则

所有 OpenTUI 代码都必须遵循以下规则:

  1. 新项目请使用 create-tui。 请参阅框架的 REFERENCE.md 快速入门。
  2. create-tui 的选项必须放在参数之前。 bunx create-tui -t react my-app 可行,bunx create-tui my-app -t react 则不行。
  3. 切勿直接调用 process.exit()。 请使用 renderer.destroy()(参见 core/gotchas.md)。
  4. React/Solid 中的文本样式需要嵌套标签。 使用修饰元素,而不是属性(参见 components/text-display.md)。

如何使用此技能

参考文件结构

框架参考资料采用 5 个文件的模式。跨领域概念则以单文件指南的形式提供。

./references/<framework>/ 中的每个框架都包含:

文件用途阅读时机
REFERENCE.md概述、适用场景、快速入门始终先读
api.md运行时 API、组件、钩子编写代码时
configuration.md设置、tsconfig、打包配置项目时
patterns.md常见模式、最佳实践获取实现指导时
gotchas.md陷阱、限制、调试排查问题时

./references/<concept>/ 中的跨领域概念以 REFERENCE.md 作为入口文件。

阅读顺序
  1. 从所选框架的 REFERENCE.md 开始
  2. 然后阅读与任务相关的其他文件:
    • 构建组件 -> api.md + components/<category>.md
    • 设置项目 -> configuration.md
    • 布局/定位 -> layout/REFERENCE.md
    • 键盘/输入处理 -> keyboard/REFERENCE.md
    • 动画 -> animation/REFERENCE.md
    • 故障排查 -> gotchas.md + testing/REFERENCE.md
示例路径
./references/react/REFERENCE.md           # Start here for React
./references/react/api.md              # React components and hooks
./references/solid/configuration.md    # Solid project setup
./references/components/inputs.md      # Input, Textarea, Select docs
./references/core/gotchas.md           # Core debugging tips
运行时说明

OpenTUI 在 Bun 上运行,并使用 Zig 进行原生构建。请阅读 ./references/core/gotchas.md,了解运行时要求和构建指南。

快速决策树

“我应该使用哪个框架?”
Which framework?
├─ I want full control, maximum performance, no framework overhead
│  └─ core/ (imperative API)
├─ I know React, want familiar component patterns
│  └─ react/ (React reconciler)
├─ I want fine-grained reactivity, optimal re-renders
│  └─ solid/ (Solid reconciler)
└─ I'm building a library/framework on top of OpenTUI
   └─ core/ (imperative API)
“我需要显示内容”
Display content?
├─ Plain or styled text -> components/text-display.md
├─ Container with borders/background -> components/containers.md
├─ Scrollable content area -> components/containers.md (scrollbox)
├─ ASCII art banner/title -> components/text-display.md (ascii-font)
├─ Data table with borders/wrapping -> components/code-diff.md (TextTable)
├─ Code with syntax highlighting -> components/code-diff.md
├─ Diff viewer (unified/split) -> components/code-diff.md
├─ Line numbers with diagnostics -> components/code-diff.md
└─ Markdown content (streaming) -> components/code-diff.md (markdown)
“我需要用户输入”
User input?
├─ Single-line text field -> components/inputs.md (input)
├─ Multi-line text editor -> components/inputs.md (textarea)
├─ Select from a list (vertical) -> components/inputs.md (select)
├─ Tab-based selection (horizontal) -> components/inputs.md (tab-select)
└─ Custom keyboard shortcuts -> keyboard/REFERENCE.md
“我需要布局/定位”
Layout?
├─ Flexbox-style layouts (row, column, wrap) -> layout/REFERENCE.md
├─ Absolute positioning -> layout/patterns.md
├─ Responsive to terminal size -> layout/patterns.md
├─ Centering content -> layout/patterns.md
└─ Complex nested layouts -> layout/patterns.md
“我需要动画”
Animations?
├─ Timeline-based animations -> animation/REFERENCE.md
├─ Easing functions -> animation/REFERENCE.md
├─ Property transitions -> animation/REFERENCE.md
└─ Looping animations -> animation/REFERENCE.md
“我需要处理输入”
Input handling?
├─ Keyboard events (keypress, release) -> keyboard/REFERENCE.md
├─ Focus management -> keyboard/REFERENCE.md
├─ Paste events -> keyboard/REFERENCE.md
├─ Mouse events -> components/containers.md
├─ Text selection & copy-on-select -> keyboard/REFERENCE.md (selection)
└─ Clipboard (OSC 52) -> keyboard/REFERENCE.md (clipboard)
“我需要测试我的 TUI”
Testing?
├─ Snapshot testing -> testing/REFERENCE.md
├─ Interaction testing -> testing/REFERENCE.md
├─ Test renderer setup -> testing/REFERENCE.md
└─ Debugging tests -> testing/REFERENCE.md
“我需要调试/排查问题”
Troubleshooting?
├─ Runtime errors, crashes -> <framework>/gotchas.md
├─ Layout issues -> layout/REFERENCE.md + layout/patterns.md
├─ Input/focus issues -> keyboard/REFERENCE.md
└─ Repro + regression tests -> testing/REFERENCE.md
故障排查索引
  • 终端清理、崩溃 -> core/gotchas.md
  • 文本样式未生效 -> components/text-display.md
  • 输入焦点/快捷键 -> keyboard/REFERENCE.md
  • 布局错位 -> layout/REFERENCE.md
  • 快照不稳定 -> testing/REFERENCE.md

有关组件命名差异和文本修饰符,请参阅 components/REFERENCE.md。

产品索引

框架
框架入口文件描述
Core./references/core/REFERENCE.md命令式 API,所有基础组件
React./references/react/REFERENCE.md用于声明式 TUI 的 React 协调器
Solid./references/solid/REFERENCE.md用于声明式 TUI 的 SolidJS 协调器
跨领域概念
概念入口文件描述
布局./references/layout/REFERENCE.mdYoga/Flexbox 布局系统
组件./references/components/REFERENCE.md按类别划分的组件参考
键盘./references/keyboard/REFERENCE.md键盘输入处理
动画./references/animation/REFERENCE.md基于时间线的动画
测试./references/testing/REFERENCE.md测试渲染器和快照
组件类别
类别入口文件组件
文本与显示./references/components/text-display.mdtext、ascii-font、styled text
容器./references/components/containers.mdbox、scrollbox、边框
输入./references/components/inputs.mdinput、textarea、select、tab-select
代码与差异./references/components/code-diff.mdcode、line-number、diff、markdown、text-table

资源

代码仓库:https://github.com/anomalyco/opentui 核心文档:https://github.com/anomalyco/opentui/tree/main/packages/core/docs 示例:https://github.com/anomalyco/opentui/tree/main/packages/core/src/examples 精选列表:https://github.com/msmps/awesome-opentui

评论

支持 Markdown