Инструкция для Trip2G LLM Wiki базы

Дата: 2026-05-03 11:21 UTC

Главный вывод

Для Trip2G нужно показать пример базы знаний, где рядом с контентом лежит инструкция для агента. Эта инструкция объясняет:

  • как читать базу;
  • когда использовать RAG/search;
  • когда читать index.md и идти только по wikilinks;
  • как ingest-ить новые источники;
  • как сохранять хорошие ответы обратно в wiki;
  • как не портить provenance;
  • как вести log.md;
  • как делать lint.

Так пользователь видит, что Trip2G — не только storage/RAG, а knowledge protocol, где база сама содержит правила своего использования.

Пример структуры базы

llm-wiki/
├── _index.md                    # public/site index for Trip2G
├── AGENTS.md                    # main instruction for agents
├── SCHEMA.md                    # domain conventions and page rules
├── index.md                     # content catalog for index-first navigation
├── log.md                       # chronological append-only activity log
├── raw/
│   ├── articles/
│   ├── papers/
│   ├── transcripts/
│   └── assets/
├── entities/
├── concepts/
├── comparisons/
├── queries/
├── decisions/
└── _meta/
    ├── retrieval-policy.md
    ├── source-quality.md
    └── lint-checklist.md

Для Trip2G можно сделать public/private:

---
free: true
---

на публичных demo-страницах и free: false или отсутствие free на приватных.

Главная инструкция рядом с базой: AGENTS.md

Ниже пример, который можно положить в demo-базу Trip2G.

# Agent Instructions for This LLM Wiki

You are working with a Trip2G-hosted LLM Wiki.

This wiki is not a raw document dump. It is a maintained, interlinked markdown knowledge base built from raw sources. Your job is to use it as a compounding artifact: read the index, follow links, cite sources, update pages carefully, and file valuable new synthesis back into the wiki.

## Core principle

The wiki is the durable artifact, not the chat.

Do not answer only from transient conversation if the answer should improve the knowledge base. If a query produces durable synthesis, save it as a page and update `index.md` and `log.md`.

## Layers

This wiki has three layers:

1. `raw/` — immutable source material. Read but never edit.
2. wiki pages — maintained markdown pages in `entities/`, `concepts/`, `comparisons/`, `queries/`, `decisions/`.
3. schema/instructions — `AGENTS.md`, `SCHEMA.md`, `_meta/*`.

## Start every session

Before answering domain questions or modifying the wiki:

1. Read `SCHEMA.md`.
2. Read `index.md`.
3. Read the last 20 entries of `log.md`.
4. If the question mentions a specific topic, search the wiki for that topic.

This prevents duplicate pages, stale assumptions and missed cross-links.

## Retrieval policy

Use the lightest retrieval method that can answer the question correctly.

### Mode A — Index-first traversal

Use this mode when:

- the wiki is small or medium;
- the topic is likely represented in `index.md`;
- the user asks a conceptual, comparative or synthesis question;
- exact keyword search is less important than known structure.

Steps:

1. Read `index.md`.
2. Pick 3–7 likely pages.
3. Open those pages.
4. Follow relevant `[[wikilinks]]` one hop.
5. Answer with citations to wiki pages.
6. If the answer is durable, file it into `queries/` or `comparisons/`.

### Mode B — Search/RAG-assisted retrieval

Use this mode when:

- `index.md` is too large;
- the user asks about exact terms, quotes, dates or obscure details;
- the wiki has hundreds/thousands of pages;
- the index-first pass fails;
- the question may require raw source verification.

Steps:

1. Use Trip2G `search(query)` or available search tool.
2. Open the strongest results with `note_html` or file read.
3. Follow wikilinks from the strongest pages.
4. If needed, inspect raw source files cited by the pages.
5. Answer with citations.
6. If retrieval found missing/unclear pages, update `index.md` or create a lint note.

### Mode C — Raw source verification

Use this mode when:

- the claim is high-stakes;
- there is a contradiction;
- the user asks for exact wording;
- a wiki page has low confidence;
- a cited source is old or contested.

Steps:

1. Find the source in page frontmatter or provenance marker.
2. Read the raw source.
3. Compare the source with the wiki claim.
4. Update the wiki if needed.
5. Mark uncertainty explicitly.

## Answering questions

When answering from the wiki:

- mention which pages you used;
- do not pretend the wiki is complete;
- separate wiki-backed claims from your own inference;
- if pages disagree, surface the disagreement;
- prefer short synthesis with links over long unsupported essays.

Example answer pattern:

