wiki-graph 0.4.1 → 0.6.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.
Files changed (36) hide show
  1. package/dist/cli.js +1360 -1017
  2. package/dist/cli.js.map +1 -1
  3. package/dist/data/help/commands/library-predicate.jinja +19 -19
  4. package/dist/data/help/commands/library.jinja +8 -5
  5. package/dist/data/help/commands/maintenance/chapter/add.jinja +2 -2
  6. package/dist/data/help/commands/maintenance/chapter/set-source.jinja +3 -20
  7. package/dist/data/help/commands/maintenance/chapter.jinja +3 -2
  8. package/dist/data/help/commands/maintenance/upgrade.jinja +2 -2
  9. package/dist/data/help/commands/maintenance.jinja +1 -1
  10. package/dist/data/help/commands/predicate.jinja +143 -119
  11. package/dist/data/help/commands/root.jinja +4 -2
  12. package/dist/data/help/commands/shared/chapter-source-set.jinja +21 -0
  13. package/dist/data/help/commands/uri.jinja +89 -23
  14. package/dist/data/help/topics/config.jinja +27 -0
  15. package/dist/data/help/topics/file-import.jinja +49 -0
  16. package/dist/data/help/topics/format.jinja +6 -4
  17. package/dist/data/help/topics/library.jinja +11 -7
  18. package/dist/data/help/topics/readiness.jinja +73 -34
  19. package/dist/data/help/topics/recipe.jinja +15 -12
  20. package/dist/data/help/topics/runtime.jinja +1 -1
  21. package/dist/data/help/topics/source-locators.jinja +45 -0
  22. package/dist/data/help/topics/uri.jinja +19 -4
  23. package/dist/gc-worker.js +508 -253
  24. package/dist/gc-worker.js.map +1 -1
  25. package/dist/index.cjs +5232 -2809
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.js +5153 -2731
  28. package/dist/index.js.map +1 -1
  29. package/dist/queue-worker.js +1856 -647
  30. package/dist/queue-worker.js.map +1 -1
  31. package/package.json +9 -8
  32. package/LICENSE +0 -201
  33. package/dist/cli.d.ts +0 -1
  34. package/dist/gc-worker.d.ts +0 -1
  35. package/dist/index.d.cts +0 -36
  36. package/dist/queue-worker.d.ts +0 -1
@@ -4,7 +4,7 @@ Command: {{ commandName }} <uri>
4
4
  URI Command
5
5
 
6
6
  Target:
7
- {{ uri }}
7
+ {{ displayUri }}
8
8
 
9
9
  {% if target.name == "archive-scope" %}
10
10
  URI type:
@@ -12,7 +12,9 @@ URI type:
12
12
 
13
13
  Default behavior:
14
14
  - `{{ commandName }} {{ uri }}` enumerates archive-level objects.
15
- - `{{ commandName }} {{ uri }} --query <query>` applies keyword retrieval across archive scopes.
15
+ - `{{ commandName }} {{ uri }} --query <query>` applies search index retrieval across archive scopes.
16
+ - Broad query results are bucketed by object family: chapter/title hits, graph objects, chunks, then text streams.
17
+ - Query is strict by default; add `--skip-unindexed` only to intentionally search indexed chapters and ignore uncovered chapters.
16
18
 
17
19
  Use when:
18
20
  - You need the archive entry point before narrowing to chapters, chunks, entities, triples, source, or summaries.
@@ -28,7 +30,8 @@ URI type:
28
30
 
29
31
  Default behavior:
30
32
  - `{{ commandName }} {{ uri }}` enumerates chapters.
31
- - `{{ commandName }} {{ uri }} --query <query>` applies keyword retrieval to chapter objects.
33
+ - `{{ commandName }} {{ uri }} --query <query>` applies search index retrieval to chapter objects.
34
+ - Query is strict by default; add `--skip-unindexed` only to intentionally search indexed chapters and ignore uncovered chapters.
32
35
  - Chapter collection scope covers the full chapter tree by default; use `--depth 0` for root-level chapters only.
33
36
  - Chapter path URIs are the public CLI handles; internal chapter ids are not command targets.
34
37
 
@@ -40,19 +43,28 @@ URI type:
40
43
 
41
44
  Default behavior:
42
45
  - `{{ commandName }} {{ uri }}` enumerates objects inside this chapter subtree.
43
- - `{{ commandName }} {{ uri }} --query <query>` applies keyword retrieval inside this chapter subtree.
46
+ - `{{ commandName }} {{ uri }} --query <query>` applies search index retrieval inside this chapter subtree.
47
+ - Broad query results are bucketed by object family: chapter/title hits, graph objects, chunks, then text streams.
48
+ - Query is strict by default; add `--skip-unindexed` only to intentionally search indexed chapters and ignore uncovered chapters.
44
49
  - Use `--depth 0` to restrict the scope to this chapter only; `--depth 1` includes direct children.
45
50
  - The path in this URI is the public CLI handle for the chapter; internal chapter ids are not command targets.
46
51
 
47
52
  Use when:
48
53
  - You already selected a chapter and want local source, summary, chunk, entity, or triple objects.
