@thothdev/pink 1.0.16 → 1.0.23

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/CHANGELOG.md CHANGED
@@ -3,6 +3,51 @@
3
3
  O Pink é um fork do Pi (MIT, veja `LICENSE-PI.txt` e `NOTICE.md`). Aqui só entra o que mudou no Pink; a base de cada
4
4
  versão está no campo `upstream` do `rebrand.json` do repositório.
5
5
 
6
+ ## [1.0.23] - 2026-11-27
7
+
8
+ - A coluna de sessões e o seletor de sessão seguem o idioma (português, espanhol ou inglês), como o resto do Pink; o "erro" das linhas de comando também.
9
+
10
+ ## [1.0.22] - 2026-11-27
11
+
12
+ - Com o `/agente` ligado, ALTERAÇÕES lista os arquivos que ele editou (já durante a resposta) e SESSÃO mostra os tokens e o modelo dele, não os do modelo do Pink.
13
+
14
+ ## [1.0.21] - 2026-11-27
15
+
16
+ - Enquanto trabalha, a tela mostra o que está acontecendo (pensamento, comandos e ferramentas, texto que vai chegando), do mesmo jeito para o `/agente` (Claude Code, Codex, OpenCode), modelo de provedor logado e modelo local.
17
+ - `/agente`: o texto e o pensamento do Claude Code aparecem enquanto chegam, e o comando do Codex aparece quando começa, não só quando termina.
18
+
19
+ ## [1.0.20] - 2026-11-27
20
+
21
+ - Novo `/esforco`: troca o esforço do agente ligado pelo `/agente` sem abrir outra conversa; mostra os níveis do modelo e avisa quando o agente não informa nenhum.
22
+
23
+ ## [1.0.19] - 2026-11-27
24
+
25
+ - `/resume`, `/settings`, `/tree` e outros comandos sem opções, quando digitados com um texto depois, não são mais enviados ao modelo: o Pink avisa.
26
+ - Excluir sessão agora pergunta na própria linha.
27
+ - A lista de sessões mostra o nome em vez de "(sem mensagens)".
28
+ - Comandos sem ficar no escuro: o espaço depois do comando (e de cada nível, como em /agente <agente> <modelo>) abre as
29
+ opções; /loop, /review, /themes, /modo, /processos e /subagentes sugerem o que vale, com descrição.
30
+ - Argumento errado diz o que vale em vez de fazer outra coisa calado (/memoria, /microfone, /sandbox, /tela,
31
+ /processos, /subagentes, /themes, /review, /session-open e os comandos sem opções, como /context e /notificacoes).
32
+ - Avisos de "nada para mostrar" ou "não instalado" dizem o que fazer (/agente, /review, /sessoes, /sessions, /todos).
33
+ - /skill-nova avisa o que está fazendo.
34
+
35
+ ## [1.0.18] - 2026-11-27
36
+
37
+ - Subagentes aparecem enquanto trabalham: na lateral eles não somem mais quando a coluna está cheia, e no /agente o
38
+ subagente em segundo plano do Claude fica na lista até terminar de verdade (no Codex, interrompidos também saem).
39
+ - O rótulo mostra só o nível de esforço ("Sonnet 5.5 · medium").
40
+ - A cota do Claude e do Codex não precisa mais do Thoth.
41
+ - Os itens do Thoth só aparecem com um MCP dele configurado no Pink; sem ele fica só uma linha apontando thothdev.ia.br.
42
+ - Sessão que cai reabre sozinha (no máximo 3 vezes em 10 min). Isso não corrige a causa da queda.
43
+ - Aviso quando a conta ChatGPT bate o limite de Subscription Sharing.
44
+
45
+ ## [1.0.17] - 2026-11-26
46
+
47
+ - Esc com o /agente trabalhando interrompe o agente. Antes o Esc ia para o Pi, que não sabe do /agente: dois Esc abriam a
48
+ árvore da conversa, voltavam a sessão para antes do pedido (a resposta ficava num galho sem ele e o /resume parecia
49
+ vazio) e punham o prompt inteiro de volta na caixa.
50
+
6
51
  ## [1.0.16] - 2026-11-26
7
52
 
8
53
  - Esc com o /agente preso (ex.: opencode esperando um subagente que nunca abre) agora encerra o agente de verdade: no
package/README.md CHANGED
@@ -1,98 +1,174 @@
1
1
  <p align="center">
2
- <img src="https://raw.githubusercontent.com/ricardopiresqa/pink/main/docs/images/pink-logo.png" alt="PINK" width="360">
2
+ <img src="https://raw.githubusercontent.com/ricardopiresqa/pink/main/docs/images/pink-logo.png" alt="PINK logo" width="360">
3
3
  </p>
4
4
 
5
+ <h3 align="center">Your agents. Your workflow. One terminal.</h3>
6
+
5
7
  <p align="center">