```text
Based on [[concepts/llm-wiki]] and [[comparisons/rag-vs-llm-wiki]], the strongest answer is...

Evidence:
- ...
- ...

Uncertainty:
- ...

Suggested next wiki update:
- ...

Ingesting a new source

When the user adds a source:

  1. Save the source under raw/ with frontmatter:
---
source_url: <url if any>
ingested: YYYY-MM-DD
sha256: <hash of body>
---
  1. Read the source.
  2. Summarize the key takeaways.
  3. Search index.md for existing pages to update.
  4. Update or create pages only if the source is central enough.
  5. Add at least two [[wikilinks]] to every new page.
  6. Add source/provenance markers.
  7. Update index.md.
  8. Append to log.md.
  9. Report all changed files.

Do not create pages for every passing mention.

Page creation thresholds

Create a new page when:

  • the entity/concept is central to a source;
  • the entity/concept appears across 2+ sources;
  • the user explicitly asks to track it;
  • it is needed as a hub for multiple existing pages.

Do not create a page when:

  • it appears once in passing;
  • it is outside the wiki domain;
  • it duplicates an existing page under another name.

Filing query results

If a user asks a question and the answer is valuable beyond the current chat, save it.

Save as:

  • queries/YYYY-MM-DD-question-slug.md for one-off durable answers;
  • comparisons/topic-a-vs-topic-b.md for comparisons;
  • decisions/YYYY-MM-DD-decision-slug.md for decisions and rationale.

Always update index.md and log.md after filing.

Human edits

Human edits have priority.

Do not overwrite a section that appears manually curated unless explicitly asked.

If possible, use markers:

<!-- human:keep -->
This section should not be rewritten automatically.
<!-- /human:keep -->

If you need to change a human section, propose a patch instead of replacing it silently.

Contradictions

When new information conflicts with existing pages:

  1. Do not silently pick a winner.
  2. Note both claims with dates and sources.
  3. Mark the page frontmatter:
contested: true
contradictions:
  - other-page
confidence: medium
  1. Add an item to log.md.
  2. Ask the user if the contradiction matters.

Provenance

Every important claim should be traceable.

Use at least one of:

  • sources: in frontmatter;
  • paragraph-level source marker;
  • link to raw source;
  • citation to another wiki page that has sources.

Do not let summaries become untraceable facts.

Lint tasks

Periodically run a wiki health check:

  • broken wikilinks;
  • orphan pages;
  • pages missing from index.md;
  • pages with no sources;
  • low-confidence pages;
  • contested pages;
  • stale pages;
  • raw source hash mismatches;
  • pages over 200 lines;
  • duplicated concepts.

Append lint results to log.md.

Trip2G-specific behavior

When using Trip2G MCP tools:

  1. Use search for broad discovery.
  2. Use note_html to open source pages.
  3. Use toc_path when opening long pages.
  4. Use similar only after reading a strong seed page.
  5. Prefer links to Trip2G pages in final answers when pages are public.
  6. Respect private/public flags.
  7. If a note describes a remote knowledge base, use federation tools only when relevant.

What not to do

  • Do not answer solely from raw RAG chunks if the wiki already has curated pages.
  • Do not create duplicate pages without checking index.md.
  • Do not edit raw/ sources.
  • Do not overwrite human-written sections silently.
  • Do not remove uncertainty.
  • Do not cite a page if you did not read it.
  • Do not turn every chat answer into a page; file only durable synthesis.

## `SCHEMA.md` пример

```markdown
# Wiki Schema

## Domain

This wiki tracks knowledge about: <domain>.

## Page types

- `entity` — people, organizations, products, projects.
- `concept` — ideas, mechanisms, methods.
- `comparison` — structured comparison between options.
- `query` — durable answer to a user question.
- `decision` — decision, rationale, tradeoffs.
- `source-summary` — summary of one raw source.

## Required frontmatter

```yaml
---
title: Page Title
created: YYYY-MM-DD
updated: YYYY-MM-DD
type: entity | concept | comparison | query | decision | source-summary
tags: []
sources: []
confidence: high | medium | low
contested: false
---

Linking rules

  • Every new wiki page should link to at least 2 other pages.
  • Every important source summary should link to concepts/entities it affects.
  • Use wikilinks: [[concepts/example-concept]].
  • If a link target does not exist, either create it intentionally or leave a TODO.

Index rules

Every maintained page must appear in index.md under the right section with a one-line summary.

Format:

- [[concepts/llm-wiki]] — persistent, compounding markdown knowledge base maintained by agents.

Logging rules

Append every operation to log.md:

## [YYYY-MM-DD] ingest | Source title
- Created:
- Updated:
- Findings:
- Next:

## `index.md` пример

```markdown
# Wiki Index

> Read this first. It is the content map for the wiki.
> Last updated: 2026-05-03

## How to use this index

1. Find the relevant section.
2. Open 3–7 likely pages.
3. Follow their wikilinks.
4. Use search only if this index is insufficient.

## Concepts

- [[concepts/llm-wiki]] — persistent markdown wiki maintained by an LLM from raw sources.
- [[concepts/rag-vs-llm-wiki]] — comparison of query-time retrieval and compiled knowledge.
- [[concepts/provenance]] — source tracing, hashes, citations and auditability.

## Entities / Products