54
+
55
+ Common child targets:
56
+ - `{{ commandName }} {{ uri }}/source --help`: normalized source text and source ranges.
57
+ - `{{ commandName }} {{ uri }}/summary --help`: chapter summary text and ranges.
58
+ - `{{ commandName }} {{ uri }}/state --help`: current stage and readiness.
59
+ - `{{ commandName }} {{ uri }}/title --help`: explicit chapter title.
49
60
  {% elif target.name == "chunk-scope" %}
50
61
  URI type:
51
62
  Chunk scope
52
63
 
53
64
  Default behavior:
54
65
  - `{{ commandName }} {{ uri }}` enumerates Reading Graph chunks.
55
- - `{{ commandName }} {{ uri }} --query <query>` applies keyword retrieval to chunks in this scope.
66
+ - `{{ commandName }} {{ uri }} --query <query>` applies search index retrieval to chunks in this scope.
67
+ - Query is strict by default; add `--skip-unindexed` only to intentionally search indexed chapters and ignore uncovered chapters.
56
68
  {% if uriContext.isChapterQualified %}
57
69
  - This chapter-qualified scope covers the selected chapter subtree by default.
58
70
  - Use `--depth 0` for only the selected chapter, or `--depth 1` for the selected chapter plus direct children.
@@ -69,7 +81,8 @@ URI type:
69
81
 
70
82
  Default behavior:
71
83
  - `{{ commandName }} {{ uri }}` enumerates Knowledge Graph entities.
72
- - `{{ commandName }} {{ uri }} --query <query>` applies keyword retrieval to entities in this scope.
84
+ - `{{ commandName }} {{ uri }} --query <query>` applies search index retrieval to entities in this scope.
85
+ - Query is strict by default; add `--skip-unindexed` only to intentionally search indexed chapters and ignore uncovered chapters.
73
86
  {% if uriContext.isChapterQualified %}
74
87
  - This chapter-qualified scope covers the selected chapter subtree by default.
75
88
  - Use `--depth 0` for only the selected chapter, or `--depth 1` for the selected chapter plus direct children.
@@ -86,7 +99,8 @@ URI type:
86
99
 
87
100
  Default behavior:
88
101
  - `{{ commandName }} {{ uri }}` enumerates Knowledge Graph triples matching this scope or pattern.
89
- - `{{ commandName }} {{ uri }} --query <query>` applies keyword retrieval to triples in this scope.
102
+ - `{{ commandName }} {{ uri }} --query <query>` applies search index retrieval to triples in this scope.
103
+ - Query is strict by default; add `--skip-unindexed` only to intentionally search indexed chapters and ignore uncovered chapters.
90
104
  {% if uriContext.isChapterQualified %}
91
105
  - This chapter-qualified scope covers the selected chapter subtree by default.
92
106
  - Use `--depth 0` for only the selected chapter, or `--depth 1` for the selected chapter plus direct children.
@@ -97,6 +111,31 @@ Use when:
97
111
  {% if libraryContext.isLibraryWide %}
98
112
  - Open returned triple object URIs for `evidence`; expand related context through the subject or object entity.
99
113
  {% endif %}
114
+ {% elif target.name == "artifact-object" %}
115
+ URI type:
116
+ Source artifact object
117
+
118
+ Default behavior:
119
+ - `{{ commandName }} {{ uri }}` reads the imported file identity and available metadata.
120
+ - An artifact fragment selects one stored PDF page box or EPUB CFI; it is not a separate object.
121
+
122
+ Use when:
123
+ - A source passage returns an artifact locator URI and you need to inspect its source location.
124
+ - Read `{{ commandName }} help source-locators` for the mapping syntax.
125
+ {% elif target.name == "chapter-source-locator-scope" %}
126
+ URI type:
127
+ Source locator collection scope
128
+
129
+ Default behavior:
130
+ - `{{ commandName }} {{ uri }}` lists mappings from source-text character ranges to artifact locator URIs.
131
+ - Add a fragment such as `#4..8` to select source sentences 4 through 8 before listing their mappings.
132
+ - Returned character ranges are 1-based, inclusive, and local to the selected source text.
133
+ - Use `--limit <n>` for a bounded page, `{{ commandName }} next <cursor>` to continue, or `--all` for the complete collection.
134
+ - JSON and JSONL items have the shape `{"range":[1,23],"uri":"wikg://artifact/<short-uid>#..."}`.
135
+
136
+ Use when:
137
+ - You need to trace source text back to an imported PDF or EPUB location.
138
+ - Read `{{ commandName }} help source-locators` for artifact fragments and range semantics.
100
139
  {% elif target.name == "chapter-source-object" %}
101
140
  URI type:
102
141
  Chapter source object
@@ -104,11 +143,13 @@ URI type:
104
143
  Default behavior:
105
144
  - `{{ commandName }} {{ uri }}` reads source text.
106
145
  - Source range fragments such as `#4..8` read sentence numbers 4 through 8, inclusive.
146
+ - Range fragments are read-only; `set` fills the complete source object of a planned chapter.
107
147
  - Range sentence numbers are 1-based. `#1` is the first sentence; `#1..2` is the first two sentences.
108
- - Whole source reads are plain text streams and do not support `--json`; source range fragments are structured range objects and support `--json`.
148
+ - Whole and ranged source reads print text by default. With `--json`, they return one object containing `uri` and `text`.
109
149
 
110
150
  Use when:
111
151
  - You need continuous original wording from a selected chapter.
152
+ - Open `{{ commandName }} {{ uri }}/locators --help` to trace this text to an imported source file.
112
153
  {% elif target.name == "chapter-source-range-object" %}
