@thothdev/pink 1.0.3 → 1.0.4

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,14 @@
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.4] - 2026-11-24
7
+
8
+ - `/tela`: no pedido de confirmação, "Sim, e não perguntar de novo para o msedge.exe" libera aquele programa até
9
+ `/tela desligar` (terminais seguem pedindo sempre, com a segunda confirmação). O título da janela sai com acento
10
+ ("páginas", não "p�ginas").
11
+ - Contorno da `/tela`: por dentro da janela e só no monitor dela (por fora, a janela maximizada ficava só com a borda de
12
+ baixo, ainda mais com dois monitores); na captura da tela inteira, um contorno em cada monitor.
13
+
6
14
  ## [1.0.3] - 2026-11-24
7
15
 
8
16
  - `/agente`: só uma linha em branco entre o pedido e a resposta do agente (eram três).
@@ -62,10 +62,18 @@ class Borda : Form
62
62
  try { SetWindowDisplayAffinity(Handle, 0x11); } catch { } // WDA_EXCLUDEFROMCAPTURE: o modelo não vê o contorno
63
63
  }
64
64
 
65
+ // tela inteira: um contorno por monitor (o retângulo único dos dois monitores ficava com bordas fora da tela)
65
66
  protected override void OnPaint(PaintEventArgs e)
66
67
  {
67
68
  using (var pen = new Pen(color, THICK))
68
- e.Graphics.DrawRectangle(pen, THICK / 2, THICK / 2, Width - THICK, Height - THICK);
69
+ {
70
+ if (!screen) { e.Graphics.DrawRectangle(pen, THICK / 2, THICK / 2, Width - THICK, Height - THICK); return; }
71
+ foreach (var s in Screen.AllScreens)
72
+ {
73
+ var b = s.Bounds;
74
+ e.Graphics.DrawRectangle(pen, b.X - Left + THICK / 2, b.Y - Top + THICK / 2, b.Width - THICK, b.Height - THICK);
75
+ }
76
+ }
69
77
  }
70
78
 
71
79
  public void Command(string line)
@@ -107,9 +115,13 @@ class Borda : Form
107
115
  RECT w;
108
116
  // limites sem a sombra invisível do Windows 10/11
109
117
  if (DwmGetWindowAttribute(target, 9, out w, Marshal.SizeOf(typeof(RECT))) != 0) GetWindowRect(target, out w);
110
- r = Rectangle.FromLTRB(w.L - THICK, w.T - THICK, w.R + THICK, w.B + THICK);
118
+ // por dentro da janela e recortado ao monitor dela: por fora, a janela maximizada perdia as bordas de cima e do
119
+ // lado (fora da tela) e a do outro lado caía no monitor vizinho; sobrava só a de baixo
120
+ var win = Rectangle.FromLTRB(w.L, w.T, w.R, w.B);
121
+ r = Rectangle.Intersect(win, Screen.FromRectangle(win).Bounds);
122
+ if (r.Width <= 2 * THICK || r.Height <= 2 * THICK) { if (Visible) Hide(); return; }
111
123
  }
112
- if (Bounds != r) Bounds = r;
124
+ if (Bounds != r) { Bounds = r; Invalidate(); }
113
125
  if (!Visible) Show();
114
126
  }
115
127
 
@@ -176,8 +176,12 @@ export function lookup(pid: unknown, sync = spawnSync): Target {
176
176
  if (!Number.isInteger(n) || n <= 0) return undefined;
177
177
  try {
178
178
  // caminho fixo: um tasklist.exe plantado na pasta do projeto não decide o que a pessoa vê
179
- const exe = path.join(process.env.SystemRoot || "C:\\Windows", "System32", "tasklist.exe");
180
- const out = String(sync(exe, ["/V", "/FI", `PID eq ${n}`, "/FO", "CSV", "/NH"], { windowsHide: true, timeout: 5000, encoding: "utf8" }).stdout ?? "");
179
+ const system = path.join(process.env.SystemRoot || "C:\\Windows", "System32");
180
+ const exe = path.join(system, "tasklist.exe");
181
+ // o tasklist escreve na página do console (850 no Brasil): "páginas" virava "p�ginas"; chcp 65001 antes dá UTF-8.
182
+ // n é inteiro validado acima, e os dois caminhos são fixos: nada de fora entra na linha do cmd
183
+ const line = `"chcp 65001>nul & "${exe}" /V /FI "PID eq ${n}" /FO CSV /NH"`;
184
+ const out = String(sync(path.join(system, "cmd.exe"), ["/d", "/s", "/c", line], { windowsHide: true, timeout: 5000, encoding: "utf8", windowsVerbatimArguments: true }).stdout ?? "");
181
185
  const cols = [...(out.trim().split(/\r?\n/)[0] ?? "").matchAll(/"((?:[^"]|"")*)"/g)].map((cell) => cell[1].replace(/""/g, '"'));
182
186
  // o título vem de quem abriu a janela: sem controles e curto
183
187
  const title = (cols.at(-1) ?? "").replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/g, " ").slice(0, 80);
