wiki-graph 0.3.0 → 0.4.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 (69) hide show
  1. package/README.md +10 -271
  2. package/dist/cli.d.ts +1 -0
  3. package/dist/cli.js +2983 -4
  4. package/dist/cli.js.map +1 -0
  5. package/{data → dist/data}/editor/text_compressor.jinja +17 -13
  6. package/{data → dist/data}/help/commands/archive/next.jinja +7 -2
  7. package/{data → dist/data}/help/commands/gc.jinja +2 -1
  8. package/{data → dist/data}/help/commands/legacy/migrate.jinja +6 -1
  9. package/{data → dist/data}/help/commands/legacy.jinja +3 -2
  10. package/dist/data/help/commands/library-predicate.jinja +296 -0
  11. package/dist/data/help/commands/library.jinja +235 -0
  12. package/{data → dist/data}/help/commands/maintenance/chapter/add.jinja +3 -3
  13. package/{data → dist/data}/help/commands/maintenance/chapter/list.jinja +4 -4
  14. package/{data → dist/data}/help/commands/maintenance/chapter/move.jinja +4 -4
  15. package/{data → dist/data}/help/commands/maintenance/chapter/remove.jinja +1 -1
  16. package/{data → dist/data}/help/commands/maintenance/chapter/reset.jinja +1 -1
  17. package/{data → dist/data}/help/commands/maintenance/chapter/set-source.jinja +2 -2
  18. package/{data → dist/data}/help/commands/maintenance/chapter/set-summary.jinja +1 -1
  19. package/{data → dist/data}/help/commands/maintenance/chapter/set-title.jinja +3 -3
  20. package/{data → dist/data}/help/commands/maintenance/chapter/tree.jinja +6 -6
  21. package/{data → dist/data}/help/commands/maintenance/chapter.jinja +10 -10
  22. package/{data → dist/data}/help/commands/maintenance/meta.jinja +7 -7
  23. package/dist/data/help/commands/maintenance/upgrade.jinja +35 -0
  24. package/dist/data/help/commands/maintenance.jinja +23 -0
  25. package/{data → dist/data}/help/commands/predicate.jinja +204 -28
  26. package/{data → dist/data}/help/commands/root.jinja +10 -3
  27. package/{data → dist/data}/help/commands/uri.jinja +165 -6
  28. package/{data → dist/data}/help/topics/config.jinja +10 -3
  29. package/dist/data/help/topics/library.jinja +87 -0
  30. package/{data → dist/data}/help/topics/readiness.jinja +32 -2
  31. package/{data → dist/data}/help/topics/recipe.jinja +42 -17
  32. package/{data → dist/data}/help/topics/runtime.jinja +20 -3
  33. package/{data → dist/data}/help/topics/uri.jinja +51 -25
  34. package/dist/gc-worker.d.ts +1 -0
  35. package/dist/gc-worker.js +548 -0
  36. package/dist/gc-worker.js.map +1 -0
  37. package/dist/index.cjs +12463 -19690
  38. package/dist/index.cjs.map +1 -1
  39. package/dist/index.d.cts +36 -842
  40. package/dist/index.d.ts +36 -842
  41. package/dist/index.js +13871 -9
  42. package/dist/index.js.map +1 -0
  43. package/dist/queue-worker.d.ts +1 -0
  44. package/dist/queue-worker.js +2110 -0
  45. package/dist/queue-worker.js.map +1 -0
  46. package/package.json +18 -45
  47. package/dist/cli.cjs +0 -41734
  48. package/dist/cli.cjs.map +0 -1
  49. package/docs/images/flowchart.excalidraw +0 -3293
  50. package/docs/images/flowchart.svg +0 -4
  51. package/docs/images/terminal-cn.png +0 -0
  52. package/docs/images/terminal-en.png +0 -0
  53. package/docs/wikispine-runtime.md +0 -143
  54. /package/{data → dist/data}/editor/clue_reviewer.jinja +0 -0
  55. /package/{data → dist/data}/editor/clue_reviewer_generator.jinja +0 -0
  56. /package/{data → dist/data}/editor/revision_feedback.jinja +0 -0
  57. /package/{data → dist/data}/guaranteed/response_intent_classifier.jinja +0 -0
  58. /package/{data → dist/data}/help/commands/maintenance/cover.jinja +0 -0
  59. /package/{data → dist/data}/help/commands/transform.jinja +0 -0
  60. /package/{data → dist/data}/help/topics/format.jinja +0 -0
  61. /package/{data → dist/data}/output/epub/cover.xhtml.jinja +0 -0
  62. /package/{data → dist/data}/output/epub/nav.xhtml.jinja +0 -0
  63. /package/{data → dist/data}/output/epub/package.opf.xml.jinja +0 -0
  64. /package/{data → dist/data}/output/epub/section.xhtml.jinja +0 -0
  65. /package/{data → dist/data}/topologization/book_coherence_extraction.jinja +0 -0
  66. /package/{data → dist/data}/topologization/chunk_extraction.jinja +0 -0
  67. /package/{data → dist/data}/topologization/evidence_choice.jinja +0 -0
  68. /package/{data → dist/data}/topologization/translate_chunks.jinja +0 -0
  69. /package/{data → dist/data}/topologization/user_focused_extraction.jinja +0 -0