113
154
  URI type:
114
155
  Chapter source range object
@@ -116,10 +157,12 @@ URI type:
116
157
  Default behavior:
117
158
  - `{{ commandName }} {{ uri }}` reads a structured source sentence range.
118
159
  - Range sentence numbers are 1-based. `#1` is the first sentence; `#1..2` is the first two sentences.
119
- - Source range fragments support `--json`.
160
+ - Range numbers address the current stored source revision and may change after source is reset and written again.
161
+ - Source range fragments support `--json`; the result contains `uri` and `text`.
120
162
 
121
163
  Use when:
122
164
  - You need bounded original wording with machine-readable range metadata.
165
+ - Move the fragment after `/locators`, as in `<chapter-uri>/source/locators#4..8`, to trace the selected sentences to an imported source file.
123
166
  {% elif target.name == "chapter-summary-object" or target.name == "summary-object" %}
124
167
  URI type:
125
168
  Summary object
@@ -128,7 +171,8 @@ Default behavior:
128
171
  - `{{ commandName }} {{ uri }}` reads summary text.
129
172
  - Summary range fragments such as `#4..8` read sentence numbers 4 through 8, inclusive.
130
173
  - Range sentence numbers are 1-based. `#1` is the first sentence; `#1..2` is the first two sentences.
131
- - Whole summary reads are plain text streams and do not support `--json`; summary range fragments are structured range objects and support `--json`.
174
+ - Whole and ranged summary reads print text by default. With `--json`, they return one object containing `uri` and `text`.
175
+ - Summary readiness means a summary object exists and is current for the chapter source. It does not guarantee the prose answers every question about the chapter.
132
176
 
133
177
  Use when:
134
178
  - You need compact readable prose before tracing source evidence.
@@ -170,6 +214,17 @@ Default behavior:
170
214
 
171
215
  Use when:
172
216
  - You need to know whether source, Reading Graph, Reading Summary, or Knowledge Graph data exists for a chapter.
217
+ {% elif target.name == "chapter-index-artifact" %}
218
+ URI type:
219
+ Chapter index artifact object
220
+
221
+ Default behavior:
222
+ - `{{ commandName }} {{ uri }}` reads this chapter index artifact status and summary.
223
+
224
+ Use when:
225
+ - You need to build or delete one chapter-level index artifact stored in the `.wikg` archive.
226
+ - Use `/index/fts` for lexical retrieval, `/index/embedding/source` for Dense source retrieval, or `/index/embedding/summary` for Dense summary retrieval.
227
+ - Build enqueues a local job; read the returned job status or watch the job before assuming the artifact is ready.
173
228
  {% elif target.name == "chunk-object" %}
174
229
  URI type:
175
230
  Chunk object
@@ -217,20 +272,21 @@ Use when:
217
272
  - You need to redirect or pipe the cover resource.
218
273
  {% elif target.name == "index-object" %}
219
274
  URI type:
220
- Index object
275
+ Index cache object
221
276
 
222
277
  Default behavior:
223
- - `{{ commandName }} {{ uri }}` reads archive FTS index status, readiness, storage policy, and materialization state.
224
- - Use this page when `inspect`, `--query`, `related`, or `evidence` reports missing, stale, or unavailable index support.
278
+ - `{{ commandName }} {{ uri }}` reads index cache status and capabilities.
279
+ - Chapter-level `/index/...` URIs manage index artifacts. Archive and library `/index` URIs manage derived cache.
225
280
 
226
281
  Use when:
227
- - You need to inspect currentness, enable, disable, embed, or externalize searchable FTS index support.
282
+ - You need to inspect, sync, or clean query cache materialization.
228
283
  {% elif target.name == "job-collection-scope" %}
229
284
  URI type:
230
285
  Local job collection scope
231
286
 
232
287
  Default behavior:
233
288
  - `{{ commandName }} {{ uri }}` shows local generation jobs.
289
+ - Use `--json` for a machine-readable job list. Job list does not support `--jsonl`; `watch --jsonl` is the streaming job interface.
234
290
 
235
291
  Use when:
236
292
  - You need to inspect, add, or clean local generation jobs.
@@ -268,6 +324,7 @@ Use when:
268
324
 
269
325
  Sections:
270
326
  - `{{ commandName }} wikg://local/config/llm --help`
327
+ - `{{ commandName }} wikg://local/config/embeddings --help`
271
328
  - `{{ commandName }} wikg://local/config/concurrent --help`
272
329
  - `{{ commandName }} wikg://local/config/wikispine --help`
273
330
  {% elif target.name == "local-config-section" %}
@@ -279,6 +336,9 @@ Default behavior:
279
336
 
280
337
  Use when:
281
338
  - You need to read, replace, edit, clear, or test local configuration.
339
+ {% if "/embeddings" in uri %}
340
+ - This section is used by Dense embedding artifact builds and Dense query embeddings.
341
+ {% endif %}
282
342
  {% if "/wikispine" in uri %}
283
343
 
284
344
  WikiSpine runtime guide:
@@ -310,6 +370,8 @@ Library context:
310
370
  {% endif %}
311
371
  - Library archive shortcuts such as `wikg://lib/arc/<archive-id>/chapter` query or maintain one managed archive through its membership id.
