Agent Skillsslopus/happy › terminal-emulator

terminal-emulator

GitHub

使用 @microsoft/tui-test 对交互式 CLI/TUI 应用进行测试,支持模拟终端输入、箭头键导航及快照对比。

.claude/skills/terminal-emulator/SKILL.md slopus/happy

Trigger Scenarios

test CLI test TUI run interactively automate terminal input simulate user input in terminal

Install

npx skills add slopus/happy --skill terminal-emulator -g -y
More Options

Non-standard path

npx skills add https://github.com/slopus/happy/tree/main/.claude/skills/terminal-emulator -g -y

Use without installing

npx skills use slopus/happy@terminal-emulator

指定 Agent (Claude Code)

npx skills add slopus/happy --skill terminal-emulator -a claude-code -g -y

安装 repo 全部 skill

npx skills add slopus/happy --all -g -y

预览 repo 内 skill

npx skills add slopus/happy --list

SKILL.md

Frontmatter
{
    "name": "terminal-emulator",
    "description": "Test interactive CLI\/TUI applications using @microsoft\/tui-test. Use when you need to test CLI tools with interactive prompts, TUI rendering, arrow key navigation, or any command that requires a TTY. Triggers include \"test CLI\", \"test TUI\", \"run interactively\", \"automate terminal input\", \"simulate user input in terminal\".",
    "allowed-tools": "Bash(npx tui-test:*), Bash(node:*)"
}

Testing Interactive CLI / TUI with @microsoft/tui-test

Playwright-like API for terminals. Real PTY per test. Made by Microsoft.

Install

yarn add -D @microsoft/tui-test

Usage

import { test, expect } from '@microsoft/tui-test';

test.use({ program: { file: 'node', args: ['./my-cli.js'] } });

test('selects option and proceeds', async ({ terminal }) => {
    await expect(terminal.getByText('Select an option')).toBeVisible();
    await terminal.write('\x1B[B');  // Arrow Down
    await terminal.submit();          // Enter
    await expect(terminal.getByText('Option 2 selected')).toBeVisible();
});

test('matches snapshot', async ({ terminal }) => {
    await expect(terminal).toMatchSnapshot();
});

API

// Navigation
await terminal.write('\x1B[A');    // Arrow Up
await terminal.write('\x1B[B');    // Arrow Down
await terminal.write('\x1B[C');    // Arrow Right
await terminal.write('\x1B[D');    // Arrow Left
await terminal.submit();           // Enter
await terminal.write('\t');        // Tab
await terminal.write('\x03');      // Ctrl+C
await terminal.write('\x1B');      // Escape
await terminal.write('\x7F');      // Backspace
await terminal.write('hello');     // Type text

// Assertions
await expect(terminal.getByText('pattern')).toBeVisible();
await expect(terminal.getByText('pattern', { full: true })).toBeVisible();
await expect(terminal).toMatchSnapshot();

// Reading
const content = terminal.content;  // Full terminal content as string

Running

npx tui-test                       # Run all tests
npx tui-test --update-snapshots    # Update snapshots
npx tui-test my-test.ts            # Run specific test

Reference

  • Used by VS Code terminal team
  • Real PTY isolation per test (no mocking)
  • Auto-waits for terminal renders
  • Cross-platform (macOS, Linux, Windows)
  • Snapshot testing built-in

Version History

  • eb980a5 Current 2026-08-20 11:11

Same Skill Collection

.agents/skills/agent-browser/SKILL.md
.agents/skills/control-flow/SKILL.md
.agents/skills/dev/SKILL.md
.agents/skills/maintain/SKILL.md
.agents/skills/metrics-graphana/SKILL.md
.agents/skills/release/SKILL.md
.agents/skills/sessions/SKILL.md
.agents/skills/terminal-emulator/SKILL.md
.claude/skills/agent-browser/SKILL.md
.agents/skills/office-hours/SKILL.md

Metadata

Files
0
Version
b824cd0
Hash
c44b1d00
Indexed
2026-08-20 11:11

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-12 00:50
浙ICP备14020137号-1 $방문자$