@equationalapplications/expo-llm-wiki 4.15.3 → 4.17.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 +82 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -18,7 +18,8 @@ Local-first LLM memory for Expo and React Native. Combines the core semantic sea
|
|
|
18
18
|
- **Retrieval tuning** — Per-call overrides for search behavior (pre-filter, hybrid blend, tier weights)
|
|
19
19
|
- **Multi-entity reads** — Search across multiple `entity_id` namespaces in one pass with `tierWeights`
|
|
20
20
|
- **Source provenance** — `WikiFact.source_type` distinguishes immutable document facts (`immutable_document`) from mutable derived/user facts. Immutable document content is protected from librarian/heal rewriting and only changed by `forget()` or re-ingest.
|
|
21
|
-
- **
|
|
21
|
+
- **Seeded ontologies** — Enforce strict taxonomies or allow emergent graph relationship extraction (`useOntologyManifest`, `useSetOntologyManifest`; Strict, Emergent, or Off; defaults to Off).
|
|
22
|
+
- **React hooks** — `WikiProvider`, `useMemoryRead`, `useOntologyManifest`, `useSetOntologyManifest`, `useWikiTraversal`, and all other hooks re-exported from `@equationalapplications/expo-llm-wiki`
|
|
22
23
|
- **Full-featured memory** — Facts, tasks, events, maintenance jobs (librarian, heal, reembed, prune)
|
|
23
24
|
- **Interoperability:** Supports [Open Knowledge Format (OKF) v0.1](https://github.com/GoogleCloudPlatform/knowledge-catalog/tree/main/okf) import and export.
|
|
24
25
|
|
|
@@ -233,6 +234,73 @@ export function EntityLoadingSpinner({ entityId }: { entityId: string }) {
|
|
|
233
234
|
}
|
|
234
235
|
```
|
|
235
236
|
|
|
237
|
+
### `useOntologyManifest(entityId)`
|
|
238
|
+
|
|
239
|
+
Reactive read — fetches on mount and when `entityId` or `wiki` changes:
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
import { useOntologyManifest } from '@equationalapplications/expo-llm-wiki';
|
|
243
|
+
|
|
244
|
+
const { manifest, mode, isPending, error, refetch } = useOntologyManifest('user-123');
|
|
245
|
+
// manifest: OntologyManifest | null
|
|
246
|
+
// mode: OntologyMode | null ('strict' | 'emergent' | 'off' when present)
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
Note: `manifest` and `mode` are `null` when the entity has no persisted or seeded manifest (`getOntologyManifest` returned `null`). Call `refetch()` after mutations to refresh.
|
|
250
|
+
|
|
251
|
+
### `useSetOntologyManifest()`
|
|
252
|
+
|
|
253
|
+
Mutation — same `{ execute, isPending, error, lastResult }` contract as `useWikiWrite`:
|
|
254
|
+
|
|
255
|
+
```typescript
|
|
256
|
+
import { useOntologyManifest, useSetOntologyManifest } from '@equationalapplications/expo-llm-wiki';
|
|
257
|
+
|
|
258
|
+
export function OntologySettings({ entityId }: { entityId: string }) {
|
|
259
|
+
const { manifest, mode, refetch } = useOntologyManifest(entityId);
|
|
260
|
+
const { execute, isPending, error } = useSetOntologyManifest();
|
|
261
|
+
|
|
262
|
+
const handleSave = async () => {
|
|
263
|
+
await execute(entityId, {
|
|
264
|
+
node_types: [{ type: 'person', description: 'An individual.' }],
|
|
265
|
+
edge_types: [{
|
|
266
|
+
type: 'reports_to',
|
|
267
|
+
source_type: 'person',
|
|
268
|
+
target_type: 'person',
|
|
269
|
+
description: 'Reporting hierarchy.',
|
|
270
|
+
}],
|
|
271
|
+
}, { mode: 'strict' });
|
|
272
|
+
refetch();
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
// render manifest/mode; wire handleSave to a save button
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Global defaults and `seedManifests` bootstrap are configured at construction time via `createWiki(..., { config: { ontology: ... } })`. See the [core package README § Per-Entity Seeded Ontology](https://github.com/equationalapplications/expo-llm-wiki/blob/main/packages/core/README.md#per-entity-seeded-ontology) for mode semantics and manifest schema.
|
|
280
|
+
|
|
281
|
+
`useSetOntologyManifest` does not automatically refresh `useOntologyManifest` — call `refetch()` after a successful `execute()`, same as `useWikiWrite` + `useMemoryRead`.
|
|
282
|
+
|
|
283
|
+
### `useWikiTraversal(entityId, options)`
|
|
284
|
+
|
|
285
|
+
Reactive read — fetches on mount and whenever `entityId` or `options` change. Walks the knowledge graph N hops outward from a fact (`options.sourceId`) using edges written by `runLibrarian()`/`ingestDocument()`'s Seeded Ontology extraction pass:
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
import { useWikiTraversal, formatGraphContext } from '@equationalapplications/expo-llm-wiki';
|
|
289
|
+
|
|
290
|
+
const { nodes, edges, isPending, error, refetch } = useWikiTraversal('user-123', {
|
|
291
|
+
sourceId: 'fact_42',
|
|
292
|
+
maxDepth: 2,
|
|
293
|
+
direction: 'both',
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
const promptContext = formatGraphContext({ nodes, edges });
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
- `maxDepth` is clamped to `[1, 3]` regardless of input.
|
|
300
|
+
- `edgeTypes: []` (explicit empty array) matches nothing; omitting it matches all edge types.
|
|
301
|
+
- Defaults (`maxTraversalNodes`, `minTraversalConfidence`, `traversalDirection`, `excludeSourceTypes`) can be set globally via `createWiki(..., { config: { maxTraversalNodes: 20, ... } })` and overridden per-call.
|
|
302
|
+
- `formatGraphContext()` is a pure function — call it with the hook's `{ nodes, edges }` to get a dense text block suitable for prompt injection.
|
|
303
|
+
|
|
236
304
|
## Component Lifecycle
|
|
237
305
|
|
|
238
306
|
```mermaid
|
|
@@ -244,6 +312,8 @@ flowchart TD
|
|
|
244
312
|
C -->|"useWikiIngest()"| F["[Ingest Document]"]
|
|
245
313
|
C -->|"useWikiForget()"| G["[Delete Memory]"]
|
|
246
314
|
C -->|"useWikiMaintenance()"| H["[Run Jobs]"]
|
|
315
|
+
C -->|"useOntologyManifest(entityId)"| S["[Read Ontology]"]
|
|
316
|
+
C -->|"useSetOntologyManifest()"| T["[Update Ontology]"]
|
|
247
317
|
D --> I{"entityId, query, wiki,<br/>or ReadOptions changed?"}
|
|
248
318
|
I -->|"Yes"| J["Auto-refetch"]
|
|
249
319
|
I -->|"No"| K["Return cached data"]
|
|
@@ -252,10 +322,17 @@ flowchart TD
|
|
|
252
322
|
M --> N["Phase 1: Score facts<br/>Phase 2: Fetch winners"]
|
|
253
323
|
N --> O["Update component state"]
|
|
254
324
|
O --> P["Re-render with data"]
|
|
325
|
+
S --> I2{"entityId or wiki changed?"}
|
|
326
|
+
I2 -->|"Yes"| J2["Auto-refetch"]
|
|
327
|
+
I2 -->|"No"| K2["Return cached manifest/mode"]
|
|
328
|
+
J2 --> L2["Trigger getOntologyManifest()"]
|
|
329
|
+
L2 --> O2["Update component state"]
|
|
330
|
+
O2 --> P2["Re-render with manifest/mode"]
|
|
255
331
|
E --> Q["Execute write()"]
|
|
256
332
|
F --> Q
|
|
257
333
|
G --> Q
|
|
258
334
|
H --> Q
|
|
335
|
+
T --> Q
|
|
259
336
|
Q --> R["Write completes"]
|
|
260
337
|
```
|
|
261
338
|
|
|
@@ -263,8 +340,10 @@ flowchart TD
|
|
|
263
340
|
1. **Wrap app** with `<WikiProvider wiki={wiki}>` — provides wiki context
|
|
264
341
|
2. **Use hooks** in components — access memory reactively
|
|
265
342
|
3. **Read operations** auto-refetch when `entityId`, `query`, `wiki`, or `ReadOptions` values change; call `refetch()` to refresh manually
|
|
266
|
-
4. **
|
|
267
|
-
5. **
|
|
343
|
+
4. **Ontology reads** auto-refetch when `entityId` or `wiki` changes; call `refetch()` manually after ontology mutations
|
|
344
|
+
5. **Write operations** (write, ingest, forget, maintenance) do not automatically re-trigger `useMemoryRead`; call `refetch()` after a write to refresh read results
|
|
345
|
+
6. **Ontology writes** (`useSetOntologyManifest`) do not automatically re-trigger `useOntologyManifest` in the same component unless `refetch()` is called after `execute()` succeeds
|
|
346
|
+
7. **Re-render** with new data flowing back to UI
|
|
268
347
|
|
|
269
348
|
## Retrieval Engine Internals
|
|
270
349
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equationalapplications/expo-llm-wiki",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.17.0",
|
|
4
4
|
"description": "Local-first LLM memory for Expo and React Native. Combines the core semantic search and extraction engine with expo-sqlite and ready-to-use React hooks.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"registry": "https://registry.npmjs.org"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@equationalapplications/
|
|
59
|
-
"@equationalapplications/
|
|
58
|
+
"@equationalapplications/core-llm-wiki": "4.17.0",
|
|
59
|
+
"@equationalapplications/react-llm-wiki": "4.17.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"expo-sqlite": "^14.0.0 || ^15.0.0 || ^55.0.0 || ^56.0.0",
|