> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tuturuuu.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Tuturuuu Wiki

> Workspace knowledge base with Markdown pages, spaces, permissions, search, history and a CLI.

Tuturuuu Wiki is the workspace knowledge base in `apps/web` under
`/{locale}/{wsId}/wiki`. A workspace holds **spaces**; each space holds a
nested **page tree**. Pages are written in Markdown and rendered with the shared
renderer in `packages/ui` (`@tuturuuu/ui/wiki/wiki-markdown`), so Wiki and
Tuturuuu Docs render the same way.

## Product decisions

| Decision | Scope and default | Exceptions |
| - | - | - |
| Markdown is the canonical page body. | Every Wiki page. The editor stores and versions raw Markdown (GFM, footnotes, Mermaid, KaTeX, callouts, `[[wikilinks]]`). | The structured document schema in `@tuturuuu/wiki-core` (W1) stays the contract for the docs-corpus importer and publication scanner. |
| Page identity is its path inside the space (`guides/setup`, up to eight kebab-case segments). | Moves rewrite the whole subtree and leave redirects, so old links keep working. | A new page created at a redirected path takes the path back. |
| Space visibility is one of `workspace`, `restricted`, `authenticated` or `public`. | Default `workspace`: workspace members plus invited space members can read. | `restricted`: invited members only (plus workspace document managers). `authenticated`: any signed-in account can read, and the share UI warns before you select it. `public`: anyone holding the share link, once anonymous share-link reading ships; until then the option is hidden and dashboard pages never read share tokens. |
| Writes need an editor/admin space role or `manage_documents` in the workspace. | Every write API and the editor. | Managing sharing and members needs a space admin role or `manage_documents`. |
| Missing and unreadable spaces or pages look the same (404). | API routes and server pages. | None. Responses never reveal titles of pages the viewer cannot read. |
| The Wiki ships behind the `ENABLE_WIKI` workspace flag. | Off by default; the migration turns it on for the root workspace. | The EduFest workshop preparation page reads the root workspace space regardless of the viewer's own workspace flags. |
| Search ignores Vietnamese diacritics. | `kich ban` matches `kịch bản`; titles rank above body text. | Code fence contents are searchable; fence markers and link targets are not. |

## Data and authorization

The tables live in the `private` schema
(`apps/database/supabase/migrations/20261129033000_add_wiki_spaces_and_pages.sql`):
`wiki_spaces`, `wiki_space_members`, `wiki_pages`, `wiki_page_revisions`,
`wiki_page_links`, `wiki_page_redirects`, `wiki_page_stars` and
`wiki_page_comments`. RLS is enabled with no policies, and every privilege is
revoked from `anon`, `authenticated` and `authenticator`. Only `service_role`
reaches them, through `apps/web/src/lib/wiki/*` after the request passes the
membership, permission and visibility checks in
`@tuturuuu/wiki-core/source` (`resolveWikiSpaceAccess`).

Saves go through `private.wiki_put_page`, which is idempotent by path. It
returns `created`, `updated`, `unchanged`, `conflict` (stale `base_revision`) or
`parent_missing`. Concurrent puts serialize per path, and moves
(`private.wiki_move_page`) take an exclusive per-space lock. Each save writes a
revision row; history shows a line diff and restores by saving the old content
as a new revision.

## Rendering safety

The renderer keeps Streamdown's hardening on and never executes raw HTML. Every
rendered href and image source passes `safeWikiRenderHref`, which reuses W1's
reviewed `parseWikiLink` and only admits app-internal paths under explicit
prefixes. GitHub alert blockquotes (`> [!WARNING]`) become callouts. A bare
YouTube or video link on its own line becomes a privacy-friendly embed.

## CLI

`ttr wiki` authors content through the signed-in CLI session:

```bash theme={null}
ttr wiki spaces
ttr wiki create-space handbook --title "Tuturuuu Handbook"
ttr wiki put handbook getting-started --file getting-started.md
ttr wiki import handbook ./handbook          # dry run: prints the plan
ttr wiki import handbook ./handbook --apply  # writes, parents first
ttr wiki export handbook ./out
```

Import files are Markdown with optional front matter (`title`, `slug`,
`parent`, `position`, `icon`). `dir/index.md` describes the page `dir`. A repeated
import is idempotent: unchanged pages report `unchanged` and write nothing.

## EduFest workshop preparation

`https://tuturuuu.com/workshops/edufest-2026/prep` requires sign-in. It renders
the root workspace space `edufest-2026-workshop` (visibility `workspace`, with
presenters from outside the root workspace invited as space viewers). Signed-out
visitors see a sign-in prompt. Signed-in viewers without access see an
"ask for access" page with no titles or content. Regression coverage:
`apps/web/src/lib/workshops/edufest-prep.test.ts`. The public agenda stays on
the roadmap at `/roadmap/workshops/edufest-2026`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.