312
372
  - Use a standalone archive URI or library archive shortcut for chapter maintenance writes.
373
+ {% elif target.name == "artifact-object" %}
374
+ - A source artifact belongs to one archive. Use a library archive shortcut such as `wikg://lib/arc/<archive-id>/artifact/<short-uid>` to open it through library membership.
313
375
  {% elif target.name == "triple-scope" or target.name == "triple-object" %}
314
376
  {% if libraryContext.isLibraryWide %}
315
377
  - Library-wide scopes such as `wikg://lib/triple` use the aggregate library index.
@@ -357,10 +419,16 @@ Predicate commands:
357
419
  {% endif %}
358
420
  {% elif predicate == "boost" %}
359
421
  - boost: move a waiting job forward. Help: {{ commandName }} {{ uri }} boost --help
422
+ {% elif predicate == "build" %}
423
+ - build: build or replace this chapter index artifact. Help: {{ commandName }} {{ uri }} build --help
360
424
  {% elif predicate == "cancel" %}
361
425
  - cancel: cancel a local job. Help: {{ commandName }} {{ uri }} cancel --help
362
426
  {% elif predicate == "clean" %}
427
+ {% if target.name == "index-object" %}
428
+ - clean: remove derived index cache materialization. Help: {{ commandName }} {{ uri }} clean --help
429
+ {% else %}
363
430
  - clean: remove completed local jobs. Help: {{ commandName }} {{ uri }} clean --help
431
+ {% endif %}
364
432
  {% elif predicate == "clear" %}
365
433
  {% if target.name == "metadata-object" %}
366
434
  - clear: clear this metadata map. Help: {{ commandName }} {{ uri }} clear --help
@@ -370,23 +438,19 @@ Predicate commands:
370
438
  {% elif predicate == "create" %}
371
439
  - create: create the archive; use `--replace` only when discarding an existing archive. Help: {{ commandName }} {{ uri }} create --help
372
440
  {% elif predicate == "delete" %}
373
- {% if target.name == "metadata-object" %}
441
+ {% if target.name == "chapter-index-artifact" %}
442
+ - delete: delete this chapter index artifact. Help: {{ commandName }} {{ uri }} delete --help
443
+ {% elif target.name == "metadata-object" %}
374
444
  - delete: delete one metadata key. Help: {{ commandName }} {{ uri }} delete --help
375
445
  {% else %}
376
446
  - delete: delete a config key. Help: {{ commandName }} {{ uri }} delete --help
377
447
  {% endif %}
378
- {% elif predicate == "disable" %}
379
- - disable: disable searchable index support and remove index materialization. Help: {{ commandName }} {{ uri }} disable --help
380
- {% elif predicate == "embed" %}
381
- - embed: use archive-embedded searchable index storage. Help: {{ commandName }} {{ uri }} embed --help
382
- {% elif predicate == "enable" %}
383
- - enable: enable searchable index support and bring it to current. Help: {{ commandName }} {{ uri }} enable --help
384
448
  {% elif predicate == "evidence" %}
385
449
  - evidence: trace this object to source-backed evidence; supports `--reverse` without `--query`. Help: {{ commandName }} {{ uri }} evidence --help
386
450
  {% elif predicate == "export" %}
387
451
  - export: export an archive projection. Help: {{ commandName }} {{ uri }} export --help
388
- {% elif predicate == "external" %}
389
- - external: use local-cache searchable index storage. Help: {{ commandName }} {{ uri }} external --help
452
+ {% elif predicate == "sync" %}
453
+ - sync: rebuild derived index cache from chapter index artifacts. Help: {{ commandName }} {{ uri }} sync --help
390
454
  {% elif predicate == "inspect" %}
391
455
  - inspect: inspect archive readiness. Help: {{ commandName }} {{ uri }} inspect --help
392
456
  {% elif predicate == "move" %}
@@ -414,6 +478,8 @@ Predicate commands:
414
478
  - set: replace this local config section with a JSON object. Help: {{ commandName }} {{ uri }} set --help
415
479
  {% elif target.name == "job-target-object" %}
416
480
  - set: change this local job target. Help: {{ commandName }} {{ uri }} set --help
481
+ {% elif target.name == "chapter-source-object" %}
482
+ - set: initialize source for a planned chapter. Help: {{ commandName }} {{ uri }} set --help
417
483
  {% else %}
418
484
  {% if target.name == "metadata-object" %}
419
485
  - set: replace this metadata map. Help: {{ commandName }} {{ uri }} set --help
@@ -11,6 +11,12 @@ Sections:
11
11
  `wikg://local/config/llm`
12
12
  LLM provider, model, optional base URL, client name, and API key.
13
13
 
14
+ `wikg://local/config/embeddings`
15
+ Embedding provider for Dense search index vectors and Dense query vectors:
16
+ - `provider`: `openai` or `openai-compatible`.
17
+ - `model`: embedding model name.
18
+ - `dimensions`: optional positive integer when the provider/model supports dimension control.
19
+
14
20
  `wikg://local/config/concurrent`
15
21
  Local concurrency settings:
16
22
  - `job`: simultaneous generation jobs. Default: 3.
@@ -25,17 +31,21 @@ Sections:
25
31
  Operations:
26
32
  Read a section:
27
33
  {{ commandName }} wikg://local/config/llm
34
+ {{ commandName }} wikg://local/config/embeddings
28
35
  {{ commandName }} wikg://local/config/concurrent