- [[entities/trip2g]] — MCP-accessible markdown knowledge hub with publishing, sync and federation.
- [[entities/obsidian]] — local markdown PKM app used as an IDE for wiki browsing.

## Comparisons

- [[comparisons/rag-vs-llm-wiki]] — when to use RAG, when to use index-first wiki traversal, and when to combine both.

## Queries

- [[queries/2026-05-03-how-to-start-llm-wiki]] — first steps for creating a Trip2G-hosted LLM Wiki.

log.md пример

# Wiki Log

> Append-only timeline of wiki actions.

## [2026-05-03] create | Wiki initialized

- Created `AGENTS.md`, `SCHEMA.md`, `index.md`, `log.md`.
- Domain: LLM Wiki / agent memory / Trip2G.
- Next: ingest Karpathy LLM Wiki gist.

## [2026-05-03] ingest | Karpathy LLM Wiki gist

- Raw source saved: `raw/articles/karpathy-llm-wiki.md`.
- Created:
  - [[concepts/llm-wiki]]
  - [[concepts/rag-vs-llm-wiki]]
- Updated:
  - [[index]]
- Findings:
  - LLM Wiki is a persistent compounding artifact, not a query-time retrieval layer.

Пример первой страницы: concepts/llm-wiki.md

---
title: LLM Wiki
created: 2026-05-03
updated: 2026-05-03
type: concept
tags: [agent-memory, markdown, knowledge-base]
sources:
  - raw/articles/karpathy-llm-wiki.md
confidence: medium
contested: false
---
# LLM Wiki

## Definition

An LLM Wiki is a persistent, interlinked markdown knowledge base maintained by an LLM agent from curated raw sources.

Unlike standard RAG, which retrieves chunks at query time, an LLM Wiki compiles knowledge into durable pages that can be updated, cross-linked and reused.

## Why it matters

- Knowledge compounds across sessions.
- Agents stop rediscovering the same context.
- Good answers can be saved back into the wiki.
- Contradictions and stale claims can be tracked explicitly.

## Risks

- Summaries can lose caveats.
- Agents can introduce errors.
- Large wikis still need search or graph traversal.
- Provenance and review are mandatory.

## Related

- [[concepts/rag-vs-llm-wiki]]
- [[concepts/provenance]]
- [[entities/trip2g]]

Пример retrieval policy note: _meta/retrieval-policy.md

# Retrieval Policy

## Default mode

Start with `index.md`.

Use RAG/search only when:

- the index does not identify relevant pages;
- exact text matters;
- the wiki has too many pages;
- the user asks for obscure details;
- source verification is required.

## Index-first answer flow

```text
Question
  ↓
Read index.md
  ↓
Open likely pages
  ↓
Follow wikilinks one hop
  ↓
Answer with citations
  ↓
File durable synthesis if useful

RAG-assisted answer flow

Question
  ↓
Search Trip2G
  ↓
Open top pages
  ↓
Follow links / inspect raw sources
  ↓
Answer with citations
  ↓
Update index if search revealed missing map entries

## Как показывать это пользователю в Trip2G

Первый onboarding для LLM Wiki base:

```markdown
Let's create your first LLM Wiki.

Give me one source:

- an article URL;
- a PDF;
- a folder of notes;
- a transcript;
- a research question.

I will create:

- `AGENTS.md` — how agents should use this base;
- `SCHEMA.md` — what pages look like;
- `index.md` — the map agents read first;
- `log.md` — what changed;
- the first concept/source pages.

После создания:

Your LLM Wiki is ready.

Try asking your agent:

> Read the Trip2G wiki index and explain the difference between RAG and LLM Wiki using only linked pages.

Or:

> Ingest this article and update the wiki without creating duplicate concept pages.

Как связать с Trip2G features

MCP

База становится MCP hub:

Claude/Cursor/Codex → Trip2G MCP → index.md / search / note_html → answer with citations

Frontmatter patches

Можно массово задавать доступ:

if std.startsWith(path, "raw/") then { free: false }
else if std.startsWith(path, "concepts/") then { free: true }
else {}

Default template

Можно сделать:

  • public index page;
  • sidebar с concepts/entities/comparisons;
  • right TOC;
  • magazine grid для public concepts.

Webhooks/cron

Можно запускать:

  • daily lint;
  • weekly digest;
  • source freshness check;
  • broken link repair;
  • new source ingest;
  • query filing.

Federation

Можно иметь несколько wiki:

Personal research wiki
  ↔ product wiki
  ↔ team decisions wiki
  ↔ public expert wiki

Агент сначала читает local index.md, затем при необходимости идёт в remote KB.

Что важно не обещать

  • Не обещать, что LLM Wiki полностью заменяет RAG.
  • Не обещать, что агент всегда правильно поддерживает знания без review.
  • Не обещать бесконечный scale без search/index/graph.
  • Не обещать “truth”, если нет provenance.

Правильное обещание:

Trip2G gives your LLM Wiki a durable, inspectable, MCP-accessible home — with instructions, publishing, permissions, automation and federation.