6
- <b>The coding agent for your terminal that works where you can see it.</b><br>
7
- Plan, changed files and context on screen, many sessions side by side, a real undo,
8
- and the agents you already pay for, all in one place.
8
+ Pink is an open-source AI coding agent for your terminal that also drives the agents you already have<br>
9
+ (Claude Code, Codex, OpenCode and more) with their own login, while plan, context and changed files stay on screen.
9
10
  </p>
10
11
 
11
12
  <p align="center">
12
- <a href="https://www.npmjs.com/package/@thothdev/pink"><img src="https://img.shields.io/npm/v/@thothdev/pink?color=ff6eb4&label=npm" alt="npm"></a>
13
+ <a href="https://www.npmjs.com/package/@thothdev/pink"><img src="https://img.shields.io/npm/v/@thothdev/pink?color=ff6eb4&label=npm" alt="npm version"></a>
14
+ <a href="https://www.npmjs.com/package/@thothdev/pink"><img src="https://img.shields.io/npm/dm/@thothdev/pink?color=ff6eb4&label=downloads" alt="npm monthly downloads"></a>
13
15
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-ff6eb4" alt="MIT license"></a>
14
- <a href="https://pink.thothdev.ia.br"><img src="https://img.shields.io/badge/site-pink.thothdev.ia.br-ff6eb4" alt="website"></a>
16
+ <img src="https://img.shields.io/badge/node-%E2%89%A5%2022.19-ff6eb4" alt="Node.js 22.19 or newer">
15
17
  </p>
16
18
 
17
19
  <p align="center">
18
- <a href="https://ko-fi.com/thothdev">♥ Support Pink on Ko-fi</a>
19
- &nbsp;·&nbsp;
20
- <a href="https://github.com/ricardopiresqa/pink/discussions/new?category=ideas">💡 Suggest an idea</a>
20
+ <b>English</b> · <a href="README.pt-BR.md">Português (Brasil)</a> · <a href="https://pink.thothdev.ia.br">Website</a>
21
21
  </p>
22
22
 
23
+ ```bash
24
+ npm install -g @thothdev/pink
25
+ ```
26
+
23
27
  <p align="center">
24
- <img src="https://raw.githubusercontent.com/ricardopiresqa/pink/main/docs/images/pink-screen.png" alt="Pink in the terminal: sessions on the left, the conversation in the middle, context, plan and changed files on the right" width="900">
28
+ <img src="https://raw.githubusercontent.com/ricardopiresqa/pink/main/docs/images/pink-demo.gif" alt="Pink working on a task: plan, file edits with diffs, a test run and the changed files in the side column" width="900">
25
29
  </p>
26
30
 
27
- ## Install
31
+ <p align="center"><sub>Real Pink screen, recorded on a demo project with a scripted model.</sub></p>
32
+
33
+ ## Why Pink
34
+
35
+ Coding agents in a terminal tend to leave you guessing: what is it doing, what did it change, how full is the context, and which window had the other task. And if you pay for more than one agent, each lives in its own tool. Pink puts that in one screen.
36
+
37
+ - **Use the agents you already have.** Pink detects the coding agents installed on your machine, with nothing to configure. `/agente claude`, `/agente codex`, `/agente opencode`... hands the conversation to one of them, with its own login and plan.
38
+ - **See the work as it happens.** Reasoning, commands and text appear while they run; plan, changed files, context and quota stay on the side.
39
+ - **Run sessions side by side.** Each session is its own process. If one hangs or crashes, the others keep going, and a mark shows which one is waiting for you.
40
+ - **Undo for real.** `/undo` rolls back the last message, the replies and the file changes, without touching your git index, stash or commits.
41
+ - **Stay in control.** Destructive commands ask first; `.env`, keys and `.git` are protected.
42
+
43
+ ## Quick start
44
+
45
+ Needs Node.js 22.19 or newer.
28
46
 
29
47
  ```bash
30
48
  npm install -g @thothdev/pink
49
+ cd your-project
50
+ pink
31
51
  ```
32
52
 
33
- Then run `pink` inside your project folder. Needs Node.js 22.19 or newer.
53
+ On the first run, use `/login` or set an API key such as `ANTHROPIC_API_KEY` or `OPENAI_API_KEY`. If you only want to drive an agent you already use, type `/agente` and pick it.
34
54
 
35
55
  ```bash
36
56
  pink # interactive session
37
57
  pink -p "explain this repository" # one-shot answer
58
+ pink -c # continue the last session
38
59
  pink --help
39
60
  ```
40
61
 
41
- ## What only Pink does
62
+ ## Supported agents
42
63
 