29
36
  {{ commandName }} wikg://local/config/wikispine
30
37
 
31
38
  Replace a section with a JSON object:
32
39
  {{ commandName }} wikg://local/config/llm set '{"provider":"openai","model":"gpt-4.1"}'
40
+ {{ commandName }} wikg://local/config/embeddings set '{"provider":"openai","model":"text-embedding-3-small"}'
33
41
  {{ commandName }} wikg://local/config/concurrent set '{"job":3,"request":6}'
34
42
  {{ commandName }} wikg://local/config/wikispine set '{"provider":"fetch"}'
35
43
 
36
44
  Update one key:
37
45
  {{ commandName }} wikg://local/config/llm put provider openai
38
46
  {{ commandName }} wikg://local/config/llm put model gpt-4.1
47
+ {{ commandName }} wikg://local/config/embeddings put provider openai
48
+ {{ commandName }} wikg://local/config/embeddings put model text-embedding-3-small
39
49
  {{ commandName }} wikg://local/config/concurrent put job 3
40
50
  {{ commandName }} wikg://local/config/concurrent put request 6
41
51
  {{ commandName }} wikg://local/config/wikispine put provider cli
@@ -43,6 +53,7 @@ Operations:
43
53
 
44
54
  Store the API key:
45
55
  {{ commandName }} wikg://local/config/llm put apiKey --secret
56
+ {{ commandName }} wikg://local/config/embeddings put apiKey --secret
46
57
 
47
58
  Secret handling:
48
59
  - `apiKey` is read through an interactive hidden prompt.
@@ -56,6 +67,18 @@ Minimum LLM-backed operation configuration:
56
67
  - `llm.model`
57
68
  - Provider credentials when required by the selected provider.
58
69
 
70
+ Minimum Dense embedding configuration:
71
+ - `embeddings.provider`
72
+ - `embeddings.model`
73
+ - `embeddings.baseURL` when using `openai-compatible`
74
+ - Provider credentials when required by the selected provider.
75
+
76
+ Dense search notes:
77
+ - FTS artifact builds do not use this section.
78
+ - Source and summary embedding artifact builds require this section.
79
+ - Index cache sync does not call the embeddings provider; it uses vectors already stored in artifacts.
80
+ - Query uses this section when the current index cache includes Dense vectors. If Dense query embedding fails, Hybrid query can still fall back to FTS.
81
+
59
82
  One-run overrides:
60
83
  `--llm <json>` can provide an LLM object for one invocation.
61
84
  It accepts direct LLM objects and common OpenAI-compatible aliases such as `baseUrl`.
@@ -68,6 +91,10 @@ Examples:
68
91
  {{ commandName }} wikg://local/config/llm put model gpt-4.1
69
92
  {{ commandName }} wikg://local/config/llm put apiKey --secret
70
93
  {{ commandName }} wikg://local/config/llm test
94
+ {{ commandName }} wikg://local/config/embeddings put provider openai
95
+ {{ commandName }} wikg://local/config/embeddings put model text-embedding-3-small
96
+ {{ commandName }} wikg://local/config/embeddings put apiKey --secret
97
+ {{ commandName }} wikg://local/config/embeddings test
71
98
  {{ commandName }} wikg://local/config/wikispine put provider fetch
72
99
  {{ commandName }} wikg://local/config/wikispine test
73
100
 
@@ -0,0 +1,49 @@
1
+ Help Type: topic
2
+ Topic: file-import
3
+
4
+ Source Files and Provenance
5
+
6
+ Purpose:
7
+ Put source-file content into a `.wikg` archive while keeping normalized text
8
+ traceable to the file and location that produced it.
9
+
10
+ Built-in EPUB import:
11
+ {{ commandName }} wikg://book.wikg create --import ./book.epub
12
+ - `create --import` currently accepts EPUB and creates its chapter structure,
13
+ source text, and source-text map.
14
+
15
+ External extractor input:
16
+ {{ commandName }} wikg://book.wikg/chapter add --title "Part" --json
17
+ {{ commandName }} <locatedUri>/source set --input ./source.jsonl --input-format jsonl
18
+ - Use this path for PDF, or when another extractor handles EPUB.
19
+ - Chapter paths are returned handles, not title-derived slugs. Reuse `locatedUri`
20
+ from the first command; the selected chapter must be `planned`.
21
+
22
+ JSONL contract:
23
+ - Each non-empty line is one `artifact` or `text` object. At least one of each is required.
24
+ - An artifact record is `{"type":"artifact","digest":"<64 hex SHA-256 of source file bytes>","mediaType":"application/pdf|application/epub+zip","name":"<optional>","identifier":"<optional>"}`.
25
+ - A text record is `{"type":"text","text":"...","locator":{...}}` and belongs to the most recently declared artifact.
26
+ - PDF locators are `{"pageIndex":1,"bbox":[left,bottom,right,top]}`; page indexes are 1-based and bbox coordinates are ordered numbers in `[0,1]`.
27
+ - EPUB locators are `{"cfi":"epubcfi(...)"}`.
28
+ - Text records are concatenated exactly in order. WG computes their Unicode character offsets; offsets are not input fields.
29
+
30
+ Minimal PDF example:
31
+ {"type":"artifact","digest":"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef","mediaType":"application/pdf","name":"book.pdf"}
32
+ {"type":"text","text":"Source text\n","locator":{"pageIndex":1,"bbox":[0,0,1,1]}}
33
+
34
+ Verification:
35
+ {{ commandName }} <chapter-uri>/source/locators --json
36
+ - This independent scope lists the stored source-text mappings. Read `{{ commandName }} help source-locators` for its range syntax.
37
+
38
+ Boundaries:
39
+ - OCR, layout analysis, and format-specific extraction belong to the importer; WG consumes the contract above.
40
+ - WG stores normalized source text and its source-text map, not the original PDF or EPUB file.
41
+ - Source text remains usable without a source-text map, but evidence cannot point back to a PDF page or EPUB CFI.
42
+ - Source-file input does not generate Reading Graph, Summary, or Knowledge Graph
43
+ data.
44
+
45
+ See also:
46
+ - {{ commandName }} wikg://book.wikg create --help
47
+ - {{ commandName }} <chapter-uri>/source set --help
48
+ - {{ commandName }} help format
49
+ - {{ commandName }} help source-locators
@@ -10,7 +10,7 @@ Managed archive format:
10
10
  wikg
