@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 +45 -0
- package/README.md +155 -54
- package/dist/bundle/chunks/chunk-T726RZZU.js +1 -1
- package/dist/mux/pink.mjs +153 -72
- package/examples/extensions/subagent/agents.ts +1 -1
- package/examples/extensions/subagent/background.ts +15 -10
- package/examples/extensions/subagent/external.ts +58 -8
- package/examples/extensions/subagent/pink-i18n.ts +22 -1
- package/extensions/pink-agente.ts +105 -12
- package/extensions/pink-context.ts +3 -3
- package/extensions/pink-hooks.ts +3 -3
- package/extensions/pink-i18n.ts +22 -1
- package/extensions/pink-loop.ts +5 -2
- package/extensions/pink-mcp-server.mjs +1 -1
- package/extensions/pink-memory.ts +2 -1
- package/extensions/pink-microfone.ts +2 -1
- package/extensions/pink-natives.ts +3 -3
- package/extensions/pink-notify.ts +3 -3
- package/extensions/pink-permissions.ts +3 -3
- package/extensions/pink-review.ts +19 -4
- package/extensions/pink-rules.ts +2 -2
- package/extensions/pink-sandbox.ts +2 -1
- package/extensions/pink-sessions-bus.ts +4 -4
- package/extensions/pink-shell-bg.ts +15 -10
- package/extensions/pink-skill-propose.ts +1 -0
- package/extensions/pink-skills.ts +3 -3
- package/extensions/pink-tela.ts +2 -1
- package/extensions/pink-ui.ts +202 -109
- package/package.json +16 -4
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// (pink -p) não se registram.
|
|
9
9
|
// Risco aceito (Argus R1): mesmo usuário na mesma máquina; um processo que grave direto em bus/inbox pode alegar o id de
|
|
10
10
|
// outra sessão. A confiança vem do registro, não de prova criptográfica; o aviso de "dado, não pedido" vale sempre.
|
|
11
|
-
import { t } from "./pink-i18n.ts";
|
|
11
|
+
import { noArgs, t } from "./pink-i18n.ts";
|
|
12
12
|
import fs from "node:fs";
|
|
13
13
|
import os from "node:os";
|
|
14
14
|
import path from "node:path";
|
|
@@ -279,10 +279,10 @@ export function createBus(pink: any, { env = process.env, now = Date.now, alive
|
|
|
279
279
|
});
|
|
280
280
|
pink.registerCommand("sessoes", {
|
|
281
281
|
description: t("Outras sessões do Pink abertas nesta máquina (para o agente conversar com elas)", "Otras sesiones de Pink abiertas en esta máquina (para que el agente hable con ellas)", "Other Pink sessions open on this machine (so the agent can talk to them)"),
|
|
282
|
-
handler: async (_args: string, ctx: any) => {
|
|
282
|
+
handler: noArgs("/sessoes", async (_args: string, ctx: any) => {
|
|
283
283
|
const others = listSessions(env, alive, now).filter((entry) => entry.id !== me?.id);
|
|
284
|
-
ctx.ui.notify(`${me ? `${t("Esta sessão", "Esta sesión", "This session")}: ${label(me)}` : t("Esta sessão não está no barramento.", "Esta sesión no está en el bus.", "This session is not on the bus.")}\n\n${others.length ? others.map(label).join("\n") : t("Nenhuma outra sessão aberta.", "Ninguna otra sesión abierta.", "No other open session.")}`, "info");
|
|
285
|
-
},
|
|
284
|
+
ctx.ui.notify(`${me ? `${t("Esta sessão", "Esta sesión", "This session")}: ${label(me)}` : t("Esta sessão não está no barramento.", "Esta sesión no está en el bus.", "This session is not on the bus.")}\n\n${others.length ? others.map(label).join("\n") : t("Nenhuma outra sessão aberta. Abra o Pink em outra janela para o agente conversar com ela.", "Ninguna otra sesión abierta. Abre Pink en otra ventana para que el agente hable con ella.", "No other open session. Open Pink in another window so the agent can talk to it.")}`, "info");
|
|
285
|
+
}),
|
|
286
286
|
});
|
|
287
287
|
|
|
288
288
|
return { drain, register, unregister, me: () => me };
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// A ferramenta continua se chamando bash/powershell e a execução é a original (createBashToolDefinition), então
|
|
6
6
|
// permissões, hooks, RTK e modo plano valem igual. Ao fechar, trocar ou recarregar a sessão os processos são encerrados.
|
|
7
7
|
// Sem tela (pink -p, subagente) o processo acabaria antes do resultado: o comando espera como antes.
|
|
8
|
-
import { choose, t } from "./pink-i18n.ts";
|
|
8
|
+
import { type Choice, choose, completeFrom, t, unknown } from "./pink-i18n.ts";
|
|
9
9
|
import { createBashToolDefinition, createPowerShellToolDefinition, SettingsManager } from "@earendil-works/pi-coding-agent";
|
|
10
10
|
import { Type } from "typebox";
|
|
11
11
|
|
|
@@ -197,27 +197,32 @@ export function createShellJobs(pink: any, { now = Date.now, write = muxWrite }
|
|
|
197
197
|
},
|
|
198
198
|
});
|
|
199
199
|
|
|
200
|
+
const none = () => t("Nenhum processo em segundo plano. Peça ao agente para rodar um comando em segundo plano.", "Ningún proceso en segundo plano. Pide al agente que ejecute un comando en segundo plano.", "No background processes. Ask the agent to run a background command.");
|
|
201
|
+
const options = (): Choice[] => [
|
|
202
|
+
{ value: "listar", description: jobs.size ? t("mostra os que estão rodando", "muestra los que están corriendo", "shows the running ones") : t("nada rodando agora", "nada corriendo ahora", "nothing running now") },
|
|
203
|
+
...(jobs.size ? [{ value: "encerrar todos", description: t("para todos", "detiene todos", "stops all") }] : []),
|
|
204
|
+
...[...jobs.keys()].map((id) => ({ value: `encerrar ${id}` })),
|
|
205
|
+
];
|
|
200
206
|
pink.registerCommand("processos", {
|
|
201
207
|
description: t("Comandos em segundo plano: lista; 'encerrar <n>' ou 'encerrar todos'", "Comandos en segundo plano: lista; 'encerrar <n>' o 'encerrar todos'", "Background commands: list; 'stop <n>' or 'stop all'"),
|
|
202
|
-
getArgumentCompletions: (
|
|
203
|
-
["encerrar todos", ...[...jobs.keys()].map((id) => `encerrar ${id}`)].filter((item) => item.startsWith(prefix)).map((value) => ({ value, label: value })),
|
|
208
|
+
getArgumentCompletions: completeFrom(options),
|
|
204
209
|
handler: async (args: string, ctx: any) => {
|
|
205
210
|
if (!args.trim() && jobs.size) {
|
|
206
|
-
const choice = await choose(ctx, "/processos",
|
|
207
|
-
{ value: "listar", description: t("mostra os que estão rodando", "muestra los que están corriendo", "shows the running ones") },
|
|
208
|
-
...["encerrar todos", ...[...jobs.keys()].map((id) => `encerrar ${id}`)].map((value) => ({ value })),
|
|
209
|
-
]);
|
|
211
|
+
const choice = await choose(ctx, "/processos", options());
|
|
210
212
|
if (choice === undefined) return;
|
|
211
|
-
args = choice
|
|
213
|
+
args = choice;
|
|
212
214
|
}
|
|
213
215
|
const [verb, target] = args.trim().split(/\s+/);
|
|
216
|
+
if (verb && !["listar", "list", "encerrar", "stop"].includes(verb)) return unknown(ctx, "/processos", args.trim(), options());
|
|
217
|
+
if ((verb === "encerrar" || verb === "stop") && !jobs.size) return void ctx.ui.notify(none(), "warning");
|
|
214
218
|
if (verb === "encerrar" || verb === "stop") {
|
|
215
219
|
const targets = target === "todos" || target === "all" ? [...jobs.values()] : ([find(target)].filter(Boolean) as Job[]);
|
|
216
220
|
for (const job of targets) job.controller.abort();
|
|
217
|
-
|
|
221
|
+
if (!targets.length) return unknown(ctx, "/processos", args.trim(), options());
|
|
222
|
+
ctx.ui.notify(t(`Encerrando ${targets.length} processo(s).`, `Deteniendo ${targets.length} proceso(s).`, `Stopping ${targets.length} process(es).`), "info");
|
|
218
223
|
return;
|
|
219
224
|
}
|
|
220
|
-
ctx.ui.notify(jobs.size ? lines().join("\n") :
|
|
225
|
+
ctx.ui.notify(jobs.size ? lines().join("\n") : none(), "info");
|
|
221
226
|
},
|
|
222
227
|
});
|
|
223
228
|
|
|
@@ -132,6 +132,7 @@ export default function (pink: any) {
|
|
|
132
132
|
description: t("Propõe uma skill a partir do que deu certo nesta sessão (você vê e aprova antes de gravar): /skill-nova [assunto]", "Propone una skill a partir de lo que funcionó en esta sesión (tú lo ves y apruebas antes de guardar): /skill-nova [asunto]", "Proposes a skill from what worked in this session (you see and approve it before it is saved): /skill-nova [topic]"),
|
|
133
133
|
handler: async (args: string, ctx: any) => {
|
|
134
134
|
const prompt = PROPOSE_PROMPT(String(args ?? "").trim());
|
|
135
|
+
ctx?.ui?.notify?.(t("Pedindo ao agente uma skill desta sessão; você vê e aprova antes de gravar.", "Pidiendo al agente una skill de esta sesión; la ves y apruebas antes de guardar.", "Asking the agent for a skill from this session; you see and approve it before it is saved."), "info");
|
|
135
136
|
if (ctx?.isIdle?.() === false) pink.sendUserMessage?.(prompt, { deliverAs: "followUp" });
|
|
136
137
|
else pink.sendUserMessage?.(prompt);
|
|
137
138
|
},
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// O evento input roda depois dos comandos de extensão e antes da expansão de skills e templates (agent-session.prompt);
|
|
7
7
|
// os comandos nativos (/model, /new...) são tratados pela interface antes de chegar aqui. Template com o mesmo nome vence.
|
|
8
8
|
|
|
9
|
-
import { t } from "./pink-i18n.ts";
|
|
9
|
+
import { noArgs, t } from "./pink-i18n.ts";
|
|
10
10
|
const NAME = /^\/([a-z0-9][a-z0-9._-]*)(?=\s|$)/i;
|
|
11
11
|
|
|
12
12
|
type Command = { name: string; description?: string; source: string; sourceInfo?: { scope?: string; path?: string } };
|
|
@@ -51,7 +51,7 @@ export default function (pink: any) {
|
|
|
51
51
|
});
|
|
52
52
|
pink.registerCommand("skills", {
|
|
53
53
|
description: t("Lista as skills (SKILL.md) desta sessão; chame uma com /nome", "Lista las skills (SKILL.md) de esta sesión; llama una con /nombre", "Lists this session's skills (SKILL.md); call one with /name"),
|
|
54
|
-
handler: async (_args: string, ctx: any) => {
|
|
54
|
+
handler: noArgs("/skills", async (_args: string, ctx: any) => {
|
|
55
55
|
const skills = skillsOf(commands());
|
|
56
56
|
if (!skills.length) {
|
|
57
57
|
const off = ctx?.isProjectTrusted?.() === false ? t(" As skills do projeto só carregam em pasta confiável.", " Las skills del proyecto solo se cargan en una carpeta de confianza.", " Project skills only load in a trusted folder.") : "";
|
|
@@ -59,6 +59,6 @@ export default function (pink: any) {
|
|
|
59
59
|
}
|
|
60
60
|
const lines = skills.map((skill) => `/${skill.name} (${SCOPE[skill.scope] ?? (skill.scope || t("pacote", "paquete", "package"))}) · ${skill.description}`);
|
|
61
61
|
ctx.ui.notify(`Skills:\n${lines.join("\n")}`, "info");
|
|
62
|
-
},
|
|
62
|
+
}),
|
|
63
63
|
});
|
|
64
64
|
}
|
package/extensions/pink-tela.ts
CHANGED
|
@@ -14,7 +14,7 @@ import os from "node:os";
|
|
|
14
14
|
import path from "node:path";
|
|
15
15
|
import { fileURLToPath } from "node:url";
|
|
16
16
|
import { Type } from "typebox";
|
|
17
|
-
import { type Choice, choose, completeFrom, t } from "./pink-i18n.ts";
|
|
17
|
+
import { type Choice, choose, completeFrom, t, unknown } from "./pink-i18n.ts";
|
|
18
18
|
|
|
19
19
|
const TELA_CHOICES = (): Choice[] => [
|
|
20
20
|
{ value: "status", description: t("ligada ou desligada?", "¿activada o desactivada?", "on or off?") },
|
|
@@ -662,6 +662,7 @@ export function createTela(pink: any, { env = process.env, run = mcpRun as Run,
|
|
|
662
662
|
const done = await installer({ env });
|
|
663
663
|
return ctx.ui.notify(done, /^(Tela|Pantalla|Screen): cua-driver .* (instalado|installed)/.test(done) ? "info" : "error");
|
|
664
664
|
}
|
|
665
|
+
if (verb && !["ligar", "on", "activar", "desligar", "off", "desactivar", "status", "estado"].includes(verb)) return unknown(ctx, "/tela", verb, TELA_CHOICES());
|
|
665
666
|
const text = ["ligar", "on", "activar"].includes(verb) ? await turnOn() : ["desligar", "off", "desactivar"].includes(verb) ? turnOff() : status();
|
|
666
667
|
ctx.ui.notify(text, /^(Não|No pude|Could not|Tela: |Pantalla: |Screen: )/.test(text) ? "error" : "info");
|
|
667
668
|
},
|