43
- | | |
44
- |---|---|
45
- | **Use the agents you already have** | `/agente claude`, `/agente codex`, `/agente opencode`... hands the session to Claude Code, Codex, opencode, Gemini, Qwen, Cline, Goose or Copilot, with their own login and plan. No new API key. A menu picks the model; `/agente off` comes back. |
46
- | **Your rules come along** | The chosen agent gets Pink's MCP servers, `AGENTS.md` and skills, and can call Pink itself as an MCP tool (`pink_tarefa`). |
47
- | **Sees and uses your screen** | On Windows, `/tela ligar` lets the agent see your windows and click or type in them. Seeing never asks; every click asks for your OK, and typing into a terminal asks twice. Off by default. |
48
- | **Sessions side by side** | Each session runs in its own process in the left sidebar. If one hangs, the others keep going. A spinner shows who is working and `!` who is waiting for you. |
49
- | **A real `/undo`** | Rolls back the last message, the replies and the file changes, and puts your text back in the box, without touching your git index, stash or commits. |
50
-
51
- ## Everything else
52
-
53
- - **Build and Plan agents.** `tab` on an empty box switches. Plan only reads and plans: it asks before running a command and never edits files.
54
- - **Subagents.** The `subagent` tool hands work to a separate `pink` process, alone, in parallel or in a chain. Custom agents live in `~/.pink/agent/agents/*.md`.
55
- - **Guard before danger.** Destructive commands ask first; `.env`, `.git` and keys are protected. Rules go in `permissions.json` (`allow` / `ask` / `deny`), and hooks in `hooks.json` use the Claude Code format.
56
- - **MCP and the web.** `/mcp` connects MCP servers. `web_search` and `web_fetch` work with no key and no extra server.
57
- - **Compact transcript.** Each read, edit and command becomes one short line. `ctrl+o` opens the full tool output with the diff, `ctrl+t` opens the thinking.
58
- - **Adapts to the width.** Three columns from 150 columns up, two from 115, just the conversation below that.
59
- - **Questions with options**, a todo list in the sidebar, and a system notification when an answer finishes while the window is in the background.
64
+ Pink looks for these on your `PATH`; `/agente` lists only the ones it finds.
65
+
66
+ | Agent | Command Pink looks for | Uses |
67
+ |---|---|---|
68
+ | Claude Code | `claude` | your Claude login and quota |
69
+ | Codex CLI | `codex` | your ChatGPT login and quota |
70
+ | OpenCode | `opencode` | its own models and login |
71
+ | Gemini CLI | `gemini` | your Google login |
72
+ | GitHub Copilot CLI | `copilot` | your Copilot plan |
73
+ | Qwen Code | `qwen` | its own setup |
74
+ | Cline | `cline` | its own setup |
75
+ | Goose | `goose` | its own setup |
76
+
77
+ The chosen agent also receives Pink's MCP servers, `AGENTS.md` and skills, and can call Pink back as an MCP tool (`pink_tarefa`). `/esforco` changes the reasoning level when the agent reports levels, and `/agente off` returns to Pink.
78
+
79
+ <p align="center">
80
+ <img src="https://raw.githubusercontent.com/ricardopiresqa/pink/main/docs/images/pink-agents.png" alt="The /agente menu listing the agents Pink detected on the machine" width="900">
81
+ </p>
82
+
83
+ ## Model providers
84
+
85
+ Pink's own agent works with the providers inherited from Pi, including Anthropic, OpenAI, Google Gemini, OpenRouter, DeepSeek, Mistral, Groq, xAI, Amazon Bedrock, Google Vertex AI, Azure OpenAI and GitHub Copilot, plus local or self-hosted OpenAI-compatible servers through `~/.pink/agent/models.json`.
86
+
87
+ ## Features
88
+
89
+ **Screen**
90
+ - Three columns from 150 columns of width, two from 115, just the conversation below that.
91
+ - Compact transcript: one line per read, edit and command. `ctrl+o` opens the full output and diff, `ctrl+t` opens the reasoning.
92
+ - Side column with context usage, plan, changed files, session tokens, subagents and the Claude and Codex quota.
93
+
94
+ **Work**
95
+ - Build and Plan agents (`tab` on an empty box). Plan reads and plans, asks before running a command and never edits files.
96
+ - Subagents, alone, in parallel or in a chain, also in the background. Custom agents live in `~/.pink/agent/agents/*.md`.
97
+ - Background commands, with watching for a line in the output (`/processos`).
98
+ - `/review` runs an independent, read-only review of your diff.
99
+ - `/loop` repeats a task on an interval or at the agent's own pace.
100
+ - Questions with clickable options, a todo list, and a system notification when an answer finishes in the background.
101
+
102
+ **Knowledge**
103
+ - Per-project memory (`/memoria`), `AGENTS.md`, skills (`/skills`, `/skill-nova`) and rules by file type (`/regras`).
104
+ - `/context` shows what is filling the context window.
105
+ - Language server errors fed back after edits (TypeScript and Pyright, when installed, in trusted folders).
106
+
107
+ **Connections**
108
+ - `/mcp` connects MCP servers.
109
+ - `web_search` and `web_fetch` work without an extra key.
110
+ - Open Pink sessions on the same machine can message each other (`/sessoes`).
111
+
112
+ **Optional, off by default**
113
+ - `/microfone`: dictate instead of typing; speech is transcribed on your machine.
114
+ - `/tela ligar` (Windows x64): the agent can see your windows and click or type in them. Every click asks for your OK.
115
+ - `/sandbox ligar` (Windows): agent commands can only write inside the project folder.
60
116
 
