Skip to content

Commit 467bc82

Browse files
authored
fix(help): improve agent-facing Wiki Graph help edges (#99)
1 parent 2b35aec commit 467bc82

33 files changed

Lines changed: 599 additions & 178 deletions

data/help/commands/maintenance/chapter.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Input rules:
3737
- `<archive-uri>/chapter/tree set` applies a complete chapter tree JSON. It can reorder chapters and change titles when a node includes `title`.
3838
- `reset --to` accepts `planned`, `source`, or `reading-graph`.
3939
- Structure edits, `/title set`, `/source set`, `/summary set`, and `reset` do not call an LLM provider.
40-
- To generate reading-graph, reading-summary, or knowledge-graph for a chapter, use `wikigraph wikg://local/job add --input <chapter-uri> --task <reading-graph|reading-summary|knowledge-graph> --accept-cost`.
40+
- To generate reading-graph, reading-summary, or knowledge-graph, use `wikigraph wikg://local/job add --input <archive-uri|chapter-uri> --task <reading-graph|reading-summary|knowledge-graph> --accept-cost`.
4141
- `<chapter-uri>/state` shows the aggregate chapter state. `<chapter-uri>/state/<target>` checks one target.
4242
- Append `--help` after an action for action-specific details, for example `wikigraph wikg://book.wikg/chapter/3 reset --help`.
4343

data/help/commands/maintenance/chapter/add.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Output shape:
2727
The `Chapter: <id>` line is the new chapter id for later commands.
2828

2929
Typical next step:
30-
wikigraph wikg://local/job add --input <chapter-uri> --task reading-graph --accept-cost
30+
wikigraph wikg://local/job add --input <archive-uri|chapter-uri> --task reading-graph --accept-cost
3131

3232
Examples:
3333
wikigraph wikg://book.wikg/chapter add --stage planned --title "Part I"

data/help/commands/maintenance/chapter/reset.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Behavior:
1818
- `reading-summary` is not supported because reset is a backward operation.
1919
- Reset is destructive and may discard work.
2020
- Does not call an LLM provider.
21-
- After resetting to `source` or `reading-graph`, use `wikigraph wikg://local/job add --input <chapter-uri> --task <reading-graph|reading-summary|knowledge-graph> --accept-cost` to generate again.
21+
- After resetting to `source` or `reading-graph`, use `wikigraph wikg://local/job add --input <archive-uri|chapter-uri> --task <reading-graph|reading-summary|knowledge-graph> --accept-cost` to generate again.
2222
- After resetting to `planned`, restore source text before starting generated tasks.
2323

2424
See also:

data/help/commands/maintenance/chapter/set-source.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Behavior:
2323
- Does not call an LLM provider.
2424

2525
Typical next step:
26-
wikigraph wikg://local/job add --input <chapter-uri> --task reading-graph --accept-cost
26+
wikigraph wikg://local/job add --input <archive-uri|chapter-uri> --task reading-graph --accept-cost
2727

2828
See also:
2929
- wikigraph wikg://book.wikg/chapter/3/state --help

data/help/commands/maintenance/chapter/set-summary.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Input:
1515
Preconditions:
1616
- The chapter must be `reading-graph`.
1717
- If the chapter is `source`, run:
18-
wikigraph wikg://local/job add --input <chapter-uri> --task reading-graph --accept-cost
18+
wikigraph wikg://local/job add --input <archive-uri|chapter-uri> --task reading-graph --accept-cost
1919

2020
Behavior:
2121
- Moves the chapter to `reading-summary`.

data/help/commands/predicate.jinja

Lines changed: 210 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,44 @@ Purpose:
5050
Create or replace the archive at this URI.
5151

5252
Usage:
53-
wikigraph {{ uri }} create [source] [--input-format <format>] [--llm <json>] [--prompt <text>]
53+
wikigraph {{ uri }} create [source] [--input-format <format>] [--llm <json>] [--prompt <text>] [--json]
5454

5555
Notes:
56-
- `source` may be EPUB, Markdown, txt, or another supported input.
56+
- `source` may be EPUB, Markdown, txt, URL, or another supported input path.
57+
- Without `source`, an empty `.wikg` archive is created unless stdin is selected with `--input-format`.
5758
- Stdin is supported when `--input-format markdown` or `--input-format txt` is provided.
59+
- Input format is inferred from the source extension when possible; use `--input-format` when stdin or the extension is ambiguous.
60+
- Creating from EPUB, Markdown, txt, URL, or stdin runs only the import/source stage.
61+
- This command creates or replaces the target archive file; parent directories must already exist.
62+
- `--llm <json>` passes local LLM settings to the import pipeline when the selected input path needs them.
63+
- On success, text output is the archive object (`<archive>`). With `--json`, output is `{"uri":"..."}`.
64+
65+
Examples:
66+
wikigraph {{ uri }} create ./book.epub
67+
wikigraph {{ uri }} create ./notes.md --input-format markdown
68+
cat chapter.md | wikigraph {{ uri }} create --input-format markdown
69+
wikigraph {{ uri }} create --json
70+
71+
Next:
72+
wikigraph {{ uri }} inspect
5873
{% elif predicate == "export" %}
5974
Purpose:
6075
Export a projection from this archive.
6176

6277
Usage:
63-
wikigraph {{ uri }} export --output-format <format> [--output <path>]
78+
wikigraph {{ uri }} export [--output-format markdown|txt|epub] [--output <path>]
6479

6580
Notes:
81+
- Default output format is markdown when omitted by the parser, but explicit `--output-format` is recommended.
82+
- Without `--output`, exported content is written to stdout.
83+
- `--json` and `--jsonl` are not supported; the output stream is the exported projection.
84+
- Text exports depend on available source/summary content. Missing summaries produce an error that points to the generation command.
85+
- Export does not build Reading Graph or Knowledge Graph coverage.
6686
- Projections are portable views; they do not replace the `.wikg` archive.
87+
88+
Examples:
89+
wikigraph {{ uri }} export --output-format markdown --output book.md
90+
wikigraph {{ uri }} export --output-format txt > book.txt
6791
{% elif predicate == "inspect" %}
6892
Purpose:
6993
Inspect archive readiness before `--query`, retrieval, or starting generated work.
@@ -84,10 +108,11 @@ Purpose:
84108
Add a local generation job.
85109

86110
Usage:
87-
wikigraph {{ uri }} add --input <chapter-uri> --task reading-graph|reading-summary|knowledge-graph --accept-cost [--boost] [--llm <json>] [--prompt <text>]
111+
wikigraph {{ uri }} add --input <archive-uri|chapter-uri> --task reading-graph|reading-summary|knowledge-graph --accept-cost [--boost] [--llm <json>] [--prompt <text>]
88112

89113
Notes:
90114
- Generation jobs may call an LLM provider and incur cost.
115+
- Archive input adds jobs for all eligible chapters; chapter input adds one job.
91116
{% elif predicate == "move" %}
92117
Purpose:
93118
Move this chapter in the chapter tree.
@@ -107,49 +132,179 @@ Purpose:
107132
Usage:
108133
wikigraph {{ uri }} reset --to source|reading-graph|reading-summary|knowledge-graph [--confirm]
109134
{% elif predicate == "set" %}
135+
{% if target.name == "chapter-tree-object" %}
110136
Purpose:
111-
Modify this writable URI target.
137+
Replace the chapter tree with a JSON tree document.
112138

113-
{% if target.name == "chapter-tree-object" %}
114139
Usage:
115140
wikigraph {{ uri }} set --input <tree.json>
141+
142+
Notes:
143+
- The input is a chapter tree JSON document produced by the chapter tree view.
144+
- This rewires chapter hierarchy and order; it does not rewrite chapter source text or generated graph content.
116145
{% elif target.name == "chapter-source-object" %}
146+
Purpose:
147+
Replace this chapter source text.
148+
117149
Usage:
118150
wikigraph {{ uri }} set [text] [--input <path>] --input-format markdown|txt
151+
152+
Notes:
153+
- `--input-format` is required and must be markdown or txt.
154+
- Source replacement invalidates later generated work for that chapter.
155+
- Use `wikigraph {{ uri }} --help` to inspect the source object before replacing it.
119156
{% elif target.name == "chapter-summary-object" %}
157+
Purpose:
158+
Replace this chapter summary text.
159+
120160
Usage:
121161
wikigraph {{ uri }} set [text] [--input <path>]
162+
163+
Notes:
164+
- The input is plain summary text.
165+
- This sets the summary resource directly; it does not call an LLM provider.
122166
{% elif target.name == "chapter-title-object" %}
167+
Purpose:
168+
Replace this chapter title.
169+
123170
Usage:
124171
wikigraph {{ uri }} set <title>
172+
173+
Notes:
174+
- Use `clear` on the same title URI to remove an explicit title.
125175
{% elif target.name == "job-target-object" %}
176+
Purpose:
177+
Change the generation target for this local job.
178+
126179
Usage:
127180
wikigraph {{ uri }} set reading-graph|reading-summary|knowledge-graph
181+
182+
Notes:
183+
- This changes what the job will generate when resumed or picked up by a worker.
184+
- Use `wikigraph {{ uri }} --help` to inspect the current job target first.
128185
{% elif target.name == "local-config-section" %}
186+
Purpose:
187+
Replace this entire local config section with a JSON object.
188+
189+
Usage:
190+
wikigraph {{ uri }} set <json> [--json]
191+
wikigraph {{ uri }} set --json-input <json> [--json]
192+
193+
{% if "/llm" in uri %}
194+
Schema:
195+
{
196+
"provider": "openai|openai-compatible|anthropic|google",
197+
"model": "<model-name>",
198+
"baseURL": "<url>",
199+
"name": "<display-name>"
200+
}
201+
202+
Notes:
203+
- Allowed keys: provider, model, baseURL, name, apiKey.
204+
- `apiKey` is sensitive and cannot be set from JSON.
205+
- If current output shows `"apiKey":"****"`, passing the same masked value preserves the existing secret.
206+
- To add or replace the secret, use `wikigraph {{ uri }} put apiKey --secret`.
207+
- To remove the secret, use `wikigraph {{ uri }} delete apiKey`.
208+
{% elif "/wikispine" in uri %}
209+
Schema:
210+
{
211+
"provider": "fetch|cli"
212+
}
213+
214+
Notes:
215+
- `fetch` uses the built-in WikiSpine service endpoint.
216+
- `cli` runs the local `wikispine` command from PATH.
217+
{% elif "/concurrent" in uri %}
218+
Schema:
219+
{
220+
"job": 3,
221+
"request": 6
222+
}
223+
224+
Notes:
225+
- Allowed keys: job, request.
226+
- Values must be positive integers.
227+
{% endif %}
228+
229+
Examples:
230+
{% if "/llm" in uri %}
231+
wikigraph {{ uri }} set '{"provider":"openai","model":"gpt-4.1"}'
232+
wikigraph {{ uri }} set --json-input '{"provider":"openai-compatible","model":"model-name"}'
233+
wikigraph {{ uri }} set '{"provider":"google","model":"gemini-2.5-pro"}' --json
234+
{% elif "/wikispine" in uri %}
235+
wikigraph {{ uri }} set '{"provider":"fetch"}'
236+
wikigraph {{ uri }} set '{"provider":"cli"}'
237+
{% elif "/concurrent" in uri %}
238+
wikigraph {{ uri }} set '{"job":3,"request":6}'
239+
wikigraph {{ uri }} set --json-input '{"job":2,"request":4}'
240+
{% endif %}
241+
{% elif "/meta" in uri %}
242+
Purpose:
243+
Replace this metadata object from a JSON object or input value.
244+
129245
Usage:
130-
wikigraph {{ uri }} set [<json>] [--json <json>|--json-input <json>]
246+
wikigraph {{ uri }} set <json> [--json]
247+
wikigraph {{ uri }} set --json-input <json> [--json]
248+
249+
Notes:
250+
- Metadata shape depends on whether this is archive metadata or object metadata.
251+
- `put`, `delete`, and `clear` are usually safer for single-key metadata edits.
131252
{% else %}
253+
Purpose:
254+
This URI target has no generic `set` behavior.
255+
132256
Usage:
133-
wikigraph {{ uri }} set [options]
257+
wikigraph {{ uri }} --help
258+
259+
Notes:
260+
- `set` is target-specific. Use the URI help page to find the writable child resource or supported predicate.
134261
{% endif %}
135262
{% elif predicate == "clear" %}
136263
Purpose:
137264
Clear this writable resource or local config section.
138265

139266
Usage:
140267
wikigraph {{ uri }} clear
268+
269+
{% if target.name == "local-config-section" %}
270+
Notes:
271+
- Clears every key in this local config section, including secrets.
272+
- No confirmation prompt is shown.
273+
- Success output is the now-empty JSON object: `{}`.
274+
{% elif "/meta" in uri %}
275+
Notes:
276+
- Clears all metadata keys for this metadata object.
277+
- No confirmation prompt is shown.
278+
{% else %}
279+
Notes:
280+
- This predicate is only available on URI targets that explicitly support clearing.
281+
{% endif %}
141282
{% elif predicate == "build" %}
142283
Purpose:
143284
Build the FTS index for this archive.
144285

145286
Usage:
146287
wikigraph {{ uri }} build [--jsonl]
288+
289+
Notes:
290+
- Safe to run repeatedly; it refreshes a missing or outdated FTS index.
291+
- By default the index is stored as local cache outside the `.wikg` archive.
292+
- Build uses local CPU and disk only; it does not call an LLM provider.
293+
- Text success output is a short status summary.
294+
- With `--jsonl`, progress is emitted as line-delimited event records such as step/status/error records.
295+
- After build, `--query`, `related --query`, and `evidence --query` become available.
147296
{% elif predicate == "embed" %}
148297
Purpose:
149298
Store the FTS index inside the archive.
150299

151300
Usage:
152301
wikigraph {{ uri }} embed
302+
303+
Notes:
304+
- Embedding writes the current FTS index into the `.wikg` archive.
305+
- This makes the archive more portable, but increases archive size.
306+
- Run `build` first if the index is missing or outdated.
307+
- If embed fails because the index is unavailable, run `wikigraph {{ uri }} build`.
153308
{% elif predicate == "external" %}
154309
Purpose:
155310
Keep the FTS index outside the archive as local cache.
@@ -198,19 +353,65 @@ Purpose:
198353

199354
Usage:
200355
wikigraph {{ uri }} put <key> <value>
356+
wikigraph {{ uri }} put <key> --json-input <json>
357+
{% if "/llm" in uri %}
201358
wikigraph {{ uri }} put <key> --secret
359+
{% endif %}
360+
361+
{% if target.name == "local-config-section" %}
362+
{% if "/llm" in uri %}
363+
Keys:
364+
- provider: openai, openai-compatible, anthropic, or google
365+
- model: non-empty model name
366+
- baseURL: non-empty provider base URL string
367+
- name: non-empty display name
368+
- apiKey: secret; use `--secret`
369+
{% elif "/wikispine" in uri %}
370+
Keys:
371+
- provider: fetch or cli
372+
{% elif "/concurrent" in uri %}
373+
Keys:
374+
- job: positive integer
375+
- request: positive integer
376+
{% endif %}
377+
378+
Notes:
379+
- Positional `<value>` is stored as a string.
380+
- `--json-input` stores a JSON value and is useful for numeric config sections.
381+
{% if "/llm" in uri %}
382+
- `--secret` reads the value from an interactive terminal without echoing it; use it for `apiKey`.
383+
{% endif %}
384+
- Success output is the full section JSON with sensitive values masked.
385+
{% endif %}
202386
{% elif predicate == "delete" %}
203387
Purpose:
204388
Delete one key from this local config section.
205389

206390
Usage:
207391
wikigraph {{ uri }} delete <key>
392+
393+
{% if target.name == "local-config-section" %}
394+
Notes:
395+
- Deletes the key if present; deleting an absent key leaves the section unchanged.
396+
- Success output is the full section JSON after deletion.
397+
- Key aliases are normalized where supported, for example `api-key` to `apiKey`.
398+
{% endif %}
208399
{% elif predicate == "test" %}
209400
Purpose:
210401
Test connectivity for this local config section.
211402

212403
Usage:
213-
wikigraph {{ uri }} test
404+
wikigraph {{ uri }} test [--json]
405+
406+
Notes:
407+
- For `llm`, this sends a small request to the configured model.
408+
- For `wikispine`, this checks the built-in fetch service or local `wikispine` command.
409+
- Text success output is intentionally short.
410+
- With `--json`, success and failure both return `{ "ok": true|false, ... }`; failures set a non-zero exit code.
411+
- Without `--json`, failures print the command error. Use `wikigraph help readiness` and `wikigraph help config` to recover.
412+
{% if "/wikispine" in uri %}
413+
- Runtime setup and recovery guide: https://raw.githubusercontent.com/oomol-lab/wiki-graph/refs/heads/main/docs/wikispine-runtime.md
414+
{% endif %}
214415
{% endif %}
215416

216417
Related help:

data/help/commands/transform.jinja

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,26 @@ Help Type: command
22
Command: wikigraph transform
33

44
Purpose:
5-
Run a direct one-shot digest/export without creating a reusable `.wikg` archive.
5+
Run a direct one-shot digest/export.
6+
This is not a plain file-format converter; source inputs usually require LLM-backed digest work, and `--output-format wikg` can create a reusable `.wikg` archive.
67

78
Usage:
89
wikigraph transform [--input <path>] [--output <path>] [--input-format <format>] [--output-format <format>] [--digest-dir <path>] [--llm <json>] [--prompt <text>] [--stage <planned|source|reading-graph|reading-summary>] [--verbose|-v]
910

1011
Behavior:
1112
- Reads from `--input <path>`, or from stdin when `--input` is omitted.
1213
- Writes to `--output <path>`, or to stdout when `--output` is omitted.
13-
- May call an LLM depending on output format, target stage, and source state.
14+
- Source inputs (`epub`, `txt`, `markdown`) call an LLM unless `--output-format wikg --stage planned|source` is used.
15+
- Existing `.wikg` input can be exported to text without running digest generation.
1416
- Does not leave a managed archive unless `--output-format wikg` is selected.
1517

16-
Examples:
18+
LLM-backed source examples:
1719
cat chapter.txt | wikigraph transform --input-format txt --output-format markdown
1820
wikigraph transform --input book.epub --output digest.md --output-format markdown
1921

22+
Existing archive export example:
23+
wikigraph transform --input book.wikg --output digest.md --output-format markdown
24+
2025
Where to go next:
2126
- Prefer reusable archives:
2227
wikigraph wikg://book.wikg create <source>

data/help/commands/uri.jinja

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ Default behavior:
203203

204204
Use when:
205205
- You need to read, replace, edit, clear, or test local configuration.
206+
{% if "/wikispine" in uri %}
207+
208+
WikiSpine runtime guide:
209+
https://raw.githubusercontent.com/oomol-lab/wiki-graph/refs/heads/main/docs/wikispine-runtime.md
210+
{% endif %}
206211
{% endif %}
207212

208213
Predicate commands:

0 commit comments

Comments
 (0)