mirror of
https://github.com/mudler/LocalAI.git
synced 2026-11-07 04:53:24 -05:00
The add-on declares the three index files of the person's notes (capabilities.contextFiles, manifest API 2), so the host loads them into the prompt and serves their topics with context_read. It ships two skills: memory, whose description asks the model to read the matching topic before it answers almost anything and to save a note only as a proposal the person confirms, and memory-check-own-files, which says what the model can and cannot read. Its executable serves no tool, and its page explains the notes and opens the Memory tab of the account. The add-on joins the packaging matrix, the release workflow, the library index and the case inventory. The declared capabilities the host hands to an add-on now include the context files. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
38 lines
1.6 KiB
JavaScript
38 lines
1.6 KiB
JavaScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { load, draw } from './load.mjs'
|
|
|
|
test('page: it says how the notes work and offers to open them', async () => {
|
|
const { mod, sdk } = await load()
|
|
const addon = mod.createAddon(sdk)
|
|
const html = draw(addon, { page: 'memory' })
|
|
assert.match(html, /data-testid="memory-page"/)
|
|
assert.match(html, /Short memory/)
|
|
assert.match(html, /saved only after you confirm/)
|
|
assert.match(html, /data-testid="memory-open"/)
|
|
})
|
|
|
|
test('page: it draws nothing for a page it does not own', async () => {
|
|
const { mod, sdk } = await load()
|
|
assert.equal(draw(mod.createAddon(sdk), { page: 'other' }), '')
|
|
})
|
|
|
|
test('page: the button opens the Memory tab of the account', async () => {
|
|
const { mod, sdk } = await load()
|
|
const opened = []
|
|
const addon = mod.createAddon({ ...sdk, navigation: { ...sdk.navigation, openApp: (a) => opened.push(a) } })
|
|
const tree = addon.Component({ page: 'memory' })
|
|
const button = JSON.stringify(tree, (k, v) => (typeof v === 'function' ? 'fn' : v))
|
|
assert.match(button, /memory-open/)
|
|
// The handler is the one prop of type function on the button.
|
|
const find = (node) => {
|
|
if (!node || typeof node !== 'object') return null
|
|
if (node.props && node.props['data-testid'] === 'memory-open') return node
|
|
const kids = node.props ? [].concat(node.props.children || []) : []
|
|
for (const k of kids) { const r = find(k); if (r) return r }
|
|
return null
|
|
}
|
|
find(tree).props.onClick()
|
|
assert.deepEqual(opened, [mod.NOTES_ADDRESS || '/app/account?tab=memory'])
|
|
})
|