@easbot/terminal 0.3.27 → 0.3.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +29 -21
- package/README.md +30 -21
- package/package.json +3 -3
package/README.en.md
CHANGED
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
## Version
|
|
8
8
|
|
|
9
|
-
v0.3.
|
|
10
|
-
|
|
9
|
+
v0.3.28
|
|
11
10
|
## Introduction
|
|
12
11
|
|
|
13
12
|
`@easbot/terminal` is a terminal interaction toolkit for the EASBOT ecosystem. It encapsulates the common capabilities required by CLI / TUI scenarios: themed color output, ANSI handling, table rendering, command output formatting, styled prompts, JSON contract output, human-output helpers (`printHuman` / `renderLines`), a unified **interactive Prompt namespace**, an interactive searchable multi-select prompt, a readline-based CLI input helper, a lightweight markdown renderer, shared icon / status-symbol constants, a stateless Loader spinner, and terminal-state recovery. Every module auto-detects terminal capability (`NO_COLOR` / `FORCE_COLOR` / TTY) and degrades gracefully in non-TTY environments (pipes, redirected files, CI logs).
|
|
@@ -86,7 +85,12 @@ console.log(formatStatus('running', 'Building...'));
|
|
|
86
85
|
### Paths & hyperlinks
|
|
87
86
|
|
|
88
87
|
```typescript
|
|
89
|
-
import {
|
|
88
|
+
import {
|
|
89
|
+
resolveUserPath,
|
|
90
|
+
resolveConfigDir,
|
|
91
|
+
displayPath,
|
|
92
|
+
formatTerminalLink,
|
|
93
|
+
} from '@easbot/terminal';
|
|
90
94
|
|
|
91
95
|
const configDir = resolveConfigDir(); // ~/.config/easbot (or $EASBOT_STATE_DIR if set)
|
|
92
96
|
console.log(displayPath(configDir));
|
|
@@ -127,14 +131,11 @@ console.log(
|
|
|
127
131
|
import { printHuman, renderLines } from '@easbot/terminal';
|
|
128
132
|
|
|
129
133
|
// The canonical "grouped detail + summary + outro" page
|
|
130
|
-
printHuman(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
empty: 'No skills tracked in lock file.',
|
|
136
|
-
},
|
|
137
|
-
);
|
|
134
|
+
printHuman([' ✓ eas-agent-creation', ' ✓ eas-agent-evolution', ' ✗ eas-legacy-tool'], {
|
|
135
|
+
title: 'Project Skills Update',
|
|
136
|
+
outro: 'Run `easbot skills list` to see current state.',
|
|
137
|
+
empty: 'No skills tracked in lock file.',
|
|
138
|
+
});
|
|
138
139
|
|
|
139
140
|
// renderLines: build a grouped tree (list / find / store-list style)
|
|
140
141
|
const lines = renderLines({
|
|
@@ -182,7 +183,10 @@ const selected = await Prompt.multiselect({
|
|
|
182
183
|
const skills = await Prompt.groupMultiselect({
|
|
183
184
|
message: 'Pick the skills to install',
|
|
184
185
|
options: {
|
|
185
|
-
General: [
|
|
186
|
+
General: [
|
|
187
|
+
{ value: 'foo', label: 'foo' },
|
|
188
|
+
{ value: 'bar', label: 'bar' },
|
|
189
|
+
],
|
|
186
190
|
'Advanced Plugins': [{ value: 'baz', label: 'baz' }],
|
|
187
191
|
},
|
|
188
192
|
});
|
|
@@ -328,7 +332,11 @@ Keyboard shortcuts: `↑↓ ←→` move · `PageUp/Down` page · `Home/End` jum
|
|
|
328
332
|
### Safe stream writes & state recovery
|
|
329
333
|
|
|
330
334
|
```typescript
|
|
331
|
-
import {
|
|
335
|
+
import {
|
|
336
|
+
createSafeStreamWriter,
|
|
337
|
+
restoreTerminalState,
|
|
338
|
+
registerActiveProgressLine,
|
|
339
|
+
} from '@easbot/terminal';
|
|
332
340
|
|
|
333
341
|
const writer = createSafeStreamWriter();
|
|
334
342
|
registerActiveProgressLine(process.stdout);
|
|
@@ -507,14 +515,14 @@ The single recommended entry point for business code. Details in the "Prompt nam
|
|
|
507
515
|
|
|
508
516
|
## Environment Variables
|
|
509
517
|
|
|
510
|
-
| Variable
|
|
511
|
-
|
|
512
|
-
| `NO_COLOR`
|
|
513
|
-
| `FORCE_COLOR`
|
|
514
|
-
| `HOME` / `USERPROFILE` | Fallback sources for home directory resolution
|
|
515
|
-
| `EASBOT_TEST_HOME`
|
|
516
|
-
| `EASBOT_HOME`
|
|
517
|
-
| `EASBOT_STATE_DIR`
|
|
518
|
+
| Variable | Description |
|
|
519
|
+
| ---------------------- | ------------------------------------------------------------------------------------------------------- |
|
|
520
|
+
| `NO_COLOR` | Disables colors when set (unless `FORCE_COLOR` is also set) — see [no-color.org](https://no-color.org/) |
|
|
521
|
+
| `FORCE_COLOR` | Forces colors when non-empty and not equal to `'0'` |
|
|
522
|
+
| `HOME` / `USERPROFILE` | Fallback sources for home directory resolution |
|
|
523
|
+
| `EASBOT_TEST_HOME` | **Test-only** highest-priority home override (highest priority; see `home-dir.ts`) |
|
|
524
|
+
| `EASBOT_HOME` | Explicit override for the home directory; changes the display prefix from `~` to `$EASBOT_HOME` |
|
|
525
|
+
| `EASBOT_STATE_DIR` | Override the resolved config directory |
|
|
518
526
|
|
|
519
527
|
**Home resolution order (highest to lowest):**
|
|
520
528
|
`EASBOT_TEST_HOME` → `EASBOT_HOME` → `HOME` → `USERPROFILE` → `os.homedir()`.
|
package/README.md
CHANGED
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
## 版本
|
|
8
8
|
|
|
9
|
-
v0.3.
|
|
10
|
-
|
|
9
|
+
v0.3.28
|
|
11
10
|
## 简介
|
|
12
11
|
|
|
13
12
|
`@easbot/terminal` 是一个面向 EASBOT 生态的终端交互工具库,封装了命令行 / TUI 场景下常用的能力:终端主题色、ANSI 处理、表格渲染、命令输出格式化、提示样式化、JSON 规范输出、人类输出统一封装(`printHuman` / `renderLines`)、一个**统一的交互式 Prompt namespace**、一个**可搜索的多选交互 prompt**、一个**CLI 输入 helper**、一个**轻量级 markdown 渲染器**、图标 / 状态符号统一常量、Loader 旋转动画、终端状态恢复等。所有能力都基于终端能力自动检测(`NO_COLOR` / `FORCE_COLOR` / TTY)进行降级,可在管道、文件重定向等非 TTY 场景下安全使用。
|
|
@@ -86,7 +85,12 @@ console.log(formatStatus('running', '正在执行构建...'));
|
|
|
86
85
|
### 路径与超链接
|
|
87
86
|
|
|
88
87
|
```typescript
|
|
89
|
-
import {
|
|
88
|
+
import {
|
|
89
|
+
resolveUserPath,
|
|
90
|
+
resolveConfigDir,
|
|
91
|
+
displayPath,
|
|
92
|
+
formatTerminalLink,
|
|
93
|
+
} from '@easbot/terminal';
|
|
90
94
|
|
|
91
95
|
const configDir = resolveConfigDir(); // ~/.config/easbot(如设了 EASBOT_STATE_DIR 则用之)
|
|
92
96
|
console.log(displayPath(configDir));
|
|
@@ -127,14 +131,11 @@ console.log(
|
|
|
127
131
|
import { printHuman, renderLines } from '@easbot/terminal';
|
|
128
132
|
|
|
129
133
|
// 业务侧常见的"分组细节 + 总结 + outro"一页输出
|
|
130
|
-
printHuman(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
empty: 'No skills tracked in lock file.',
|
|
136
|
-
},
|
|
137
|
-
);
|
|
134
|
+
printHuman([' ✓ eas-agent-creation', ' ✓ eas-agent-evolution', ' ✗ eas-legacy-tool'], {
|
|
135
|
+
title: 'Project Skills Update',
|
|
136
|
+
outro: 'Run `easbot skills list` to see current state.',
|
|
137
|
+
empty: 'No skills tracked in lock file.',
|
|
138
|
+
});
|
|
138
139
|
|
|
139
140
|
// renderLines:构造 list / find 风格的分组树状
|
|
140
141
|
const lines = renderLines({
|
|
@@ -182,7 +183,10 @@ const selected = await Prompt.multiselect({
|
|
|
182
183
|
const skills = await Prompt.groupMultiselect({
|
|
183
184
|
message: '选择要安装的技能',
|
|
184
185
|
options: {
|
|
185
|
-
General: [
|
|
186
|
+
General: [
|
|
187
|
+
{ value: 'foo', label: 'foo' },
|
|
188
|
+
{ value: 'bar', label: 'bar' },
|
|
189
|
+
],
|
|
186
190
|
'Advanced Plugins': [{ value: 'baz', label: 'baz' }],
|
|
187
191
|
},
|
|
188
192
|
});
|
|
@@ -209,6 +213,7 @@ spinner.stop(`Found ${count} skill(s)`);
|
|
|
209
213
|
```
|
|
210
214
|
|
|
211
215
|
**取消语义收口**:
|
|
216
|
+
|
|
212
217
|
- `Prompt.cancelSymbol` —— 唯一 sentinel(与 `Search.cancelSymbol` 同引用)
|
|
213
218
|
- `Prompt.isCancel(value)` —— 类型守卫,同时识别 `Prompt.cancelSymbol` 与 clack 的 `Symbol('')`
|
|
214
219
|
- `Prompt.cancel(message?)` —— `never` 返回 + 内置 `process.exit(0)`
|
|
@@ -327,7 +332,11 @@ if (result === cancelSymbol) return;
|
|
|
327
332
|
### 安全流写入与状态恢复
|
|
328
333
|
|
|
329
334
|
```typescript
|
|
330
|
-
import {
|
|
335
|
+
import {
|
|
336
|
+
createSafeStreamWriter,
|
|
337
|
+
restoreTerminalState,
|
|
338
|
+
registerActiveProgressLine,
|
|
339
|
+
} from '@easbot/terminal';
|
|
331
340
|
|
|
332
341
|
const writer = createSafeStreamWriter();
|
|
333
342
|
registerActiveProgressLine(process.stdout);
|
|
@@ -497,14 +506,14 @@ emitJsonError('E_NOT_FOUND', '资源不存在');
|
|
|
497
506
|
|
|
498
507
|
## 环境变量
|
|
499
508
|
|
|
500
|
-
| 变量
|
|
501
|
-
|
|
502
|
-
| `NO_COLOR`
|
|
503
|
-
| `FORCE_COLOR`
|
|
504
|
-
| `HOME` / `USERPROFILE` | 主目录解析的备选来源(OS 默认值)
|
|
505
|
-
| `EASBOT_TEST_HOME`
|
|
506
|
-
| `EASBOT_HOME`
|
|
507
|
-
| `EASBOT_STATE_DIR`
|
|
509
|
+
| 变量 | 作用 |
|
|
510
|
+
| ---------------------- | --------------------------------------------------------------------------------------------------- |
|
|
511
|
+
| `NO_COLOR` | 存在时禁用终端颜色(除非同时设置了 `FORCE_COLOR`),遵循 [no-color.org](https://no-color.org/) 规范 |
|
|
512
|
+
| `FORCE_COLOR` | 非空且不为 `'0'` 时强制启用颜色 |
|
|
513
|
+
| `HOME` / `USERPROFILE` | 主目录解析的备选来源(OS 默认值) |
|
|
514
|
+
| `EASBOT_TEST_HOME` | **测试专用** 最高优先级的主目录覆盖(详见 `home-dir.ts`) |
|
|
515
|
+
| `EASBOT_HOME` | 显式指定主目录;设置后路径显示前缀由 `~` 切换为 `$EASBOT_HOME` |
|
|
516
|
+
| `EASBOT_STATE_DIR` | 配置目录覆盖项 |
|
|
508
517
|
|
|
509
518
|
**主目录解析顺序(高 → 低)**:
|
|
510
519
|
`EASBOT_TEST_HOME` → `EASBOT_HOME` → `HOME` → `USERPROFILE` → `os.homedir()`。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easbot/terminal",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.28",
|
|
4
4
|
"description": "Terminal interaction toolkit for the EASBOT ecosystem — themed colors, ANSI utilities, OSC-8 hyperlinks, command formatting, table rendering, styled prompts, safe stream writes, and terminal-state recovery",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@clack/prompts": "^1.7.0",
|
|
49
49
|
"chalk": "^6.0.0",
|
|
50
|
-
"@easbot/types": "0.3.
|
|
51
|
-
"@easbot/utils": "0.3.
|
|
50
|
+
"@easbot/types": "0.3.28",
|
|
51
|
+
"@easbot/utils": "0.3.28"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/node": "^25.9.5",
|