@@ -22,7 +22,7 @@ Behavior:
22
22
 
23
23
  Output shape:
24
24
  Prints the new chapter status.
25
- The `Chapter: <id>` line is the new chapter id for later commands.
25
+ The `Chapter: <uri>` line is the new chapter URI for later commands.
26
26
  With `--json`, prints the new chapter status as one JSON object.
27
27
 
28
28
  Typical next step:
@@ -30,12 +30,12 @@ Typical next step:
30
30
 
31
31
  Examples:
32
32
  {{ commandName }} wikg://book.wikg/chapter add --title "Part I"
33
- {{ commandName }} wikg://book.wikg/chapter add --title "Chapter 1" --input ./chapter.txt --parent wikg://book.wikg/chapter/3
33
+ {{ commandName }} wikg://book.wikg/chapter add --title "Chapter 1" --input ./chapter.txt --parent wikg://book.wikg/chapter/part
34
34
  cat chapter.txt | {{ commandName }} wikg://book.wikg/chapter add --title "Chapter 1" --input -
35
35
 
36
36
  See also:
37
37
  - {{ commandName }} wikg://book.wikg/chapter --help
38
- - {{ commandName }} wikg://book.wikg/chapter/3/source set --help
38
+ - {{ commandName }} wikg://book.wikg/chapter/part/source set --help
39
39
  - {{ commandName }} help format
40
40
  - {{ commandName }} help readiness
41
41
  - {{ commandName }} --help
@@ -10,7 +10,7 @@ Usage:
10
10
  {{ commandName }} <archive-uri>/chapter [--all] [--limit <n>] [--cursor <token>] [--json|--jsonl] [--llm <json>] [--help|-h]
11
11
 
12
12
  Output shape:
13
- wikg://chapter/<id> <title-or-[untitled]> source:<ready|missing> reading-graph:<ready|missing> reading-summary:<ready|missing> knowledge-graph:<ready|missing>
13
+ wikg://chapter/<path> <title-or-[untitled]> source:<ready|missing> reading-graph:<ready|missing> reading-summary:<ready|missing> knowledge-graph:<ready|missing>
14
14
 
15
15
  With machine-readable output, each chapter object includes `uri`, `title`, and `state`.
16
16
 
@@ -18,16 +18,16 @@ Behavior:
18
18
  - Includes sourced, generated, and unfinished chapters.
19
19
  - Some chapters are structural table-of-contents nodes that organize child chapters; missing generated artifacts alone does not make them abnormal.
20
20
  - Read `{{ commandName }} help uri` before choosing `--limit`, `--all`, `--json`, or `--jsonl`.
21
- - Chapter ids are encoded in the returned `wikg://chapter/<id>` URIs.
21
+ - Chapter paths are encoded in the returned `wikg://chapter/<path>` URIs.
22
22
  - Does not call an LLM provider.
23
23
  - Does not mutate chapter content or summaries.
24
24
 
25
25
  Use this before mutation:
26
- Discover ids and missing generated artifacts with:
26
+ Discover chapter URIs and missing generated artifacts with:
27
27
  {{ commandName }} <archive-uri>/chapter
28
28
 
29
29
  See also:
