@celljs/tui 4.6.1 → 4.7.0
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 +38 -0
- package/package.json +2 -2
package/README.en.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Cell - TUI Component
|
|
2
|
+
|
|
3
|
+
Use [pi-tui](https://www.npmjs.com/package/@earendil-works/pi-tui) to provide a terminal interface for Cell CLI applications: differential rendering without flicker, built-in editor, Markdown, list, loading animation and other components.
|
|
4
|
+
|
|
5
|
+
- `TuiFactory`: creates a main screen (preserves scroll history) or fullscreen `TUI`; stops all TUIs and restores the terminal when the application stops.
|
|
6
|
+
- `AgentChat`: agent conversation in the terminal. The target can be an `Agent` from [@celljs/ai-agent](../../ai-packages/ai-agent), or a session from [@celljs/ai-coding-agent](../../ai-packages/ai-coding-agent): answers are displayed as Markdown streams, tool calls and errors appear on separate lines. Send with Enter, cancel the current run with Escape, and exit with Ctrl+C.
|
|
7
|
+
|
|
8
|
+
pi-tui uses dynamic `import()`, which requires Node.js >= 22.19 or Bun.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { AgentFactory } from '@celljs/ai-agent';
|
|
14
|
+
import { Autowired, Component } from '@celljs/core';
|
|
15
|
+
import { AgentChat } from '@celljs/tui';
|
|
16
|
+
|
|
17
|
+
@Component()
|
|
18
|
+
export class ChatCommand {
|
|
19
|
+
@Autowired(AgentFactory)
|
|
20
|
+
protected readonly agentFactory: AgentFactory;
|
|
21
|
+
|
|
22
|
+
@Autowired(AgentChat)
|
|
23
|
+
protected readonly agentChat: AgentChat;
|
|
24
|
+
|
|
25
|
+
async run(): Promise<void> {
|
|
26
|
+
const agent = await this.agentFactory.create();
|
|
27
|
+
await this.agentChat.run(agent, { title: 'ACME assistant' });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
To customize the interface, use `TuiFactory.create({ screen: 'alt' })` to get `TUI`, then use pi-tui components (`PiTuiUtil.load()` returns the pi-tui module). `TuiThemeUtil` provides a default theme that follows terminal colors.
|
|
33
|
+
|
|
34
|
+
A complete CLI application (`cli` preset, enters conversation after startup, exits on Ctrl+C) is in [examples/tui-app](../../examples/tui-app).
|
|
35
|
+
|
|
36
|
+
## Testing
|
|
37
|
+
|
|
38
|
+
`FakeTerminal` in `@celljs/tui/lib/node/test` records output (`text` removes escape sequences), `type()` simulates key-by-key input, passed to `create({ terminal })` or `run(target, { terminal })`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/tui",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "Terminal UIs (pi-tui) for Cell command-line applications, with a chat for agents",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cell-component"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@celljs/core": "4.
|
|
34
|
+
"@celljs/core": "4.7.0",
|
|
35
35
|
"@earendil-works/pi-tui": "^1.5.0"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|