@pithosai/pithosai 1.0.5 → 1.0.10

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 CHANGED
@@ -1,154 +1,208 @@
1
1
  # Pithosai (`@pithosai/pithosai`)
2
2
 
3
- **Multi-role AI CLI** for coding and product work: natural-language requests, pluggable models (Cursor, DeepSeek, OpenRouter), and role-based prompts stored in SQLite.
3
+ **Multi-role AI CLI** for coding and product work: natural-language requests, pluggable models (DeepSeek, OpenRouter, Ollama, Cursor), and role-based prompts stored in SQLite.
4
+
5
+ | | |
6
+ |---|---|
7
+ | **Best for** | Agent-style coding, multi-role workflows (RD / PM / QA / …), local or cloud models, repeatable prompts from a local database |
8
+ | **Requirements** | **Node.js ≥ 18.12** and **at least one** [model provider](#model-providers) |
9
+ | **License** | Proprietary — see [License](#license) |
4
10
 
5
11
  ---
6
12
 
7
- ## What's New in v1.0.5 (Customer Security View)
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install -g @pithosai/pithosai
17
+ ```
18
+
19
+ On a global install, if `~/.pithosai/pithosai.db` does not exist, it is created from the bundled schema. Override the path with `PITHOSAI_DB_PATH`.
8
20
 
9
- - **Encrypted storage upgrade for existing users:** Legacy plaintext `pithosai.db` data is upgraded to encrypted storage on first open when encryption support is available.
10
- - **Device-tied protection:** Database protection is tied to your machine, reducing the risk of copied files being opened elsewhere.
11
- - **Safer release logging defaults:** Packaged releases now default to `INFO` logging to reduce unnecessary verbose output in normal usage.
12
- - **Controlled Markdown terminal output:** `render-markdown` now supports pager-based scrolling by default, with explicit `--show-all` when full direct terminal output is desired.
21
+ **Highlights**
13
22
 
14
- See the database notes below for migration behavior and security details.
23
+ - **DeepSeek V4** — Cost-first `deepseek-v4-flash` by default; `--pro` and `--reasoner` for harder work ([details](#deepseek-api-v4)).
24
+ - **Role shortcuts** — `rdsai`, `pmsai`, `qasai`, `cosai`, `mktai`, `wrsai` preset role and model defaults.
25
+ - **Full-screen TUI** — Transcript, tool output, and slash commands (`/model`, `/shell`, `/list`, skills, …).
26
+ - **Virtual projects** — Switch workspaces from the REPL via `~/.pithosai/projects.json` ([details](#virtual-projects)).
27
+ - **Plan alignment** — `/grill-me` stress-tests a design one question at a time ([details](#plan-alignment-grill-me)).
28
+ - **Run modes** — `agent` (full tools), `dialog` (read-only), `plan` (writes `<slug>-plan.md`).
29
+ - **Local persistence** — Tasks and prompts in SQLCipher-backed SQLite; optional `pithosai migrate-db` from legacy plaintext DBs.
30
+ - **Skills & email** — ClawHub-style skills in-session; `heartbeat` / `email-monitor` for IMAP-driven tasks.
15
31
 
16
32
  ---
17
33
 
18
- ## Install
19
-
20
- **Node.js ≥ 18.12** required.
34
+ ## Quick start
21
35
 
22
36
  ```bash
23
- npm install -g @pithosai/pithosai
37
+ export DEEPSEEK_API_KEY=sk-... # or another provider below
38
+ cd your-project
39
+ pithosai init
40
+ pithosai "Describe what you want done"
24
41
  ```
25
42
 
26
- On a **global** install, the package runs a one-time step: if `~/.pithosai/pithosai.db` does not exist, it is created from the bundled schema. Override the path anytime with `PITHOSAI_DB_PATH`.
43
+ | Invocation | Behavior |
44
+ |------------|----------|
45
+ | `pithosai -i` | Interactive session with no initial prompt |
46
+ | `pithosai --no-interactive "…"` | Single run, then exit |
47
+ | `pithosai -C ./other-dir "…"` | Use a different project directory |
48
+ | `/exit` or `/quit` | Leave the REPL (plain `exit` is sent to the agent) |
27
49
 
28
- ---
50
+ Each run prints a short ASCII banner. Prompts load from the local database (default `~/.pithosai/pithosai.db`). Optional role overrides live under `.pithosai/<role>/` in your project.
51
+
52
+ ### Language
53
+
54
+ Default locale is **English**. Set per run with `--lang`, or rely on the shell `LANG`.
55
+
56
+ ```bash
57
+ pithosai --lang zh "请解释这个错误"
58
+ ```
59
+
60
+ Supported codes include `en`, `ar`, `de`, `es`, `fr`, `it`, `ja`, `ko`, `nl`, `pt`, `zh`, and `zh-hant` (Traditional Chinese, fixed in **1.0.7**). Run `pithosai --help` for the full list.
29
61
 
30
- ## What you get
62
+ ### Upgrading from v1.0.4 (plaintext database)
31
63
 
32
- | You run | Purpose |
33
- |--------|---------|
34
- | `pithosai` | Main CLI: `init`, `migrate-db`, interactive agent, `task`, `heartbeat`, `skills`, `memorize`, and more. |
35
- | `rdsai`, `pmsai`, `qasai`, `cosai`, `mktai`, `wrsai` | Same CLI with a **default role** (e.g. RD, PM, QA). |
36
- | `email-monitor` | Heartbeat / email-driven task loop (`heartbeat` bundle). |
37
- | `render-markdown` | Render Markdown files in the terminal. |
38
- | `init` | Manually initialize `~/.pithosai/pithosai.db` if needed (usually automatic after global install). |
64
+ From **1.0.5** onward, plaintext databases migrate automatically when encryption is available, or you can run `pithosai migrate-db`. See [`CHANGELOG.md`](CHANGELOG.md) section **[1.0.5]**.
39
65
 
40
66
  ---
41
67
 
42
- ## Choose a model provider
68
+ ## Model providers
43
69
 
44
- Configure **at least one** of:
70
+ Configure **at least one** of the following.
45
71
 
46
- 1. **DeepSeek** — `export DEEPSEEK_API_KEY=sk-...`
72
+ | Provider | Setup |
73
+ |----------|--------|
74
+ | **DeepSeek** | `export DEEPSEEK_API_KEY=sk-...` |
75
+ | **OpenRouter** | `export OPENROUTER_API_KEY=sk-or-...` |
76
+ | **Ollama (local)** | Install Ollama, run a model, then `export OPENAI_LOCAL_API_BASE=http://localhost:11434/v1` |
77
+ | **Cursor CLI** | Install the Cursor agent, sign in, set e.g. `export CURSOR_MODEL=auto`, and pass `--cursor` when needed |
47
78
 
48
- 2. **OpenRouter** — `export OPENROUTER_API_KEY=sk-or-...`
79
+ **Precedence:** DeepSeek → Ollama (`OPENAI_LOCAL_API_BASE`) → OpenRouter → `CURSOR_MODEL` / `--cursor`.
49
80
 
50
- 3. **Cursor CLI** (last resort)
51
- ```bash
52
- curl https://cursor.com/install -fsS | bash
53
- cursor-agent login
54
- export CURSOR_MODEL=auto
55
- ```
56
- Use **`pithosai "your request" --cursor`** or set `CURSOR_MODEL`.
81
+ ### DeepSeek API (V4)
57
82
 
58
- **Precedence:** DeepSeek → OpenRouter → `CURSOR_MODEL` / `--cursor`.
83
+ With a native **`DEEPSEEK_API_KEY`**, flags map to:
59
84
 
60
- ---
85
+ | Your choice | API model id | Typical use |
86
+ |-------------|----------------|-------------|
87
+ | Default (no `--pro` / `--reasoner`) | `deepseek-v4-flash` | Cost-efficient daily work |
88
+ | `--pro` | `deepseek-v4-pro` | Harder tasks |
89
+ | `--chat` | `deepseek-v4-flash` | Explicit chat path |
90
+ | `--reasoner` | `deepseek-v4-pro` + reasoning | Longer chain-of-thought |
61
91
 
62
- ## Quick start
92
+ Legacy ids `deepseek-chat` and `deepseek-reasoner` are retired upstream; see [DeepSeek API docs](https://api-docs.deepseek.com/). Flash paths disable API “thinking” by default so tool-heavy turns stay stable; `--reasoner` keeps extended reasoning enabled.
63
93
 
64
- ```bash
65
- cd your-project
66
- pithosai init
67
- pithosai "Describe what you want done"
68
- ```
94
+ With **OpenRouter** only, use slugs `deepseek/deepseek-v4-flash` (default) and `deepseek/deepseek-v4-pro` (`--pro` / `--reasoner`). An OpenRouter regression was fixed in **1.0.8**.
69
95
 
70
- - **`pithosai -i`** — interactive session with no initial prompt.
71
- - **`pithosai --no-interactive "…"`** — one shot, then exit.
72
- - **`pithosai -C ./other-dir "…"`** — use another project directory.
73
- - Every CLI invocation prints a cyan ASCII `pithosai` slogan banner first.
96
+ ### Role entrypoints
74
97
 
75
- Prompts load from a local database (default `~/.pithosai/pithosai.db`). Optional role overrides live under `.pithosai/<role>/` in your project.
98
+ | Command | Role | Default model |
99
+ |---------|------|----------------|
100
+ | `rdsai` | RD | `deepseek-v4-flash` (unless `--pro` / `--reasoner`) |
101
+ | `pmsai`, `qasai`, `cosai`, `mktai` | PM / QA / CO / MKT | flash (`--chat`) |
102
+ | `wrsai` | WR (`task` mode) | flash; default language **zh** |
76
103
 
77
- ### Language selection
104
+ These ship as POSIX shell wrappers next to `pithosai.mjs` that invoke the same binary with preset flags (**1.0.9** / **1.0.10**).
78
105
 
79
- - Default language is **English (`en`)**.
80
- - Set language per command with `--lang`.
81
- - Or export `LANG` in your shell to set terminal locale preference.
106
+ Use `/model` in the REPL to list and switch models interactively.
82
107
 
83
- Examples:
108
+ ---
84
109
 
85
- ```bash
86
- pithosai --lang zh "请解释这个错误"
87
- ```
110
+ ## Commands
88
111
 
89
- ```bash
90
- export LANG=ja_JP.UTF-8
91
- pithosai "今日のタスクを要約してください"
92
- ```
112
+ | Command | Purpose |
113
+ |---------|---------|
114
+ | `pithosai` | Main CLI: `init`, `migrate-db`, interactive agent, `task`, `heartbeat`, `skills`, `memorize`, … |
115
+ | `rdsai`, `pmsai`, `qasai`, `cosai`, `mktai`, `wrsai` | Same CLI with a default role |
116
+ | `email-monitor` | Heartbeat / email-driven task loop |
117
+ | `render-markdown` | Render Markdown in the terminal |
118
+ | `init` | Initialize `~/.pithosai/pithosai.db` manually |
119
+
120
+ ### Project maintenance
121
+
122
+ | Command | What it does |
123
+ |---------|----------------|
124
+ | `pithosai init [dir]` | Scaffold project, `.pithosai/sessions/`, settings |
125
+ | `pithosai migrate-db` | Legacy plaintext DB → SQLCipher |
126
+ | `pithosai add-role <role>` | Add a role to the project |
127
+ | `pithosai task --file <md>` | Watch a task file and run tasks |
128
+ | `pithosai memorize --start … --end … -r <role>` | Build `.pithosai/<role>/memory.md` |
129
+ | `pithosai heartbeat` / `heartbeat --once` | Email pipeline (IMAP/SMTP in settings) |
130
+ | `pithosai skills …` | Install / list / remove skills |
131
+ | `pithosai shell "cmd"` | Run a shell command via the CLI |
93
132
 
94
- Supported language codes:
95
- - `en` (English)
96
- - `ar` (Arabic)
97
- - `de` (German)
98
- - `es` (Spanish)
99
- - `fr` (French)
100
- - `it` (Italian)
101
- - `ja` (Japanese)
102
- - `ko` (Korean)
103
- - `nl` (Dutch)
104
- - `pt` (Portuguese)
105
- - `zh` (Simplified Chinese)
106
- - `zh-hant` (Traditional Chinese)
107
-
108
- ### Upgrading from v1.0.4 (plaintext `pithosai.db`)
109
-
110
- - **Automatic:** After upgrading to **1.0.5+**, plaintext databases are migrated in place to encrypted storage on first open when encryption support is available.
111
- - **Manual (optional):** You can run `pithosai migrate-db` if you want to trigger migration directly.
133
+ Use `pithosai --help` and `pithosai <command> --help` for flags such as `--timeout`, `--lang`, `--role`, and `--log-path`.
112
134
 
113
135
  ---
114
136
 
115
- ## Run modes (`--mode`)
137
+ ## Run modes
116
138
 
117
139
  | Mode | Use case |
118
140
  |------|----------|
119
- | **`agent`** (default) | Full tools: edit files, run commands, etc. |
120
- | **`dialog`** | Answers and read-only tools (no shell tool). |
121
- | **`plan`** | Writes a plan file (`<slug>-plan.md`) in the project root; read-only tools. |
141
+ | `agent` (default) | Full tools: edit files, run commands, … |
142
+ | `dialog` | Answers and read-only tools (no shell tool) |
143
+ | `plan` | Writes `<slug>-plan.md`; read-only tools |
122
144
 
123
145
  ```bash
124
146
  pithosai --mode dialog "Explain this error"
125
147
  pithosai --mode plan "Outline the next sprint"
126
148
  ```
127
149
 
128
- Result previews (terminal or optional Chrome via Playwright) can be tuned with `PITHOSAI_SKIP_RESULT_BROWSER`, `PITHOSAI_RESULT_BROWSER`, and `PITHOSAI_PLAYWRIGHT_CHANNEL`.
150
+ Markdown previews: `PITHOSAI_SKIP_RESULT_BROWSER`, `PITHOSAI_RESULT_BROWSER`, `PITHOSAI_PLAYWRIGHT_CHANNEL`.
129
151
 
130
152
  ---
131
153
 
132
- ## Common commands
154
+ ## Interactive session
133
155
 
134
- | Command | What it does |
135
- |---------|----------------|
136
- | `pithosai init [dir]` | Scaffold project, `.pithosai/sessions/`, settings. |
137
- | `pithosai migrate-db` | Convert a legacy plaintext global DB to SQLCipher (optional; usually automatic on first open). |
138
- | `pithosai add-role <role>` | Add a role to the project. |
139
- | `pithosai task --file <md>` | Watch a task file and run tasks sequentially. |
140
- | `pithosai memorize --start … --end … -r <role>` | Build `.pithosai/<role>/memory.md` from stored tasks. |
141
- | `pithosai heartbeat` / `heartbeat --once` | Email-driven task pipeline (needs IMAP/SMTP in settings). |
142
- | `pithosai skills …` | Install / list / remove skills. |
143
- | `pithosai shell "cmd"` | Run a shell command via the CLI. |
156
+ The default UI is a **full-screen TUI**: transcript above, input below. **Ctrl+S** stops the agent; **Ctrl+P** pauses. Set `PITHOSAI_NO_TUI=1` for a classic line prompt (scripts, minimal terminals).
157
+
158
+ ### Core slash commands
159
+
160
+ | Command | Description |
161
+ |---------|-------------|
162
+ | `/model` | List and switch models |
163
+ | `/shell <cmd>` | Run a shell command in-process |
164
+ | `/shell cd <dir>` | Change working directory (`~` supported); syncs session `projectPath` (**1.0.8**) |
165
+ | `/list` | Show persisted tasks for the current session project (includes `projectPath` column) |
166
+ | `/list <text>` | Filter tasks by title, description, or path |
167
+ | `/select`, `/show`, `/show-task`, `/show-prompt` | Work with persisted tasks |
168
+ | `/new` | Start a new task id (no prior messages loaded) |
169
+ | `/list-skill`, `/install-skill`, `/remove-skill` | Same as `pithosai skills` (ClawHub) |
170
+ | `/grill-me [topic]` | Stress-test a plan with one question at a time (**1.0.8**) |
171
+ | `/exit`, `/quit` | Leave the REPL (**1.0.7**) |
172
+
173
+ Tab completion covers slash commands (including `/list-project` and `/grill-me`). Directory navigation via `/shell cd` and `ls` is tracked for recall (**1.0.8**).
174
+
175
+ ### Virtual projects
176
+
177
+ Manage multiple workspaces from the REPL without leaving the session. Registry file: **`~/.pithosai/projects.json`** (**1.0.8**).
178
+
179
+ | Command | Description |
180
+ |---------|-------------|
181
+ | `/create-project [name path lang description]` | Register a project, create its directory if needed, `chdir`, and start a new task id. With no arguments, registers the current directory (or shows it if already registered). |
182
+ | `/list-project [filter]` | List registered projects (index, name, path). Optional filter matches name, path, language, or description. |
183
+ | `/show-project` | Show cwd and registry metadata when cwd matches a saved path |
184
+ | `/switch-project <index>` | `chdir` to a listed project and start a new task id |
185
+
186
+ `/list` is scoped to the active session project path and does not collide with `/list-project` or `/list-skill` by prefix.
187
+
188
+ ### Plan alignment (`/grill-me`)
189
+
190
+ `/grill-me` runs a Matt Pocock–style alignment prompt (one question per turn) to sharpen plans before implementation. Optional text after the command sets the focus topic. Prompt language follows `--lang` / settings (`en`, `zh`, `zh-hant`, …). A matching Cursor skill lives at `.cursor/skills/grill-me/SKILL.md`.
144
191
 
145
- Use **`pithosai --help`** and **`pithosai <command> --help`** for flags (`--timeout`, `--lang`, `--role`, `--log-path`, etc.).
192
+ ### Reliability
193
+
194
+ - **Connection-loss retry (1.0.8):** Transient API drops (`network connection lost`) are retried like timeouts.
195
+ - **Tool result display:** Orphaned error tool results are filtered so the transcript stays consistent; ANSI styling in tool output was corrected in **1.0.8**.
146
196
 
147
197
  ---
148
198
 
149
- ## Interactive session (short)
199
+ ## Startup version check
200
+
201
+ On launch, the CLI **may** check npm for a newer `@pithosai/pithosai` (at most once per 24 hours; state in `~/.pithosai/auto-upgrade-check.json`) and run `npm install -g @pithosai/pithosai@latest` (**1.0.7**).
150
202
 
151
- In a normal terminal, the default UI uses a **full-screen TUI** (bottom input, scrolling transcript). **`Ctrl+S`** stops a run; **`Ctrl+P`** pauses. Slash commands include `/shell`, `/list`, `/show-task`, `/show-prompt`, and skill helpers. Set **`PITHOSAI_NO_TUI=1`** for a classic line-based prompt (e.g. scripts or minimal terminals).
203
+ Notices use the same resolved CLI language as help. **The running process remains the old build** until you start `pithosai` again. When stdin and stdout are TTYs and the full-screen TUI would start, the CLI **waits for Enter** so upgrade messages are visible.
204
+
205
+ Disable with `PITHOSAI_AUTO_UPGRADE=0` (or `false` / `no` / `off`).
152
206
 
153
207
  ---
154
208
 
@@ -156,26 +210,61 @@ In a normal terminal, the default UI uses a **full-screen TUI** (bottom input, s
156
210
 
157
211
  | Variable | Role |
158
212
  |----------|------|
159
- | `CURSOR_MODEL`, `CURSOR_AGENT_BIN` | Cursor CLI integration |
160
213
  | `DEEPSEEK_API_KEY`, `OPENROUTER_API_KEY` | API providers |
161
- | `PITHOSAI_DB_PATH` | SQLite DB path (default `~/.pithosai/pithosai.db`) |
214
+ | `OPENAI_LOCAL_API_BASE` | Local Ollama (`/v1` base URL) |
215
+ | `CURSOR_MODEL`, `CURSOR_AGENT_BIN` | Cursor CLI |
216
+ | `PITHOSAI_DB_PATH` | SQLite DB (default `~/.pithosai/pithosai.db`) |
217
+ | `PITHOSAI_AUTO_UPGRADE` | Disable startup check: `0` / `false` / `no` / `off` |
162
218
  | `PITHOSAI_SKIP_RESULT_BROWSER` | Skip markdown preview (e.g. CI) |
163
- | `PITHOSAI_RESULT_BROWSER` | `chrome` for Playwright browser preview |
164
- | `PITHOSAI_TIMEOUT_MS` / `--timeout` | Run time limits |
165
- | `SCRAPERAPI_API_KEY` | Used by skills / some tools |
219
+ | `PITHOSAI_RESULT_BROWSER` | e.g. `chrome` for Playwright |
220
+ | `PITHOSAI_TIMEOUT_MS` / `--timeout` | Run limits |
221
+ | `SCRAPERAPI_API_KEY` | Some skills / tools |
222
+
223
+ ---
224
+
225
+ ## What's new (v1.0.7 – v1.0.10)
226
+
227
+ Highlights for the published CLI (excluding unreleased components). Full per-version notes: [`CHANGELOG.md`](CHANGELOG.md).
228
+
229
+ ### v1.0.10 — Packaging and distribution
230
+
231
+ - Simplified npm publish layout (`.npmignore`, narrowed `files` field).
232
+ - Role binaries (`rdsai`, `pmsai`, …) ship as POSIX wrappers under `scripts/bin-shims/` with corrected paths to `pithosai.mjs`.
233
+ - Dependencies use published `@mariozechner/*` packages on npm instead of vendored `lib/pi-mono` copies.
234
+
235
+ ### v1.0.9 — Install reliability
236
+
237
+ - Improved `npm install -g` resolution for bundled agent dependencies.
238
+ - Role commands consolidated as thin shell wrappers invoking `pithosai.mjs`.
239
+
240
+ ### v1.0.8 — Session productivity
241
+
242
+ - **Virtual projects** — `/create-project`, `/list-project`, `/show-project`, `/switch-project` with `~/.pithosai/projects.json`.
243
+ - **`/grill-me`** — Interactive plan alignment (localized prompts).
244
+ - **`/shell cd`** — In-process directory changes with `~` expansion and directory history.
245
+ - **Task list** — `/list` shows `projectPath`, supports `/list <text>` filter, scopes to the session project.
246
+ - **Resilience** — Automatic retry on connection loss; OpenRouter regression fix; `taskRef.projectPath` kept in sync after `cd` and project switches.
247
+
248
+ ### v1.0.7 — Models and startup
249
+
250
+ - **DeepSeek V4** — Default `deepseek-v4-flash`; `--pro` / `--reasoner` select `deepseek-v4-pro` with optional reasoning.
251
+ - **Startup auto-upgrade** — Optional global update check (24 h throttle, TTY-aware prompt).
252
+ - **REPL exit** — `/exit` and `/quit` (plain `exit` goes to the agent).
253
+ - **Locales** — `zh-hant` resolution fix; `render-markdown` dist entry fix.
166
254
 
167
255
  ---
168
256
 
169
- ## Help and support
257
+ ## Help
170
258
 
171
- Use `pithosai --help` for top-level options, and `pithosai <command> --help` for command-specific details.
259
+ - `pithosai --help`
260
+ - `pithosai <command> --help`
172
261
 
173
262
  ---
174
263
 
175
264
  ## License
176
265
 
177
- Pithosai is **proprietary** software — it is **not** published under an open-source or ISC license.
266
+ Pithosai is **proprietary** software; it is **not** published under an open-source license.
178
267
 
179
268
  Copyright © 2026 [lidh04@gmail.com](mailto:lidh04@gmail.com). All rights reserved.
180
269
 
181
- See [`LICENSE`](LICENSE) for the copyright notice (included in the npm package). The `license` field in `package.json` is `UNLICENSED`, which npm uses when no public license is granted.
270
+ See [`LICENSE`](LICENSE) in the npm package. The `license` field in `package.json` is **`UNLICENSED`** (npm convention when no public license is granted).
package/dist/935.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- export const __rspack_esm_id="935";export const __rspack_esm_ids=["935"];export const __webpack_modules__={8498(t,e,i){i.a(t,async function(t,s){try{i.d(e,{showMarkdownInPiTui:()=>a});var l=i(8691),r=i(2421),n=i(4127),h=t([l,r,n]);[l,r,n]=h.then?(await h)():h;let o=!1;class c{constructor(t){let{terminal:e,tui:i,markdown:s,hintText:l,documentTitle:r,onClose:n}=t;this.terminal=e,this.tui=i,this._markdown=s,this.hintText=l,this.documentTitle=r?.trim()||"",this.onClose=n,this.scrollTop=0,this._fullLines=null,this._cachedWidth=null,this._ggAwaitingSecondG=!1,this._ggTimer=null}clearGgPrefixState(){null!=this._ggTimer&&(clearTimeout(this._ggTimer),this._ggTimer=null),this._ggAwaitingSecondG=!1}invalidate(){this._markdown.invalidate(),this._fullLines=null,this._cachedWidth=null}handleInput(t){let e=this.terminal.columns,i=this.terminal.rows,s=+!!this.documentTitle,l=Math.max(1,i-s-1),r=this._getFullLines(e).length,h=Math.max(0,r-l);if((0,n.matchesKey)(t,"escape")||(0,n.matchesKey)(t,"esc")||(0,n.matchesKey)(t,"q")||(0,n.matchesKey)(t,"shift+q")||(0,n.matchesKey)(t,"ctrl+c")){this.clearGgPrefixState(),this.onClose();return}if((0,n.matchesKey)(t,"shift+g")){this.clearGgPrefixState(),this.scrollTop=h;return}if((0,n.matchesKey)(t,"g")){if(this._ggAwaitingSecondG){this.clearGgPrefixState(),this.scrollTop=0;return}this._ggAwaitingSecondG=!0,null!=this._ggTimer&&clearTimeout(this._ggTimer),this._ggTimer=setTimeout(()=>{this._ggTimer=null,this._ggAwaitingSecondG=!1},500);return}if(this.clearGgPrefixState(),(0,n.matchesKey)(t,"up")||(0,n.matchesKey)(t,"k")){this.scrollTop=Math.max(0,this.scrollTop-1);return}if((0,n.matchesKey)(t,"down")||(0,n.matchesKey)(t,"j")){this.scrollTop=Math.min(h,this.scrollTop+1);return}if((0,n.matchesKey)(t,"pageUp")||(0,n.matchesKey)(t,"ctrl+u")){this.scrollTop=Math.max(0,this.scrollTop-l);return}if((0,n.matchesKey)(t,"pageDown")||(0,n.matchesKey)(t,"ctrl+d")){this.scrollTop=Math.min(h,this.scrollTop+l);return}if((0,n.matchesKey)(t,"home")){this.scrollTop=0;return}if((0,n.matchesKey)(t,"end")){this.scrollTop=h;return}}_getFullLines(t){return this._fullLines&&this._cachedWidth===t||(this._cachedWidth=t,this._fullLines=this._markdown.render(t)),this._fullLines}render(t){let e=this.terminal.rows,i=this.documentTitle?[l.m.bold.cyan((0,n.truncateToWidth)(this.documentTitle,t))]:[],s=i.length,r=Math.max(1,e-s-1);null!=this._cachedWidth&&this._cachedWidth!==t&&this.invalidate();let h=this._getFullLines(t),a=Math.max(0,h.length-r);this.scrollTop=Math.min(this.scrollTop,a);let o=h.slice(this.scrollTop,this.scrollTop+r);for(;o.length<r;)o.push("");let c=l.m.dim((0,n.truncateToWidth)(this.hintText,t));return[...i,...o,c]}}async function a(t){let{markdown:e,t:i,documentTitle:s,tuiSession:l=null}=t;if(!e||"string"!=typeof e||!e.trim())return;if(!(process.stdout.isTTY&&process.stdin.isTTY))return void process.stdout.write(`${e}
2
+ export const __rspack_esm_id="935";export const __rspack_esm_ids=["935"];export const __webpack_modules__={8498(t,e,i){i.a(t,async function(t,s){try{i.d(e,{showMarkdownInPiTui:()=>a});var l=i(8691),r=i(4802),n=i(4127),h=t([l,r,n]);[l,r,n]=h.then?(await h)():h;let o=!1;class c{constructor(t){let{terminal:e,tui:i,markdown:s,hintText:l,documentTitle:r,onClose:n}=t;this.terminal=e,this.tui=i,this._markdown=s,this.hintText=l,this.documentTitle=r?.trim()||"",this.onClose=n,this.scrollTop=0,this._fullLines=null,this._cachedWidth=null,this._ggAwaitingSecondG=!1,this._ggTimer=null}clearGgPrefixState(){null!=this._ggTimer&&(clearTimeout(this._ggTimer),this._ggTimer=null),this._ggAwaitingSecondG=!1}invalidate(){this._markdown.invalidate(),this._fullLines=null,this._cachedWidth=null}handleInput(t){let e=this.terminal.columns,i=this.terminal.rows,s=+!!this.documentTitle,l=Math.max(1,i-s-1),r=this._getFullLines(e).length,h=Math.max(0,r-l);if((0,n.matchesKey)(t,"escape")||(0,n.matchesKey)(t,"esc")||(0,n.matchesKey)(t,"q")||(0,n.matchesKey)(t,"shift+q")||(0,n.matchesKey)(t,"ctrl+c")){this.clearGgPrefixState(),this.onClose();return}if((0,n.matchesKey)(t,"shift+g")){this.clearGgPrefixState(),this.scrollTop=h;return}if((0,n.matchesKey)(t,"g")){if(this._ggAwaitingSecondG){this.clearGgPrefixState(),this.scrollTop=0;return}this._ggAwaitingSecondG=!0,null!=this._ggTimer&&clearTimeout(this._ggTimer),this._ggTimer=setTimeout(()=>{this._ggTimer=null,this._ggAwaitingSecondG=!1},500);return}if(this.clearGgPrefixState(),(0,n.matchesKey)(t,"up")||(0,n.matchesKey)(t,"k")){this.scrollTop=Math.max(0,this.scrollTop-1);return}if((0,n.matchesKey)(t,"down")||(0,n.matchesKey)(t,"j")){this.scrollTop=Math.min(h,this.scrollTop+1);return}if((0,n.matchesKey)(t,"pageUp")||(0,n.matchesKey)(t,"ctrl+u")){this.scrollTop=Math.max(0,this.scrollTop-l);return}if((0,n.matchesKey)(t,"pageDown")||(0,n.matchesKey)(t,"ctrl+d")){this.scrollTop=Math.min(h,this.scrollTop+l);return}if((0,n.matchesKey)(t,"home")){this.scrollTop=0;return}if((0,n.matchesKey)(t,"end")){this.scrollTop=h;return}}_getFullLines(t){return this._fullLines&&this._cachedWidth===t||(this._cachedWidth=t,this._fullLines=this._markdown.render(t)),this._fullLines}render(t){let e=this.terminal.rows,i=this.documentTitle?[l.m.bold.cyan((0,n.truncateToWidth)(this.documentTitle,t))]:[],s=i.length,r=Math.max(1,e-s-1);null!=this._cachedWidth&&this._cachedWidth!==t&&this.invalidate();let h=this._getFullLines(t),a=Math.max(0,h.length-r);this.scrollTop=Math.min(this.scrollTop,a);let o=h.slice(this.scrollTop,this.scrollTop+r);for(;o.length<r;)o.push("");let c=l.m.dim((0,n.truncateToWidth)(this.hintText,t));return[...i,...o,c]}}async function a(t){let{markdown:e,t:i,documentTitle:s,tuiSession:l=null}=t;if(!e||"string"!=typeof e||!e.trim())return;if(!(process.stdout.isTTY&&process.stdin.isTTY))return void process.stdout.write(`${e}
3
3
  `);let h=l&&"function"==typeof l.suspendForReadline&&"function"==typeof l.resumeFromReadline;h&&l.suspendForReadline();try{o||((0,r.initTheme)("dark"),o=!0);let t=(0,r.getMarkdownTheme)(),l=new n.Markdown(e,1,1,t),h=i("cli.resultPreviewTerminalHint"),a=new n.ProcessTerminal,m=new n.TUI(a);m.setClearOnShrink(!0),await new Promise(t=>{let e,i=new c({terminal:a,tui:m,markdown:l,hintText:h,documentTitle:s,onClose:()=>{e?.clearGgPrefixState(),m.stop(),t()}});e=i;let r=new n.Container;r.addChild(i),m.addChild(r),m.setFocus(i),m.start(),m.requestRender(!0)})}finally{h&&l.resumeFromReadline()}}s()}catch(t){s(t)}})}};
package/dist/cosai ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env sh
2
+ set -e
3
+ exec pithosai -r CO --chat "$@"