11
11
 
12
12
  Archive create/import input:
13
- epub via `{{ commandName }} <archive-uri> create --import <epub-path>`
13
+ source files via `{{ commandName }} <archive-uri> create --import <source-file>`
14
14
 
15
15
  Export formats:
16
16
  txt, markdown, epub
@@ -23,7 +23,8 @@ Inference rules:
23
23
  - File paths use their extension when the format flag is omitted.
24
24
  - Transform stdin requires an explicit `--input-format`.
25
25
  - Commands that accept content input use `--input <path>` for files and `--input -` for stdin.
26
- - Archive chapter/source text commands read plain source text and do not use `--input-format`.
26
+ - Archive chapter/source text commands read plain source text by default; `chapter/<path>/source set` also accepts `--input-format jsonl` for source provenance input.
27
+ - Read `{{ commandName }} help file-import` for source-file import behavior and provenance boundaries.
27
28
  - Stdout text export requires an explicit or inferable output format.
28
29
  - `transform --stage` is only valid when creating `.wikg` from source input.
29
30
 
@@ -31,8 +32,9 @@ Command output shapes:
31
32
  - Default text output is for direct human reading and quick inspection.
32
33
  - Use `--json` when an Agent or script needs one stable machine-readable response.
33
34
  - Use `--jsonl` when a command returns many records, streams progress, or feeds a Unix pipeline.
34
- - Whole `source` and `summary` text objects are plain text streams and do not support `--json`.
35
- - Ranged fragments such as `/source#20..30` and `/summary#20..30` are structured range objects and support `--json`.
35
+ - Whole `source` and `summary` objects print plain text by default; with `--json`, both return `uri` and `text`.
36
+ - `<chapter-uri>/source/locators` is a paged collection whose JSON and JSONL items contain `range` and artifact locator `uri`.
37
+ - Ranged fragments such as `/source#20..30` and `/summary#20..30` use the same output choices and retain the requested range in `uri`.
36
38
  - Source and summary range numbers are 1-based and inclusive.
37
39
  - Commands that do not support `--json` or `--jsonl` say so in their command help or error message.
38
40
 
@@ -54,6 +54,7 @@ Library-wide query:
54
54
  - `{{ commandName }} wikg://lib/entity --query <query>` searches across present archive members through the library index.
55
55
  - `{{ commandName }} wikg://lib/triple --query <query>` searches library-wide Knowledge Graph triples.
56
56
  - `{{ commandName }} wikg://lib/chunk --query <query>` searches library-wide Reading Graph chunks.
57
+ - Add `--skip-unindexed` only when you intentionally want to search indexed chapters and ignore uncovered chapters.
57
58
  - Library-wide object predicates such as `evidence`, `related`, and `pack` use the same aggregate library index.
58
59
  - Library-wide object URIs such as `wikg://lib/entity/<qid>` are aggregate views over matching objects from present archive members.
59
60
  - Evidence and related output should be interpreted with the returned archive/member provenance; cite the specific returned evidence or member, not just the library-wide URI.
@@ -61,18 +62,21 @@ Library-wide query:
61
62
 
62
63
  Library index lifecycle:
63
64
  - `{{ commandName }} <library-uri>/index` reads library index status.
64
- - `{{ commandName }} <library-uri>/index enable` rebuilds the aggregate index from registered present archives.
65
- - `{{ commandName }} <library-uri>/index disable` removes the local library index materialization.
65
+ - `{{ commandName }} <library-uri>/index sync` rebuilds the aggregate index cache from registered present archives' artifacts.
66
+ - `{{ commandName }} <library-uri>/index clean` removes the local library index cache.
66
67
  - Library indexes are local derived state under Wiki Graph staging, not files inside the library folder.
67
- - `scan`, `add`, archive `path set`, archive `remove`, and archive writes can make the aggregate index dirty.
68
- - Enable the library index again when library-wide query reports that the index is missing, dirty, or stale.
69
- - Library indexes do not support archive-style `embed` or `external` modes.
68
+ - Sync does not build missing chapter artifacts and does not call an embeddings provider.
69
+ - Dense query still requires `wikg://local/config/embeddings` to embed the query text.
70
+ - When both FTS and Dense exist, library query combines them automatically; there is no separate query mode flag.
71
+ - Library membership changes can make the aggregate index stale.
72
+ - Managed archive writes try to sync an existing library index cache immediately; if sync cannot complete, library-wide query reports the cache as stale or not ready.
73
+ - Sync the library index again when library-wide query reports that the index is missing, stale, or not ready.
70
74
 
