mundogiru-agent 0.4.0 → 0.4.2

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.
@@ -1,14 +1,58 @@
1
1
  /**
2
2
  * Skill de chat general: fallback que llama al LLM con la conversación.
3
+ *
4
+ * El system prompt declara explícitamente las capacidades reales del agente
5
+ * (voz TTS edge-tts, memoria persistente SQLite, asistente personal) e
6
+ * inyecta la fecha/hora local de cada turno. Patrón inspirado en
7
+ * `giru-agent/src/runtime/context.ts` (identidad + reglas + contexto).
3
8
  */
4
9
  import { appendChatMessage } from "../core/memory.js";
10
+ function formatNowES(now) {
11
+ const date = now.toLocaleDateString("es-ES", {
12
+ weekday: "long",
13
+ year: "numeric",
14
+ month: "long",
15
+ day: "numeric",
16
+ });
17
+ const time = now.toLocaleTimeString("es-ES", {
18
+ hour: "2-digit",
19
+ minute: "2-digit",
20
+ });
21
+ return { date, time };
22
+ }
23
+ export function buildSystemPrompt(config, now = new Date()) {
24
+ const { date, time } = formatNowES(now);
25
+ const agent = config.agentName || "Mundo";
26
+ const user = config.userName || "el usuario";
27
+ return [
28
+ `Eres ${agent}, el agente personal de inteligencia artificial de ${user}.`,
29
+ ``,
30
+ `CAPACIDADES REALES (esto eres tú, no lo niegues nunca):`,
31
+ `- Voz: hablas con una voz robótica sintetizada vía edge-tts y oyes al usuario con reconocimiento de voz (faster-whisper). SÍ TIENES VOZ. Cuando ${user} te pregunte si hablas, contesta que sí, que tienes voz robótica.`,
32
+ `- Memoria persistente: recuerdas conversaciones anteriores y datos importantes entre sesiones (SQLite local cifrado).`,
33
+ `- Asistente personal completo: ayudas con dudas, planificación, tareas, código, búsquedas y conversación general.`,
34
+ `- Funcionas en local en la máquina de ${user}, con privacidad por defecto.`,
35
+ ``,
36
+ `REGLAS:`,
37
+ `1. Responde SIEMPRE en español, sea cual sea el idioma del mensaje. Inglés técnico solo para nombres de código/comandos.`,
38
+ `2. Sé breve, directo y útil. Sin relleno ni disclaimers innecesarios.`,
39
+ `3. No inventes datos. Si no sabes algo, dilo claro.`,
40
+ `4. NUNCA digas "soy una IA de texto", "no tengo voz", "no puedo hablar" ni variantes. Tienes voz, memoria y oído.`,
41
+ `5. Cuando ${user} te pregunte qué puedes hacer o quién eres, habla de tus capacidades reales (voz, memoria, asistencia).`,
42
+ ``,
43
+ `CONTEXTO DEL TURNO:`,
44
+ `- Fecha actual: ${date}`,
45
+ `- Hora actual: ${time}`,
46
+ `- Usuario: ${user}`,
47
+ `- Tu nombre: ${agent}`,
48
+ ].join("\n");
49
+ }
5
50
  export const chatSkill = {
6
51
  name: "chat",
7
52
  description: "Conversación general con el LLM.",
8
53
  match: () => true, // se usa como fallback
9
54
  async handle(ctx) {
10
- const systemPrompt = `Eres ${ctx.config.agentName}, un asistente IA local de ${ctx.config.userName}.\n` +
11
- `Responde en español, breve y útil. No inventes datos.`;
55
+ const systemPrompt = buildSystemPrompt(ctx.config);
12
56
  const response = await ctx.llm.chat([
13
57
  { role: "system", content: systemPrompt },
14
58
  ...ctx.history,
@@ -1 +1 @@
1
- {"version":3,"file":"chat.js","sourceRoot":"","sources":["../../src/skills/chat.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGtD,MAAM,CAAC,MAAM,SAAS,GAAU;IAC5B,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,kCAAkC;IAC/C,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,uBAAuB;IAC1C,KAAK,CAAC,MAAM,CAAC,GAAiB;QAC1B,MAAM,YAAY,GACd,QAAQ,GAAG,CAAC,MAAM,CAAC,SAAS,8BAA8B,GAAG,CAAC,MAAM,CAAC,QAAQ,KAAK;YAClF,uDAAuD,CAAC;QAC5D,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC;YAChC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,YA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