knowledge-base-wiki
Compile this profile's uploaded knowledge base documents into a wiki of markdown pages under knowledge-base/wiki/, and refresh it after documents are added, replaced or deleted. Use when the user asks to build, compile, update or rebuild the knowledge base wiki.
Try your first task
A source-grounded starter task has not been verified for this skill yet.
SKILL.md
name: knowledge-base-wikidescription: Compile this profile's uploaded knowledge base documents into a wiki of markdown pages under knowledge-base/wiki/, and refresh it after documents are added, replaced or deleted. Use when the user asks to build, compile, update or rebuild the knowledge base wiki.The wiki turns uploaded documents into pages you maintain, so a question is answered from one compiled page instead of re-reading every source. knowledge_base_search already searches knowledge-base/wiki/*.md next to the documents. Nothing else is needed for the pages to be found.
Three layers, each with one owner:
- Sources.
knowledge-base/manifest.jsonand the<id>.extracted.txtfiles beside it. The user owns them through uploads. Never write, edit or delete anything inknowledge-base/outsidewiki/. - Wiki.
knowledge-base/wiki/*.md. You own these. They are derived from the sources, so deleting the folder loses nothing. - Schema.
knowledge-base/wiki/SCHEMA.md. Says what pages exist and how they are shaped. You write it on the first compile and keep it current.
Reading the sources
read_fileknowledge-base/manifest.json. It holdsdocuments, a list of{ id, filename, status, uploadedAt, ... }.- Only documents with
status: "ready"have text. Their text is inknowledge-base/<id>.extracted.txt. The first three lines are a# source:/# mediaType:/# uploadedAt:header; the body follows. - Use
read_filewithoffsetandlimitfor long documents. Do not open the stored originals (<id>--<filename>); the extracted text is the source of truth.
A replaced document gets a new id, so "changed" and "deleted" look the same here: an id a page cites is no longer in the ready set.
Page format
Every page except SCHEMA.md starts with frontmatter listing the ids of the documents it was written from:
---
title: Refund policy
sources: [kb_abc123, kb_def456]
---
# Refund policy
Refunds are issued within 14 days of a request (kb_abc123).
- File names are lowercase kebab-case:
knowledge-base/wiki/refund-policy.md. One topic per page, so a page stays short enough to read in one call. sourceslists only ids that are in the manifest withstatus: "ready", and every id listed was actually used on the page.- Write what the documents say. When two documents disagree, state both with their ids rather than picking one.
- Link related pages with relative links:
[Billing](billing.md).
SCHEMA.md has no sources. It lists every page with a one-line summary, the conventions above as they apply to this knowledge base, and the date of the last compile. Keep it under about 100 lines.
Compile
- Read the manifest and collect the ready ids.
read_fileknowledge-base/wiki/SCHEMA.md. If it is missing, this is the first compile: every ready document is new.- Find every existing page with
search_filesfor the querysources:under the pathknowledge-base/wiki, then for each page read itssources:- every id still ready: leave the page alone
- some ids gone: rewrite the page from the sources that remain, plus any new document on the same topic
- no id left:
delete_filethe page
- A ready id that no page cites is a new document. Read it, then add its facts to the existing pages they belong on and create pages for topics nothing covers yet. Add its id to the
sourcesof every page you touched. - Rewrite
SCHEMA.mdto match the pages now on disk. - Tell the user which pages were created, rewritten and deleted, in a few lines.
Use write_file to create or fully rewrite a page and edit_file for a small change. Never delete SCHEMA.md.
To rebuild from scratch, delete_file every page in knowledge-base/wiki/, including SCHEMA.md, then compile.