30
- - {{ commandName }} wikg://book.wikg/chapter/3/state --help
30
+ - {{ commandName }} wikg://book.wikg/chapter/part/state --help
31
31
  - {{ commandName }} help readiness
32
32
  - {{ commandName }} help uri
33
33
  - {{ commandName }} --help
@@ -15,7 +15,7 @@ Usage:
15
15
  {{ commandName }} <chapter-uri> move --last [--llm <json>] [--help|-h]
16
16
 
17
17
  Behavior:
18
- - Moves only the chapter tree node. Source text, Reading Graph data, and summary stay attached to the same chapter id.
18
+ - Moves only the chapter tree node. Source text, Reading Graph data, and summary stay attached to the same internal chapter record.
19
19
  - `--parent <chapter-uri>` moves the chapter under another chapter.
20
20
  - `--root` moves the chapter to the top level.
21
21
  - `--before <chapter-uri>` or `--after <chapter-uri>` moves the chapter next to the target chapter.
@@ -25,9 +25,9 @@ Behavior:
25
25
  - Does not call an LLM provider.
26
26
 
27
27
  Examples:
28
- {{ commandName }} wikg://book.wikg/chapter/8 move --parent wikg://book.wikg/chapter/3 --first
29
- {{ commandName }} wikg://book.wikg/chapter/8 move --root --last
30
- {{ commandName }} wikg://book.wikg/chapter/8 move --before wikg://book.wikg/chapter/9
28
+ {{ commandName }} wikg://book.wikg/chapter/intro move --parent wikg://book.wikg/chapter/part --first
29
+ {{ commandName }} wikg://book.wikg/chapter/intro move --root --last
30
+ {{ commandName }} wikg://book.wikg/chapter/intro move --before wikg://book.wikg/chapter/appendix
31
31
 
32
32
  See also:
33
33
  - {{ commandName }} wikg://book.wikg/chapter --help
@@ -21,6 +21,6 @@ Safety:
21
21
 
22
22
  See also:
23
23
  - {{ commandName }} wikg://book.wikg/chapter --help
24
- - {{ commandName }} wikg://book.wikg/chapter/3 reset --help
24
+ - {{ commandName }} wikg://book.wikg/chapter/part reset --help
25
25
  - {{ commandName }} help readiness
26
26
  - {{ commandName }} --help
@@ -23,7 +23,7 @@ Behavior:
23
23
 
24
24
  See also:
25
25
  - {{ commandName }} wikg://local/job --help
26
- - {{ commandName }} wikg://book.wikg/chapter/3/state --help
26
+ - {{ commandName }} wikg://book.wikg/chapter/part/state --help
27
27
  - {{ commandName }} help readiness
28
28
  - {{ commandName }} help runtime
29
29
  - {{ commandName }} --help
@@ -26,8 +26,8 @@ Typical next step:
26
26
  {{ commandName }} wikg://local/job add --input <archive-uri|chapter-uri> --task reading-graph --accept-cost
27
27
 
28
28
  See also:
29
- - {{ commandName }} wikg://book.wikg/chapter/3/state --help
30
- - {{ commandName }} wikg://book.wikg/chapter/3 reset --help
29
+ - {{ commandName }} wikg://book.wikg/chapter/part/state --help
30
+ - {{ commandName }} wikg://book.wikg/chapter/part reset --help
31
31
  - {{ commandName }} wikg://local/job --help
32
32
  - {{ commandName }} help format
33
33
  - {{ commandName }} help readiness
@@ -25,7 +25,7 @@ Behavior:
25
25
 
26
26
  See also:
27
27
  - {{ commandName }} wikg://local/job --help
28
- - {{ commandName }} wikg://book.wikg/chapter/3/state --help
28
+ - {{ commandName }} wikg://book.wikg/chapter/part/state --help
29
29
  - {{ commandName }} help readiness
30
30
  - {{ commandName }} help runtime
31
31
  - {{ commandName }} --help
@@ -19,11 +19,11 @@ Output shape:
19
19
  Prints the updated chapter object.
20
20
 
21
21
  Examples:
22
- {{ commandName }} wikg://book.wikg/chapter/12/title set "New Chapter Title"
23
- {{ commandName }} wikg://book.wikg/chapter/12/title clear
22
+ {{ commandName }} wikg://book.wikg/chapter/part/title set "New Chapter Title"
23
+ {{ commandName }} wikg://book.wikg/chapter/part/title clear
24
24
 
