@thothdev/pink 1.0.15 → 1.0.16
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,15 @@
|
|
|
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.16] - 2026-11-26
|
|
7
|
+
|
|
8
|
+
- Esc com o /agente preso (ex.: opencode esperando um subagente que nunca abre) agora encerra o agente de verdade: no
|
|
9
|
+
Windows o Pink matava só o cmd do npm e o opencode.exe seguia vivo, segurando o "Trabalhando" para sempre.
|
|
10
|
+
- O "Trabalhando" avisa quando o agente fica 3 min sem mandar nada: "sem resposta há 32m · esc interrompe".
|
|
11
|
+
- Esc com texto na caixa limpa a caixa primeiro (como no Claude Code); o próximo Esc interrompe.
|
|
12
|
+
- Na tela dividida, quando o rótulo e as dicas não cabem juntos, as dicas ficam embaixo alinhadas à esquerda, sem o
|
|
13
|
+
recuo solto.
|
|
14
|
+
|
|
6
15
|
## [1.0.15] - 2026-11-26
|
|
7
16
|
|
|
8
17
|
- /agente funciona como um modelo logado:
|
|
@@ -425,12 +425,15 @@ export function acpModels(session: any): ModelChoice[] {
|
|
|
425
425
|
// /agente com ACP (opencode, cline...): o processo fica aberto entre as mensagens (keep), porque subir o agente e abrir a
|
|
426
426
|
// sessão custa ~10 s e uma mensagem no processo aberto ~3 s; fecha com closeKept (off, troca, cancelar, erro, saída do Pink)
|
|
427
427
|
export type Resume = { id?: string; keep?: boolean; live?: AcpConn };
|
|
428
|
-
|
|
428
|
+
// `force` (Esc): um agente preso (ex.: opencode esperando um subagente que não abre) ignora o fim da entrada, e no Windows
|
|
429
|
+
// o kill pega só o cmd do npm: o opencode.exe seguia vivo, segurando os pipes, e o Esc não soltava (owner 2026-11-26)
|
|
430
|
+
export function closeKept(resume?: Resume, force = false, kill: typeof spawn = spawn) {
|
|
429
431
|
const conn = resume?.live;
|
|
430
432
|
if (resume) resume.live = undefined;
|
|
431
433
|
if (!conn) return;
|
|
432
434
|
try {
|
|
433
435
|
conn.child.stdin?.end?.(); // fim da entrada: o agente sai sozinho (o kill do .cmd do npm pega só o shell)
|
|
436
|
+
if (force && process.platform === "win32" && conn.child.pid) kill("taskkill", ["/PID", String(conn.child.pid), "/T", "/F"], { stdio: "ignore", windowsHide: true }).on?.("error", () => undefined);
|
|
434
437
|
conn.child.kill();
|
|
435
438
|
} catch {
|
|
436
439
|
/* já saiu */
|
|
@@ -480,14 +483,17 @@ export function warmKept(agent: ExternalAgent, cwd: string, resume: Resume, star
|
|
|
480
483
|
async function runAcpKept(agent: ExternalAgent, task: string, cwd: string, signal: AbortSignal | undefined, result: any, emit: () => void, start: typeof spawn, ask: () => Ask | undefined, resume: Resume): Promise<any> {
|
|
481
484
|
const conn = openKept(agent, cwd, start, resume);
|
|
482
485
|
let aborted = false;
|
|
486
|
+
let release: (code: number) => void = () => undefined;
|
|
487
|
+
const released = new Promise<number>((resolve) => (release = resolve));
|
|
483
488
|
const stop = () => {
|
|
484
489
|
aborted = true;
|
|
485
|
-
closeKept(resume); // a próxima mensagem abre de novo e retoma a sessão pelo id
|
|
490
|
+
closeKept(resume, true); // a próxima mensagem abre de novo e retoma a sessão pelo id
|
|
491
|
+
release(1); // o Esc solta já, sem esperar o processo fechar os pipes
|
|
486
492
|
};
|
|
487
493
|
if (signal?.aborted) stop();
|
|
488
494
|
else signal?.addEventListener?.("abort", stop, { once: true });
|
|
489
495
|
try {
|
|
490
|
-
result.exitCode = aborted ? 1 : await runAcp(conn.child, agent.name, task, cwd, result, emit, ask, conn.exited, resume, agent.model, agent.extras, conn);
|
|
496
|
+
result.exitCode = aborted ? 1 : await Promise.race([runAcp(conn.child, agent.name, task, cwd, result, emit, ask, conn.exited, resume, agent.model, agent.extras, conn), released]);
|
|
491
497
|
} finally {
|
|
492
498
|
signal?.removeEventListener?.("abort", stop);
|
|
493
499
|
}
|
|
@@ -11,7 +11,7 @@ import os from "node:os";
|
|
|
11
11
|
import path from "node:path";
|
|
12
12
|
import { fileURLToPath } from "node:url";
|
|
13
13
|
import { closeKept, externalAgents, listModels, pinkExtras, runExternal, warmKept } from "../examples/extensions/subagent/external.ts";
|
|
14
|
-
import { bulleted, elapsedLabel, fit, runLabel, shortModel, streamedTokens, thinkingLabel, toolSummary, userLines, workingLabel } from "./pink-ui.ts";
|
|
14
|
+
import { bulleted, elapsedLabel, fit, runLabel, shortModel, stallNote, streamedTokens, thinkingLabel, toolSummary, userLines, workingLabel } from "./pink-ui.ts";
|
|
15
15
|
|
|
16
16
|
// o Pink junto (card 1dfwh7kgfjx): MCPs do mcp.json, AGENTS.md e skills do Pink, mais o próprio Pink como MCP
|
|
17
17
|
const readJson = (file: string) => {
|
|
@@ -358,7 +358,14 @@ export default function (pink: any, list: typeof externalAgents = externalAgents
|
|
|
358
358
|
lastUi = ui;
|
|
359
359
|
if (!ui?.setWidget) return;
|
|
360
360
|
const started = Date.now();
|
|
361
|
-
|
|
361
|
+
// sem token novo por muito tempo, o "Trabalhando" contava igual e não dava para saber se o agente tinha travado
|
|
362
|
+
// (owner 2026-11-26: o OpenCode ficou 30 min esperando um stream que nunca veio)
|
|
363
|
+
let seen = -1, since = started;
|
|
364
|
+
const message = () => {
|
|
365
|
+
const now = Date.now(), out = output();
|
|
366
|
+
if (out !== seen) (seen = out), (since = now);
|
|
367
|
+
return workingLabel({ ms: now - started, output: out }) + stallNote(now - since);
|
|
368
|
+
};
|
|
362
369
|
(globalThis as any).__pinkAgentBusy = true; // a caixa mostra "esc interromper · ctrl+enter envia agora" (pink-ui)
|
|
363
370
|
// a área dos widgets já deixa uma linha em branco antes: a linha vazia do topo do Loader sai
|
|
364
371
|
if (tui?.Loader) {
|
package/extensions/pink-ui.ts
CHANGED
|
@@ -104,11 +104,12 @@ export function inputBox({ theme, content, width, label, inline = false, hints =
|
|
|
104
104
|
// os botões do microfone (opcional) vão antes das dicas; sem lugar para os dois, as dicas saem
|
|
105
105
|
const tip = mic ? (visible(left) + 1 + visible(mic) + 3 + visible(hint) <= text ? `${mic} ${hint}` : mic) : hint;
|
|
106
106
|
// a coluna onde os botões começam dentro da caixa (a barra e um espaço vêm antes), para o clique
|
|
107
|
-
const at = (rowIndex) => Object.assign(out, mic ? { micAt: { y: rowIndex, x: 2 + Math.max(visible(left) + 1, text - visible(tip)) } } : {});
|
|
107
|
+
const at = (rowIndex) => Object.assign(out, mic ? { micAt: { y: rowIndex, x: own ? 2 : 2 + Math.max(visible(left) + 1, text - visible(tip)) } } : {});
|
|
108
108
|
let out;
|
|
109
109
|
if (own) {
|
|
110
|
-
// rótulo e dicas não cabem juntos: o rótulo ganha a linha dele, em vez de cortar as dicas
|
|
111
|
-
|
|
110
|
+
// rótulo e dicas não cabem juntos: o rótulo ganha a linha dele, em vez de cortar as dicas; as dicas embaixo,
|
|
111
|
+
// alinhadas à esquerda com o rótulo (à direita ficavam com um recuo solto na tela dividida, owner 2026-11-26)
|
|
112
|
+
out = [row(""), ...lines.map(row), row(""), row(theme.fg("muted", label)), row(tip), row("")];
|
|
112
113
|
return at(out.length - 2);
|
|
113
114
|
}
|
|
114
115
|
// linha vazia também embaixo do rótulo, como a caixa do OpenCode (owner 2026-11-24)
|
|
@@ -891,6 +892,9 @@ export function install(pink, ctx, { CustomEditor, SessionManager, version = "",
|
|
|
891
892
|
if (globalThis.__pinkAgentSendNow?.(text)) return void this.setText("");
|
|
892
893
|
return void super.handleInput("\r");
|
|
893
894
|
}
|
|
895
|
+
// Esc com texto na caixa (e sem lista de sugestões aberta): limpa a caixa primeiro, como o Claude Code; o próximo
|
|
896
|
+
// Esc interrompe. Antes o Esc só interrompia, e um prompt longo na caixa não tinha como sair (owner 2026-11-26)
|
|
897
|
+
if (matchesKey?.(data, "escape") && String(this.getText?.() ?? "") !== "" && !(Number(this.renderedAutocompleteHeight) > 0)) return void this.setText("");
|
|
894
898
|
super.handleInput(data);
|
|
895
899
|
}
|
|
896
900
|
|
|
@@ -1375,6 +1379,9 @@ export function tokenLabel(n) {
|
|
|
1375
1379
|
export const runLabel = ({ ms, output }) => `${elapsedLabel(ms)} · ↓ ${tokenLabel(output)} tokens`;
|
|
1376
1380
|
// "Trabalhando… (6s · ↓ 306 tokens)", como o "Thinking… (...)" do Claude Code; o /agente usa o mesmo
|
|
1377
1381
|
export const workingLabel = (run) => `${t("Trabalhando", "Trabajando", "Working")}… (${runLabel(run)})`;
|
|
1382
|
+
// 3 min sem token novo: avisa (um comando longo, como um build, também cai aqui; por isso "sem resposta", não "travou")
|
|
1383
|
+
export const STALL_MS = 3 * 60 * 1000;
|
|
1384
|
+
export const stallNote = (quietMs) => (quietMs >= STALL_MS ? ` · ${t("sem resposta há", "sin respuesta hace", "no output for")} ${elapsedLabel(quietMs).replace(/ \d+s$/, "")} · ${t("esc interrompe", "esc interrumpe", "esc stops")}` : "");
|
|
1378
1385
|
|
|
1379
1386
|
// os provedores só mandam usage.output no fim de cada passo: durante o passo, estima pelo texto que já chegou (~4 caracteres/token)
|
|
1380
1387
|
export function streamedTokens(message) {
|