Files
gnome-jarvis/vendor/agent-harness/agent/memory-format.js
T
2026-09-11 13:41:22 -04:00

23 lines
504 B
JavaScript

/**
* Format memory hits for prompt injection. No Bare imports.
*/
function formatInject(hits, max) {
const list = (hits || []).slice(0, max || 5);
if (!list.length) return '';
return (
'[memory]\n' +
list
.map((h) => {
const snip = String(h.snippet || '')
.replace(/\s+/g, ' ')
.trim()
.slice(0, 220);
return '- ' + (h.name || 'note') + (snip ? ': ' + snip : '');
})
.join('\n')
);
}
module.exports = { formatInject };