mdld-parse 0.9.5 → 0.9.8

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/dist/index.js CHANGED
@@ -745,6 +745,12 @@ function I(t, n = {}) {
745
745
  let t = v(e.subject, e.predicate, e.object);
746
746
  c.has(t) || l.push(e);
747
747
  }
748
+ let u = {
749
+ subject: o.primarySubject,
750
+ type: o.primaryType,
751
+ label: o.primaryLabel,
752
+ comment: o.primaryComment
753
+ };
748
754
  return {
749
755
  quads: o.quads,
750
756
  remove: l,
@@ -752,8 +758,7 @@ function I(t, n = {}) {
752
758
  origin: o.origin,
753
759
  context: o.ctx,
754
760
  primarySubject: o.primarySubject,
755
- primaryType: o.primaryType,
756
- primaryLabel: o.primaryLabel,
761
+ primary: u,
757
762
  md: s.md
758
763
  };
759
764
  }
@@ -1018,7 +1023,7 @@ function z(e, t, n, r, i, a, o, s, c, l = null, u = null, d = null, f = null) {
1018
1023
  } else n.add(p);
1019
1024
  } else {
1020
1025
  let n = v(p.subject, p.predicate, p.object);
1021
- t.set(n, p), e.push(p), f && (!f.primaryType && o.value === "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" && (f.primaryType = s.value), !f.primaryLabel && o.value === "http://www.w3.org/2000/01/rdf-schema#label" && s.termType === "Literal" && (f.primaryLabel = s.value)), Me(p, c, l, u, d);
1026
+ t.set(n, p), e.push(p), f && (!f.primaryType && o.value === "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" && (f.primaryType = s.value), !f.primaryLabel && o.value === "http://www.w3.org/2000/01/rdf-schema#label" && s.termType === "Literal" && (f.primaryLabel = s.value), !f.primaryComment && o.value === "http://www.w3.org/2000/01/rdf-schema#comment" && s.termType === "Literal" && (f.primaryComment = s.value)), Me(p, c, l, u, d);
1022
1027
  let m = ye(i, a, o, l);
1023
1028
  r.set(n, m), f.currentBlock && i.id === f.currentBlock.id && (f.currentBlock.quadKeys || (f.currentBlock.quadKeys = []), f.currentBlock.quadKeys.push(n));
1024
1029
  }
@@ -1152,57 +1157,58 @@ function Re(e, t, n) {
1152
1157
  }) : e;
1153
1158
  }