71
75
  Concurrency:
72
76
  - Library registry and membership writes hold the library write lock.
73
- - `arc scan`, `arc add`, library `path set`, library archive `path set`, library archive `remove`, and library index `enable` or `disable` cannot run concurrently for the same library.
77
+ - `arc scan`, `arc add`, library `path set`, library archive `path set`, library archive `remove`, and library index `sync` or `clean` cannot run concurrently for the same library.
74
78
  - Library-wide object `--query`, object scope enumeration, evidence, related, and pack commands read the current aggregate index.
75
- - If a write marks the aggregate index dirty, rebuild it with `{{ commandName }} <library-uri>/index enable` before relying on library-wide query results.
79
+ - If a write cannot resync the aggregate index, rebuild it with `{{ commandName }} <library-uri>/index sync` before relying on library-wide query results.
76
80
 
77
81
  Upgrade and cleanup:
78
82
  - Upgrade a whole library with `{{ commandName }} maintenance upgrade wikg://lib` or `{{ commandName }} maintenance upgrade wikg://lib/<lib-id>`.
@@ -10,47 +10,69 @@ Purpose:
10
10
  Start with inspect:
11
11
  {{ commandName }} <archive-uri> inspect
12
12
 
13
- Archive FTS readiness:
14
- Archive `--query` uses that archive's FTS index. Without a current index, keyword retrieval is unavailable for archive scopes, evidence, and related results.
15
-
16
- Default behavior:
17
- `{{ commandName }} <archive-uri>/index enable` enables the searchable index as local cache outside the `.wikg` archive.
18
- This keeps the archive smaller, but the index does not travel with copied archive files.
19
- If another user receives the `.wikg`, they usually need to enable their own local index.
20
- After an index is enabled, CLI archive writes keep it synchronized automatically.
21
- Do not enable the index again after every generation job.
22
-
23
- Portable behavior:
24
- `{{ commandName }} <archive-uri>/index embed` switches to an archive-embedded searchable index and ensures it is current.
25
- This makes the archive more self-contained, but increases file size.
26
- After embedding, CLI archive writes keep the embedded index synchronized automatically.
27
- If you are unsure, enable the local index first and embed only when distribution convenience matters.
13
+ Archive index readiness:
14
+ Ordinary archive source query needs chapter index artifacts. For each content chapter, at least one of these must be current:
15
+ - FTS artifact: `<chapter-uri>/index/fts`
16
+ - Source embedding artifact: `<chapter-uri>/index/embedding/source`
17
+
18
+ Summary semantic retrieval is separate:
19
+ - Summary embedding artifact: `<chapter-uri>/index/embedding/summary`
20
+ - Summary embedding alone does not satisfy ordinary archive source query readiness.
21
+
22
+ Artifact behavior:
23
+ Chapter artifacts are stored inside the `.wikg` archive.
24
+ Build FTS artifacts locally for an archive or chapter, without provider calls:
25
+ {{ commandName }} wikg://local/job add --input <archive-uri|chapter-uri> --task index-fts
26
+ Build source embedding artifacts with the chapter index URI or queue target `index-embedding-source`.
27
+ Build summary embedding artifacts with the chapter index URI or queue target `index-embedding-summary`.
28
+ Building embedding artifacts requires `wikg://local/config/embeddings` and may call the configured provider.
29
+ Archive input creates one job per eligible chapter. Re-run inspect after the jobs finish to verify query readiness.
30
+
31
+ Cache behavior:
32
+ `{{ commandName }} <archive-uri>/index sync` builds or repairs local `index.db` cache from artifacts.
33
+ Sync does not build missing artifacts and does not call an embeddings provider.
34
+ Archive-level query can create a missing cache from current artifacts on first use, but explicit sync avoids the first-query delay.
35
+ If query reports a missing or outdated cache, run `{{ commandName }} <archive-uri>/index sync`; library query always requires a current library cache.
36
+ `{{ commandName }} <archive-uri>/index clean` deletes only the local cache.
37
+
38
+ Query behavior:
39
+ FTS artifact only: FTS query.
40
+ Source embedding artifact only: semantic/Dense-only query.
41
+ Both artifacts: Hybrid query with automatic fusion.
42
+ Broad query is grouped by result type first: chapter/title, object, chunk, then source/summary text.
43
+ FTS, Dense, and Hybrid ranking affect ordering inside those result groups and evidence-backed object ranking; they do not flatten the type groups into one global rerank.
44
+ Missing both FTS and source embedding for any content chapter in scope: ordinary query fails.
45
+ Add `--skip-unindexed` to a scope query, `related --query`, or `evidence --query` only when you want to search indexed chapters and ignore uncovered chapters.
46
+ Results produced with `--skip-unindexed` are intentionally partial; inspect coverage before treating absent chapters as negative evidence.
47
+ Summary embedding artifacts are for summary semantic retrieval and are not the minimum requirement for ordinary source query.
28
48
 
29
49
  Commands:
30
50
  {{ commandName }} <archive-uri>/index