25
25
  See also:
26
26
  - {{ commandName }} wikg://book.wikg/chapter --help
27
- - {{ commandName }} wikg://book.wikg/chapter/12/state --help
27
+ - {{ commandName }} wikg://book.wikg/chapter/part/state --help
28
28
  - {{ commandName }} help uri
29
29
  - {{ commandName }} --help
@@ -16,10 +16,10 @@ Tree JSON shape:
16
16
  {
17
17
  "chapters": [
18
18
  {
19
- "id": 1,
19
+ "uri": "wikg://chapter/part",
20
20
  "title": "Part I",
21
21
  "children": [
22
- { "id": 2, "title": null, "children": [] }
22
+ { "uri": "wikg://chapter/part/intro", "title": null, "children": [] }
23
23
  ]
24
24
  }
25
25
  ]
@@ -27,8 +27,8 @@ Tree JSON shape:
27
27
 
28
28
  Apply rules:
29
29
  - `set` reads tree JSON from `--input <path>` or `--input -` for stdin.
30
- - Every existing chapter id must appear exactly once.
31
- - Unknown, duplicated, or missing chapter ids are rejected.
30
+ - Every existing chapter URI must appear exactly once.
31
+ - Unknown, duplicated, or missing chapter URIs are rejected.
32
32
  - `children` is required on every node.
33
33
  - `title` is optional when setting the tree.
34
34
  - Omitted `title` means keep the current title.
@@ -51,8 +51,8 @@ Examples:
51
51
  cat tree.json | {{ commandName }} wikg://book.wikg/chapter/tree set --input -
52
52
 
53
53
  See also:
54
- - {{ commandName }} wikg://book.wikg/chapter/3 move --help
55
- - {{ commandName }} wikg://book.wikg/chapter/3/title set --help
54
+ - {{ commandName }} wikg://book.wikg/chapter/part move --help
55
+ - {{ commandName }} wikg://book.wikg/chapter/part/title set --help
56
56
  - {{ commandName }} help readiness
57
57
  - {{ commandName }} help uri
58
58
  - {{ commandName }} --help
@@ -7,8 +7,8 @@ Usage:
7
7
  {{ commandName }} <archive-uri>/chapter [--llm <json>] [--help|-h]
8
8
  {{ commandName }} <chapter-uri>/state [--json] [--help|-h]
9
9
  {{ commandName }} <chapter-uri>/state/<source|reading-graph|reading-summary|knowledge-graph> [--json] [--help|-h]
10
- {{ commandName }} <archive-uri>/chapter add [--title <title>] [--parent <id>] [--input <path|->] [--llm <json>] [--json] [--help|-h]
11
- {{ commandName }} <chapter-uri> move (--parent <id>|--root|--before <id>|--after <id>|--first|--last) [--llm <json>] [--help|-h]
10
+ {{ commandName }} <archive-uri>/chapter add [--title <title>] [--parent <chapter-path>] [--input <path|->] [--llm <json>] [--json] [--help|-h]
11
+ {{ commandName }} <chapter-uri> move (--parent <chapter-path>|--root|--before <chapter-path>|--after <chapter-path>|--first|--last) [--llm <json>] [--help|-h]
12
12
  {{ commandName }} <chapter-uri> remove [--recursive] [--llm <json>] [--help|-h]
13
13
  {{ commandName }} <chapter-uri> reset --to <planned|source|reading-graph> [--llm <json>] [--help|-h]
14
14
  {{ commandName }} <chapter-uri>/source set [text] [--input <path|->] [--llm <json>] [--json] [--help|-h]
@@ -26,7 +26,7 @@ Chapter stages:
26
26
 
27
27
  Input rules:
28
28
  - Use Wiki Graph URIs; bare `.wikg` filesystem paths are not accepted.
29
- - `<chapter-uri>` includes the numeric chapter id printed by the chapter collection or `add`.
29
+ - `<chapter-uri>` includes the chapter path printed by the chapter collection or `add`.
30
30
  - `add` creates an empty planned chapter. Use this for chapter directories, groups, and drafting placeholders.
31
31
  - `add --input <path>` creates a chapter and fills it from source text; use `--input -` for stdin.
32
32
  - `<chapter-uri>/source set` and `<chapter-uri>/summary set` read a positional value, `--input <path>`, or `--input -` for stdin.
@@ -38,18 +38,18 @@ Input rules:
38
38
  - Structure edits, `/title set`, `/source set`, `/summary set`, and `reset` do not call an LLM provider.
39
39
  - To generate reading-graph, reading-summary, or knowledge-graph, use `{{ commandName }} wikg://local/job add --input <archive-uri|chapter-uri> --task <reading-graph|reading-summary|knowledge-graph> --accept-cost`.
40
40
  - `<chapter-uri>/state` shows the aggregate chapter state. `<chapter-uri>/state/<target>` checks one target.
41
- - Append `--help` after an action for action-specific details, for example `{{ commandName }} wikg://book.wikg/chapter/3 reset --help`.
41
+ - Append `--help` after an action for action-specific details, for example `{{ commandName }} wikg://book.wikg/chapter/part reset --help`.
42
42
 
43
43
  See also:
44
44
  - {{ commandName }} wikg://book.wikg/chapter
45
- - {{ commandName }} wikg://book.wikg/chapter/3/state
46
- - {{ commandName }} wikg://book.wikg/chapter/3/state/knowledge-graph
45
+ - {{ commandName }} wikg://book.wikg/chapter/part/state
46
+ - {{ commandName }} wikg://book.wikg/chapter/part/state/knowledge-graph
47
47
  - {{ commandName }} wikg://book.wikg/chapter/tree
48
- - {{ commandName }} wikg://book.wikg/chapter/3/title set "New Title"
49
- - {{ commandName }} wikg://book.wikg/chapter/3/title clear
48
+ - {{ commandName }} wikg://book.wikg/chapter/part/title set "New Title"
49
+ - {{ commandName }} wikg://book.wikg/chapter/part/title clear
50
50
  - {{ commandName }} wikg://book.wikg/chapter add --input chapter.txt
51
- - {{ commandName }} wikg://book.wikg/chapter/3/source set --input chapter.txt
52
- - {{ commandName }} wikg://book.wikg/chapter/3/summary set --input summary.md
51
+ - {{ commandName }} wikg://book.wikg/chapter/part/source set --input chapter.txt
52
+ - {{ commandName }} wikg://book.wikg/chapter/part/summary set --input summary.md
53
53
  - cat tree.json | {{ commandName }} wikg://book.wikg/chapter/tree set --input -
54
54
  - {{ commandName }} wikg://local/job --help
55
55
  - {{ commandName }} help format
@@ -8,12 +8,11 @@ Purpose:
8
8
 
9
9
  Usage:
10
10
  {{ commandName }} <object-uri>/meta [--json] [--help|-h]
11
- {{ commandName }} <object-uri>/meta set --json <object> [--help|-h]
12
- {{ commandName }} <object-uri>/meta set --json --input <path|-> [--help|-h]
11
+ {{ commandName }} <object-uri>/meta set <json> [--json] [--help|-h]
12
+ {{ commandName }} <object-uri>/meta set --input <path|-> [--json] [--help|-h]
13
13
  {{ commandName }} <object-uri>/meta set --json-input <object> [--json] [--help|-h]
14
- {{ commandName }} <object-uri>/meta put <key> <value> [--help|-h]
15
- {{ commandName }} <object-uri>/meta put <key> --json <value> [--help|-h]
16
- {{ commandName }} <object-uri>/meta put <key> --input <path|-> [--help|-h]
14
+ {{ commandName }} <object-uri>/meta put <key> <value> [--json] [--help|-h]
15
+ {{ commandName }} <object-uri>/meta put <key> --input <path|-> [--json] [--help|-h]
17
16
  {{ commandName }} <object-uri>/meta put <key> --json-input <value> [--json] [--help|-h]
18
17
  {{ commandName }} <object-uri>/meta delete <key> [--json] [--help|-h]
19
18
  {{ commandName }} <object-uri>/meta clear [--json] [--help|-h]
@@ -22,7 +21,8 @@ Input:
22
21
  - `set` replaces the whole metadata map and requires a JSON object.
23
22
  - `put` writes one key. Without `--json`, the value is stored as a string.
24
23
  - `--json-input <json>` reads an inline JSON value.
25
- - `--json --input <path>` reads JSON from a file.
24
+ - `--input <path|->` reads a value from a file or stdin.
25
+ - `--json` controls output shape; it is not JSON input.
26
26
  - Use `--input -` to read from stdin.
27
27
  - Metadata keys are command arguments, not URI segments.
28
28
 
@@ -42,7 +42,7 @@ Examples:
42
42
  {{ commandName }} wikg://book.wikg/meta --json
43
43
  {{ commandName }} wikg://book.wikg/meta put title "New Title"
44
44
  {{ commandName }} wikg://book.wikg/entity/Q42/meta put note "reviewed"
45
- {{ commandName }} wikg://book.wikg/entity/Q42/meta put rank --json 7
45
+ {{ commandName }} wikg://book.wikg/entity/Q42/meta put rank --json-input 7
46
46
  {{ commandName }} wikg://book.wikg/entity/Q42/meta delete note
47
47
  {{ commandName }} wikg://book.wikg/entity/Q42/meta clear
48
48
 
@@ -0,0 +1,35 @@
1
+ Help Type: command
2
+ Command: {{ commandName }} maintenance upgrade
3
+
4
+ Purpose:
5
+ Explicitly upgrade persistent Wiki Graph data. Home state may be upgraded automatically before real commands; user archives and libraries are upgraded only through this maintenance command.
6
+
7
+ Usage:
8
+ {{ commandName }} maintenance upgrade <target> [--json]
9
+ {{ commandName }} maintenance upgrade <path.sdpub> [--output <path.wikg>] [--json]
10
+
11
+ Targets:
12
+ - Home state: ~/.wikigraph
13
+ - Standalone archive: ./book.wikg, /path/to/book.wikg, wikg://book.wikg, wikg:///path/to/book.wikg
14
+ - Legacy sdpub: ./book.sdpub, optionally with --output
15
+ - Library: wikg://lib or wikg://lib/<lib-id>
16
+
17
+ Notes:
18
+ - This maintenance command accepts filesystem paths. URI-targeted archive/object commands still require Wiki Graph URIs; see `{{ commandName }} help uri`.
19
+ - Home state may be schema-gated automatically before real commands, but this command is the explicit recovery and batch-upgrade entry point.
20
+ - Internal SQLite files are part of the home target and are not user-facing upgrade targets.
21
+ - Standalone .wikg, home, and library targets are upgraded in place and do not support --output.
22
+ - Library archive member URIs such as wikg://lib/arc/<archive-id>/ are not standalone upgrade targets; upgrade the whole library.
23
+ - Library upgrade covers the registry and managed archive members for that library.
24
+
25
+ Examples:
26
+ {{ commandName }} maintenance upgrade ~/.wikigraph
27
+ {{ commandName }} maintenance upgrade ./book.wikg
28
+ {{ commandName }} maintenance upgrade wikg://lib
29
+ {{ commandName }} maintenance upgrade ./book.sdpub --output ./book.wikg
30
+
31
+ Related help:
32
+ - URI target forms and path conversion:
33
+ {{ commandName }} help uri
34
+ - Library upgrade scope:
35
+ {{ commandName }} help library
@@ -0,0 +1,23 @@
1
+ Help Type: command
2
+ Command: {{ commandName }} maintenance
3
+
4
+ Purpose:
5
+ Run explicit maintenance operations for persistent Wiki Graph data.
6
+
7
+ Usage:
8
+ {{ commandName }} maintenance upgrade <target> [--json]
9
+
10
+ Commands:
11
+ upgrade Upgrade home state, a .wikg archive, a library, or migrate .sdpub.
12
+
13
+ Upgrade targets:
14
+ {{ commandName }} maintenance upgrade ~/.wikigraph
15
+ {{ commandName }} maintenance upgrade ./book.wikg
16
+ {{ commandName }} maintenance upgrade wikg://book.wikg
17
+ {{ commandName }} maintenance upgrade ./book.sdpub [--output ./book.wikg]
18
+ {{ commandName }} maintenance upgrade wikg://lib
19
+ {{ commandName }} maintenance upgrade wikg://lib/<lib-id>
20
+
21
+ See Also:
22
+ {{ commandName }} maintenance upgrade --help
23
+ {{ commandName }} help format