@codeworksh/tui 0.0.0-stage → 0.0.1-canary.33.1.g4dc50635

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sanchit Kudari <0xsanchit@gmail.com> & Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,130 @@
1
- # Temporary Holding Version
1
+ # codework-tui
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A fast and lightweight terminal interface for [CodeWork](https://www.codework.sh), written in **Rust**.
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.
6
+
7
+ ---
8
+
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.
20
+
21
+ ---
22
+
23
+ ## Getting Started
24
+
25
+ ### Prerequisites
26
+
27
+ - [Rust](https://rustup.rs/) (latest stable version)
28
+ - Node.js and pnpm (to run the CodeWork CLI and background server)
29
+
30
+ ### Running the App
31
+
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.
33
+
34
+ To run the binary directly against a server you started with `codework serve`, use Cargo:
35
+
36
+ ```bash
37
+ # Run in development mode
38
+ cargo run
39
+
40
+ # Build and run an optimized release version
41
+ cargo build --release
42
+ ./target/release/codework-tui
43
+ ```
44
+
45
+ Or using pnpm:
46
+
47
+ ```bash
48
+ # From packages/tui
49
+ pnpm start
50
+
51
+ # Or from the project root
52
+ pnpm --filter @codeworksh/tui start
53
+ ```
54
+
55
+ ---
56
+
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
+ ## Keyboard Shortcuts
73
+
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.
118
+
119
+ ---
120
+
121
+ ## Contributors
122
+
123
+ - **Prem** ([@prem315](https://github.com/prem315))
124
+ - **Sanchit** ([@sanchitrk](https://github.com/sanchitrk))
125
+
126
+ ---
127
+
128
+ ## License
129
+
130
+ MIT © [CodeWork](https://codework.sh)
package/index.mjs ADDED
@@ -0,0 +1,64 @@
1
+ import { createRequire } from "node:module";
2
+ import { existsSync } from "node:fs";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ //#region src/binary.ts
6
+ const require = createRequire(import.meta.url);
7
+ /** Resolve the current platform, or `undefined` where no prebuilt is published. */
8
+ function platform() {
9
+ const os = process.platform;
10
+ const arch = process.arch;
11
+ if (os !== "darwin" && os !== "linux") return void 0;
12
+ if (arch !== "arm64" && arch !== "x64") return void 0;
13
+ return {
14
+ os,
15
+ arch
16
+ };
17
+ }
18
+ const packageFor = (value) => `@codeworksh/tui-${value.os}-${value.arch}`;
19
+ const binaryName = "codework-tui";
20
+ /** A source-tree build, used when neither an override nor a platform package is present. */
21
+ function devBuild() {
22
+ for (const profile of ["release", "debug"]) {
23
+ const candidate = fileURLToPath(new URL(`../target/${profile}/${binaryName}`, import.meta.url));
24
+ if (existsSync(candidate)) return candidate;
25
+ }
26
+ }
27
+ var LauncherError = class extends Error {};
28
+ /**
29
+ * The `codework-tui` executable to run.
30
+ *
31
+ * Resolution order, most specific first:
32
+ * 1. `CODEWORK_TUI_BIN` — an explicit path, for a local build or a test.
33
+ * 2. The platform package's `bin/` — what a normal install ships.
34
+ * 3. A `target/{release,debug}` build in the source tree, so `codework tui`
35
+ * works from a checkout without publishing anything.
36
+ *
37
+ * Nothing is ever downloaded: a missing binary is an error that names the
38
+ * package to install, because a silent runtime fetch is both surprising and a
39
+ * supply-chain surface.
40
+ */
41
+ function resolveBinary(env = process.env) {
42
+ const override = env["CODEWORK_TUI_BIN"];
43
+ if (override !== void 0 && override.length > 0) {
44
+ if (!existsSync(override)) throw new LauncherError(`CODEWORK_TUI_BIN points at a missing file: ${override}`);
45
+ return override;
46
+ }
47
+ const current = platform();
48
+ if (current !== void 0) try {
49
+ const manifest = require.resolve(`${packageFor(current)}/package.json`);
50
+ const binary = join(dirname(manifest), "bin", binaryName);
51
+ if (existsSync(binary)) return binary;
52
+ } catch {}
53
+ const dev = devBuild();
54
+ if (dev !== void 0) return dev;
55
+ throw new LauncherError(current === void 0 ? `no prebuilt CodeWork TUI is published for ${process.platform}-${process.arch}` : `the CodeWork TUI binary is missing. Install ${packageFor(current)}, or build it with \`cargo build --release\` in packages/tui`);
56
+ }
57
+ //#endregion
58
+ //#region src/index.ts
59
+ /** The environment variable the Rust TUI reads for the server endpoint. */
60
+ const ENV_SERVER = "CODEWORK_RPC_SERVER";
61
+ //#endregion
62
+ export { ENV_SERVER, LauncherError, platform, resolveBinary };
63
+
64
+ //# sourceMappingURL=index.mjs.map
package/index.mjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/binary.ts","../../src/index.ts"],"sourcesContent":["/* @effect-diagnostics nodeBuiltinImport:off -- the launcher resolves a file on the host. */\nimport { createRequire } from \"node:module\";\nimport { existsSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst require = createRequire(import.meta.url);\n\n/** The Rust binary, by the package that publishes a prebuilt for this platform. */\nexport interface Platform {\n\treadonly os: \"darwin\" | \"linux\";\n\treadonly arch: \"arm64\" | \"x64\";\n}\n\n/** Resolve the current platform, or `undefined` where no prebuilt is published. */\nexport function platform(): Platform | undefined {\n\tconst os = process.platform;\n\tconst arch = process.arch;\n\tif (os !== \"darwin\" && os !== \"linux\") return undefined;\n\tif (arch !== \"arm64\" && arch !== \"x64\") return undefined;\n\treturn { os, arch };\n}\n\nconst packageFor = (value: Platform) => `@codeworksh/tui-${value.os}-${value.arch}`;\nconst binaryName = \"codework-tui\";\n\n/** A source-tree build, used when neither an override nor a platform package is present. */\nfunction devBuild(): string | undefined {\n\tfor (const profile of [\"release\", \"debug\"]) {\n\t\tconst candidate = fileURLToPath(new URL(`../target/${profile}/${binaryName}`, import.meta.url));\n\t\tif (existsSync(candidate)) return candidate;\n\t}\n\treturn undefined;\n}\n\nexport class LauncherError extends Error {}\n\n/**\n * The `codework-tui` executable to run.\n *\n * Resolution order, most specific first:\n * 1. `CODEWORK_TUI_BIN` — an explicit path, for a local build or a test.\n * 2. The platform package's `bin/` — what a normal install ships.\n * 3. A `target/{release,debug}` build in the source tree, so `codework tui`\n * works from a checkout without publishing anything.\n *\n * Nothing is ever downloaded: a missing binary is an error that names the\n * package to install, because a silent runtime fetch is both surprising and a\n * supply-chain surface.\n */\nexport function resolveBinary(env: NodeJS.ProcessEnv = process.env): string {\n\tconst override = env[\"CODEWORK_TUI_BIN\"];\n\tif (override !== undefined && override.length > 0) {\n\t\tif (!existsSync(override)) throw new LauncherError(`CODEWORK_TUI_BIN points at a missing file: ${override}`);\n\t\treturn override;\n\t}\n\n\tconst current = platform();\n\tif (current !== undefined) {\n\t\ttry {\n\t\t\t// Resolve through the package's own manifest so the binary path is not part of\n\t\t\t// the platform package's public `exports` surface.\n\t\t\tconst manifest = require.resolve(`${packageFor(current)}/package.json`);\n\t\t\t// In a checkout the platform package is a workspace link with no binary staged.\n\t\t\tconst binary = join(dirname(manifest), \"bin\", binaryName);\n\t\t\tif (existsSync(binary)) return binary;\n\t\t} catch {\n\t\t\t// Fall through to the source-tree build below.\n\t\t}\n\t}\n\n\tconst dev = devBuild();\n\tif (dev !== undefined) return dev;\n\n\tthrow new LauncherError(\n\t\tcurrent === undefined\n\t\t\t? `no prebuilt CodeWork TUI is published for ${process.platform}-${process.arch}`\n\t\t\t: `the CodeWork TUI binary is missing. Install ${packageFor(current)}, or build it with \\`cargo build --release\\` in packages/tui`,\n\t);\n}\n","/**\n * Finds the CodeWork TUI binary. Running it is the CLI's job: the child must\n * share the CLI's lifetime and terminal, which the CLI's own runtime manages.\n */\nexport { LauncherError, platform, resolveBinary, type Platform } from \"./binary.ts\";\n\n/** The environment variable the Rust TUI reads for the server endpoint. */\nexport const ENV_SERVER = \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;ACxEA,MAAa,aAAa"}
package/package.json CHANGED
@@ -1,6 +1,38 @@
1
1
  {
2
- "name": "@codeworksh/tui",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@codeworksh/tui",
3
+ "version": "0.0.1-canary.33.1.g4dc50635",
4
+ "description": "High-performance Terminal User Interface (TUI) for CodeWork in Rust, with a thin TypeScript launcher",
5
+ "keywords": [
6
+ "codework",
7
+ "ratatui",
8
+ "rust",
9
+ "tui"
10
+ ],
11
+ "homepage": "https://www.codework.sh",
12
+ "license": "MIT",
13
+ "author": "Prem (https://github.com/prem315)",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/codeworksh/codework.git",
17
+ "directory": "packages/tui"
18
+ },
19
+ "type": "module",
20
+ "exports": {
21
+ ".": {
22
+ "import": "./index.mjs",
23
+ "default": "./index.mjs"
24
+ },
25
+ "./package.json": "./package.json"
26
+ },
27
+ "files": [
28
+ "**/*",
29
+ "README.md",
30
+ "LICENSE"
31
+ ],
32
+ "optionalDependencies": {
33
+ "@codeworksh/tui-darwin-arm64": "0.0.1-canary.33.1.g4dc50635",
34
+ "@codeworksh/tui-darwin-x64": "0.0.1-canary.33.1.g4dc50635",
35
+ "@codeworksh/tui-linux-arm64": "0.0.1-canary.33.1.g4dc50635",
36
+ "@codeworksh/tui-linux-x64": "0.0.1-canary.33.1.g4dc50635"
37
+ }
38
+ }