@@ -411,6 +415,7 @@ export function createTela(pink: any, { env = process.env, run = mcpRun as Run,
411
415
  let pipe = "";
412
416
  let dir = "";
413
417
  let exeUsed = "";
418
+ const allowed = new Set<string>(); // programas liberados sem perguntar, até desligar a tela
414
419
  const stateFile = path.join(tmp, `pink-tela-${process.pid}.json`);
415
420
 
416
421
  const binary = (): { exe?: string; error?: string } => {
@@ -540,6 +545,7 @@ export function createTela(pink: any, { env = process.env, run = mcpRun as Run,
540
545
  outline = undefined;
541
546
  daemon = undefined;
542
547
  on = false;
548
+ allowed.clear(); // ligar de novo volta a perguntar tudo
543
549
  pipe = dir = exeUsed = "";
544
550
  return t("Tela desligada.", "Pantalla desactivada.", "Screen off.");
545
551
  }
@@ -561,7 +567,22 @@ export function createTela(pink: any, { env = process.env, run = mcpRun as Run,
561
567
  if (isAct(action)) {
562
568
  if (!ctx?.hasUI) return reply(t("Controlar a tela pede confirmação da pessoa, e aqui não há tela para perguntar.", "Controlar la pantalla requiere confirmación de la persona, y aquí no hay interfaz para preguntar.", "Controlling the screen needs the person's confirmation, and there is no UI here to ask."), true);
563
569
  const target = find(args.pid ?? args.target?.pid, sync);
564
- if (!(await ctx.ui.confirm(t("O agente quer agir na sua tela", "El agente quiere actuar en tu pantalla", "The agent wants to act on your screen"), describe(action, args, target)))) return reply(t("A pessoa recusou esta ação na tela. Não repita; pergunte o que ela prefere.", "La persona rechazó esta acción en la pantalla. No la repitas; pregunta qué prefiere.", "The person declined this screen action. Do not repeat it; ask what they prefer."), true);
570
+ // liberar por programa (owner 2026-11-24): "Sim, e não perguntar de novo para o msedge.exe" vale até /tela desligar;
571
+ // terminal e alvo desconhecido nunca entram na lista (seguem pedindo sempre, com a segunda confirmação)
572
+ const program = target && !SHELLS.test(target.image) ? target.image.toLowerCase() : "";
573
+ if (!(program && allowed.has(program))) {
574
+ const title = t("O agente quer agir na sua tela", "El agente quiere actuar en tu pantalla", "The agent wants to act on your screen");
575
+ const body = describe(action, args, target);
576
+ let ok: boolean;
577
+ if (program && ctx.ui.select) {
578
+ const yes = t("Sim", "Sí", "Yes");
579
+ const always = t(`Sim, e não perguntar de novo para o ${target!.image} (até /tela desligar)`, `Sí, y no volver a preguntar para ${target!.image} (hasta /tela desactivar)`, `Yes, and don't ask again for ${target!.image} (until /tela off)`);
580
+ const picked = await ctx.ui.select(`${title}\n${body}`, [yes, always, t("Não", "No", "No")]);
581
+ if (picked === always) allowed.add(program);
582
+ ok = picked === yes || picked === always;
583
+ } else ok = await ctx.ui.confirm(title, body);
584
+ if (!ok) return reply(t("A pessoa recusou esta ação na tela. Não repita; pergunte o que ela prefere.", "La persona rechazó esta acción en la pantalla. No la repitas; pregunta qué prefiere.", "The person declined this screen action. Do not repeat it; ask what they prefer."), true);
585
+ }
565
586
  // alvo desconhecido conta como terminal
566
587
  if (KEYED.includes(action) && (!target || SHELLS.test(target.image))) {
567
588
  const who = target ? t(`${target.image} executa o que for digitado como comando.`, `${target.image} ejecuta como comando lo que se escriba.`, `${target.image} runs whatever is typed as a command.`) : t("Não consegui identificar o programa alvo: pode ser um terminal.", "No pude identificar el programa destino: puede ser una terminal.", "Could not identify the target program: it may be a terminal.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thothdev/pink",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Pink: coding agent of the Thoth project, with a pink theme",
5
5
  "type": "module",
6
6
  "piConfig": {