e147209e77
This commit introduces the complete wiki feature for WeKnora, enabling AI-powered wiki page generation and management. The implementation includes: **Backend Changes:** - Wiki data model: WikiPage type with support for multiple page types (Summary, Entity, Concept, Index, Log) - Database schema: wiki_pages table with full migration support - WikiPageService: CRUD operations and page management - WikiPageRepository: GORM-based persistence layer - Wiki ingest pipeline: Automated generation of wiki pages from knowledge documents * Summary page generation using LLM * Entity and concept extraction in a single LLM call * Synthesis opportunity detection * Index page rebuilding * Log page maintenance - Wiki boost feature: Enhance chat retrieval with wiki context - Wiki linting: Maintenance and validation utilities - Agent wiki tools: Enable agents to query and interact with wiki pages - Wiki prompts: Comprehensive LLM prompt templates for all wiki generation tasks - Language support: Reuse existing middleware language infrastructure for LLM prompts **Frontend Changes:** - Wiki browser UI: View all wiki pages with filtering and search - Wiki API client: Knowledge base wiki management endpoints - Knowledge base editor: Configure wiki settings (language, auto-ingest, synthesis model) - i18n updates: Support for English, Korean, Russian, and Chinese interfaces **Configuration:** - Container DI: Wire up all wiki services - Router: Register wiki API endpoints - Task handling: Support async wiki ingest tasks **Testing:** - Unit tests for wiki page types - Service layer tests - Endpoint tests for wiki operations - Integration tests with LLM mocking **Documentation:** - Language refactoring analysis and guides - Implementation completion reports - Quick reference guides for developers **Key Features:** ✅ LLM-powered wiki page generation from documents ✅ Multi-language support (9+ languages) ✅ Automatic extraction of entities and concepts ✅ Synthesis opportunity detection ✅ Index and log page maintenance ✅ Progressive wiki building across multiple documents ✅ Agent-based wiki interaction ✅ Chat retrieval enhancement with wiki context ✅ Full frontend UI for wiki browsing Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
58 lines
2.5 KiB
SQL
58 lines
2.5 KiB
SQL
-- Migration: 000032_wiki_pages
|
|
-- Description: Add wiki_pages table and wiki_config column to knowledge_bases.
|
|
-- Wiki pages are LLM-generated, interlinked markdown documents that form a persistent wiki.
|
|
DO $$ BEGIN RAISE NOTICE '[Migration 000032] Creating wiki_pages table and adding wiki_config column'; END $$;
|
|
|
|
-- Add wiki_config column to knowledge_bases
|
|
ALTER TABLE knowledge_bases ADD COLUMN IF NOT EXISTS wiki_config JSONB;
|
|
|
|
COMMENT ON COLUMN knowledge_bases.wiki_config IS 'Wiki configuration: {"auto_ingest": bool, "synthesis_model_id": string, "wiki_language": string, "max_pages_per_ingest": int}';
|
|
|
|
-- Create wiki_pages table
|
|
CREATE TABLE IF NOT EXISTS wiki_pages (
|
|
id VARCHAR(36) PRIMARY KEY,
|
|
tenant_id BIGINT NOT NULL,
|
|
knowledge_base_id VARCHAR(36) NOT NULL,
|
|
slug VARCHAR(255) NOT NULL,
|
|
title VARCHAR(512) NOT NULL DEFAULT '',
|
|
page_type VARCHAR(32) NOT NULL DEFAULT 'summary',
|
|
status VARCHAR(32) NOT NULL DEFAULT 'published',
|
|
content TEXT NOT NULL DEFAULT '',
|
|
summary TEXT NOT NULL DEFAULT '',
|
|
source_refs JSONB DEFAULT '[]'::JSONB,
|
|
in_links JSONB DEFAULT '[]'::JSONB,
|
|
out_links JSONB DEFAULT '[]'::JSONB,
|
|
page_metadata JSONB DEFAULT '{}'::JSONB,
|
|
version INT NOT NULL DEFAULT 1,
|
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
|
|
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
|
|
deleted_at TIMESTAMP WITH TIME ZONE
|
|
);
|
|
|
|
-- Unique constraint: slug must be unique within a knowledge base (for non-deleted pages)
|
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_wiki_pages_kb_slug
|
|
ON wiki_pages (knowledge_base_id, slug)
|
|
WHERE deleted_at IS NULL;
|
|
|
|
-- Index for listing pages by knowledge base
|
|
CREATE INDEX IF NOT EXISTS idx_wiki_pages_kb_id
|
|
ON wiki_pages (knowledge_base_id);
|
|
|
|
-- Index for filtering by page type
|
|
CREATE INDEX IF NOT EXISTS idx_wiki_pages_page_type
|
|
ON wiki_pages (knowledge_base_id, page_type);
|
|
|
|
-- Index for tenant isolation
|
|
CREATE INDEX IF NOT EXISTS idx_wiki_pages_tenant_id
|
|
ON wiki_pages (tenant_id);
|
|
|
|
-- Index for soft delete queries
|
|
CREATE INDEX IF NOT EXISTS idx_wiki_pages_deleted_at
|
|
ON wiki_pages (deleted_at);
|
|
|
|
-- Full-text search index on title and content
|
|
CREATE INDEX IF NOT EXISTS idx_wiki_pages_fulltext
|
|
ON wiki_pages USING GIN (to_tsvector('simple', coalesce(title, '') || ' ' || coalesce(content, '')));
|
|
|
|
DO $$ BEGIN RAISE NOTICE '[Migration 000032] wiki_pages table and wiki_config column created successfully'; END $$;
|