terminalos 0.4.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.md ADDED
@@ -0,0 +1,324 @@
1
+ <div align="center">
2
+
3
+ <img src="public/icon.png" alt="terminalOS Logo" width="96" />
4
+
5
+ # terminalOS
6
+
7
+ **The terminal built for AI-native developers.**
8
+
9
+ [![Version](https://img.shields.io/badge/version-0.4.0-blue.svg)](package.json)
10
+ [![Platform](https://img.shields.io/badge/platform-macOS%20%7C%20Windows%20%7C%20Linux-lightgrey.svg)]()
11
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)]()
12
+
13
+ </div>
14
+
15
+ ---
16
+
17
+ ## The Problem
18
+
19
+ AI coding tools like Claude Code, Aider, and OpenCode are becoming central to how developers work — but your terminal wasn't built for them.
20
+
21
+ Running an AI session today means:
22
+
23
+ - **No visibility into token consumption** — you discover your API bill at the end of the month.
24
+ - **No way to tell when AI is "thinking"** — your terminal looks the same whether AI is running or idle.
25
+ - **Context switching hell** — juggling docs, code files, and multiple AI sessions across different windows.
26
+ - **Generic terminals** that treat AI tool output as noise — no structured parsing, no error surfacing, no smart detection.
27
+
28
+ You're using a 1980s tool to run 2025 software.
29
+
30
+ ---
31
+
32
+ ## What terminalOS Does
33
+
34
+ terminalOS is a **desktop terminal multiplexer purpose-built for AI coding workflows**. It understands AI tools natively — detecting when they're running, tracking how much you're spending, and giving you a workspace that matches the way AI-assisted development actually works.
35
+
36
+ > Think iTerm2, but redesigned from scratch around Claude Code, Aider, and OpenCode.
37
+
38
+ ---
39
+
40
+ ## Core Features
41
+
42
+ ### AI-Aware Session Detection
43
+
44
+ Every terminal pane detects when an AI coding tool is running. A live color-coded badge shows which tool is active with instant visual feedback when a session starts or ends.
45
+
46
+ | Tool | Badge Color |
47
+ | ----------- | ---------------- |
48
+ | Claude Code | Tan `#D4A27F` |
49
+ | OpenCode | Blue `#7FB5D4` |
50
+ | Aider | Purple `#A27FD4` |
51
+ | Continue | Green `#7FD4A2` |
52
+
53
+ Detection works by scanning PTY output directly — no process polling, no shell hooks required. A 3-second grace period prevents false positives when TUI input prompts appear at startup.
54
+
55
+ ---
56
+
57
+ ### Real-Time Token Tracking & Cost Estimation
58
+
59
+ terminalOS parses token usage directly from CLI output — **no API key required, no external service**. Token counts and estimated USD cost are surfaced in the status bar as you work.
60
+
61
+ **Supported output formats (all tools, automatically detected):**
62
+
63
+ | Format | Example |
64
+ | -------- | --------------------- |
65
+ | OpenCode | `64,101 31%` |
66
+ | Generic | `↑ 5.2k tokens` |
67
+ | Claude | `tokens used: 12,345` |
68
+ | Aider | `(5.2k tokens)` |
69
+
70
+ **Built-in model pricing:**
71
+
72
+ | Model | Price per 1M tokens |
73
+ | ----------------------- | ------------------- |
74
+ | Claude Opus 4 / 4.5 | $15.00 |
75
+ | Claude Sonnet 4.5 / 4.6 | $3.00 |
76
+ | Claude Haiku 4.5 | $0.80 |
77
+
78
+ The status bar shows two counters simultaneously: **session tokens** (focused pane only) and **workspace tokens** (all panes in the active tab).
79
+
80
+ ---
81
+
82
+ ### API Error Alerts
83
+
84
+ Detects and surfaces common AI API errors as visual alerts inside the pane — before they silently fail and waste your time:
85
+
86
+ - Invalid or missing API key
87
+ - Model not found (404)
88
+ - Authentication token conflicts (`ANTHROPIC_AUTH_TOKEN` vs `ANTHROPIC_API_KEY`)
89
+
90
+ ---
91
+
92
+ ### Multi-Pane Workspace
93
+
94
+ Split your workspace horizontally or vertically into an unlimited 2D pane tree. Run Claude in one pane, your test suite in another, and a markdown doc in a third — all in a single window.
95
+
96
+ - **Drag-to-resize** split handles between panes
97
+ - **Multiple tabs** — each with its own independent layout
98
+ - **Auto-save** — layout (splits, ratios, active pane) saved automatically every 500ms
99
+ - **Full restore** — exact layout reconstructed on every launch
100
+
101
+ ---
102
+
103
+ ### Integrated Markdown Editor
104
+
105
+ A built-in file editor with live preview designed for reviewing AI-generated docs, editing prompts, and working with code files without leaving your terminal.
106
+
107
+ - **Live markdown preview** — rendered side-by-side as you type
108
+ - **Automatic version history** — up to 50 snapshots saved per file, with a sidebar panel to browse, preview, and restore any previous version
109
+ - **Syntax highlighting** for 25+ languages (TypeScript, JavaScript, Python, Rust, Go, C/C++, and more)
110
+ - **File browser** — navigate directories, open files with a single click
111
+ - **File management** — create and rename files and folders inline
112
+ - **Drag-and-drop** file operations within the browser
113
+
114
+ #### Version History
115
+
116
+ Every time you save a file, terminalOS captures a snapshot automatically. A version badge (`v{n}`) appears in the editor header when history exists.
117
+
118
+ - **Auto-save deduplication** — identical content is never stored twice
119
+ - **Manual saves** always create a new version; auto-saves are throttled to 2-minute intervals
120
+ - **Up to 50 versions** per file, stored locally in `{userData}/md-versions/`
121
+ - **Restore any version** from the sidebar panel with a single click
122
+
123
+ ---
124
+
125
+ ### Command Palette
126
+
127
+ Open anything instantly with `⌘K`. A fuzzy-search interface with score-based ranking covers every action in the app — no mouse required.
128
+
129
+ **Available command categories:**
130
+
131
+ - Pane operations (split right, split below, close)
132
+ - Tab management (new workspace)
133
+ - AI tool launchers (Claude Code, OpenCode, Aider)
134
+ - Markdown editor toggle
135
+ - Folder and workspace management
136
+ - Settings
137
+ - Recent folders (up to 10, instantly accessible)
138
+
139
+ ---
140
+
141
+ ### Terminal Engine
142
+
143
+ Built on XTerm.js with full modern terminal support:
144
+
145
+ - **Full ANSI/256-color/truecolor** escape sequence rendering
146
+ - **5,000-line scrollback** buffer per pane
147
+ - **Clickable URLs** — detected and linked automatically
148
+ - **In-terminal search** — find text within any pane's output
149
+ - **Auto-resize** — panes reflow instantly on window or split resize
150
+ - **Mouse selection → clipboard** — selected text is auto-copied
151
+ - **Font support:** JetBrains Mono, Meslo LGS NF, Hack Nerd Font
152
+
153
+ ---
154
+
155
+ ### Workspace Management
156
+
157
+ - **Root folder** — set once, persists across launches
158
+ - **Git branch** — current branch shown in the status bar
159
+ - **Conda environment** — active conda env detected and displayed
160
+ - **Recent folders** — last 10 workspaces accessible from the command palette
161
+ - **CWD tracking** — current working directory always visible in the status bar
162
+
163
+ ---
164
+
165
+ ## Who This Is For
166
+
167
+ ### Primary Audience — AI-Native Engineers
168
+
169
+ Developers who use AI coding tools **every day** as a core part of their workflow. They're past the "let me try this AI thing" phase — Claude Code or Aider is open all day, on real production codebases.
170
+
171
+ **Their pain:** Standard terminals weren't built for this. They're duct-taping iTerm + Notes + a browser tab to manage their AI sessions.
172
+
173
+ **Why terminalOS:** One purpose-built workspace that gives them visibility and control over AI sessions without changing their terminal habits.
174
+
175
+ ---
176
+
177
+ ### Secondary Audience — Engineering Teams Adopting AI Tooling
178
+
179
+ Team leads and senior engineers rolling out AI coding tools across their org. They care about:
180
+
181
+ - **Cost predictability**: Token tracking helps engineers self-regulate API usage.
182
+ - **Workflow consistency**: A shared tool creates a consistent AI dev experience across the team.
183
+ - **Onboarding**: Built-in AI launchers lower the barrier for engineers new to CLI-based AI tools.
184
+
185
+ ---
186
+
187
+ ### Who This Is NOT For (Yet)
188
+
189
+ - Developers who only use AI through browser-based IDEs (Cursor, GitHub Copilot in VS Code).
190
+ - Non-technical users — this is a power-user terminal tool.
191
+ - Teams already satisfied with Warp AI or Ghostty — though terminalOS goes deeper on AI-specific tooling.
192
+
193
+ ---
194
+
195
+ ## Why terminalOS vs. Alternatives
196
+
197
+ | | terminalOS | iTerm2 / Warp | VS Code Terminal | AI IDEs (Cursor) |
198
+ | -------------------------- | ---------- | ------------- | ---------------- | ---------------- |
199
+ | Native AI tool detection | ✅ | ❌ | ❌ | Partial |
200
+ | Real-time token tracking | ✅ | ❌ | ❌ | ❌ |
201
+ | API error alerts | ✅ | ❌ | ❌ | ❌ |
202
+ | Multi-pane AI sessions | ✅ | Manual | Manual | ❌ |
203
+ | Integrated markdown editor | ✅ | ❌ | Extension | ❌ |
204
+ | Markdown version history | ✅ | ❌ | ❌ | ❌ |
205
+ | Built for CLI AI tools | ✅ | ❌ | ❌ | ❌ |
206
+ | Works with any AI tool | ✅ | — | — | ❌ (locked in) |
207
+
208
+ The key distinction: Warp and others add AI **to** a terminal. terminalOS is a terminal built **for** AI.
209
+
210
+ ---
211
+
212
+ ## Installation
213
+
214
+ ### Download (Recommended)
215
+
216
+ Download the latest release for your platform from the [Releases page]().
217
+
218
+ | Platform | Download |
219
+ | ----------------------------- | ----------------------- |
220
+ | macOS (Apple Silicon + Intel) | `.dmg` universal binary |
221
+ | Windows | `.exe` NSIS installer |
222
+ | Linux | `.AppImage` |
223
+
224
+ ### Build from Source
225
+
226
+ **Requirements:** Node.js 18+, npm 9+
227
+
228
+ ```bash
229
+ git clone https://github.com/your-org/terminalOS
230
+ cd terminalOS
231
+ npm install
232
+ npm run rebuild # Compiles native terminal module
233
+ npm run build # Production build
234
+ npm run dist # Package for your platform
235
+ ```
236
+
237
+ **Development (hot reload):**
238
+
239
+ ```bash
240
+ npm run dev
241
+ ```
242
+
243
+ ---
244
+
245
+ ## Getting Started
246
+
247
+ 1. **Open a folder** — use `⌘O` or the command palette to set your workspace root.
248
+ 2. **Launch an AI tool** — press `⌘⇧C` for Claude Code, `⌘⇧O` for OpenCode, or type the command manually.
249
+ 3. **Watch the badge appear** — terminalOS detects the AI process and shows a live status indicator.
250
+ 4. **Split your workspace** — `⌘D` to split right, `⌘⇧D` to split below. Run your tests alongside AI.
251
+ 5. **Track tokens** — token usage and estimated cost appear in the status bar as your AI session runs.
252
+
253
+ ---
254
+
255
+ ## Keyboard Shortcuts
256
+
257
+ | Shortcut | Action |
258
+ | -------- | --------------------- |
259
+ | `⌘K` | Open command palette |
260
+ | `⌘T` | New tab / workspace |
261
+ | `⌘D` | Split pane right |
262
+ | `⌘⇧D` | Split pane below |
263
+ | `⌘W` | Close active pane |
264
+ | `⌘M` | Open markdown editor |
265
+ | `⌘⇧C` | Launch Claude Code |
266
+ | `⌘⇧O` | Launch OpenCode |
267
+ | `⌘O` | Open folder |
268
+ | `⌘S` | Save file (in editor) |
269
+
270
+ > On Windows/Linux, replace `⌘` with `Ctrl`.
271
+
272
+ ---
273
+
274
+ ## Tech Stack
275
+
276
+ | Layer | Technology |
277
+ | ------------------- | --------------------- |
278
+ | Desktop runtime | Electron 33 |
279
+ | UI framework | React 19 + TypeScript |
280
+ | Build tooling | Vite 6 |
281
+ | Terminal emulator | XTerm.js 5.3 |
282
+ | PTY management | node-pty |
283
+ | State management | Zustand 5 |
284
+ | File watching | Chokidar 4 |
285
+ | Markdown rendering | Marked 17 |
286
+ | Syntax highlighting | Highlight.js 11 |
287
+ | Auto-updater | electron-updater |
288
+ | Virtualized lists | React Window |
289
+
290
+ ---
291
+
292
+ ## Roadmap
293
+
294
+ The following are areas actively being explored based on developer feedback:
295
+
296
+ - [ ] **Multi-model token display** — differentiate input vs. output token costs
297
+ - [ ] **Session history and replay** — review past AI sessions
298
+ - [ ] **Prompt scratchpad** — dedicated pane for drafting and reusing prompts
299
+ - [ ] **Team token budgets** — per-project spend limits with alerts
300
+ - [ ] **Plugin API** — extend terminalOS with custom AI tool integrations
301
+
302
+ ---
303
+
304
+ ## Contributing
305
+
306
+ Contributions are welcome. Please open an issue before submitting a PR for significant changes.
307
+
308
+ ```bash
309
+ npm run dev # Start development environment with hot reload
310
+ ```
311
+
312
+ ---
313
+
314
+ ## License
315
+
316
+ MIT © terminalOS
317
+
318
+ ---
319
+
320
+ <div align="center">
321
+
322
+ **Built for the developers who run AI all day.**
323
+
324
+ </div>
package/bin/cli.js ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const args = process.argv.slice(2);
5
+
6
+ const hasRun = args.includes("--run") || args.includes("--start");
7
+ if (!hasRun) {
8
+ console.log(`
9
+ terminalos CLI
10
+
11
+ Usage:
12
+ npx terminalos --run Start the terminal in your browser (default port 7513)
13
+ npx terminalos --run --port N Use a custom port
14
+ `);
15
+ process.exit(0);
16
+ }
17
+
18
+ const portFlag = args.indexOf("--port");
19
+ const port = portFlag !== -1 ? parseInt(args[portFlag + 1], 10) : 7513;
20
+
21
+ if (isNaN(port) || port < 1 || port > 65535) {
22
+ console.error(" Invalid port number. Use --port <1-65535>");
23
+ process.exit(1);
24
+ }
25
+
26
+ // The runtime server is compiled to runtime-dist/server.js
27
+ const { startServer } = require("../runtime-dist/server");
28
+ startServer(port);