61
117
  ## Keys and commands
62
118
 
119
+ Some command names are in Portuguese; the table says what they do.
120
+
63
121
  | Key / command | What it does |
64
122
  |---|---|
65
- | `ctrl+p` | Command palette (also `/help`) |
123
+ | `ctrl+p` | Command palette |
66
124
  | `tab` (empty box) | Switch between Build and Plan |
67
125
  | `f2` / `shift+f2` | Next / previous model |
68
- | `ctrl+t` / `ctrl+o` | Open thinking / full tool output |
126
+ | `ctrl+t` / `ctrl+o` | Open reasoning / full tool output |
69
127
  | `ctrl+n` | New session |
70
- | `/agente [name] [model]` | Talk to an installed agent; `/agente off` returns to Pink |
71
- | `/tela ligar` | Let the agent see and use the screen (Windows) |
128
+ | `/agente [name] [model]` | Talk to an installed agent ("agent"); `/agente off` returns |
129
+ | `/esforco` | Reasoning effort of the active agent |
72
130
  | `/undo` / `/redo` | Undo / redo the last message and its file changes |
73
- | `/sessions`, `/themes`, `/mcp` | Switch session, pick a theme, manage MCP servers |
131
+ | `/sessions`, `/themes`, `/mcp` | Switch session, theme, MCP servers |
132
+ | `/tela`, `/microfone` | Screen access, dictation |
74
133
  | `/lateral` | Hide or show the side columns |
75
- | `/sugestao [text]` | Open the ideas page on GitHub, with your text as the title |
134
+ | `/sugestao [text]` | Open an idea on GitHub |
76
135
 
77
- ## Support and ideas
136
+ ## Examples
78
137
 