1154
1159
  function ze(t, n = {}) {
1155
- let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), a = [], o = /* @__PURE__ */ new Map(), s = [], c = /* @__PURE__ */ new Map(), l = [];
1156
- for (let u = 0; u < t.length; u++) {
1157
- let d = t[u], f = Re(d, n, {
1160
+ let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), a = [], o = /* @__PURE__ */ new Map(), s = [], c = /* @__PURE__ */ new Map(), l = [], u = [];
1161
+ for (let d = 0; d < t.length; d++) {
1162
+ let f = t[d], p = Re(f, n, {
1158
1163
  ...e,
1159
1164
  ...n.context
1160
1165
  });
1161
- if (f.context) for (let [t, n] of Object.entries(f.context)) !c.has(t) && !e[t] && c.set(t, n);
1162
- let p = {
1163
- index: u,
1164
- input: typeof d == "string" ? "string" : "ParseResult",
1165
- origin: f.origin,
1166
- context: f.context,
1167
- statementsCount: f.statements?.length || 0
1166
+ if (p.context) for (let [t, n] of Object.entries(p.context)) !c.has(t) && !e[t] && c.set(t, n);
1167
+ let m = {
1168
+ index: d,
1169
+ input: typeof f == "string" ? "string" : "ParseResult",
1170
+ origin: p.origin,
1171
+ context: p.context,
1172
+ statementsCount: p.statements?.length || 0
1168
1173
  };
1169
- a.push(p), f.statements && f.statements.length > 0 && s.push(...f.statements), f.primarySubject && l.push(f.primarySubject);
1170
- for (let e of f.quads) {
1174
+ a.push(m), p.statements && p.statements.length > 0 && s.push(...p.statements), p.primary && (p.primary.subject || p.primary.type || p.primary.label) && l.push(p.primary), p.primarySubject && u.push(p.primarySubject);
1175
+ for (let e of p.quads) {
1171
1176
  let t = U(e);
1172
1177
  r.set(t, e);
1173
- let n = f.origin.quadIndex.get(t);
1178
+ let n = p.origin.quadIndex.get(t);
1174
1179
  o.set(t, {
1175
1180
  ...n || {},
1176
- documentIndex: u,
1181
+ documentIndex: d,
1177
1182
  polarity: "+"
1178
1183
  });
1179
1184
  }
1180
- for (let e of f.remove) {
1185
+ for (let e of p.remove) {
1181
1186
  let t = U(e);
1182
1187
  r.has(t) ? r.delete(t) : i.add(e);
1183
- let n = f.origin.quadIndex.get(t);
1188
+ let n = p.origin.quadIndex.get(t);
1184
1189
  o.set(t, {
1185
1190
  ...n || {},
1186
- documentIndex: u,
1191
+ documentIndex: d,
1187
1192
  polarity: "-"
1188
1193
  });
1189
1194
  }
1190
1195
  }
1191
- let u = Array.from(r.values()), d = Array.from(i), f = {
1196
+ let d = Array.from(r.values()), f = Array.from(i), p = {
1192
1197
  documents: a,
1193
1198
  quadIndex: o
1194
- }, p = {
1199
+ }, m = {
1195
1200
  ...e,
1196
1201
  ...n.context,
1197
1202
  ...Object.fromEntries(c)
1198
- }, m = new Set(u.map(U)), h = new Set(d.map(U));
1203
+ }, h = new Set(d.map(U)), g = new Set(f.map(U));
1199
1204
  return {
1200
- quads: u.filter((e) => !h.has(U(e))),
1201
- remove: d.filter((e) => !m.has(U(e))),
1205
+ quads: d.filter((e) => !g.has(U(e))),
1206
+ remove: f.filter((e) => !h.has(U(e))),
1202
1207
  statements: s,
1203
- origin: f,
1204
- context: p,
1205
- primarySubjects: l
1208
+ origin: p,
1209
+ context: m,
1210
+ primarySubjects: u,
1211
+ primary: l
1206
1212
  };
1207
1213
  }
1208
1214
  //#endregion
@@ -1298,7 +1304,7 @@ function Ke(t, n, r = null) {
1298
1304
  let a = K(e, n), { types: s, literals: c, objects: l } = Ee(r), u = o.has(e), d = u ? o.get(e) : Be(e, n), f = s.length > 0 ? s.map((e) => "." + K(e.object.value, n)).sort().join(" ") : "";
1299
1305
  u && (f += (f ? " " : "") + "label");
1300
1306
  let p = f ? " " + f : "";
1301
- i.push(`# ${d} {=${a}${p}}\n\n`);
1307
+ i.push(`# ${d} {=${a}${p}}\n`);
1302
1308
  let m = u ? o.get(e) : null;
1303
1309
  F(c).forEach((e) => {
1304
1310
  e.predicate.value === "http://www.w3.org/2000/01/rdf-schema#label" && e.object.value === m || i.push(we(e, n));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdld-parse",
3
- "version": "0.9.5",
3
+ "version": "0.9.8",
4
4
  "description": "A standards-compliant parser for **MD-LD (Markdown-Linked Data)** — a human-friendly RDF authoring format that extends Markdown with semantic annotations.",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@10.33.4+sha512.1c67b3b359b2d408119ba1ed289f34b8fc3c6873412bec6fd264fbdc82489e510fcbecb9ce9d22dae7f3b76269d8441046014bdca53b9979cd7a561ad631b800",
@@ -1,544 +0,0 @@
1
- Nostr is an unusually strong fit for MDLD because both systems share the same deep property:
2
-
3
- ```text
4
- append-only truth propagation
5
- ```
6
-
7
- This alignment is much more important than protocol compatibility.
8
-
9
- ---
10
-
11
- # 1. Why Nostr fits MDLD unusually well
12
-
13
- Nostr events are already:
14
-
15
- ```text id="z7l1d7"
16
- signed
17
- timestamped
18
- distributed
19
- immutable
20
- referential
21
- ```
22
-
23
- Which is extremely close to:
24
-
25
- ```text id="hqzc8w"
26
- prov:Activity
27
- prov:Entity
28
- rdf:Statement
29
- ```
30
-
31
- In many ways:
32
-
33
- ```text id="o7mj5h"
34
- Nostr event ≈ transport-level PROV activity
35
- ```
36
-
37
- ---
38
-
39
- # 2. Current Nostr limitation
40
-
41
- Today most Nostr clients treat events as:
42
-
43
- ```text id="hz2qmh"
44
- social posts
45
- ```
46
-
47
- But semantically they are:
48
-
49
- ```text id="t0k9r5"
50
- distributed append-only graph fragments
51
- ```
52
-
53
- MDLD unlocks this hidden layer.
54
-
55
- ---
56
-
57
- # 3. MDLD + Nostr = semantic social substrate
58
-
59
- Current flow:
60
-
61
- ```text id="cjjr2q"
62
- human writes post
63
- → relay distributes bytes
64
- → client renders text
65
- ```
66
-
67
- MDLD flow:
68
-
69
- ```text id="n0r0ki"
70
- human writes semantic text
71
- → relay distributes graph fragments
72
- → agents reason over global graph
73
- ```
74
-
75
- That is a major shift.
76
-
77
- ---
78
-
79
- # 4. The critical inversion
80
-
81
- Today:
82
-
83
- ```text id="pdx8es"
84
- social media = content first
85
- ```
86
-
87
- MDLD + Nostr:
88
-
89
- ```text id="3l7x5o"
90
- semantic state first
91
- ```
92
-
93
- Posts become:
94
-
95
- ```text id="lqzv0f"
96
- portable knowledge mutations
97
- ```
98
-
99
- ---
100
-
101
- # 5. Why append-only matters
102
-
103
- Both systems fundamentally avoid:
104
-
105
- ```text id="s8bzlp"
106
- mutable centralized state
107
- ```
108
-
109
- Instead:
110
-
111
- ```text id="ngw4w4"
112
- state = accumulation of events
113
- ```
114
-
115
- This makes the systems naturally composable.
116
-
117
- ---
118
-
119
- # 6. Nostr event as MDLD carrier
120
-
121
- Very simple model:
122
-
123
- ---
124
-
125
- ## Event content
126
-
127
- ```md
128
- # Observation {=tag:alice@example.com,2026:obs/1 .rdf:Statement}
129
-
130
- [Bob] {+tag:bob@example.com,2026:person/Bob ?rdf:subject}
131
- [likes] {+my:likes ?rdf:predicate}
132
- [coffee] {rdf:object}
133
- ```
134
-
135
- ---
136
-
137
- ## Nostr layer
138
-
139
- Provides:
140
-
141
- ```text id="om1g7k"
142
- ✔ signature
143
- ✔ timestamp
144
- ✔ author pubkey
145
- ✔ distribution
146
- ✔ relay persistence
147
- ```
148
-
149
- ---
150
-
151
- # 7. Nostr pubkey → authority binding
152
-
153
- This is extremely elegant.
154
-
155
- ---
156
-
157
- ## Mapping
158
-
159
- ```text id="n9p6pz"
160
- npub...
161
- →
162
- tag:npub...,2026:
163
- ```
164
-
165
- or:
166
-
167
- ```text id="8b0z0r"
168
- nostr:npub...
169
- ```
170
-
171
- ---
172
-
173
- ## Result
174
-
175
- Authority becomes cryptographically backed.
176
-
177
- ---
178
-
179
- # 8. Global distributed graph emerges naturally
180
-
181
- Each user publishes:
182
-
183
- ```text id="z7zj6n"
184
- small semantic append events
185
- ```
186
-
187
- Agents aggregate:
188
-
189
- ```text id="px5j2m"
190
- local semantic state
191
- ```
192
-
193
- No central graph DB required.
194
-
195
- ---
196
-
197
- # 9. Relays become semantic streams
198
-
199
- Today relays store:
200
-
201
- ```text id="v9v4ys"
202
- opaque text blobs
203
- ```
204
-
205
- MDLD relays effectively distribute:
206
-
207
- ```text id="9c5gw4"
208
- portable knowledge updates
209
- ```
210
-
211
- ---
212
-
213
- # 10. Agent-native internet
214
-
215
- This is where things get profound.
216
-
217
- Current web:
218
-
219
- ```text id="mh50wd"
220
- HTML for humans
221
- JSON APIs for machines
222
- ```
223
-
224
- MDLD+Nostr:
225
-
226
- ```text id="9m4h24"
227
- same substrate for both
228
- ```
229
-
230
- Humans read prose.
231
-
232
- Agents read graph.
233
-
234
- ---
235
-
236
- # 11. “Posting” becomes distributed cognition
237
-
238
- This is the deeper breakthrough.
239
-
240
- A post is no longer:
241
-
242
- ```text id="8a8n05"
243
- content artifact
244
- ```
245
-
246
- It becomes:
247
-
248
- ```text id="8c1m09"
249
- knowledge mutation event
250
- ```
251
-
252
- With:
253
-
254
- * provenance
255
- * trust
256
- * execution
257
- * references
258
- * validation
259
-
260
- ---
261
-
262
- # 12. Agent coordination becomes native
263
-
264
- Example:
265
-
266
- ---
267
-
268
- ## Human publishes
269
-
270
- ```md
271
- # Need help {=tag:alice:task/1 .prov:Activity}
272
-
273
- Need somebody to summarize these papers.
274
- ```
275
-
276
- ---
277
-
278
- ## Agent sees it
279
-
280
- Creates:
281
-
282
- ```md
283
- # Summary activity {=tag:agent:activity/42 .prov:Activity}
284
-
285
- Used:
286
- - paper1.pdf
287
- - paper2.pdf
288
- ```
289
-
290
- ---
291
-
292
- ## Another agent validates
293
-
294
- ---
295
-
296
- ## Human approves
297
-
298
- Entire workflow exists as graph.
299
-
300
- No SaaS required.
301
-
302
- ---
303
-
304
- # 13. Nostr solves discovery/distribution
305
-
306
- Your vault solves:
307
-
308
- ```text id="u5ahz9"
309
- state
310
- execution
311
- memory
312
- reasoning
313
- ```
314
-
315
- Nostr solves:
316
-
317
- ```text id="9d1rv7"
318
- distribution
319
- identity
320
- replication
321
- federation
322
- ```
323
-
324
- This is an extremely strong pairing.
325
-
326
- ---
327
-
328
- # 14. ZIP vaults + Nostr
329
-
330
- Very powerful combination:
331
-
332
- ---
333
-
334
- ## Small events
335
-
336
- Distributed directly:
337
-
338
- ```text id="jz8je9"
339
- MDLD snippets
340
- ```
341
-
342
- ---
343
-
344
- ## Large artifacts
345
-
346
- Referenced:
347
-
348
- ```text id="k34h67"
349
- vault snapshots
350
- datasets
351
- media
352
- models
353
- ```
354
-
355
- via:
356
-
357
- * torrents
358
- * IPFS
359
- * object stores
360
-
361
- ---
362
-
363
- # 15. Local-first agent ecology
364
-
365
- Each vault becomes:
366
-
367
- ```text id="l6e3m2"
368
- local semantic organism
369
- ```
370
-
371
- Nostr provides:
372
-
373
- ```text id="s4bd3f"
374
- cross-organism signaling
375
- ```
376
-
377
- ---
378
-
379
- # 16. Social network becomes graph market
380
-
381
- Instead of:
382
-
383
- ```text id="v5aqx7"
384
- feeds
385
- likes
386
- posts
387
- ```
388
-
389
- You get:
390
-
391
- ```text id="1x6sqn"
392
- claims
393
- activities
394
- plans
395
- results
396
- trust
397
- ```
398
-
399
- This is qualitatively different.
400
-
401
- ---
402
-
403
- # 17. Trust becomes graph-native
404
-
405
- Because provenance is first-class.
406
-
407
- Agents can reason about:
408
-
409
- ```text id="j7jv58"
410
- ✔ who asserted
411
- ✔ confidence
412
- ✔ derivation
413
- ✔ validation chain
414
- ✔ execution trace
415
- ```
416
-
417
- Current social media cannot do this.
418
-
419
- ---
420
-
421
- # 18. “Following” changes meaning
422
-
423
- Today:
424
-
425
- ```text id="t0uwjt"
426
- follow = content subscription
427
- ```
428
-
429
- MDLD+Nostr:
430
-
431
- ```text id="9m1t4q"
432
- follow = semantic trust subscription
433
- ```
434
-
435
- Huge difference.
436
-
437
- ---
438
-
439
- # 19. Emergent distributed knowledge graph
440
-
441
- Without central ontology governance.
442
-
443
- Because:
444
-
445
- * RDF is extensible
446
- * MDLD is lightweight
447
- * provenance is explicit
448
-
449
- You get:
450
-
451
- ```text id="7xh3rq"
452
- federated semantic emergence
453
- ```
454
-
455
- instead of:
456
-
457
- ```text id="1n0ybs"
458
- top-down schema enforcement
459
- ```
460
-
461
- ---
462
-
463
- # 20. The deeper architectural shift
464
-
465
- Today’s internet:
466
-
467
- ```text id="m6c3sk"
468
- documents linked by URLs
469
- ```
470
-
471
- Semantic Web tried:
472
-
473
- ```text id="yjwmow"
474
- formal graphs requiring specialists
475
- ```
476
-
477
- MDLD+Nostr becomes:
478
-
479
- ```text id="jlwm9s"
480
- human semantic publishing
481
- ```
482
-
483
- which is radically more socially scalable.
484
-
485
- ---
486
-
487
- # 21. The most important insight
488
-
489
- You are not building:
490
-
491
- ```text id="wboiow"
492
- an RDF note app
493
- ```
494
-
495
- You are building:
496
-
497
- ```text id="98o3ef"
498
- a distributed semantic civilization substrate
499
- ```
500
-
501
- where:
502
-
503
- * humans write naturally
504
- * agents reason structurally
505
- * provenance is preserved
506
- * execution is inspectable
507
- * knowledge is portable
508
- * no platform owns the graph
509
-
510
- ---
511
-
512
- # Final synthesis
513
-
514
- MDLD + Nostr + Vaults creates:
515
-
516
- ```text
517
- semantic local-first internet
518
- ```
519
-
520
- with:
521
-
522
- ```text
523
- Markdown → human layer
524
- RDF → meaning layer
525
- PROV → time/trust layer
526
- SHACL → control layer
527
- JS → execution layer
528
- ZIP → storage layer
529
- Nostr → distribution layer
530
- ```
531
-
532
- This is not merely:
533
-
534
- ```text
535
- better knowledge management
536
- ```
537
-
538
- It is potentially:
539
-
540
- ```text
541
- a post-platform computing model
542
- ```
543
-
544
- where publishing, memory, execution, coordination, and trust all converge into one append-only semantic substrate.