corvusmem 0.3.3 → 0.5.1
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 +59 -0
- package/README.md +118 -94
- package/cli/corvusmem.mjs +1 -0
- package/cli/import.mjs +1 -0
- package/cli/memory-check.mjs +2 -1
- package/cli/memory.mjs +2 -1
- package/cli/search.mjs +1 -0
- package/commands/corvus-absorb.md +13 -12
- package/commands/corvus-cortex.md +14 -0
- package/cortex/cortex-text.mjs +7 -6
- package/cortex/cortex.mjs +11 -3
- package/docs.md +125 -108
- package/install.mjs +77 -5
- package/package.json +2 -2
- package/src/facts-guard.mjs +1 -0
- package/src/facts.mjs +5 -3
- package/src/file-memory.mjs +1 -0
- package/src/host.mjs +120 -118
- package/src/import.mjs +1 -0
- package/src/lib.mjs +47 -9
- package/src/live-memory.mjs +1 -0
- package/src/live-recall.mjs +3 -2
- package/src/messages.mjs +1 -0
- package/src/session-end.mjs +1 -0
- package/src/session-start.mjs +3 -2
- package/src/session-state.mjs +1 -0
package/src/host.mjs
CHANGED
|
@@ -1,118 +1,120 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// ·
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
// ·
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
try { fs.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Corvusmem · author: Peterson Sena (r3v3rs3) · https://github.com/petersonsenadevs/corvusmem
|
|
3
|
+
// host.mjs — Detección de anfitrión del núcleo de memoria (carve-out Corvusmem, F9-T2).
|
|
4
|
+
// El MISMO núcleo corre bajo varios anfitriones; aquí se resuelve, por señales del entorno, determinista y sin red:
|
|
5
|
+
// · agente: 'claude' | 'codex' | 'obsidian' | 'standalone' — el runtime que ejecuta el núcleo
|
|
6
|
+
// · senzu: ¿está la capa Senzu presente en el proyecto? — clave para el apretón de manos (F9-T3): si está,
|
|
7
|
+
// el núcleo cede la inyección para no duplicarla
|
|
8
|
+
// · memoria: dónde leer/escribir — { proyecto, usuario (global), estado (sesión) }
|
|
9
|
+
// · inyeccion: por dónde sale el contexto — 'hook-stdout' (claude/codex) | 'plugin-api' (obsidian) | 'stdout'
|
|
10
|
+
// Señales REALES del repo (ver lib.readHookInput): Claude exporta CLAUDE_PROJECT_DIR/CLAUDE_PLUGIN_ROOT; Codex no,
|
|
11
|
+
// y la raíz llega como "cwd" en la entrada, con forma de parche (apply_patch / codex_tool_name); Senzu = marcador
|
|
12
|
+
// senzu/senzu.json (lib.rutaMarcador). Obsidian y standalone aún no corren en este repo: Obsidian lo marca su
|
|
13
|
+
// adaptador (CORVUS_OBSIDIAN, F10-T3); sin señales → standalone. Todo lee de un `env` INYECTABLE: así se testea
|
|
14
|
+
// hermético y queda determinista.
|
|
15
|
+
import fs from 'node:fs';
|
|
16
|
+
import os from 'node:os';
|
|
17
|
+
import path from 'node:path';
|
|
18
|
+
import crypto from 'node:crypto';
|
|
19
|
+
import { pathToFileURL } from 'node:url';
|
|
20
|
+
import { rutaNativa, ruta, rutaMarcador } from './lib.mjs';
|
|
21
|
+
|
|
22
|
+
export const ANFITRIONES = ['claude', 'codex', 'obsidian', 'standalone'];
|
|
23
|
+
|
|
24
|
+
// Espejo de lib.rutaMemoriaUsuario pero leyendo del env inyectado (memoria global, igual en todos los anfitriones).
|
|
25
|
+
const rutaUsuario = env => env.SENZU_MEMORIA_USUARIO || env.DEV_STANDARDS_MEMORIA_USUARIO
|
|
26
|
+
|| path.join(os.homedir(), '.config', 'senzu', 'memoria.md');
|
|
27
|
+
|
|
28
|
+
const existeMarcadorSenzu = raiz => { try { return fs.existsSync(rutaMarcador(raiz)); } catch { return false; } };
|
|
29
|
+
|
|
30
|
+
function detectarAgente(env, input) {
|
|
31
|
+
// 1) Forzado explícito, pero SOLO si es un valor conocido: una variable "mentida"/basura se ignora y se detecta igual
|
|
32
|
+
const forzado = String(env.CORVUS_ANFITRION || '').toLowerCase();
|
|
33
|
+
if (ANFITRIONES.includes(forzado)) return forzado;
|
|
34
|
+
// 2) Obsidian: marcador explícito de su adaptador (gana a Claude: es una señal deliberada, no ambiental)
|
|
35
|
+
if (env.CORVUS_OBSIDIAN) return 'obsidian';
|
|
36
|
+
// 3) Claude: exporta estas variables de entorno
|
|
37
|
+
if (env.CLAUDE_PROJECT_DIR || env.CLAUDE_PLUGIN_ROOT) return 'claude';
|
|
38
|
+
// 4) Codex: no exporta CLAUDE_*; la raíz llega como cwd y la edición como parche
|
|
39
|
+
if (input && (input.codex_tool_name || input.tool_name === 'apply_patch' || input.cwd)) return 'codex';
|
|
40
|
+
// 5) Sin señales: uso directo (CLI / biblioteca)
|
|
41
|
+
return 'standalone';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Resuelve el anfitrión y el mapa de memoria. input = entrada del hook (opcional); env = variables (inyectable);
|
|
45
|
+
// root = raíz del proyecto (opcional; si falta se deduce del env/input/cwd). Solo lectura: no crea carpetas.
|
|
46
|
+
export function resolverHost({ input = {}, env = process.env, root } = {}) {
|
|
47
|
+
const raiz = rutaNativa(root || env.CLAUDE_PROJECT_DIR || (input && input.cwd) || process.cwd());
|
|
48
|
+
const agente = detectarAgente(env, input);
|
|
49
|
+
const senzu = existeMarcadorSenzu(raiz);
|
|
50
|
+
const inyeccion = agente === 'obsidian' ? 'plugin-api' : agente === 'standalone' ? 'stdout' : 'hook-stdout';
|
|
51
|
+
// Corvus's project store is ALWAYS its own .corvusmem/ — it never resolves into senzu/ any more. The `senzu` flag
|
|
52
|
+
// above still drives the hand-off: when Senzu is present Corvus's hooks stand down (lib.cederASenzu), they do not
|
|
53
|
+
// share Senzu's file. Obsidian keeps its vault.
|
|
54
|
+
const proyecto = agente === 'obsidian' ? (env.CORVUS_VAULT || null) : path.join(raiz, '.corvusmem');
|
|
55
|
+
return {
|
|
56
|
+
agente,
|
|
57
|
+
senzu,
|
|
58
|
+
raiz,
|
|
59
|
+
inyeccion,
|
|
60
|
+
memoria: {
|
|
61
|
+
proyecto,
|
|
62
|
+
usuario: rutaUsuario(env),
|
|
63
|
+
estado: path.join(ruta(raiz, '.estado'), 'ultima-sesion.json'), // sin efecto: no crea el dir (a diferencia de lib.rutaEstado)
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// ---------------------------------------------------------------- apretón de manos (F9-T3)
|
|
69
|
+
// Que recuerdo-vivo + session-start (los que emiten additionalContext) no inyecten DOS VECES cuando hay dos capas
|
|
70
|
+
// registradas para el mismo evento (p. ej. el núcleo Corvusmem y el adaptador Senzu). Cerrojo de turno
|
|
71
|
+
// "primero-gana", atómico: la primera invocación de un evento+turno se queda el turno e inyecta; la segunda lo ve
|
|
72
|
+
// y cede. El contenido es el mismo motor en ambas capas, así que da igual quién gane: basta con que inyecte UNA.
|
|
73
|
+
// NO se basa en "quién es Senzu" (en el repo fuente los hooks son los de Senzu pero no hay senzu.json; un cede por
|
|
74
|
+
// marcador los silenciaría): el dueño determinista por capa se decide en F10, cuando cada capa tiene su instalación.
|
|
75
|
+
const sanitClave = s => s.replace(/[^a-zA-Z0-9_.-]/g, '_').slice(0, 180);
|
|
76
|
+
|
|
77
|
+
// Clave del turno: el mismo mensaje/arranque produce la MISMA clave en las dos capas (para que colisionen y una ceda),
|
|
78
|
+
// pero DISTINTA entre proyectos (raíz) y sesiones (sid), para no mezclar turnos de proyectos ni de sesiones distintas.
|
|
79
|
+
function claveTurno(evento, input, root) {
|
|
80
|
+
const sid = String((input && input.session_id) || 'default');
|
|
81
|
+
const raiz = root ? crypto.createHash('md5').update(String(root)).digest('hex').slice(0, 8) : '';
|
|
82
|
+
let huella = '';
|
|
83
|
+
if (evento === 'UserPromptSubmit') huella = crypto.createHash('md5').update(String((input && input.prompt) || '')).digest('hex').slice(0, 12);
|
|
84
|
+
else if (evento === 'SessionStart') huella = String((input && input.source) || '');
|
|
85
|
+
return `${evento}:${raiz}:${sid}:${huella}`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Reclamo atómico: true = me quedo el turno (inyecto); false = ya lo tiene otro fresco (cedo). Creación exclusiva
|
|
89
|
+
// (flag 'wx') → en una carrera de procesos solo uno crea el archivo. Marca caducada (crash/sesión muerta) → se
|
|
90
|
+
// retira y se reintenta. Reloj hacia atrás (ahora < ts) → diff negativa < ttl → fresca → cedo (no caduca en falso).
|
|
91
|
+
function reclamarMarca(f, { pid, ahora, ttlMs }) {
|
|
92
|
+
try { fs.mkdirSync(path.dirname(f), { recursive: true }); } catch { }
|
|
93
|
+
for (let i = 0; i < 2; i++) {
|
|
94
|
+
try {
|
|
95
|
+
fs.writeFileSync(f, JSON.stringify({ pid, ts: ahora }), { flag: 'wx' });
|
|
96
|
+
return true;
|
|
97
|
+
} catch (e) {
|
|
98
|
+
if (e.code !== 'EEXIST') throw e;
|
|
99
|
+
let ts = 0;
|
|
100
|
+
try { ts = (JSON.parse(fs.readFileSync(f, 'utf8')) || {}).ts || 0; } catch { }
|
|
101
|
+
if (ahora - ts < ttlMs) return false; // marca fresca de otra capa: cedo
|
|
102
|
+
try { fs.rmSync(f, { force: true }); } catch { } // marca huérfana: la retiro y reintento
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return false; // otro se adelantó tras retirar la huérfana: cedo
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// ¿Debo inyectar YO este evento? dir inyectable para tests; por defecto el temp con prefijo dev-standards- (lo barre
|
|
109
|
+
// session-end a los 2 días). ttlMs = ventana de un turno: pasada, una marca se considera huérfana.
|
|
110
|
+
export function reclamarInyeccion(evento, { input = {}, root, ahora = Date.now(), ttlMs = 60000, dir } = {}) {
|
|
111
|
+
const clave = claveTurno(evento, input, root);
|
|
112
|
+
const f = dir ? path.join(dir, sanitClave(clave) + '.claim') : path.join(os.tmpdir(), 'dev-standards-hsk-' + sanitClave(clave) + '.flag');
|
|
113
|
+
const inyectar = reclamarMarca(f, { pid: process.pid, ahora, ttlMs });
|
|
114
|
+
return { inyectar, clave, archivo: f, motivo: inyectar ? 'reclamado' : 'ya reclamado este turno' };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// CLI de diagnóstico: `node core/hooks/host.mjs` imprime el anfitrión resuelto aquí y ahora.
|
|
118
|
+
if (process.argv[1] && pathToFileURL(process.argv[1]).href === import.meta.url) {
|
|
119
|
+
process.stdout.write(JSON.stringify(resolverHost(), null, 2) + '\n');
|
|
120
|
+
}
|
package/src/import.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// Corvusmem · author: Peterson Sena (r3v3rs3) · https://github.com/petersonsenadevs/corvusmem
|
|
1
2
|
// Corvus memory import — DISCOVERY ONLY (deterministic, offline, zero-dependency).
|
|
2
3
|
// Finds the memory documents already in a project so nothing a teammate wrote is lost, in two tiers:
|
|
3
4
|
// tier 'agent' — known agent-memory files (CLAUDE.md, AGENTS.md, Cursor/Copilot/Gemini rules, a Senzu
|
package/src/lib.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// Corvusmem · author: Peterson Sena (r3v3rs3) · https://github.com/petersonsenadevs/corvusmem
|
|
1
2
|
// Funciones compartidas por los hooks de Senzu (Node >= 18, ESM).
|
|
2
3
|
// Port agnóstico de _common.ps1: mismo comportamiento en Windows, macOS y Linux.
|
|
3
4
|
// Los hooks leen stdin como UTF-8 directo (sin reparación de codepage OEM: eso era un problema de PowerShell).
|
|
@@ -109,20 +110,21 @@ export function carpetaBase(root) {
|
|
|
109
110
|
if (esLegado(root)) return CARPETA; // legacy Senzu project (root devlog / .dev-standards.json)
|
|
110
111
|
return CARPETA_CORVUS; // no real Senzu (even a stray senzu/) -> Corvus owns its dir
|
|
111
112
|
}
|
|
112
|
-
// Facts storage names.
|
|
113
|
-
//
|
|
113
|
+
// Facts storage names. Corvus's store is ALWAYS its own .corvusmem/memory/facts.jsonl with English names. Corvus is
|
|
114
|
+
// the memory owner: when it is installed, Senzu defers its memory hooks to Corvus (Senzu-side), and Corvus ADOPTS the
|
|
115
|
+
// facts Senzu had in senzu/memoria/hechos.jsonl into its own store (see adoptarMemoriaSenzu) so nothing is lost.
|
|
116
|
+
// MEM_*_ES remain for that adoption and for the one-time migration of pre-0.4 installs (.corvusmem/memoria/ -> memory/).
|
|
114
117
|
export const MEM_DIR_ES = 'memoria', MEM_FACTS_ES = 'hechos.jsonl', MEM_CORRUPT_ES = 'hechos.danado.jsonl';
|
|
115
118
|
export const MEM_DIR_EN = 'memory', MEM_FACTS_EN = 'facts.jsonl', MEM_CORRUPT_EN = 'facts.corrupt.jsonl';
|
|
116
|
-
export function nombresMemoria(
|
|
117
|
-
return
|
|
118
|
-
? { dir: MEM_DIR_EN, facts: MEM_FACTS_EN, corrupt: MEM_CORRUPT_EN }
|
|
119
|
-
: { dir: MEM_DIR_ES, facts: MEM_FACTS_ES, corrupt: MEM_CORRUPT_ES };
|
|
119
|
+
export function nombresMemoria(_root) {
|
|
120
|
+
return { dir: MEM_DIR_EN, facts: MEM_FACTS_EN, corrupt: MEM_CORRUPT_EN };
|
|
120
121
|
}
|
|
121
122
|
// One-time, idempotent migration: older standalone installs kept facts in .corvusmem/memoria/hechos.jsonl.
|
|
122
123
|
// Rename that to .corvusmem/memory/facts.jsonl (and the corrupted-lines file) so a standalone Corvus reads English.
|
|
123
124
|
// NEVER touches a Senzu-coupled or legacy project (base must be .corvusmem). Safe under races: best-effort, swallowed.
|
|
124
125
|
export function migrarMemoriaCorvus(root) {
|
|
125
|
-
|
|
126
|
+
// Runs regardless of Senzu: Corvus's store is always .corvusmem/, so always try to lift an old .corvusmem/memoria/
|
|
127
|
+
// into .corvusmem/memory/. It only ever touches Corvus's own dir and is idempotent, so it is safe everywhere.
|
|
126
128
|
const base = path.join(root, CARPETA_CORVUS), viejoDir = path.join(base, MEM_DIR_ES), nuevoDir = path.join(base, MEM_DIR_EN);
|
|
127
129
|
try {
|
|
128
130
|
if (!fs.existsSync(path.join(viejoDir, MEM_FACTS_ES)) || fs.existsSync(path.join(nuevoDir, MEM_FACTS_EN))) return;
|
|
@@ -134,11 +136,47 @@ export function migrarMemoriaCorvus(root) {
|
|
|
134
136
|
try { if (!fs.readdirSync(viejoDir).length) fs.rmdirSync(viejoDir); } catch { } // si queda vacía, se va
|
|
135
137
|
} catch { /* best-effort: si no se puede migrar, se sigue leyendo el viejo via ruta() */ }
|
|
136
138
|
}
|
|
139
|
+
// One-time adoption: when Corvus takes over a project that already used Senzu, lift the facts Senzu kept in
|
|
140
|
+
// senzu/memoria/hechos.jsonl into Corvus's own .corvusmem/memory/facts.jsonl (COPY, not move: Senzu's file is left
|
|
141
|
+
// intact, so nothing breaks mid-migration and it is reversible). Runs only when Corvus's store does not exist yet, so
|
|
142
|
+
// it seeds once and never clobbers Corvus's own facts. Best-effort and idempotent.
|
|
143
|
+
export function adoptarMemoriaSenzu(root) {
|
|
144
|
+
try {
|
|
145
|
+
const corvus = path.join(root, CARPETA_CORVUS, MEM_DIR_EN, MEM_FACTS_EN);
|
|
146
|
+
if (fs.existsSync(corvus)) return; // Corvus ya tiene su memoria: no se toca
|
|
147
|
+
const senzu = path.join(root, CARPETA, MEM_DIR_ES, MEM_FACTS_ES); // senzu/memoria/hechos.jsonl
|
|
148
|
+
if (!fs.existsSync(senzu)) return; // no hay memoria de Senzu que adoptar
|
|
149
|
+
fs.mkdirSync(path.dirname(corvus), { recursive: true });
|
|
150
|
+
fs.copyFileSync(senzu, corvus); // hereda los hechos (copia, no mueve)
|
|
151
|
+
const senzuBad = path.join(root, CARPETA, MEM_DIR_ES, MEM_CORRUPT_ES);
|
|
152
|
+
const corvusBad = path.join(root, CARPETA_CORVUS, MEM_DIR_EN, MEM_CORRUPT_EN);
|
|
153
|
+
if (fs.existsSync(senzuBad) && !fs.existsSync(corvusBad)) { try { fs.copyFileSync(senzuBad, corvusBad); } catch { } }
|
|
154
|
+
} catch { /* best-effort: si no se puede adoptar, Corvus arranca con su memoria vacía */ }
|
|
155
|
+
}
|
|
156
|
+
// Cómo debe GUARDAR/RECORDAR el agente, lo más rápido disponible (sin el arranque en frío de npx):
|
|
157
|
+
// 1) Plugin (Claude/Codex): el hook corre con CLAUDE_PLUGIN_ROOT y el CLI va empaquetado en <plugin>/cli/. Se emite
|
|
158
|
+
// la ruta ABSOLUTA porque el Bash del agente no tiene esa variable.
|
|
159
|
+
// 2) Proyecto (install): el CLI está en .corvusmem/cli/ y ${CLAUDE_PROJECT_DIR} sí lo tiene el agente (portable).
|
|
160
|
+
// 3) Global (install --global): CLI en ~/.config/corvusmem/cli/ (ruta absoluta al HOME).
|
|
161
|
+
// 4) Fallback para agentes SIN estos estándares (ni plugin ni install): `npx corvusmem` (lento pero siempre funciona).
|
|
162
|
+
export function rutaCliMemoria(root) {
|
|
163
|
+
const node = f => `node "${String(f).replace(/\\/g, '/')}"`;
|
|
164
|
+
try {
|
|
165
|
+
const pr = process.env.CLAUDE_PLUGIN_ROOT;
|
|
166
|
+
if (pr && fs.existsSync(path.join(pr, 'cli', 'corvusmem.mjs'))) return node(path.join(pr, 'cli', 'corvusmem.mjs'));
|
|
167
|
+
if (fs.existsSync(path.join(root, CARPETA_CORVUS, 'cli', 'corvusmem.mjs'))) return 'node "${CLAUDE_PROJECT_DIR}/.corvusmem/cli/corvusmem.mjs"';
|
|
168
|
+
const g = path.join(os.homedir(), '.config', 'corvusmem', 'cli', 'corvusmem.mjs');
|
|
169
|
+
if (fs.existsSync(g)) return node(g);
|
|
170
|
+
} catch { }
|
|
171
|
+
return 'npx corvusmem';
|
|
172
|
+
}
|
|
137
173
|
const VIEJA = { 'ui-verify': '.ui-verify', 'senzu.json': '.dev-standards.json', auditoria: 'docs/auditoria', entrega: 'docs/entrega', 'mapa.md': 'docs/MAPA.md' };
|
|
138
174
|
export function ruta(root, nombre) { // 'devlog' | 'plan' | 'design-system' | 'conventions.md' | 'conventions.json' | 'ui-verify' | 'senzu.json' | 'memoria'
|
|
175
|
+
// MEMORY is ALWAYS Corvus's own, in English, and never flips with Senzu's presence: .corvusmem/memory/. The store
|
|
176
|
+
// never moves when Senzu is added or removed; Corvus is the memory owner and Senzu defers to it (Senzu-side hayCorvus).
|
|
177
|
+
if (nombre === 'memoria') return path.join(root, CARPETA_CORVUS, MEM_DIR_EN);
|
|
139
178
|
const base = carpetaBase(root);
|
|
140
|
-
|
|
141
|
-
const nombreReal = nombre === 'memoria' && base === CARPETA_CORVUS ? MEM_DIR_EN : nombre;
|
|
179
|
+
const nombreReal = nombre;
|
|
142
180
|
const nueva = path.join(root, base, nombreReal);
|
|
143
181
|
const vieja = path.join(root, VIEJA[nombre] || nombre);
|
|
144
182
|
const [primera, segunda] = esLegado(root) ? [vieja, nueva] : [nueva, vieja];
|
package/src/live-memory.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// Corvusmem · author: Peterson Sena (r3v3rs3) · https://github.com/petersonsenadevs/corvusmem
|
|
1
2
|
// Hook UserPromptSubmit: la memoria se alimenta de lo que dice el usuario, no de que el agente se acuerde.
|
|
2
3
|
// 1. Guarda las últimas peticiones de la sesión (las lee estado-sesion para /retomar).
|
|
3
4
|
// 2. Si la petición trae una REGLA o una CORRECCIÓN clara («no vuelvas a…», «te dije…», «a partir de ahora…»,
|
package/src/live-recall.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// Corvusmem · author: Peterson Sena (r3v3rs3) · https://github.com/petersonsenadevs/corvusmem
|
|
1
2
|
// Hook UserPromptSubmit: el RECUERDO VIVO. Con cada mensaje del usuario, lo que la memoria ya sabe de eso —hechos
|
|
2
3
|
// (en cualquier idioma), decisiones de MEMORIA.md y entradas del devlog— llega al agente antes de responder, con su
|
|
3
4
|
// fuente y su motivo. Así no pregunta lo que ya se sabe ni contradice lo decidido (plan de Corvusmem, F2-T2).
|
|
@@ -6,7 +7,7 @@
|
|
|
6
7
|
|
|
7
8
|
import fs from 'node:fs';
|
|
8
9
|
import crypto from 'node:crypto';
|
|
9
|
-
import { readHookInput, projectRoot, sessionFlag, outHookJson, esMensajeDelUsuario, localeUI, msg } from './lib.mjs';
|
|
10
|
+
import { readHookInput, projectRoot, sessionFlag, outHookJson, esMensajeDelUsuario, localeUI, msg, rutaCliMemoria } from './lib.mjs';
|
|
10
11
|
import { reclamarInyeccion } from './host.mjs';
|
|
11
12
|
import { recuerdo, palabras, palabraConPeso, UMBRAL_RECUERDO, anotarUso, apuntarInyeccion, mapaMemoria, textoMapa, intencionTemporal } from './facts.mjs';
|
|
12
13
|
|
|
@@ -47,7 +48,7 @@ const elegidos = todos
|
|
|
47
48
|
if (elegidos.length || !todos.some(x => (x.fuente === 'hecho' ? x.puntuacion >= UMBRAL_HECHO : x.puntuacion > 0))) apuntarInyeccion(root, { sid, origen: 'mensaje', consulta, items: elegidos });
|
|
48
49
|
// X-T9: el agente no sabe qué hay si nadie se lo dice. Sin nada que coincida, con un mensaje con contenido (2+ palabras
|
|
49
50
|
// con peso), una línea: lo que tiene la memoria y cómo consultarla (es un índice, no datos inventados)
|
|
50
|
-
const cli =
|
|
51
|
+
const cli = rutaCliMemoria(root); // plugin/proyecto/global → node directo (rápido); npx como fallback
|
|
51
52
|
if (!elegidos.length) {
|
|
52
53
|
// (solo si de verdad no coincide NADA: si coincidía algo ya dicho en la sesión, decir «no hay nada» sería falso)
|
|
53
54
|
const nada = !todos.some(x => (x.fuente === 'hecho' ? x.puntuacion >= UMBRAL_HECHO : x.puntuacion > 0));
|
package/src/messages.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// Corvusmem · author: Peterson Sena (r3v3rs3) · https://github.com/petersonsenadevs/corvusmem
|
|
1
2
|
// Catalogo de los mensajes de la UI que ve el usuario (muros, avisos), por idioma. El CONTENIDO de las skills
|
|
2
3
|
// NO esta aqui: lo lee el agente, que responde en el idioma del usuario. Un id por mensaje; valor {en, es}.
|
|
3
4
|
// - El idioma lo resuelve localeUI(root) en lib.mjs (por defecto 'en').
|
package/src/session-end.mjs
CHANGED
package/src/session-start.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// Corvusmem · author: Peterson Sena (r3v3rs3) · https://github.com/petersonsenadevs/corvusmem
|
|
1
2
|
// Hook SessionStart (Corvusmem): inyecta SOLO la memoria del proyecto y del usuario — hechos vigentes, objetivos y
|
|
2
3
|
// pendientes abiertos, avisos de contradicción/obsolescencia, el mapa de la memoria y la continuidad de la sesión
|
|
3
4
|
// anterior. Por defecto en inglés (localeUI → catálogo messages.mjs). No bloquea.
|
|
@@ -5,7 +6,7 @@
|
|
|
5
6
|
// (p. ej. Senzu), no del motor de memoria. Corvusmem instalado solo habla de memoria y nada más.
|
|
6
7
|
|
|
7
8
|
import {
|
|
8
|
-
readHookInput, projectRoot, outHookJson, leerUltimaSesion, localeUI, msg,
|
|
9
|
+
readHookInput, projectRoot, outHookJson, leerUltimaSesion, localeUI, msg, rutaCliMemoria,
|
|
9
10
|
} from './lib.mjs';
|
|
10
11
|
import { contextoHechos, decisionesObsoletas, abiertos, FAMILIAS_CICLO, contradicciones, mapaMemoria, textoMapa, etiquetaDimension } from './facts.mjs';
|
|
11
12
|
import { reclamarInyeccion } from './host.mjs';
|
|
@@ -19,7 +20,7 @@ const L = [];
|
|
|
19
20
|
// Los valores son DATOS: entre comillas, en una línea y recortados (un hecho que dijera «ignora las reglas» no puede
|
|
20
21
|
// colarse como instrucción).
|
|
21
22
|
const citar = v => '«' + String(v).replace(/[\r\n\t]+/g, ' ').replace(/[«»]/g, '"').trim().slice(0, 160) + (String(v).length > 160 ? '…' : '') + '»';
|
|
22
|
-
const cli =
|
|
23
|
+
const cli = rutaCliMemoria(root); // plugin/proyecto/global → node directo (rápido); npx como fallback
|
|
23
24
|
try {
|
|
24
25
|
// Memoria de HECHOS (motor determinista, cualquier idioma): lo vigente por familias (objetivos y pendientes, abajo).
|
|
25
26
|
const hechos = contextoHechos(root, { presupuesto: 12 }).filter(h => !FAMILIAS_CICLO.test(h.dimension));
|
package/src/session-state.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// Corvusmem · author: Peterson Sena (r3v3rs3) · https://github.com/petersonsenadevs/corvusmem
|
|
1
2
|
// Hook Stop y PreCompact: guarda EN QUÉ ESTÁBAMOS para la siguiente sesión (/retomar), y al cerrar comprueba que
|
|
2
3
|
// las reglas y correcciones del usuario de esta sesión (las detecta memoria-viva) quedaron apuntadas.
|
|
3
4
|
// El estado va a senzu/.estado/ultima-sesion.json (ignorado por git): las últimas peticiones, los archivos que
|