| name | kb-promote |
| description | Promote a query output to wiki/synthesis/ — enriches with frontmatter, wikilinks, and cross-references. Use when the user wants to promote, save, or keep a query answer in the wiki. Also triggers on "kb-promote" or "/kb-promote". |
kb-promote
Promote a query output from output/ into wiki/synthesis/ as a permanent, cross-referenced wiki page.
Arguments
<output-file> — Path to the output file to promote (optional). If omitted, list recent outputs and let the user pick.
Step 1: Resolve KB
python3 ~/.config/kb/scripts/kb_resolve.py --mode mutating
Capture the KB root path. Abort if resolution fails.
Step 2: Select Output File
If path provided:
- Validate the file exists at
{{KB_ROOT}}/{{OUTPUT_FILE}}.
- Abort if it does not exist.
If no path provided:
- List all files in
{{KB_ROOT}}/output/ sorted by modification time (newest first).
- Present the list to the user with filenames and the
query: field from each file's frontmatter.
- Let the user pick one.
Step 3: Read Output File
- Read the full content of the selected output file.
- Extract:
- The original question (from the
query: frontmatter field or # Query: header).
- The synthesized answer body.
- The sources table (pages consulted with confidence and stability).
Step 4: Enrich with Frontmatter
Generate a synthesis page title from the question. Write the page to wiki/synthesis/<slug>.md with full frontmatter:
---
title: "{{SYNTHESIS_TITLE}}"
type: synthesis
source_ids: []
confidence: 0.7
stability: evolving
human_reviewed: false
created: {{DATE}}
last_verified: {{DATE}}
supersedes: []
contradictions: []
tags: []
---
For source_ids: trace each cited wiki page back to its source_ids and collect the unique raw source paths.
Step 5: Add Wikilinks and Dataview Fields
- Ensure all references to wiki pages use
[[wikilinks]] syntax.
- Add Dataview-compatible relationship fields:
## Relationships
- synthesizes:: [[cited-page-1]], [[cited-page-2]]
- related:: [[other-relevant-pages]]
- contradicts:: [[any-contradicting-pages]]
- Add inline Dataview fields:
[type:: synthesis]
[promoted_from:: output/{{FILENAME}}]
[original_query:: "{{QUESTION}}"]
- Add a provenance note:
> Promoted from `output/{{ORIGINAL_FILENAME}}` on {{DATE}}.
> Original query: "{{QUESTION}}"
- Preserve the sources table from the output file.
Step 6: Annotate Original Output
Add a promotion note to the top of the original output file (do not delete it):
<!-- PROMOTED: {{DATE}} → wiki/synthesis/{{SLUG}}.md -->
Step 7: Regenerate Index
python3 ~/.config/kb/scripts/kb_index.py "{{KB_ROOT}}"
Step 8: Append Log
Add a row to log.md:
| {{DATE}} | promote | Promoted output/{{FILENAME}} → wiki/synthesis/{{SLUG}}.md |
Final Output
Print:
- Path to the new synthesis page.
- Source IDs traced from cited pages.
- Tags assigned.
- Relationships added.
- Suggestion:
"Review the new synthesis page and set human_reviewed: true if it looks good."