@dotrino/terminal-agent 0.39.0 → 0.41.0
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/README.md +14 -0
- package/bin/terminal.js +115 -13
- package/consoles.js +14 -1
- package/desktop.js +10 -2
- package/index.js +1 -0
- package/package.json +2 -1
- package/service.js +189 -0
- package/skills/dotrino-terminal-note/SKILL.md +18 -9
package/README.md
CHANGED
|
@@ -51,6 +51,7 @@ dotrino-terminal link [--name <n>] # enlazar un perfil con tu bóveda
|
|
|
51
51
|
dotrino-terminal rename <perfil> [nuevo] # renombrarlo (mueve su carpeta y para su agente; mismo aparato)
|
|
52
52
|
dotrino-terminal vscode [--name <n>] # la terminal embebida de VS Code abre consolas de aquí (--off lo deshace)
|
|
53
53
|
dotrino-terminal desktop update [--check] # actualiza la app de escritorio: baja, verifica la firma e instala
|
|
54
|
+
dotrino-terminal service install|uninstall|status [--name <n>] # el agente como servicio del usuario
|
|
54
55
|
```
|
|
55
56
|
|
|
56
57
|
Cerrar la ventana no cierra la consola: sigue viva en el agente y se retoma después (se cierra
|
|
@@ -108,6 +109,7 @@ dotrino-terminal note "texto" # la reemplaza («-» la lee de la entrada
|
|
|
108
109
|
dotrino-terminal note --add "línea" # le añade una línea
|
|
109
110
|
dotrino-terminal note --clear # la borra
|
|
110
111
|
dotrino-terminal note --task "tarea" # la TAREA en curso, que va aparte de la nota
|
|
112
|
+
dotrino-terminal note --title "título" # el TÍTULO de la consola, en vez del de la shell (solo o con --task)
|
|
111
113
|
```
|
|
112
114
|
|
|
113
115
|
Son dos campos: la **nota** es de la persona (la edita desde la tarjeta) y la **tarea** es del
|
|
@@ -149,3 +151,15 @@ En la app de escritorio: menú **Perfil → Poner o cambiar la clave… / Quitar
|
|
|
149
151
|
nunca la clave. Viaja dentro de la sesión cifrada: el proxio no la ve.
|
|
150
152
|
- Hace falta agente ≥ 0.19.0, y web ≥ 0.8.9 o las apps ≥ 0.8.9 para poder escribirla. Un
|
|
151
153
|
cliente más viejo ve el error `locked` y no entra.
|
|
154
|
+
|
|
155
|
+
## Como servicio (arrancar al encender)
|
|
156
|
+
|
|
157
|
+
`dotrino-terminal service install [--name <n>]` escribe una unidad de systemd **del usuario**
|
|
158
|
+
(`~/.config/systemd/user/dotrino-terminal-agent-<perfil>.service`, `Restart=always`, con el `PATH`
|
|
159
|
+
de quien instala) y pide `loginctl enable-linger` para que arranque sin sesión; en macOS, un
|
|
160
|
+
LaunchAgent (`~/Library/LaunchAgents/com.dotrino.terminal-agent.<perfil>.plist`). Es de usuario
|
|
161
|
+
para que el agente se siga actualizando solo (§15): con quien lo levante ya puede reiniciarse.
|
|
162
|
+
Un agente que ya corre por su cuenta no se para (cerraría sus consolas): el servicio queda
|
|
163
|
+
habilitado, y `dotrino-terminal`, cuando no encuentra agente, arranca el servicio en vez de
|
|
164
|
+
levantar uno propio. Código en `service.js`; probado con systemd en un contenedor de Fedora,
|
|
165
|
+
macOS solo con pruebas unitarias.
|
package/bin/terminal.js
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
* dotrino-terminal vscode [--name <n>] la terminal embebida de VS Code abre consolas de aquí
|
|
18
18
|
* dotrino-terminal vscode --off lo deshace
|
|
19
19
|
* dotrino-terminal desktop update [--check] actualiza la app de escritorio (la ventana)
|
|
20
|
+
* dotrino-terminal service install|uninstall|status [--name <n>]
|
|
21
|
+
* el agente como servicio: arranca solo con la máquina
|
|
20
22
|
*
|
|
21
23
|
* Un PERFIL es un agente con nombre (`~/.dotrino/agent/terminal-agent/<nombre>/`), enlazado a
|
|
22
24
|
* una bóveda o solo local. Cada consola vive en el agente de un perfil.
|
|
@@ -29,6 +31,7 @@
|
|
|
29
31
|
* cierra saliendo de su shell (`exit`) o desde el panel.
|
|
30
32
|
*/
|
|
31
33
|
import fs from 'node:fs'
|
|
34
|
+
import os from 'node:os'
|
|
32
35
|
import path from 'node:path'
|
|
33
36
|
import { spawn } from 'node:child_process'
|
|
34
37
|
import { fileURLToPath } from 'node:url'
|
|
@@ -68,6 +71,8 @@ if (args.includes('-h') || args.includes('--help')) {
|
|
|
68
71
|
dotrino-terminal note --clear la borra
|
|
69
72
|
dotrino-terminal note --task <texto> pone la TAREA en curso, que va aparte de la nota: es
|
|
70
73
|
lo que usa un programa; --task '' la quita
|
|
74
|
+
dotrino-terminal note --title <texto> pone el TÍTULO de la consola en vez del de la shell
|
|
75
|
+
(solo o junto a --task); --title '' devuelve el de la shell
|
|
71
76
|
(--id <id> para otra consola; --json para leerla una máquina)
|
|
72
77
|
dotrino-terminal profiles [--json] los perfiles de esta máquina
|
|
73
78
|
dotrino-terminal link [--name <n>] enlaza un perfil con tu bóveda
|
|
@@ -82,6 +87,10 @@ if (args.includes('-h') || args.includes('--help')) {
|
|
|
82
87
|
dotrino-terminal desktop update actualiza la app de escritorio (la ventana): baja la
|
|
83
88
|
versión nueva, comprueba su firma y la instala
|
|
84
89
|
(--check solo mira si hay una)
|
|
90
|
+
dotrino-terminal service install [--name <n>] deja el agente como servicio de tu usuario: arranca
|
|
91
|
+
solo al encender la máquina, sin abrir ninguna ventana
|
|
92
|
+
dotrino-terminal service uninstall [--name <n>] lo quita (para el agente: cierra sus consolas)
|
|
93
|
+
dotrino-terminal service status [--name <n>] dice si está puesto y si está corriendo
|
|
85
94
|
|
|
86
95
|
Dentro de una consola: Ctrl+] y luego d la suelta sin cerrarla; Ctrl+] n abre otra
|
|
87
96
|
(y suelta la actual); Ctrl+] a <id> Enter pasa a esa consola; Ctrl+] p fija el tamaño de la
|
|
@@ -100,6 +109,8 @@ Cerrar la ventana no cierra la consola: sigue abierta y se retoma después.`, `u
|
|
|
100
109
|
dotrino-terminal note --clear clear it
|
|
101
110
|
dotrino-terminal note --task <text> set the TASK in progress, kept apart from the note: what
|
|
102
111
|
a program uses; --task '' removes it
|
|
112
|
+
dotrino-terminal note --title <text> set the console's TITLE instead of the shell's (alone
|
|
113
|
+
or with --task); --title '' gives the shell's back
|
|
103
114
|
(--id <id> for another console; --json for a machine to read)
|
|
104
115
|
dotrino-terminal profiles [--json] this machine's profiles
|
|
105
116
|
dotrino-terminal link [--name <n>] link a profile with your vault
|
|
@@ -114,6 +125,10 @@ Cerrar la ventana no cierra la consola: sigue abierta y se retoma después.`, `u
|
|
|
114
125
|
dotrino-terminal desktop update update the desktop app (the window): downloads the
|
|
115
126
|
new version, checks its signature and installs it
|
|
116
127
|
(--check only looks for one)
|
|
128
|
+
dotrino-terminal service install [--name <n>] run the agent as a service of your user: it starts
|
|
129
|
+
by itself when the machine boots, with no window open
|
|
130
|
+
dotrino-terminal service uninstall [--name <n>] remove it (stops the agent: closes its consoles)
|
|
131
|
+
dotrino-terminal service status [--name <n>] say whether it is installed and running
|
|
117
132
|
|
|
118
133
|
Inside a console: Ctrl+] then d detaches without closing it; Ctrl+] n opens another
|
|
119
134
|
(detaching the current one); Ctrl+] a <id> Enter switches to that console; Ctrl+] p pins the
|
|
@@ -169,13 +184,18 @@ async function agent (dir) {
|
|
|
169
184
|
}
|
|
170
185
|
fs.mkdirSync(dir, { recursive: true, mode: 0o700 })
|
|
171
186
|
const log = path.join(dir, 'agent.log')
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
187
|
+
// Si este perfil tiene servicio (`dotrino-terminal service install`), el agente es el del
|
|
188
|
+
// sistema: se arranca ese, no uno propio al lado. `--dir` fuerza una carpeta sin perfil.
|
|
189
|
+
const { startService } = await import('../service.js')
|
|
190
|
+
if (!(!opt('--dir') && !process.env.DOTRINO_TERMINAL_DIR && startService({ name: path.basename(dir) }))) {
|
|
191
|
+
const fd = fs.openSync(log, 'a', 0o600)
|
|
192
|
+
const cli = fileURLToPath(new URL('./cli.js', import.meta.url))
|
|
193
|
+
const extra = opt('--name') ? ['--name', opt('--name')] : []
|
|
194
|
+
// Sin TTY: si la máquina no está enlazada, el agente atiende solo a las ventanas locales.
|
|
195
|
+
const child = spawn(process.execPath, [cli, ...extra], { detached: true, stdio: ['ignore', fd, fd], env: process.env })
|
|
196
|
+
child.unref()
|
|
197
|
+
fs.closeSync(fd)
|
|
198
|
+
}
|
|
179
199
|
const t0 = Date.now()
|
|
180
200
|
while (Date.now() - t0 < 10000) {
|
|
181
201
|
await new Promise((r) => setTimeout(r, 100))
|
|
@@ -265,6 +285,77 @@ async function desktop () {
|
|
|
265
285
|
else console.log(t(`La app está al día (${current}).`, `The app is up to date (${current}).`))
|
|
266
286
|
}
|
|
267
287
|
|
|
288
|
+
/** Cuántas consolas tiene abiertas el agente de esa carpeta (0 si no hay agente). */
|
|
289
|
+
async function openConsoles (dir) {
|
|
290
|
+
let conn
|
|
291
|
+
try { conn = await connectLocal(dir) } catch (e) { if (e.code === 'ENOAGENT') return 0; throw e }
|
|
292
|
+
const r = await request(conn, { type: 'list' }, 'consoles')
|
|
293
|
+
conn.close()
|
|
294
|
+
if (r.type === 'fail') throw new Error(`${r.message} (${r.code})`)
|
|
295
|
+
return r.list.length
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/** El agente como servicio del usuario (systemd en Linux, launchd en macOS). */
|
|
299
|
+
async function service () {
|
|
300
|
+
const action = args[1]
|
|
301
|
+
if (!['install', 'uninstall', 'status'].includes(action)) die(t('uso: dotrino-terminal service install|uninstall|status [--name <perfil>]', 'usage: dotrino-terminal service install|uninstall|status [--name <profile>]'))
|
|
302
|
+
const asked = opt('--name')
|
|
303
|
+
if (asked !== undefined && !isValidName(asked)) die(t(`nombre de perfil no válido: ${asked}`, `invalid profile name: ${asked}`))
|
|
304
|
+
const { dir } = resolveInstance(LABEL, asked)
|
|
305
|
+
const name = path.basename(dir)
|
|
306
|
+
const { installService, uninstallService, serviceStatus } = await import('../service.js')
|
|
307
|
+
const explain = (e) => {
|
|
308
|
+
if (e.code === 'no-user-systemd') die(t('esta sesión no tiene systemd de usuario, que es donde se pone el servicio. No se instaló nada.', 'this session has no systemd user manager, which is where the service goes. Nothing was installed.'))
|
|
309
|
+
if (e.code === 'unsupported-platform') die(t('esto solo está para Linux y macOS.', 'this is only available on Linux and macOS.'))
|
|
310
|
+
throw e
|
|
311
|
+
}
|
|
312
|
+
let st
|
|
313
|
+
try { st = serviceStatus({ name }) } catch (e) { explain(e) }
|
|
314
|
+
const pid = Number((() => { try { return fs.readFileSync(path.join(dir, 'agent.pid'), 'utf8') } catch (_) { return '' } })())
|
|
315
|
+
const running = !!pid && alive(pid)
|
|
316
|
+
|
|
317
|
+
if (action === 'status') {
|
|
318
|
+
if (!st.installed) console.log(t(`El perfil «${name}» no tiene servicio: su agente arranca cuando abres una ventana. Para ponerlo: dotrino-terminal service install --name ${name}`, `Profile "${name}" has no service: its agent starts when you open a window. To add it: dotrino-terminal service install --name ${name}`))
|
|
319
|
+
else if (st.active) console.log(t(`Servicio puesto y corriendo (${st.file}).`, `Service installed and running (${st.file}).`))
|
|
320
|
+
else if (running) console.log(t(`Servicio puesto (${st.file}). Ahora corre un agente que levantó una ventana; el servicio toma el relevo cuando ese termine o al próximo arranque.`, `Service installed (${st.file}). Right now an agent started by a window is running; the service takes over when it ends or at the next start.`))
|
|
321
|
+
else console.log(t(`Servicio puesto pero parado (${st.file}). Arranca al abrir una ventana; si falló, mira por qué: journalctl --user -u dotrino-terminal-agent-${name}`, `Service installed but stopped (${st.file}). It starts when you open a window; if it failed, see why: journalctl --user -u dotrino-terminal-agent-${name}`))
|
|
322
|
+
return
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if (action === 'install') {
|
|
326
|
+
fs.mkdirSync(dir, { recursive: true, mode: 0o700 })
|
|
327
|
+
const cli = fs.realpathSync(fileURLToPath(new URL('./cli.js', import.meta.url)))
|
|
328
|
+
// Un agente que corre por su cuenta no se para: cerraría sus consolas.
|
|
329
|
+
const own = running && !st.active
|
|
330
|
+
let r
|
|
331
|
+
try { r = installService({ name, cli, dir, running: own }) } catch (e) { explain(e) }
|
|
332
|
+
console.log(t(`Servicio del perfil «${name}» puesto: ${r.file}`, `Service for profile "${name}" installed: ${r.file}`))
|
|
333
|
+
if (r.started) console.log(t('El agente ya corre como servicio.', 'The agent now runs as a service.'))
|
|
334
|
+
else console.log(t('Ahora mismo corre un agente que levantó una ventana, y no se toca para no cerrar sus consolas. El servicio toma el relevo cuando ese termine o al próximo arranque.', 'Right now an agent started by a window is running, and it is left alone so its consoles stay open. The service takes over when it ends or at the next start.'))
|
|
335
|
+
if (r.kind === 'launchd') console.log(t('Arranca solo cuando inicias sesión en esta Mac.', 'It starts by itself when you log in to this Mac.'))
|
|
336
|
+
else if (r.boot) console.log(t('Arranca solo al encender la máquina, sin que nadie inicie sesión.', 'It starts by itself when the machine boots, with nobody logged in.'))
|
|
337
|
+
else console.log(t(`Arranca solo cuando inicias sesión. Para que arranque al encender, sin iniciar sesión: sudo loginctl enable-linger ${os.userInfo().username}`, `It starts by itself when you log in. To start at boot, with nobody logged in: sudo loginctl enable-linger ${os.userInfo().username}`))
|
|
338
|
+
if (!loadLink(dir)) console.log(t(`Este perfil no está enlazado: el servicio atiende solo a las ventanas de esta máquina. Para abrir sus consolas desde otros aparatos: dotrino-terminal link --name ${name}`, `This profile is not linked: the service only serves this machine's windows. To open its consoles from other devices: dotrino-terminal link --name ${name}`))
|
|
339
|
+
console.log(t('Si cambias de versión de Node, vuelve a correr esta orden.', 'If you switch Node versions, run this command again.'))
|
|
340
|
+
return
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (!st.installed) { console.log(t(`El perfil «${name}» no tiene servicio.`, `Profile "${name}" has no service.`)); return }
|
|
344
|
+
// Quitarlo para el agente que corre bajo el servicio, y con él sus consolas.
|
|
345
|
+
if (st.active && !args.includes('--yes')) {
|
|
346
|
+
const inside = !!process.env.DOTRINO_TERMINAL_PROFILE_DIR && samePath(process.env.DOTRINO_TERMINAL_PROFILE_DIR, dir)
|
|
347
|
+
if (inside) die(t('esta consola es de ese mismo servicio: quitarlo la cerraría a mitad de la orden. Hazlo desde una terminal normal, o con --yes si eso es lo que quieres.', 'this console belongs to that very service: removing it would close it mid-command. Do it from a plain terminal, or with --yes if that is what you want.'))
|
|
348
|
+
const open = await openConsoles(dir)
|
|
349
|
+
if (open > 0) {
|
|
350
|
+
const ok = await ask(t(`El perfil «${name}» tiene ${open} consola(s) abierta(s); quitar el servicio las cierra. ¿Seguir? [s/N] `, `Profile "${name}" has ${open} open console(s); removing the service closes them. Continue? [y/N] `))
|
|
351
|
+
if (!/^[sy]/i.test(ok)) die(t('No se quitó.', 'Not removed.'))
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
let r
|
|
355
|
+
try { r = uninstallService({ name }) } catch (e) { explain(e) }
|
|
356
|
+
console.log(t(`Servicio del perfil «${name}» quitado (${r.file}). El perfil y su enlace siguen igual: el agente vuelve a arrancar cuando abras una ventana.`, `Service for profile "${name}" removed (${r.file}). The profile and its link are untouched: the agent starts again when you open a window.`))
|
|
357
|
+
}
|
|
358
|
+
|
|
268
359
|
/** Enlaza un perfil. Sin `--name`, lo pregunta. Uno ya enlazado no se pisa: eso es `enroll`. */
|
|
269
360
|
async function link () {
|
|
270
361
|
let name = opt('--name')
|
|
@@ -509,7 +600,7 @@ async function note () {
|
|
|
509
600
|
if (!id) die(t('no sé de qué consola: esta shell no corre dentro de Dotrino Terminal. Usa --id <id> (mira «dotrino-terminal ls»).', 'no console to act on: this shell is not running inside Dotrino Terminal. Use --id <id> (see "dotrino-terminal ls").'))
|
|
510
601
|
// Dentro de una consola, el perfil es el de esa consola, no el `default`.
|
|
511
602
|
const dir = opt('--dir') || (opt('--name') ? dataDir(opt('--name')) : process.env.DOTRINO_TERMINAL_PROFILE_DIR || dataDir())
|
|
512
|
-
const valued = new Set(['--id', '--dir', '--name', '--add', '--task'])
|
|
603
|
+
const valued = new Set(['--id', '--dir', '--name', '--add', '--task', '--title'])
|
|
513
604
|
const words = []
|
|
514
605
|
for (let i = 1; i < args.length; i++) {
|
|
515
606
|
if (valued.has(args[i])) { i++; continue }
|
|
@@ -519,6 +610,7 @@ async function note () {
|
|
|
519
610
|
const given = words.length ? (words.length === 1 && words[0] === '-' ? stdin() : words.join(' ')) : null
|
|
520
611
|
const add = opt('--add') === '-' ? stdin() : opt('--add')
|
|
521
612
|
const task = opt('--task') === '-' ? stdin() : opt('--task')
|
|
613
|
+
const title = opt('--title')
|
|
522
614
|
let conn
|
|
523
615
|
try { conn = await connectLocal(dir) } catch (e) {
|
|
524
616
|
if (e.code !== 'ENOAGENT') throw e
|
|
@@ -535,10 +627,16 @@ async function note () {
|
|
|
535
627
|
if (task !== undefined) {
|
|
536
628
|
// LA TAREA ES DEL PROGRAMA, LA NOTA ES DE LA PERSONA: dos campos. Esta orden solo escribe el
|
|
537
629
|
// primero, así un agente de IA no puede pisar una nota personal ni por descuido.
|
|
538
|
-
c = await ask({ type: 'note', id, task: task.split('\n').map((l) => l.trim()).filter(Boolean).join('\n') })
|
|
630
|
+
c = await ask({ type: 'note', id, task: task.split('\n').map((l) => l.trim()).filter(Boolean).join('\n'), ...(title === undefined ? {} : { title }) })
|
|
539
631
|
// Un agente anterior a la 0.37 contesta, pero no guarda tareas: se dice, no se da por hecha.
|
|
540
632
|
if (c.task === undefined) die(t('el agente que corre es anterior a la 0.37.0 y no guarda tareas. Reinícialo con la versión nueva (cierra sus consolas).', 'the running agent predates 0.37.0 and keeps no tasks. Restart it with the new version (closes its consoles).'))
|
|
541
|
-
|
|
633
|
+
// Y uno anterior a la 0.41 no guarda el título: lo mismo.
|
|
634
|
+
if (title !== undefined && c.subject === undefined) die(t('el agente que corre es anterior a la 0.41.0 y no guarda el título. Reinícialo con la versión nueva (cierra sus consolas).', 'the running agent predates 0.41.0 and keeps no title. Restart it with the new version (closes its consoles).'))
|
|
635
|
+
} else if (title !== undefined) {
|
|
636
|
+
c = await ask({ type: 'note', id, title })
|
|
637
|
+
if (c.subject === undefined) die(t('el agente que corre es anterior a la 0.41.0 y no guarda el título. Reinícialo con la versión nueva (cierra sus consolas).', 'the running agent predates 0.41.0 and keeps no title. Restart it with the new version (closes its consoles).'))
|
|
638
|
+
}
|
|
639
|
+
else if (args.includes('--clear')) c = await ask({ type: 'note', id, text: '' })
|
|
542
640
|
else if (add !== undefined) {
|
|
543
641
|
const before = (await ask({ type: 'note', id })).note || ''
|
|
544
642
|
c = await ask({ type: 'note', id, text: before ? `${before}\n${add}` : add })
|
|
@@ -567,17 +665,20 @@ function interactive (conn, first, dir) {
|
|
|
567
665
|
const out = process.stdout
|
|
568
666
|
let consoleId = null
|
|
569
667
|
let shellTitle = ''
|
|
668
|
+
let subject = ''
|
|
570
669
|
let remote = new Set()
|
|
571
670
|
let ending = false
|
|
572
671
|
|
|
573
672
|
const showTitle = () => {
|
|
574
|
-
const base = shellTitle || 'Dotrino Terminal'
|
|
673
|
+
const base = subject || shellTitle || 'Dotrino Terminal'
|
|
575
674
|
const mark = remote.size ? ` ● ${t('abierta desde otro aparato', 'open on another device')}${remote.size > 1 ? ` ×${remote.size}` : ''}` : ''
|
|
576
675
|
out.write(`\x1b]2;${base}${mark}\x07`)
|
|
577
676
|
}
|
|
578
677
|
const onInfo = (info) => {
|
|
579
678
|
if (!info) return
|
|
580
|
-
|
|
679
|
+
// El título que puso el programa (`note --title`) manda sobre el de la shell.
|
|
680
|
+
subject = info.subject || ''
|
|
681
|
+
shellTitle = info.shellTitle ?? info.title ?? ''
|
|
581
682
|
// En otra máquina (`--machine`) esta ventana es, para aquella, «otro aparato»: no se cuenta
|
|
582
683
|
// a sí misma (se reconoce por su etiqueta; sin etiqueta, es una de las que salen).
|
|
583
684
|
let far = info.watchers.filter((w) => w.origin === 'remote')
|
|
@@ -642,7 +743,7 @@ function interactive (conn, first, dir) {
|
|
|
642
743
|
const other = rest.find((c) => !c.watchers.length) || rest.find((c) => !c.watchers.some((w) => w.origin === 'local')) || rest[0]
|
|
643
744
|
if (other) return switchTo({ type: 'attach', id: other.id })
|
|
644
745
|
empty = true
|
|
645
|
-
shellTitle = ''; remote = new Set(); showTitle()
|
|
746
|
+
shellTitle = ''; subject = ''; remote = new Set(); showTitle()
|
|
646
747
|
out.write(`\x1bc\x1b[2m${t('No hay consolas abiertas. Ctrl+] y luego n abre una.', 'No open consoles. Ctrl+] then n opens one.')}\x1b[0m\r\n`)
|
|
647
748
|
})
|
|
648
749
|
return
|
|
@@ -740,6 +841,7 @@ try {
|
|
|
740
841
|
if (cmd === 'lock') { await lock(); process.exit(0) }
|
|
741
842
|
if (cmd === 'vscode') { vscode(); process.exit(0) }
|
|
742
843
|
if (cmd === 'desktop') { await desktop(); process.exit(0) }
|
|
844
|
+
if (cmd === 'service') { await service(); process.exit(0) }
|
|
743
845
|
if (cmd === 'note') { await note(); process.exit(0) }
|
|
744
846
|
const dir = opt('--dir') || dataDir(opt('--name'))
|
|
745
847
|
if (cmd === 'open' || cmd === 'attach') captureEarly()
|
package/consoles.js
CHANGED
|
@@ -87,6 +87,10 @@ class Console {
|
|
|
87
87
|
// (`dotrino-terminal note --task`). Son dos campos para que un agente de IA no pueda pisar lo
|
|
88
88
|
// que escribió la persona, ni la persona tenga que editar lo del agente: solo lo quita.
|
|
89
89
|
this.task = ''
|
|
90
|
+
// EL TÍTULO QUE PONE EL PROGRAMA (`dotrino-terminal note --title`). El de la shell (OSC 0/2) lo
|
|
91
|
+
// fija un agente de IA al empezar su sesión y no lo cambia aunque la tarea sea ya otra: este
|
|
92
|
+
// lo sustituye en todas las pantallas mientras exista. Se va con la tarea.
|
|
93
|
+
this.subject = ''
|
|
90
94
|
this.cols = cols
|
|
91
95
|
this.rows = rows
|
|
92
96
|
this.createdAt = Date.now()
|
|
@@ -161,6 +165,15 @@ class Console {
|
|
|
161
165
|
const task = String(text ?? '').slice(0, NOTE_MAX)
|
|
162
166
|
if (task === this.task) return
|
|
163
167
|
this.task = task
|
|
168
|
+
if (!task) this.subject = ''
|
|
169
|
+
this._meta()
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Cambia el título que pone el programa. Vacío, vuelve a mandar el de la shell. */
|
|
173
|
+
setSubject (text) {
|
|
174
|
+
const subject = String(text ?? '').replace(/\s+/g, ' ').trim().slice(0, 200)
|
|
175
|
+
if (subject === this.subject) return
|
|
176
|
+
this.subject = subject
|
|
164
177
|
this._meta()
|
|
165
178
|
}
|
|
166
179
|
|
|
@@ -275,7 +288,7 @@ class Console {
|
|
|
275
288
|
const watchers = [...this.viewers].filter((v) => v.origin).map((v) => ({ origin: v.origin, device: v.device || null, tag: v.tag || null }))
|
|
276
289
|
const d = this.holder
|
|
277
290
|
const sizeBy = d ? { origin: d.origin || null, device: d.device || null, tag: d.tag || null } : null
|
|
278
|
-
return { id: this.id, n: this.n, activity: this.busy ? 'busy' : 'idle', doneAt: this.doneAt, sizeBy, origin: this.origin, title: this.title, note: this.note, task: this.task, host: HOST, cwd: cwdOf(this.pty?.pid), cols: this.cols, rows: this.rows, createdAt: this.createdAt, lastActive: this.lastActive, viewers: this.viewers.size, watchers }
|
|
291
|
+
return { id: this.id, n: this.n, activity: this.busy ? 'busy' : 'idle', doneAt: this.doneAt, sizeBy, origin: this.origin, title: this.subject || this.title, shellTitle: this.title, subject: this.subject, note: this.note, task: this.task, host: HOST, cwd: cwdOf(this.pty?.pid), cols: this.cols, rows: this.rows, createdAt: this.createdAt, lastActive: this.lastActive, viewers: this.viewers.size, watchers }
|
|
279
292
|
}
|
|
280
293
|
}
|
|
281
294
|
|
package/desktop.js
CHANGED
|
@@ -29,6 +29,7 @@ export const DESKTOP_TAG = 'desktop-v'
|
|
|
29
29
|
export const BINARY = 'dotrino-terminal-desktop'
|
|
30
30
|
const PRODUCT = 'dotrino-terminal-desktop'
|
|
31
31
|
|
|
32
|
+
/** @returns {any} */
|
|
32
33
|
const fail = (code, reason, extra = {}) => ({ ok: false, code, reason, ...extra })
|
|
33
34
|
|
|
34
35
|
/** La última release del escritorio. `{ ok:false }` si no se pudo mirar, que NO es «al día». */
|
|
@@ -40,7 +41,8 @@ export const latestDesktop = (opts = {}) =>
|
|
|
40
41
|
* y cómo se pone. Se le pregunta al gestor de paquetes por ESE archivo: mirar solo qué
|
|
41
42
|
* gestor hay se equivoca con un tarball en una máquina con `dpkg`.
|
|
42
43
|
*
|
|
43
|
-
* @
|
|
44
|
+
* @param {any} [o]
|
|
45
|
+
* @returns {any} `{ ok:true, kind:'deb'|'rpm'|'tar'|'mac', app? }` o `{ ok:false, code, reason }`
|
|
44
46
|
*/
|
|
45
47
|
export function installKind ({ exe, platform = process.platform, arch = process.arch, run = execFileSync, writable = canWrite } = {}) {
|
|
46
48
|
if (!exe) return fail('no-exe', 'the desktop app was not found')
|
|
@@ -83,6 +85,11 @@ function asRoot (cmd, args, { run, uid }) {
|
|
|
83
85
|
/**
|
|
84
86
|
* Pone el archivo ya verificado. Devuelve `{ ok:true }` o por qué no se pudo; si el archivo
|
|
85
87
|
* quedó bajado y sirve para instalarlo a mano, va en `file`.
|
|
88
|
+
*
|
|
89
|
+
* @param {string} file
|
|
90
|
+
* @param {any} how
|
|
91
|
+
* @param {any} [o]
|
|
92
|
+
* @returns {any}
|
|
86
93
|
*/
|
|
87
94
|
export function install (file, how, { exe, run = execFileSync, uid = process.getuid?.() } = {}) {
|
|
88
95
|
try {
|
|
@@ -131,7 +138,8 @@ export function install (file, how, { exe, run = execFileSync, uid = process.get
|
|
|
131
138
|
* Todo el camino: mirar, bajar, verificar, instalar. `say(step, data)` va contando por dónde
|
|
132
139
|
* va, para que quien lo enseñe lo diga en su idioma.
|
|
133
140
|
*
|
|
134
|
-
* @
|
|
141
|
+
* @param {any} [o]
|
|
142
|
+
* @returns {Promise<any>} `{ ok:true, version, updated, newer?, kind? }` o `{ ok:false, code, reason, file? }`
|
|
135
143
|
*/
|
|
136
144
|
export async function updateDesktop ({ exe, current, check = false, say = () => {}, latest = latestDesktop, fetchVerifiedImpl = fetchVerified, kindOf = installKind, installImpl = install } = {}) {
|
|
137
145
|
const r = await latest({ version: current })
|
package/index.js
CHANGED
|
@@ -214,6 +214,7 @@ export function serveSession (session, hub, { origin = 'remote', gate = null } =
|
|
|
214
214
|
if (!c) return fail('no-console', 'that console no longer exists')
|
|
215
215
|
if (typeof msg.text === 'string') c.setNote(msg.text)
|
|
216
216
|
if (typeof msg.task === 'string') c.setTask(msg.task)
|
|
217
|
+
if (typeof msg.title === 'string') c.setSubject(msg.title)
|
|
217
218
|
session.send({ type: 'noted', console: c.info() })
|
|
218
219
|
return
|
|
219
220
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotrino/terminal-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.0",
|
|
4
4
|
"description": "Dotrino Terminal: las ventanas de esta máquina (dotrino-terminal) y su agente, que deja abrir esas mismas consolas desde los otros aparatos de tu cuenta, cifrado punto a punto.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"desktop.js",
|
|
20
20
|
"link.js",
|
|
21
21
|
"local.js",
|
|
22
|
+
"service.js",
|
|
22
23
|
"title.js",
|
|
23
24
|
"update.js",
|
|
24
25
|
"bin",
|
package/service.js
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* service.js — el agente como SERVICIO del usuario: arranca solo con la máquina.
|
|
3
|
+
*
|
|
4
|
+
* Sin esto el agente lo levanta la primera ventana que se abre (`dotrino-terminal`), así que
|
|
5
|
+
* tras encender la máquina nadie puede abrir sus consolas desde otro aparato hasta que
|
|
6
|
+
* alguien se siente delante. `dotrino-terminal service install` lo deja a cargo del sistema:
|
|
7
|
+
*
|
|
8
|
+
* · Linux — una unidad de systemd DEL USUARIO (`~/.config/systemd/user`), sin `sudo`. Con
|
|
9
|
+
* «linger» arranca al encender, antes de que nadie inicie sesión; sin él, al iniciarla.
|
|
10
|
+
* · macOS — un LaunchAgent (`~/Library/LaunchAgents`): arranca al iniciar sesión.
|
|
11
|
+
*
|
|
12
|
+
* Es de usuario a propósito (CONVENCIONES §15): así el agente se sigue actualizando solo, y
|
|
13
|
+
* con alguien que lo levante ya puede reiniciarse para estrenar la versión nueva.
|
|
14
|
+
*
|
|
15
|
+
* Una unidad por PERFIL: cada perfil es un agente con su enlace.
|
|
16
|
+
*/
|
|
17
|
+
import fs from 'node:fs'
|
|
18
|
+
import os from 'node:os'
|
|
19
|
+
import path from 'node:path'
|
|
20
|
+
import { execFileSync } from 'node:child_process'
|
|
21
|
+
|
|
22
|
+
const fail = (code, message) => Object.assign(new Error(message), { code })
|
|
23
|
+
|
|
24
|
+
export const unitName = (name) => `dotrino-terminal-agent-${name}.service`
|
|
25
|
+
export const plistLabel = (name) => `com.dotrino.terminal-agent.${name}`
|
|
26
|
+
|
|
27
|
+
export function unitPath (name, home = os.homedir()) {
|
|
28
|
+
return path.join(home, '.config', 'systemd', 'user', unitName(name))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function plistPath (name, home = os.homedir()) {
|
|
32
|
+
return path.join(home, 'Library', 'LaunchAgents', `${plistLabel(name)}.plist`)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** systemd parte `ExecStart` por espacios: lo que los lleve va entre comillas. */
|
|
36
|
+
const unitArg = (s) => (/[\s"'\\$%]/.test(s) ? `"${s.replace(/[\\"]/g, '\\$&').replace(/%/g, '%%').replace(/\$/g, '$$$$')}"` : s)
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* La unidad de systemd. `--local`: sin TTY el agente nunca pregunta; si el perfil no está
|
|
40
|
+
* enlazado atiende solo a las ventanas de esta máquina, igual que cuando lo levanta una ventana.
|
|
41
|
+
*
|
|
42
|
+
* El PATH es el de quien instala: el de un servicio de usuario es mínimo y no trae el Node
|
|
43
|
+
* de nvm ni las herramientas que las consolas esperan encontrar.
|
|
44
|
+
*/
|
|
45
|
+
export function unitText ({ name, node, cli, pathEnv }) {
|
|
46
|
+
return `[Unit]
|
|
47
|
+
Description=Dotrino Terminal agent (${name})
|
|
48
|
+
After=network-online.target
|
|
49
|
+
Wants=network-online.target
|
|
50
|
+
|
|
51
|
+
[Service]
|
|
52
|
+
ExecStart=${unitArg(node)} ${unitArg(cli)} --name ${name} --local
|
|
53
|
+
Environment=${unitArg(`PATH=${pathEnv}`)}
|
|
54
|
+
Restart=always
|
|
55
|
+
RestartSec=3
|
|
56
|
+
|
|
57
|
+
[Install]
|
|
58
|
+
WantedBy=default.target
|
|
59
|
+
`
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const xml = (s) => String(s).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
|
63
|
+
|
|
64
|
+
/** El LaunchAgent de macOS. `DOTRINO_SUPERVISED`: launchd lo levanta si sale (§15). */
|
|
65
|
+
export function plistText ({ name, node, cli, pathEnv, log }) {
|
|
66
|
+
const args = [node, cli, '--name', name, '--local'].map((a) => ` <string>${xml(a)}</string>`).join('\n')
|
|
67
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
68
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
69
|
+
<plist version="1.0"><dict>
|
|
70
|
+
<key>Label</key><string>${xml(plistLabel(name))}</string>
|
|
71
|
+
<key>ProgramArguments</key>
|
|
72
|
+
<array>
|
|
73
|
+
${args}
|
|
74
|
+
</array>
|
|
75
|
+
<key>EnvironmentVariables</key>
|
|
76
|
+
<dict>
|
|
77
|
+
<key>PATH</key><string>${xml(pathEnv)}</string>
|
|
78
|
+
<key>DOTRINO_SUPERVISED</key><string>1</string>
|
|
79
|
+
</dict>
|
|
80
|
+
<key>RunAtLoad</key><true/>
|
|
81
|
+
<key>KeepAlive</key><true/>
|
|
82
|
+
<key>StandardOutPath</key><string>${xml(log)}</string>
|
|
83
|
+
<key>StandardErrorPath</key><string>${xml(log)}</string>
|
|
84
|
+
</dict></plist>
|
|
85
|
+
`
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function quiet (run, cmd, args) {
|
|
89
|
+
try { run(cmd, args, { stdio: ['ignore', 'pipe', 'pipe'], encoding: 'utf8' }); return { ok: true } } catch (e) {
|
|
90
|
+
return { ok: false, reason: String(e.stderr || e.message).trim().split('\n').pop() }
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function must (run, cmd, args) {
|
|
95
|
+
const r = quiet(run, cmd, args)
|
|
96
|
+
if (!r.ok) throw fail('service-command-failed', `${cmd} ${args.join(' ')}: ${r.reason}`)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** ¿Ya arrancan los servicios de ese usuario al encender? systemd lo apunta con un archivo. */
|
|
100
|
+
const lingers = (user, root = LINGER_DIR) => fs.existsSync(path.join(root, user))
|
|
101
|
+
const LINGER_DIR = '/var/lib/systemd/linger'
|
|
102
|
+
|
|
103
|
+
/** ¿Deja este sistema instalar el servicio? Lanza con el motivo si no. */
|
|
104
|
+
function platformOf ({ platform, run }) {
|
|
105
|
+
if (platform === 'darwin') return 'launchd'
|
|
106
|
+
if (platform !== 'linux') throw fail('unsupported-platform', `there is no service support for ${platform}`)
|
|
107
|
+
// Sin systemd de usuario (un contenedor, WSL sin systemd, otra init) no hay dónde ponerlo.
|
|
108
|
+
if (!quiet(run, 'systemctl', ['--user', 'show-environment']).ok) throw fail('no-user-systemd', 'this session has no systemd user manager')
|
|
109
|
+
return 'systemd'
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Instala y enciende el servicio del perfil `name`.
|
|
114
|
+
*
|
|
115
|
+
* `running`: ya hay un agente de ese perfil corriendo por su cuenta (lo levantó una ventana).
|
|
116
|
+
* Dos agentes con el mismo enlace son la misma llave, y parar ese cerraría sus consolas: el
|
|
117
|
+
* servicio queda puesto y toma el relevo cuando ese agente termine o al próximo arranque.
|
|
118
|
+
*
|
|
119
|
+
* @returns {{ kind:'systemd'|'launchd', file:string, started:boolean, boot?:boolean, lingerReason?:string }}
|
|
120
|
+
*/
|
|
121
|
+
export function installService ({ name, node = process.execPath, cli, dir, running = false, pathEnv = process.env.PATH || '', platform = process.platform, home = os.homedir(), user = os.userInfo().username, uid = process.getuid?.(), run = execFileSync }) {
|
|
122
|
+
const kind = platformOf({ platform, run })
|
|
123
|
+
if (kind === 'launchd') {
|
|
124
|
+
const file = plistPath(name, home)
|
|
125
|
+
fs.mkdirSync(path.dirname(file), { recursive: true })
|
|
126
|
+
fs.writeFileSync(file, plistText({ name, node, cli, pathEnv, log: path.join(dir, 'agent.log') }), { mode: 0o644 })
|
|
127
|
+
if (running) return { kind, file, started: false }
|
|
128
|
+
// Si ya estaba cargado (una instalación anterior), se recarga con el archivo nuevo.
|
|
129
|
+
quiet(run, 'launchctl', ['bootout', `gui/${uid}/${plistLabel(name)}`])
|
|
130
|
+
must(run, 'launchctl', ['bootstrap', `gui/${uid}`, file])
|
|
131
|
+
return { kind, file, started: true }
|
|
132
|
+
}
|
|
133
|
+
const file = unitPath(name, home)
|
|
134
|
+
fs.mkdirSync(path.dirname(file), { recursive: true })
|
|
135
|
+
fs.writeFileSync(file, unitText({ name, node, cli, pathEnv }), { mode: 0o644 })
|
|
136
|
+
must(run, 'systemctl', ['--user', 'daemon-reload'])
|
|
137
|
+
must(run, 'systemctl', ['--user', 'enable', unitName(name)])
|
|
138
|
+
if (!running) must(run, 'systemctl', ['--user', 'restart', unitName(name)])
|
|
139
|
+
// Arrancar al ENCENDER, sin que nadie inicie sesión. Si el sistema no lo deja sin
|
|
140
|
+
// administrador, el servicio arranca al iniciar sesión, y se dice.
|
|
141
|
+
if (lingers(user)) return { kind, file, started: !running, boot: true }
|
|
142
|
+
const linger = quiet(run, 'loginctl', ['enable-linger', user])
|
|
143
|
+
return { kind, file, started: !running, boot: linger.ok, ...(linger.ok ? {} : { lingerReason: linger.reason }) }
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Arranca el servicio ya instalado de ese perfil. `false` si el perfil no tiene servicio (o
|
|
148
|
+
* este sistema no los tiene): entonces el agente lo levanta la ventana, como siempre. Lo usa
|
|
149
|
+
* `dotrino-terminal` cuando no encuentra agente, para no levantar uno propio al lado de un
|
|
150
|
+
* servicio que el sistema arrancaría después con la misma llave.
|
|
151
|
+
*/
|
|
152
|
+
export function startService ({ name, platform = process.platform, home = os.homedir(), uid = process.getuid?.(), run = execFileSync }) {
|
|
153
|
+
if (platform === 'darwin') {
|
|
154
|
+
const file = plistPath(name, home)
|
|
155
|
+
if (!fs.existsSync(file)) return false
|
|
156
|
+
// Cargado y parado no puede estar (KeepAlive): si no corre, es que no está cargado.
|
|
157
|
+
quiet(run, 'launchctl', ['bootout', `gui/${uid}/${plistLabel(name)}`])
|
|
158
|
+
must(run, 'launchctl', ['bootstrap', `gui/${uid}`, file])
|
|
159
|
+
return true
|
|
160
|
+
}
|
|
161
|
+
if (platform !== 'linux' || !fs.existsSync(unitPath(name, home))) return false
|
|
162
|
+
must(run, 'systemctl', ['--user', 'start', unitName(name)])
|
|
163
|
+
return true
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Para el servicio y lo quita. El enlace y los ajustes del perfil no se tocan. */
|
|
167
|
+
export function uninstallService ({ name, platform = process.platform, home = os.homedir(), uid = process.getuid?.(), run = execFileSync }) {
|
|
168
|
+
const kind = platformOf({ platform, run })
|
|
169
|
+
const file = kind === 'launchd' ? plistPath(name, home) : unitPath(name, home)
|
|
170
|
+
if (!fs.existsSync(file)) return { kind, file, removed: false }
|
|
171
|
+
if (kind === 'launchd') quiet(run, 'launchctl', ['bootout', `gui/${uid}/${plistLabel(name)}`])
|
|
172
|
+
else must(run, 'systemctl', ['--user', 'disable', '--now', unitName(name)])
|
|
173
|
+
fs.rmSync(file)
|
|
174
|
+
if (kind === 'systemd') must(run, 'systemctl', ['--user', 'daemon-reload'])
|
|
175
|
+
return { kind, file, removed: true }
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** ¿Está puesto, y está corriendo ahora bajo el sistema? */
|
|
179
|
+
export function serviceStatus ({ name, platform = process.platform, home = os.homedir(), uid = process.getuid?.(), run = execFileSync }) {
|
|
180
|
+
const kind = platformOf({ platform, run })
|
|
181
|
+
const file = kind === 'launchd' ? plistPath(name, home) : unitPath(name, home)
|
|
182
|
+
const installed = fs.existsSync(file)
|
|
183
|
+
const active = installed && (kind === 'launchd'
|
|
184
|
+
? quiet(run, 'launchctl', ['print', `gui/${uid}/${plistLabel(name)}`]).ok
|
|
185
|
+
: quiet(run, 'systemctl', ['--user', 'is-active', '--quiet', unitName(name)]).ok)
|
|
186
|
+
return { kind, file, installed, active }
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export default { startService, installService, uninstallService, serviceStatus, unitText, plistText, unitName, unitPath, plistLabel, plistPath }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: dotrino-terminal-note
|
|
3
|
-
description: Mantiene al día la tarea en curso en la tarjeta «de qué va» de la consola de Dotrino Terminal en la que corres (la ve el dueño flotando sobre la consola, en todas sus pantallas). Úsalo AL EMPEZAR cada tarea, cuando la tarea cambia de rumbo, y al terminar o quedar esperando al usuario, siempre que exista la variable de entorno DOTRINO_TERMINAL_CONSOLE. También cuando el usuario diga «nota de la consola», «el flotante», «la tarjeta» o «de qué va este chat». Orden: `dotrino-terminal note --task
|
|
3
|
+
description: Mantiene al día la tarea en curso en la tarjeta «de qué va» de la consola de Dotrino Terminal en la que corres (la ve el dueño flotando sobre la consola, en todas sus pantallas). Úsalo AL EMPEZAR cada tarea, cuando la tarea cambia de rumbo, y al terminar o quedar esperando al usuario, siempre que exista la variable de entorno DOTRINO_TERMINAL_CONSOLE. También cuando el usuario diga «nota de la consola», «el flotante», «la tarjeta» o «de qué va este chat». Orden: `dotrino-terminal note --task … --title …` (la tarea y el título de la consola). Las notas personales del dueño NO se tocan.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# La tarea en curso de la consola (Dotrino Terminal)
|
|
@@ -12,12 +12,14 @@ abiertas, sepa **de qué va la tarea en curso de cada una** sin entrar a leerla.
|
|
|
12
12
|
La tarjeta tiene dos partes, y son dos campos distintos:
|
|
13
13
|
|
|
14
14
|
- **La tarea**: es TUYA. La pones con `--task`. El dueño la ve y puede quitarla, no la edita.
|
|
15
|
+
- **El título**: también es TUYO, con `--title`. Es el nombre de la consola en la tarjeta, en la
|
|
16
|
+
lista y en la barra de la ventana.
|
|
15
17
|
- **Las notas**: son **personales del dueño**. Las escribe él desde la tarjeta. No son tuyas.
|
|
16
18
|
|
|
17
19
|
## Regla dura: las notas personales no se tocan
|
|
18
20
|
|
|
19
|
-
**Usa SOLO `dotrino-terminal note --task
|
|
20
|
-
del dueño.
|
|
21
|
+
**Usa SOLO `dotrino-terminal note --task … --title …`.** Esa orden escribe la tarea y el título, y
|
|
22
|
+
no puede tocar las notas del dueño.
|
|
21
23
|
|
|
22
24
|
**Prohibido**, salvo que el usuario te lo pida con esas palabras en ese momento:
|
|
23
25
|
|
|
@@ -52,15 +54,15 @@ anunciarlo ni comentarlo en la respuesta.
|
|
|
52
54
|
## Cómo
|
|
53
55
|
|
|
54
56
|
```bash
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
# la tarea por la entrada estándar; el título, en la misma orden y SIEMPRE después de --task
|
|
58
|
+
dotrino-terminal note --task - --title 'Login de facturero' <<'EOF_TASK'
|
|
57
59
|
Hecho: el formulario
|
|
58
60
|
Ahora: la validación
|
|
59
61
|
Falta: probar con firma real
|
|
60
62
|
Modelo: Opus 5.5
|
|
61
63
|
EOF_TASK
|
|
62
64
|
|
|
63
|
-
dotrino-terminal note --task '' # quita tu tarea (lo del dueño se queda)
|
|
65
|
+
dotrino-terminal note --task '' # quita tu tarea y tu título (lo del dueño se queda)
|
|
64
66
|
dotrino-terminal note # solo LEER: tu tarea (con «▸ ») y debajo sus notas
|
|
65
67
|
```
|
|
66
68
|
|
|
@@ -68,9 +70,13 @@ No hace falta decir qué consola: es la tuya.
|
|
|
68
70
|
|
|
69
71
|
## Qué escribir
|
|
70
72
|
|
|
71
|
-
- **
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
- **El título (`--title`) = de qué va la tarea, en pocas palabras** (hasta ~40 caracteres): «Login
|
|
74
|
+
de facturero», «Tarjeta de notas en Terminal». No «Trabajando en lo que pidió el usuario». Sin
|
|
75
|
+
él la consola se llama como tu sesión, que se nombró con el primer mensaje y ya no tiene que ver
|
|
76
|
+
con lo que haces: **el dueño lee ese nombre para saber qué consola es cuál**.
|
|
77
|
+
Mándalo en cada actualización. Mientras la tarea sea la misma, **el mismo título** (no lo
|
|
78
|
+
reescribas con otras palabras: lo reconoce por él). Cuando llega otro encargo, cámbialo.
|
|
79
|
+
- La tarea (`--task`) es el estado, en tres o cuatro líneas: `Hecho:` (lo ya cerrado), `Ahora:` (lo que haces en
|
|
74
80
|
este momento), `Falta:` y, si aplica, `Espera:` (a qué). Reescríbela entera cada vez: es el
|
|
75
81
|
estado actual, no un historial.
|
|
76
82
|
- **La última línea dice qué modelo eres**: `Modelo: Opus 5.5` (el nombre con el que te presentas,
|
|
@@ -83,6 +89,9 @@ No hace falta decir qué consola: es la tuya.
|
|
|
83
89
|
## Si falla
|
|
84
90
|
|
|
85
91
|
- «no sé de qué consola» / `no console to act on`: no corres dentro de Dotrino Terminal. Sigue sin nota.
|
|
92
|
+
- «el agente que corre es anterior a la 0.41.0 y no guarda el título»: la tarea sí quedó puesta.
|
|
93
|
+
Díselo al usuario una vez y sigue mandando solo `--task`, con la tarea en una frase como primera
|
|
94
|
+
línea.
|
|
86
95
|
- «el agente que corre es anterior a la 0.37.0 y no guarda tareas», o «el agente no contestó»:
|
|
87
96
|
el agente de esta máquina es viejo. **No uses las otras formas como sustituto**: díselo al
|
|
88
97
|
usuario una vez (`npm i -g @dotrino/terminal-agent@latest` y reiniciarlo él) y sigue sin tarea.
|