@semiont/make-meaning 0.2.30-build.61 → 0.2.30-build.63
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 +109 -10
- package/dist/index.d.ts +471 -159
- package/dist/index.js +2912 -1599
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,6 +21,30 @@ This package transforms raw resources into meaningful, interconnected knowledge
|
|
|
21
21
|
npm install @semiont/make-meaning
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
+
### Start Make-Meaning Service
|
|
25
|
+
|
|
26
|
+
The simplest way to use make-meaning infrastructure is through the service module:
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { startMakeMeaning } from '@semiont/make-meaning';
|
|
30
|
+
import type { EnvironmentConfig } from '@semiont/core';
|
|
31
|
+
|
|
32
|
+
// Start all infrastructure (job queue, workers, graph consumer)
|
|
33
|
+
const makeMeaning = await startMakeMeaning(config);
|
|
34
|
+
|
|
35
|
+
// Access job queue for route handlers
|
|
36
|
+
const jobQueue = makeMeaning.jobQueue;
|
|
37
|
+
|
|
38
|
+
// Graceful shutdown
|
|
39
|
+
await makeMeaning.stop();
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This single call initializes:
|
|
43
|
+
- Job queue
|
|
44
|
+
- All 6 detection/generation workers
|
|
45
|
+
- Graph consumer (event-to-graph synchronization)
|
|
46
|
+
- Shared event store connection
|
|
47
|
+
|
|
24
48
|
### Assemble Resource Context
|
|
25
49
|
|
|
26
50
|
```typescript
|
|
@@ -94,7 +118,9 @@ const paths = await GraphContext.findPath(fromResourceId, toResourceId, config,
|
|
|
94
118
|
const results = await GraphContext.searchResources('neural networks', config, 10);
|
|
95
119
|
```
|
|
96
120
|
|
|
97
|
-
### Use
|
|
121
|
+
### Use Individual Workers (Advanced)
|
|
122
|
+
|
|
123
|
+
For fine-grained control, workers can be instantiated directly:
|
|
98
124
|
|
|
99
125
|
```typescript
|
|
100
126
|
import {
|
|
@@ -108,7 +134,7 @@ import { createEventStore } from '@semiont/event-sourcing';
|
|
|
108
134
|
// Create shared dependencies
|
|
109
135
|
const jobQueue = new JobQueue({ dataDir: './data' });
|
|
110
136
|
await jobQueue.initialize();
|
|
111
|
-
const eventStore =
|
|
137
|
+
const eventStore = createEventStore('./data', 'http://localhost:3000');
|
|
112
138
|
|
|
113
139
|
// Create workers with explicit dependencies
|
|
114
140
|
const referenceWorker = new ReferenceDetectionWorker(jobQueue, config, eventStore);
|
|
@@ -123,6 +149,8 @@ await Promise.all([
|
|
|
123
149
|
]);
|
|
124
150
|
```
|
|
125
151
|
|
|
152
|
+
**Note**: In most cases, use `startMakeMeaning()` instead, which handles all initialization automatically.
|
|
153
|
+
|
|
126
154
|
## Documentation
|
|
127
155
|
|
|
128
156
|
- **[API Reference](./docs/api-reference.md)** - Complete API documentation for all classes and methods
|
|
@@ -140,6 +168,59 @@ Resources don't exist in isolation. A document becomes meaningful when we unders
|
|
|
140
168
|
|
|
141
169
|
This is the "applied meaning-making" layer - it sits between low-level AI primitives ([@semiont/inference](../inference/)) and high-level application orchestration ([apps/backend](../../apps/backend/)).
|
|
142
170
|
|
|
171
|
+
## Infrastructure Ownership
|
|
172
|
+
|
|
173
|
+
**MakeMeaningService is the single source of truth for all infrastructure:**
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
import { startMakeMeaning } from '@semiont/make-meaning';
|
|
177
|
+
|
|
178
|
+
// Create ALL infrastructure once at startup
|
|
179
|
+
const makeMeaning = await startMakeMeaning(config);
|
|
180
|
+
|
|
181
|
+
// Access infrastructure components
|
|
182
|
+
const { eventStore, graphDb, repStore, inferenceClient, jobQueue } = makeMeaning;
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**What MakeMeaningService Owns:**
|
|
186
|
+
|
|
187
|
+
1. **EventStore** - Event log and materialized views (single source of truth)
|
|
188
|
+
2. **GraphDatabase** - Graph database connection for relationships and traversal
|
|
189
|
+
3. **RepresentationStore** - Content-addressed document storage
|
|
190
|
+
4. **InferenceClient** - LLM client for AI operations
|
|
191
|
+
5. **JobQueue** - Background job processing queue
|
|
192
|
+
6. **Workers** - All 6 detection/generation workers
|
|
193
|
+
7. **GraphDBConsumer** - Event-to-graph synchronization
|
|
194
|
+
|
|
195
|
+
**Critical Design Rule:**
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
// ✅ CORRECT: Access infrastructure from MakeMeaningService
|
|
199
|
+
const { graphDb } = makeMeaning;
|
|
200
|
+
|
|
201
|
+
// ❌ WRONG: NEVER create infrastructure outside of startMakeMeaning()
|
|
202
|
+
const graphDb = await getGraphDatabase(config); // NEVER DO THIS
|
|
203
|
+
const repStore = new FilesystemRepresentationStore(...); // NEVER DO THIS
|
|
204
|
+
const eventStore = createEventStore(...); // NEVER DO THIS
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**Why This Matters:**
|
|
208
|
+
|
|
209
|
+
- **Single initialization** - All infrastructure created once, shared everywhere
|
|
210
|
+
- **No resource leaks** - Single connection per resource type (database, storage, etc.)
|
|
211
|
+
- **Consistent configuration** - Same config across all components
|
|
212
|
+
- **Testability** - Single injection point for mocking
|
|
213
|
+
- **Lifecycle management** - Centralized shutdown via `makeMeaning.stop()`
|
|
214
|
+
|
|
215
|
+
**Implementation Pattern:**
|
|
216
|
+
|
|
217
|
+
- Backend creates MakeMeaningService in [apps/backend/src/index.ts:56](../../apps/backend/src/index.ts#L56)
|
|
218
|
+
- Routes access via Hono context: `c.get('makeMeaning')`
|
|
219
|
+
- Services receive infrastructure as parameters (dependency injection)
|
|
220
|
+
- Workers receive EventStore and InferenceClient via constructor
|
|
221
|
+
|
|
222
|
+
This architectural pattern prevents duplicate connections, ensures consistent state, and provides clear ownership boundaries across the entire system.
|
|
223
|
+
|
|
143
224
|
## Architecture
|
|
144
225
|
|
|
145
226
|
Three-layer design separating concerns:
|
|
@@ -147,8 +228,8 @@ Three-layer design separating concerns:
|
|
|
147
228
|
```mermaid
|
|
148
229
|
graph TB
|
|
149
230
|
Backend["<b>apps/backend</b><br/>Job orchestration, HTTP APIs, streaming"]
|
|
150
|
-
MakeMeaning["<b>@semiont/make-meaning</b><br/>Context assembly,
|
|
151
|
-
Inference["<b>@semiont/inference</b><br/>AI primitives
|
|
231
|
+
MakeMeaning["<b>@semiont/make-meaning</b><br/>Context assembly, detection/generation,<br/>prompt engineering, response parsing,<br/>job workers"]
|
|
232
|
+
Inference["<b>@semiont/inference</b><br/>AI primitives only:<br/>generateText, client management"]
|
|
152
233
|
|
|
153
234
|
Backend --> MakeMeaning
|
|
154
235
|
MakeMeaning --> Inference
|
|
@@ -160,26 +241,40 @@ graph TB
|
|
|
160
241
|
|
|
161
242
|
**Key principles:**
|
|
162
243
|
|
|
244
|
+
- **Centralized infrastructure**: All infrastructure owned by MakeMeaningService (single initialization point)
|
|
163
245
|
- **Event-sourced context**: Resources and annotations assembled from event streams
|
|
164
246
|
- **Content-addressed storage**: Content retrieved using checksums (deduplication, caching)
|
|
165
247
|
- **Graph-backed relationships**: @semiont/graph provides traversal for backlinks, paths, connections
|
|
166
|
-
- **Explicit dependencies**: Workers receive
|
|
248
|
+
- **Explicit dependencies**: Workers receive infrastructure via constructor (dependency injection, no singletons)
|
|
249
|
+
- **No ad-hoc creation**: Routes and services NEVER create their own infrastructure instances
|
|
167
250
|
|
|
168
251
|
See [Architecture](./docs/architecture.md) for complete details.
|
|
169
252
|
|
|
170
253
|
## Exports
|
|
171
254
|
|
|
255
|
+
### Service Module (Primary)
|
|
256
|
+
|
|
257
|
+
- `startMakeMeaning(config)` - Initialize all make-meaning infrastructure
|
|
258
|
+
- `MakeMeaningService` - Type for service return value
|
|
259
|
+
- `GraphDBConsumer` - Graph consumer class (for advanced use)
|
|
260
|
+
|
|
172
261
|
### Context Assembly
|
|
173
262
|
|
|
174
263
|
- `ResourceContext` - Resource metadata and content
|
|
175
264
|
- `AnnotationContext` - Annotation queries and context building
|
|
176
265
|
- `GraphContext` - Graph traversal and search
|
|
177
266
|
|
|
178
|
-
###
|
|
267
|
+
### Detection & Generation
|
|
179
268
|
|
|
180
|
-
- `AnnotationDetection` - AI-powered semantic pattern detection
|
|
269
|
+
- `AnnotationDetection` - AI-powered semantic pattern detection (orchestrates detection pipeline)
|
|
270
|
+
- `MotivationPrompts` - Prompt builders for comment/highlight/assessment/tag detection
|
|
271
|
+
- `MotivationParsers` - Response parsers with offset validation
|
|
272
|
+
- `extractEntities` - Entity extraction with context-based disambiguation
|
|
273
|
+
- `generateResourceFromTopic` - Markdown resource generation with language support
|
|
274
|
+
- `generateResourceSummary` - Resource summarization
|
|
275
|
+
- `generateReferenceSuggestions` - Smart suggestion generation
|
|
181
276
|
|
|
182
|
-
### Job Workers
|
|
277
|
+
### Job Workers (Advanced)
|
|
183
278
|
|
|
184
279
|
- `ReferenceDetectionWorker` - Entity reference detection
|
|
185
280
|
- `GenerationWorker` - AI content generation
|
|
@@ -188,9 +283,11 @@ See [Architecture](./docs/architecture.md) for complete details.
|
|
|
188
283
|
- `AssessmentDetectionWorker` - Assessment detection
|
|
189
284
|
- `TagDetectionWorker` - Structured tag detection
|
|
190
285
|
|
|
286
|
+
**Note**: Workers are typically managed by `startMakeMeaning()`, not instantiated directly.
|
|
287
|
+
|
|
191
288
|
See [Job Workers](./docs/job-workers.md) for implementation details.
|
|
192
289
|
|
|
193
|
-
###
|
|
290
|
+
### Types
|
|
194
291
|
|
|
195
292
|
```typescript
|
|
196
293
|
export type {
|
|
@@ -198,7 +295,9 @@ export type {
|
|
|
198
295
|
HighlightMatch,
|
|
199
296
|
AssessmentMatch,
|
|
200
297
|
TagMatch,
|
|
201
|
-
} from '
|
|
298
|
+
} from './detection/motivation-parsers';
|
|
299
|
+
|
|
300
|
+
export type { ExtractedEntity } from './detection/entity-extractor';
|
|
202
301
|
```
|
|
203
302
|
|
|
204
303
|
## Configuration
|