@codeworksh/tui 0.0.3 → 0.1.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.
Files changed (2) hide show
  1. package/README.md +56 -76
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -2,21 +2,47 @@
2
2
 
3
3
  A fast and lightweight terminal interface for [CodeWork](https://www.codework.sh), written in **Rust**.
4
4
 
5
- `codework-tui` lets you chat with your AI coding agent directly from your terminal. Watch it write code, run tools, and edit files in real time, all while keeping track of token usage and costs.
5
+ The TUI is an early skeleton. Today it opens one screen: the landing site's hero — its wordmark over
6
+ the same hairline lattice the site draws it on, with a prompt line under it that takes typing. A
7
+ leading slash on an empty line opens a menu of the app's commands, as a chat prompt does; as this is
8
+ written there are two, `theme`, which lists every palette the site ships, and `exit`. The prompt
9
+ cannot be sent, and model selection and the session view are not built yet; the launcher and the RPC
10
+ transport they will need are already in place.
6
11
 
7
12
  ---
8
13
 
9
- ## Features
10
-
11
- - **Fast and Lightweight** — Starts up instantly and uses minimal memory.
12
- - **Live Streaming** — Watch the AI think, stream answers, and run tools (like running terminal commands or editing files) as it happens.
13
- - **Side-by-Side View** —
14
- - **Chat screen:** See your conversation, AI replies, tool results, and response speed (`tok/s`).
15
- - **Sidebar:** Keep an eye on your current model, context window usage, tokens used, cost, and active Git branch.
16
- - **Easy Model Picker (`/model`)** — Browse models (Anthropic, OpenAI, Google, OpenRouter, Groq), check pricing, and enter API keys directly in the terminal.
17
- - **Neat Markdown Formatting** — Code blocks, lists, bold text, links, and tables look clean and readable in the terminal.
18
- - **Cancel Anytime** — Press `Esc` or `Ctrl+C` while the AI is responding to safely stop it without losing your conversation or quitting the app.
19
- - **Auto-Connect** — `codework tui` starts or reuses the CodeWork background server, then connects the UI to it.
14
+ ## Architecture
15
+
16
+ The TUI is a thin client. It draws the screen and reads keystrokes, and a CodeWork server
17
+ owns the agent, the tools and the model calls. The two talk over a WebSocket carrying
18
+ newline-delimited JSON-RPC.
19
+
20
+ | Path | Role |
21
+ | :------------------- | :-------------------------------------------------------------------- |
22
+ | `src/main.rs` | Wiring: build the app, terminal and event loop, then run them. |
23
+ | `src/tui.rs` | Terminal lifecycle: raw mode, alternate screen, input modes, restore. |
24
+ | `src/event.rs` | Input: the reader thread, and the app events it produces. |
25
+ | `src/action.rs` | Named actions and the keymap, with the `<leader>` prefix. |
26
+ | `src/app.rs` | UI state and `update`, the one place state changes. |
27
+ | `src/prompt.rs` | The prompt line's text and caret, and the keys that edit it. |
28
+ | `src/menu.rs` | A menu: its entries, its previews and where the cursor is. |
29
+ | `src/ui.rs` | Rendering: reads state and draws, nothing else. |
30
+ | `src/ui/glyphs.rs` | Pixel glyphs, generated from the landing site's wordmark. |
31
+ | `src/ui/wordmark.rs` | Drawing the wordmark, and the mark it falls back to, in half-blocks. |
32
+ | `src/ui/field.rs` | The lattice behind the wordmark, on the wordmark's own grid. |
33
+ | `src/ui/input.rs` | The prompt box and its line, which reports where the caret goes. |
34
+ | `src/ui/menu.rs` | Drawing a menu: its rows, its scrolling and what a row previews. |
35
+ | `src/ui/badge.rs` | The tag a box clips to its top border. |
36
+ | `src/ui/text.rs` | Measuring and cutting text by columns, which both of the above need. |
37
+ | `src/theme.rs` | The palette, generated from the landing site's themes. |
38
+ | `src/rpc/` | The transport: WebSocket client and wire protocol. |
39
+ | `src/types.rs` | The DTOs the transport speaks in. |
40
+ | `src/index.ts` | Thin TypeScript launcher: resolves the platform binary for the CLI. |
41
+
42
+ Two files are generated from the landing site instead of written by hand: `src/theme/palettes.rs`
43
+ from its theme tokens — including the lattice ink its canvas derives from two of them — and
44
+ `src/ui/glyphs.rs` from its pixel wordmark. Run `node scripts/themes.mjs` or
45
+ `node scripts/wordmark.mjs` after the site moves; each takes `--check` and fails on drift.
20
46
 
21
47
  ---
22
48
 
@@ -29,9 +55,11 @@ A fast and lightweight terminal interface for [CodeWork](https://www.codework.sh
29
55
 
30
56
  ### Running the App
31
57
 
32
- `codework tui` is the normal way in: the CLI starts or reuses the background server (registered in `<home>/service.json`) and launches this binary with `CODEWORK_RPC_SERVER` set. From a checkout it picks up a `target/{release,debug}` build.
58
+ `codework tui` is the normal way in: the CLI starts or reuses the background server
59
+ (registered in `<home>/service.json`) and launches this binary with `CODEWORK_RPC_SERVER`
60
+ set. From a checkout it picks up a `target/{release,debug}` build.
33
61
 
34
- To run the binary directly against a server you started with `codework serve`, use Cargo:
62
+ To run the binary directly, use Cargo:
35
63
 
36
64
  ```bash
37
65
  # Run in development mode
@@ -47,74 +75,26 @@ Or using pnpm:
47
75
  ```bash
48
76
  # From packages/tui
49
77
  pnpm start
50
-
51
- # Or from the project root
52
- pnpm --filter @codeworksh/tui start
53
78
  ```
54
79
 
55
80
  ---
56
81
 
57
- ## Commands
58
-
59
- Type `/` in the prompt input to open the command menu:
60
-
61
- | Command | What it does |
62
- | :--------- | :------------------------------------------ |
63
- | `/help` | Show available commands and shortcuts |
64
- | `/model` | Pick an AI model or enter API keys |
65
- | `/session` | View, switch, or resume past sessions |
66
- | `/compact` | Shorten conversation history to save tokens |
67
- | `/clear` | Clear the current chat screen |
68
- | `/exit` | Exit the app |
69
-
70
- ---
71
-
72
82
  ## Keyboard Shortcuts
73
83
 
74
- ### General & Chat
75
-
76
- | Shortcut | Action |
77
- | :-------------------- | :---------------------------------------------------------------- |
78
- | `Enter` | Send message / run command |
79
- | `Esc` | Close popup, cancel current action, or stop the AI |
80
- | `Ctrl+C` | Stop the AI response / exit app when idle |
81
- | `PageUp` / `PageDown` | Scroll chat up or down by a full page |
82
- | `Ctrl+U` / `Ctrl+D` | Scroll chat up or down by half a page |
83
- | `Home` / `End` | Jump to the very top or bottom of the chat |
84
- | `Up` / `Down` | Move through slash commands (or scroll lines when input is empty) |
85
-
86
- ### Model Picker (`/model`)
87
-
88
- | Shortcut | Action |
89
- | :--------------------------- | :-------------------------------------------------- |
90
- | `Tab` / `Shift+Tab` | Move between Providers, Models, and Details columns |
91
- | `Up` / `Down` (or `j` / `k`) | Move through the list |
92
- | `/` | Search models or providers |
93
- | `s` | Change sort order (by name, context size, cost) |
94
- | `c` / `y` | Copy the selected model ID to clipboard |
95
- | `o` | Open provider website in your browser |
96
- | `Enter` | Select the model (asks for an API key if needed) |
97
-
98
- ---
99
-
100
- ## API Keys & Settings
101
-
102
- You can provide API keys in two simple ways:
103
-
104
- 1. **Inside the app:** Type `/model`, choose a provider, and enter your API key when prompted.
105
- 2. **Environment variables:** Export the key in your terminal before running:
106
- ```bash
107
- export ANTHROPIC_API_KEY="your-key-here"
108
- export OPENAI_API_KEY="your-key-here"
109
- export GEMINI_API_KEY="your-key-here"
110
- export OPENROUTER_API_KEY="your-key-here"
111
- export GROQ_API_KEY="your-key-here"
112
- ```
113
-
114
- Your configuration and keys are saved in your home folder:
115
-
116
- - **`~/.codework/config.json`** — Your selected model and provider.
117
- - **`~/.codework/credentials.json`** — Your securely stored API keys.
84
+ | Shortcut | Action |
85
+ | :------------------- | :--------------------------------------------- |
86
+ | _any character_ | Type it into the prompt |
87
+ | `←` `→` | Move the prompt's caret |
88
+ | `Home` `End` | Jump to the start or the end of the prompt |
89
+ | `Backspace` `Delete` | Erase a character |
90
+ | _paste_ | Insert the clipboard at the caret, on one line |
91
+ | `/` | Ask for the command menu |
92
+ | `↑` `↓` | Move through a menu |
93
+ | `Enter` | Take the entry a menu is on |
94
+ | `Esc` | Close the menu, or exit the app |
95
+ | `Ctrl+C` | Exit the app |
96
+ | `Ctrl+D` | Exit the app |
97
+ | `<leader>q` | Exit the app (`Ctrl+X`, then `q`) |
118
98
 
119
99
  ---
120
100
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeworksh/tui",
3
- "version": "0.0.3",
3
+ "version": "0.1.0",
4
4
  "description": "High-performance Terminal User Interface (TUI) for CodeWork in Rust, with a thin TypeScript launcher",
5
5
  "keywords": [
6
6
  "codework",
@@ -33,8 +33,8 @@
33
33
  "access": "public"
34
34
  },
35
35
  "optionalDependencies": {
36
- "@codeworksh/tui-darwin-arm64": "0.0.3",
37
- "@codeworksh/tui-linux-arm64": "0.0.3",
38
- "@codeworksh/tui-linux-x64": "0.0.3"
36
+ "@codeworksh/tui-darwin-arm64": "0.1.0",
37
+ "@codeworksh/tui-linux-arm64": "0.1.0",
38
+ "@codeworksh/tui-linux-x64": "0.1.0"
39
39
  }
40
40
  }