rag-service/docs/sesion_actual_opencode.md
2026-04-05 17:49:35 +02:00

41 lines
1.4 KiB
Markdown

# Sesion actual de OpenCode (instruccion universal para cualquier agente)
Objetivo:
- Que cualquier agente, incluso uno simple, pueda identificar su sesion del workspace actual sin ambiguedad.
## Mensaje exacto para dar al agente
Copiar y pegar tal cual:
```text
Lee `docs/sesion_actual_opencode.md` y ejecuta exactamente este comando para identificar tu sesion del workspace actual:
opencode db "SELECT id,title,directory,datetime(time_updated/1000,'unixepoch','localtime') AS updated FROM session WHERE directory='$(pwd)' ORDER BY time_updated DESC LIMIT 1" --format tsv
Luego responde SOLO con:
1) `session_id`
2) `title`
3) `directory`
4) `updated`
Si no hay filas, responde exactamente: `SIN_SESION_EN_ESTE_WORKSPACE`.
No inventes datos.
```
## Comando canonico (fuente de verdad)
```bash
opencode db "SELECT id,title,directory,datetime(time_updated/1000,'unixepoch','localtime') AS updated FROM session WHERE directory='$(pwd)' ORDER BY time_updated DESC LIMIT 1" --format tsv
```
## Continuar automaticamente la sesion detectada
```bash
opencode -s "$(opencode db \"SELECT id FROM session WHERE directory='$(pwd)' ORDER BY time_updated DESC LIMIT 1\" --format tsv | awk 'NR==2{print $1}')"
```
## Ver historial corto del workspace actual (ultimas 10)
```bash
opencode db "SELECT id,title,datetime(time_updated/1000,'unixepoch','localtime') AS updated FROM session WHERE directory='$(pwd)' ORDER BY time_updated DESC LIMIT 10" --format tsv
```