79
- Pink is free and open source. If it saves you time, you can [buy us a coffee on Ko-fi](https://ko-fi.com/thothdev).
80
- Ideas and requests go to [GitHub Discussions](https://github.com/ricardopiresqa/pink/discussions/categories/ideas), where others can vote on them; bugs go to [issues](https://github.com/ricardopiresqa/pink/issues).
138
+ ```text
139
+ > add Pix as a payment method and run the tests
140
+ > /agente codex then: review what you just changed
141
+ > /agente off
142
+ > /review main independent review of everything since main
143
+ > /loop 5m check if the deploy finished
144
+ > /undo the files go back too
145
+ ```
81
146
 
82
- ## Configuration
147
+ ## How it compares
83
148
 
84
- - Settings live in `~/.pink/agent/` (or `$PINK_CODING_AGENT_DIR`) and in `.pink/` inside the project. Environment variables start with `PINK_`.
85
- - Providers and models: `~/.pink/agent/models.json` (see `docs/models.md`).
86
- - No sidebar of sessions: `pink --sem-sessoes` or `PINK_NO_MUX=1`. The sidebar needs the optional `node-pty`; without it Pink runs as a single session.
87
- - Plain look without Pink's interface: `PINK_NO_BUILTIN_UI=1 pink --tui-mode regular`.
149
+ Several of these tools are not competitors: Pink can run them for you.
88
150
 
89
- ## Thoth in the sidebar (optional)
151
+ | Tool | License | Relationship with Pink | Runs inside Pink |
152
+ |---|---|---|---|
153
+ | [Pi](https://github.com/earendil-works/pi) | MIT | The base Pink is forked from | no |
154
+ | [OpenCode](https://github.com/anomalyco/opencode) | MIT | Alternative, also usable from Pink | `/agente opencode` |
155
+ | [Claude Code](https://github.com/anthropics/claude-code) | Proprietary | Complement | `/agente claude` |
156
+ | [Codex CLI](https://github.com/openai/codex) | Apache-2.0 | Complement | `/agente codex` |
157
+ | [Gemini CLI](https://github.com/google-gemini/gemini-cli) | Apache-2.0 | Complement | `/agente gemini` |
158
+ | [Goose](https://github.com/aaif-goose/goose) | Apache-2.0 | Alternative, also usable from Pink | `/agente goose` |
159
+ | [Aider](https://github.com/Aider-AI/aider) | Apache-2.0 | Alternative | no |
90
160
 
91
- If [Thoth](https://thothdev.ia.br) runs on the same machine, the right column gets a **THOTH** section with the approvals waiting for you, the card in progress for this folder and the model that answered the last Thoth gateway call. It only reads, in the background, every 30 seconds. Without Thoth the section says it is unavailable and Pink works as usual.
161
+ If you want a minimal, extensible harness, use Pi itself. Pink is for people who want the screen, the parallel sessions and several agents in one place.
92
162
 
93
- ## Privacy
163
+ ## Configuration
94
164
 
95
- Pink sends no install telemetry and checks no versions on third-party servers. What leaves your machine is what you send to your model provider.
165
+ - Settings live in `~/.pink/agent/` (or `$PINK_CODING_AGENT_DIR`) and in `.pink/` inside the project.
166
+ - `permissions.json` holds `allow` / `ask` / `deny` rules; `hooks.json` uses the Claude Code format.
167
+ - The interface follows your system language (English, Português, Español). Force it with `PINK_LANG=en`.
168
+ - No session sidebar: `pink --sem-sessoes` or `PINK_NO_MUX=1`.
169
+ - Plain look: `PINK_NO_BUILTIN_UI=1 pink --tui-mode regular`.
170
+ - Quota: Pink reads the Claude and Codex 5-hour and weekly quota without calling a model; when there is no answer it says "no reading".
171
+ - [Thoth](https://thothdev.ia.br) is a separate, optional product for governance and memory. Pink works fully without it.
96
172
 
97
173
  <details>
98
174
  <summary><b>Pink colors in Windows Terminal</b></summary>
@@ -127,16 +203,41 @@ Pink uses your terminal's background. For the dark `#100d13` of the screenshots,
127
203
 
128
204
  </details>
129
205
 
130
- ## Building from source
206
+ ## Troubleshooting
207
+
208
+ | Symptom | What to do |
209
+ |---|---|
210
+ | No session sidebar | The optional `node-pty` is missing. Reinstall with `npm install -g --allow-scripts=node-pty @thothdev/pink`. |
211
+ | A session closed by itself | Pink reopens it. Details are in `~/.pink/agent/crash.log`; attach the relevant lines to an issue, after removing anything private. |
212
+ | `/agente` lists nothing | The agent's command is not on `PATH`. Run it once in the same terminal to confirm. |
213
+ | Wrong interface language | Set `PINK_LANG=en`, `pt` or `es`. |
214
+
215
+ ## Security and privacy
216
+
217
+ Pink sends no install telemetry. It does ask the npm registry whether a newer version exists (`PINK_SKIP_VERSION_CHECK=1` turns that off) and reads your Claude and Codex quota from those providers. Beyond that, what leaves your machine is what you send to your model provider and to the tools you use, such as external agents, MCP servers and web search.
218
+
219
+ An agent runs commands on your computer: review what it asks to do. To report a vulnerability, see [SECURITY.md](SECURITY.md).
220
+
221
+ ## Documentation
222
+
223
+ [What is specific to Pink](docs/PINK.md) (in Portuguese) · [Changelog](CHANGELOG.md) (in Portuguese) · [What changed from Pi](NOTICE.md) (in Portuguese). The full manual ships with the package, in its `docs/` folder.
131
224
 
132
- The fork is a reproducible patch (`rebrand.json`) over a pinned upstream tarball, not a copy of its code:
225
+ ## Contributing
226
+
227
+ Bug reports go to [issues](https://github.com/ricardopiresqa/pink/issues) and ideas to [Discussions](https://github.com/ricardopiresqa/pink/discussions/categories/ideas). To build and test, see [CONTRIBUTING.md](CONTRIBUTING.md). Pink is a reproducible patch (`rebrand.json`) over a pinned upstream package:
133
228
 
134
229
  ```bash
135
230
  python -X utf8 build_pink.py --out out # builds out/thothdev-pink-<version>.tgz
136
- npm install -g out/thothdev-pink-*.tgz
231
+ npm install -g out/thothdev-pink-<version>.tgz
137
232
  ```
138
233
 
139
- ## License
234
+ ## Credits and license
235
+
236
+ Pink is a fork of [Pi](https://github.com/earendil-works/pi) (MIT, copyright (c) 2025 Mario Zechner): the agent loop, providers, terminal UI, sessions and compaction come from it, with Pink's own interface, theme and extensions on top. License: MIT ([LICENSE](LICENSE)); the upstream license is in [LICENSE-PI.txt](LICENSE-PI.txt), and [NOTICE.md](NOTICE.md) lists what changed.
237
+
238
+ ---
140
239
 
141
- Pink is a fork of [Pi](https://github.com/earendil-works/pi-mono) (MIT, copyright (c) 2025 Mario Zechner): the agent loop, providers, terminal UI, sessions and compaction come from it, with Pink's own interface, theme and extensions on top.
142
- License: MIT (see `LICENSE`); the upstream license is in `LICENSE-PI.txt`, and `NOTICE.md` lists what changed.
240
+ <p align="center">
241
+ <code>npm install -g @thothdev/pink</code><br><br>
242
+ If Pink helps you, <a href="https://github.com/ricardopiresqa/pink">star the repository</a>, watch the releases, or <a href="https://ko-fi.com/thothdev">support it on Ko-fi</a>.
243
+ </p>
@@ -75,7 +75,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
75
75
  `))}getLines(){return[...this.state.lines]}getCursor(){return{line:this.state.cursorLine,col:this.state.cursorCol}}setText(text){this.cancelAutocomplete(),this.lastAction=null,this.exitHistoryBrowsing();let normalized=this.normalizeText(text);this.getText()!==normalized&&this.pushUndoSnapshot(),this.pastes.clear(),this.pasteCounter=0,this.setTextInternal(normalized)}insertTextAtCursor(text){text&&(this.cancelAutocomplete(),this.pushUndoSnapshot(),this.lastAction=null,this.exitHistoryBrowsing(),this.insertTextAtCursorInternal(text))}normalizeText(text){return text.replace(/\r\n/g,`
76
76
  `).replace(/\r/g,`
77
77
  `).replace(/\t/g," ")}insertTextAtCursorInternal(text){if(!text)return;let normalized=this.normalizeText(text),insertedLines=normalized.split(`
78
- `),currentLine=this.state.lines[this.state.cursorLine]||"",beforeCursor=currentLine.slice(0,this.state.cursorCol),afterCursor=currentLine.slice(this.state.cursorCol);insertedLines.length===1?(this.state.lines[this.state.cursorLine]=beforeCursor+normalized+afterCursor,this.setCursorCol(this.state.cursorCol+normalized.length)):(this.state.lines=[...this.state.lines.slice(0,this.state.cursorLine),beforeCursor+insertedLines[0],...insertedLines.slice(1,-1),insertedLines[insertedLines.length-1]+afterCursor,...this.state.lines.slice(this.state.cursorLine+1)],this.state.cursorLine+=insertedLines.length-1,this.setCursorCol((insertedLines[insertedLines.length-1]||"").length)),this.onChange&&this.onChange(this.getText())}insertCharacter(char,skipUndoCoalescing){this.exitHistoryBrowsing(),skipUndoCoalescing||((isWhitespaceChar(char)||this.lastAction!=="type-word")&&this.pushUndoSnapshot(),this.lastAction="type-word");let line=this.state.lines[this.state.cursorLine]||"",before=line.slice(0,this.state.cursorCol),after=line.slice(this.state.cursorCol);if(this.state.lines[this.state.cursorLine]=before+char+after,this.setCursorCol(this.state.cursorCol+char.length),this.onChange&&this.onChange(this.getText()),this.autocompleteState)this.updateAutocomplete();else if(char==="/"&&this.isAtStartOfMessage())this.tryTriggerAutocomplete();else if(this.autocompleteTriggerCharacters.includes(char)){let textBeforeCursor=(this.state.lines[this.state.cursorLine]||"").slice(0,this.state.cursorCol);this.autocompleteTriggerPattern.test(textBeforeCursor)&&this.tryTriggerAutocomplete()}else if(/[a-zA-Z0-9.\-_]/.test(char)||cjkBreakRegex.test(char)){let textBeforeCursor=(this.state.lines[this.state.cursorLine]||"").slice(0,this.state.cursorCol);this.isInSlashCommandContext(textBeforeCursor)?this.tryTriggerAutocomplete():this.autocompleteTriggerPattern.test(textBeforeCursor)&&this.tryTriggerAutocomplete()}}handlePaste(pastedText){this.cancelAutocomplete(),this.exitHistoryBrowsing(),this.lastAction=null,this.pushUndoSnapshot();let decodedText=pastedText.replace(/\x1b\[(\d+);5u/g,(match,code)=>{let cp=Number(code);return cp>=97&&cp<=122?String.fromCharCode(cp-96):cp>=65&&cp<=90?String.fromCharCode(cp-64):match}),filteredText=this.normalizeText(decodedText).split("").filter(char=>char===`
78
+ `),currentLine=this.state.lines[this.state.cursorLine]||"",beforeCursor=currentLine.slice(0,this.state.cursorCol),afterCursor=currentLine.slice(this.state.cursorCol);insertedLines.length===1?(this.state.lines[this.state.cursorLine]=beforeCursor+normalized+afterCursor,this.setCursorCol(this.state.cursorCol+normalized.length)):(this.state.lines=[...this.state.lines.slice(0,this.state.cursorLine),beforeCursor+insertedLines[0],...insertedLines.slice(1,-1),insertedLines[insertedLines.length-1]+afterCursor,...this.state.lines.slice(this.state.cursorLine+1)],this.state.cursorLine+=insertedLines.length-1,this.setCursorCol((insertedLines[insertedLines.length-1]||"").length)),this.onChange&&this.onChange(this.getText())}insertCharacter(char,skipUndoCoalescing){this.exitHistoryBrowsing(),skipUndoCoalescing||((isWhitespaceChar(char)||this.lastAction!=="type-word")&&this.pushUndoSnapshot(),this.lastAction="type-word");let line=this.state.lines[this.state.cursorLine]||"",before=line.slice(0,this.state.cursorCol),after=line.slice(this.state.cursorCol);if(this.state.lines[this.state.cursorLine]=before+char+after,this.setCursorCol(this.state.cursorCol+char.length),this.onChange&&this.onChange(this.getText()),this.autocompleteState)this.updateAutocomplete();else if(char==="/"&&this.isAtStartOfMessage())this.tryTriggerAutocomplete();else if(char===" "&&this.isInSlashCommandContext((this.state.lines[this.state.cursorLine]||"").slice(0,this.state.cursorCol)))this.tryTriggerAutocomplete();else if(this.autocompleteTriggerCharacters.includes(char)){let textBeforeCursor=(this.state.lines[this.state.cursorLine]||"").slice(0,this.state.cursorCol);this.autocompleteTriggerPattern.test(textBeforeCursor)&&this.tryTriggerAutocomplete()}else if(/[a-zA-Z0-9.\-_]/.test(char)||cjkBreakRegex.test(char)){let textBeforeCursor=(this.state.lines[this.state.cursorLine]||"").slice(0,this.state.cursorCol);this.isInSlashCommandContext(textBeforeCursor)?this.tryTriggerAutocomplete():this.autocompleteTriggerPattern.test(textBeforeCursor)&&this.tryTriggerAutocomplete()}}handlePaste(pastedText){this.cancelAutocomplete(),this.exitHistoryBrowsing(),this.lastAction=null,this.pushUndoSnapshot();let decodedText=pastedText.replace(/\x1b\[(\d+);5u/g,(match,code)=>{let cp=Number(code);return cp>=97&&cp<=122?String.fromCharCode(cp-96):cp>=65&&cp<=90?String.fromCharCode(cp-64):match}),filteredText=this.normalizeText(decodedText).split("").filter(char=>char===`
79
79
  `||char.charCodeAt(0)>=32).join("");if(/^[/~.]/.test(filteredText)){let currentLine=this.state.lines[this.state.cursorLine]||"",charBeforeCursor=this.state.cursorCol>0?currentLine[this.state.cursorCol-1]:"";charBeforeCursor&&/\w/.test(charBeforeCursor)&&(filteredText=` ${filteredText}`)}let pastedLines=filteredText.split(`
80
80
  `),totalChars=filteredText.length;if(pastedLines.length>10||totalChars>1e3){this.pasteCounter++;let pasteId=this.pasteCounter;this.pastes.set(pasteId,filteredText);let marker=pastedLines.length>10?`[paste #${pasteId} +${pastedLines.length} lines]`:`[paste #${pasteId} ${totalChars} chars]`;this.insertTextAtCursorInternal(marker);return}if(pastedLines.length===1){this.insertTextAtCursorInternal(filteredText);return}this.insertTextAtCursorInternal(filteredText)}addNewLine(){this.cancelAutocomplete(),this.exitHistoryBrowsing(),this.lastAction=null,this.pushUndoSnapshot();let currentLine=this.state.lines[this.state.cursorLine]||"",before=currentLine.slice(0,this.state.cursorCol),after=currentLine.slice(this.state.cursorCol);this.state.lines[this.state.cursorLine]=before,this.state.lines.splice(this.state.cursorLine+1,0,after),this.state.cursorLine++,this.setCursorCol(0),this.onChange&&this.onChange(this.getText())}shouldSubmitOnBackslashEnter(data,kb){if(this.disableSubmit||!matchesKey(data,"enter"))return!1;let submitKeys=kb.getKeys("tui.input.submit");if(!(submitKeys.includes("shift+enter")||submitKeys.includes("shift+return")))return!1;let currentLine=this.state.lines[this.state.cursorLine]||"";return this.state.cursorCol>0&&currentLine[this.state.cursorCol-1]==="\\"}submitValue(){this.cancelAutocomplete();let result=this.expandPasteMarkers(this.state.lines.join(`
81
81
  `)).trim();this.state={lines:[""],cursorLine:0,cursorCol:0},this.pastes.clear(),this.pasteCounter=0,this.exitHistoryBrowsing(),this.scrollOffset=0,this.undoStack.clear(),this.lastAction=null,this.onChange&&this.onChange(""),this.onSubmit&&this.onSubmit(result)}handleBackspace(){if(this.exitHistoryBrowsing(),this.lastAction=null,this.state.cursorCol>0){this.pushUndoSnapshot();let line=this.state.lines[this.state.cursorLine]||"",beforeCursor=line.slice(0,this.state.cursorCol),graphemes=[...this.segment(beforeCursor,"grapheme")],lastGrapheme=graphemes[graphemes.length-1],graphemeLength=lastGrapheme?lastGrapheme.segment.length:1,isPastedSegmented=PASTE_MARKER_SINGLE.exec(lastGrapheme.segment);if(isPastedSegmented){let targetId=Number(isPastedSegmented[1]);this.pastes.delete(targetId),this.pasteCounter--;let higherIds=[...this.pastes.keys()].filter(id=>id>targetId).sort((a,b2)=>a-b2);for(let id of higherIds)this.pastes.set(id-1,this.pastes.get(id)),this.pastes.delete(id);this.state.lines=this.state.lines.map(line2=>line2.replace(PASTE_MARKER_REGEX,(fullMatch,idGroup,suffixGroup)=>{let x2=Number(idGroup);return x2<=targetId?fullMatch:`[paste #${x2-1}${suffixGroup}]`}))}line=this.state.lines[this.state.cursorLine]||"";let before=line.slice(0,this.state.cursorCol-graphemeLength),after=line.slice(this.state.cursorCol);this.state.lines[this.state.cursorLine]=before+after,this.setCursorCol(this.state.cursorCol-graphemeLength)}else if(this.state.cursorLine>0){this.pushUndoSnapshot();let currentLine=this.state.lines[this.state.cursorLine]||"",previousLine=this.state.lines[this.state.cursorLine-1]||"";this.state.lines[this.state.cursorLine-1]=previousLine+currentLine,this.state.lines.splice(this.state.cursorLine,1),this.state.cursorLine--,this.setCursorCol(previousLine.length)}if(this.onChange&&this.onChange(this.getText()),this.autocompleteState)this.updateAutocomplete();else{let textBeforeCursor=(this.state.lines[this.state.cursorLine]||"").slice(0,this.state.cursorCol);this.isInSlashCommandContext(textBeforeCursor)?this.tryTriggerAutocomplete():this.autocompleteTriggerPattern.test(textBeforeCursor)&&this.tryTriggerAutocomplete()}}setCursorCol(col){this.state.cursorCol=col,this.preferredVisualCol=null,this.snappedFromCursorCol=null}moveToVisualLine(visualLines,currentVisualLine,targetVisualLine){let currentVL=visualLines[currentVisualLine],targetVL=visualLines[targetVisualLine];if(!(currentVL&&targetVL))return;let currentVisualCol;if(this.snappedFromCursorCol!==null){let vlIndex=this.findVisualLineAt(visualLines,currentVL.logicalLine,this.snappedFromCursorCol);currentVisualCol=this.snappedFromCursorCol-visualLines[vlIndex].startCol}else currentVisualCol=this.state.cursorCol-currentVL.startCol;let sourceMaxVisualCol=currentVisualLine===visualLines.length-1||visualLines[currentVisualLine+1]?.logicalLine!==currentVL.logicalLine?currentVL.length:Math.max(0,currentVL.length-1),targetMaxVisualCol=targetVisualLine===visualLines.length-1||visualLines[targetVisualLine+1]?.logicalLine!==targetVL.logicalLine?targetVL.length:Math.max(0,targetVL.length-1),moveToVisualCol=this.computeVerticalMoveColumn(currentVisualCol,sourceMaxVisualCol,targetMaxVisualCol);this.state.cursorLine=targetVL.logicalLine;let targetCol=targetVL.startCol+moveToVisualCol,logicalLine=this.state.lines[targetVL.logicalLine]||"";this.state.cursorCol=Math.min(targetCol,logicalLine.length);let segments=[...this.segment(logicalLine,"grapheme")];for(let seg of segments){if(seg.index>this.state.cursorCol)break;if(!(seg.segment.length<=1)&&this.state.cursorCol<seg.index+seg.segment.length){let isContinuation=seg.index<targetVL.startCol,isMovingDown=targetVisualLine>currentVisualLine;if(isContinuation&&isMovingDown){let segEnd=seg.index+seg.segment.length,next=targetVisualLine+1;for(;next<visualLines.length&&visualLines[next].logicalLine===targetVL.logicalLine&&visualLines[next].startCol<segEnd;)next++;if(next<visualLines.length){this.moveToVisualLine(visualLines,currentVisualLine,next);return}}this.snappedFromCursorCol=this.state.cursorCol,this.state.cursorCol=seg.index;return}}this.snappedFromCursorCol=null}computeVerticalMoveColumn(currentVisualCol,sourceMaxVisualCol,targetMaxVisualCol){let hasPreferred=this.preferredVisualCol!==null,cursorInMiddle=currentVisualCol<sourceMaxVisualCol,targetTooShort=targetMaxVisualCol<currentVisualCol;if(!hasPreferred||cursorInMiddle)return targetTooShort?(this.preferredVisualCol=currentVisualCol,targetMaxVisualCol):(this.preferredVisualCol=null,currentVisualCol);let targetCantFitPreferred=targetMaxVisualCol<this.preferredVisualCol;if(targetTooShort||targetCantFitPreferred)return targetMaxVisualCol;let result=this.preferredVisualCol;return this.preferredVisualCol=null,result}moveToLineStart(){this.lastAction=null,this.setCursorCol(0)}moveToLineEnd(){this.lastAction=null;let currentLine=this.state.lines[this.state.cursorLine]||"";this.setCursorCol(currentLine.length)}deleteToStartOfLine(){this.exitHistoryBrowsing();let currentLine=this.state.lines[this.state.cursorLine]||"";if(this.state.cursorCol>0){this.pushUndoSnapshot();let deletedText=currentLine.slice(0,this.state.cursorCol);this.killRing.push(deletedText,{prepend:!0,accumulate:this.lastAction==="kill"}),this.lastAction="kill",this.state.lines[this.state.cursorLine]=currentLine.slice(this.state.cursorCol),this.setCursorCol(0)}else if(this.state.cursorLine>0){this.pushUndoSnapshot(),this.killRing.push(`