31
- {{ commandName }} <archive-uri>/index enable --help
32
- {{ commandName }} <archive-uri>/index disable --help
33
- {{ commandName }} <archive-uri>/index embed --help
34
- {{ commandName }} <archive-uri>/index external --help
51
+ {{ commandName }} <chapter-uri>/index/fts --help
52
+ {{ commandName }} <chapter-uri>/index/embedding/source --help
53
+ {{ commandName }} <chapter-uri>/index/embedding/summary --help
54
+ {{ commandName }} <archive-uri>/index sync --help
55
+ {{ commandName }} <archive-uri>/index clean --help
35
56
 
36
57
  Library index readiness:
37
- Library-wide scopes use an aggregate library index instead of one standalone archive index.
38
- Without a current library index, library-wide `--query`, evidence, related, pack, and scope enumeration may be unavailable.
58
+ Library-wide scopes use an aggregate library index cache built from member archives' artifacts.
59
+ Unlike a free archive, library query does not lazy-sync this cache. It must already be current.
39
60
 
40
61
  Default behavior:
41
- `{{ commandName }} wikg://lib/index enable` rebuilds the default library index from registered present archives.
42
- `{{ commandName }} wikg://lib/<lib-id>/index enable` rebuilds a non-default library index.
62
+ `{{ commandName }} wikg://lib/index sync` rebuilds the default library index cache from registered present archives.
63
+ `{{ commandName }} wikg://lib/<lib-id>/index sync` rebuilds a non-default library index cache.
43
64
  The index is local derived state under Wiki Graph staging, not a file inside the library folder.
65
+ Sync does not build missing chapter artifacts and does not call an embeddings provider.
44
66
 
45
- Dirty behavior:
46
- `scan`, `add`, archive `path set`, archive `remove`, archive writes, and membership changes can mark the aggregate index dirty.
47
- Re-enable the library index when library-wide query reports that it is missing, dirty, or stale.
48
- Library indexes do not support archive-style `embed` or `external` modes.
67
+ Stale behavior:
68
+ Library membership changes can make the aggregate index stale.
69
+ Managed archive writes try to sync an existing library index cache immediately.
70
+ Sync the library index when library-wide query reports that it is missing, stale, or not ready.
49
71
 
50
72
  Commands:
51
73
  {{ commandName }} wikg://lib/index
52
- {{ commandName }} wikg://lib/index enable --help
53
- {{ commandName }} wikg://lib/index disable --help
74
+ {{ commandName }} wikg://lib/index sync --help
75
+ {{ commandName }} wikg://lib/index clean --help
54
76
  {{ commandName }} help library
55
77
 
56
78
  Generation readiness:
@@ -82,6 +104,22 @@ LLM readiness:
82
104
  {{ commandName }} wikg://local/config/llm put apiKey --secret
83
105
  {{ commandName }} wikg://local/config/llm test
84
106
 
107
+ Embeddings readiness:
108
+ `wikg://local/config/embeddings` is required for source or summary embedding artifact builds and for querying an index cache that includes Dense vectors.
109
+ Hybrid query can still fall back to FTS if a Dense query embedding request fails.
110
+
111
+ Minimum configuration:
112
+ provider
113
+ model
114
+ baseURL when using openai-compatible
115
+ provider credentials when required
116
+
117
+ Common path:
118
+ {{ commandName }} wikg://local/config/embeddings put provider openai
119
+ {{ commandName }} wikg://local/config/embeddings put model text-embedding-3-small
120
+ {{ commandName }} wikg://local/config/embeddings put apiKey --secret
121
+ {{ commandName }} wikg://local/config/embeddings test
122
+
85
123
  WikiSpine readiness:
86
124
  Knowledge Graph generation also requires WikiSpine.
87
125
  WikiSpine provides entity candidate lookup for Knowledge Graph construction.
@@ -108,13 +146,14 @@ WikiSpine readiness:
108
146
  https://raw.githubusercontent.com/oomol-lab/wiki-graph/refs/heads/main/docs/wikispine-runtime.md
109
147
 
110
148
  How to choose:
111
- - Need keyword retrieval on this machine: enable local index.
112
- - Need keyword retrieval across a managed folder: enable the library index.
113
- - Need to send a more self-contained `.wikg`: consider embedding the index.
114
- - Need to intentionally drop query support or index materialization: disable index.
149
+ - Need lexical retrieval: build chapter FTS artifacts, then sync cache if you do not want lazy sync.
150
+ - Need semantic retrieval: configure embeddings, build source embedding artifacts, then sync cache.
151
+ - Need both lexical and semantic retrieval: build both FTS and source embedding artifacts, then sync the archive index cache if it already exists or query reports it outdated; query can create a missing archive cache and chooses Hybrid automatically once the cache is current.
152
+ - Need searchable retrieval across a managed folder: sync the library index cache.
153
+ - Need to intentionally drop local cache: clean index cache; artifacts remain in the archive.
115
154
  - Need generated Reading Graph or summaries: configure LLM and use local jobs.
116
155
  - Need Knowledge Graph: configure LLM and WikiSpine, then use local jobs.
117
- - Not sure whether to embed index or generate missing data: keep the archive external/local first, inspect again, and decide later.
156
+ - Not sure what is missing: run inspect and check index artifact coverage before syncing cache.
118
157
 
119
158
  Where to go next:
120
159
  - Normal workflow: