{{ctx.Locale.Tr "repo.no_desc"}}
+ {{end}} +diff --git a/.gitcleaner/health-report.md b/.gitcleaner/health-report.md new file mode 100644 index 0000000000..3a029e447d --- /dev/null +++ b/.gitcleaner/health-report.md @@ -0,0 +1,26 @@ +# Repository Health Report + +## Overall Score: 77/100 (Good) + +### Summary +- Commits Analyzed: 1000 +- Branches: 1 +- Authors: 149 +- Merges: 0 + +### Component Scores +| Component | Score | +|-----------|-------| +| Messages | 90% | +| Merges | 97% | +| Duplicates | 0% | +| Branches | 100% | +| Authorship | 100% | + +### Issues (3) +- **Merge fix commits detected**: Found 1 commits with messages like 'fix merge' detected after merges. (-3 pts) +- **Duplicate commits with identical content**: Found 1 groups of commits with identical file content (1 redundant commits). These are safe to squash as they have the same tree SHA. (-7 pts) +- **Commits with duplicate messages**: Found 1 groups of commits with identical messages but different code changes (135 commits). Consider using more descriptive messages to differentiate changes. (-1 pts) + +--- +Generated by GitCleaner for GitCaddy dd diff --git a/docs/phase5-ai-wiki-spec.md b/docs/phase5-ai-wiki-spec.md new file mode 100644 index 0000000000..8cacfd35cb --- /dev/null +++ b/docs/phase5-ai-wiki-spec.md @@ -0,0 +1,354 @@ +# Phase 5: AI-Friendly Wiki API (v2) + +**Version:** 2.0 +**Date:** January 2026 +**Status:** IN PROGRESS + +--- + +## Overview + +Phase 5 adds a v2 Wiki API designed for AI/LLM consumption and external plugin integration. This enhances the existing wiki functionality without modifying v1 endpoints. + +### Goals + +1. **AI-Ready Data** - Structured responses optimized for LLM consumption +2. **Full CRUD** - Complete wiki management via API +3. **Search** - Full-text search across wiki content +4. **Relationships** - Page link graph for navigation +5. **Health Metrics** - Wiki statistics and maintenance insights +6. **Plugin-Friendly** - Enable external tools (like .NET AI plugins) to build on top + +--- + +## V2 API Endpoints + +Base URL: `/api/v2/repos/{owner}/{repo}/wiki` + +### Pages CRUD + +#### List All Pages +``` +GET /api/v2/repos/{owner}/{repo}/wiki/pages +``` + +Query Parameters: +- `include_content` (bool, default: false) - Include full page content +- `page` (int) - Page number for pagination +- `limit` (int, default: 30) - Items per page + +Response: +```json +{ + "pages": [ + { + "name": "Home", + "title": "Home", + "path": "Home.md", + "url": "/owner/repo/wiki/Home", + "word_count": 450, + "last_commit": { + "sha": "abc123", + "author": "username", + "message": "Updated home page", + "date": "2026-01-08T10:00:00Z" + }, + "content": "# Home\n\nWelcome...", // if include_content=true + "content_html": "
Welcome to the project...
", + "word_count": 450, + "links_out": ["Installation", "Configuration", "FAQ"], + "links_in": ["Home", "README"], + "sidebar": "## Navigation\n- [[Home]]\n- [[Getting-Started]]", + "footer": "Copyright 2026", + "history_url": "https://gitea.example.com/api/v2/repos/owner/repo/wiki/pages/Getting-Started/revisions", + "last_commit": { + "sha": "def456...", + "message": "Add quick start section", + "date": "2026-01-08T14:22:00Z", + "author": { + "name": "Jane Smith", + "email": "jane@example.com" + }, + "committer": { + "name": "Jane Smith", + "email": "jane@example.com" + } + } +} +``` + +**Key Fields for AI Integration:** + +| Field | Description | +|-------|-------------| +| `content` | Raw markdown content (use for AI processing) | +| `content_html` | Pre-rendered HTML (use for display) | +| `links_out` | Pages this page links to | +| `links_in` | Pages that link to this page | +| `word_count` | Word count for content analysis | + +--- + +### Create Wiki Page + +Creates a new wiki page. + +```http +POST /api/v2/repos/{owner}/{repo}/wiki/pages +``` + +**Request Body:** `CreateWikiPageV2Option` + +```json +{ + "name": "New-Feature", + "title": "New Feature Documentation", + "content": "# New Feature\n\nThis page documents the new feature...", + "message": "Add documentation for new feature" +} +``` + +| Field | Required | Description | +|-------|----------|-------------| +| `name` | Yes | Page name (used in URL, spaces become dashes) | +| `title` | No | Display title (defaults to name) | +| `content` | Yes | Markdown content | +| `message` | No | Commit message (auto-generated if empty) | + +**Response:** Redirects to the created page (HTTP 302) + +--- + +### Update Wiki Page + +Updates an existing wiki page. Can also rename the page. + +```http +PUT /api/v2/repos/{owner}/{repo}/wiki/pages/{pageName} +``` + +**Request Body:** `UpdateWikiPageV2Option` + +```json +{ + "title": "Updated Title", + "content": "# Updated Content\n\nNew content here...", + "message": "Update page content", + "rename_to": "New-Page-Name" +} +``` + +| Field | Required | Description | +|-------|----------|-------------| +| `title` | No | New display title | +| `content` | No | New markdown content | +| `message` | No | Commit message | +| `rename_to` | No | New page name (renames the page) | + +**Response:** Redirects to the updated page (HTTP 302) + +--- + +### Delete Wiki Page + +Deletes a wiki page. + +```http +DELETE /api/v2/repos/{owner}/{repo}/wiki/pages/{pageName} +``` + +**Response:** `WikiDeleteResponseV2` + +```json +{ + "success": true +} +``` + +--- + +### Search Wiki + +Full-text search across all wiki pages. + +```http +GET /api/v2/repos/{owner}/{repo}/wiki/search?q={query} +``` + +**Query Parameters:** + +| Parameter | Type | Default | Description | +|-----------|------|---------|-------------| +| `q` | string | required | Search query | +| `limit` | int | 20 | Max results (max 100) | +| `offset` | int | 0 | Skip N results | + +**Response:** `WikiSearchResponseV2` + +```json +{ + "query": "installation", + "results": [ + { + "name": "Getting-Started", + "title": "Getting Started", + "snippet": "...Follow these steps for **installation**. First, download the package...", + "score": 8.5, + "word_count": 450, + "last_updated": "2026-01-08T14:22:00Z" + }, + { + "name": "Installation", + "title": "Installation Guide", + "snippet": "# **Installation** Guide\n\nThis page covers all **installation** methods...", + "score": 12.3, + "word_count": 890, + "last_updated": "2026-01-05T09:15:00Z" + } + ], + "total_count": 2 +} +``` + +**Score Calculation:** +- Title match: +10 points +- Page name match: +8 points +- Content matches: +0.5 per occurrence +- Normalized by word count + +--- + +### Get Link Graph + +Returns the wiki's link relationship graph (for visualization or analysis). + +```http +GET /api/v2/repos/{owner}/{repo}/wiki/graph +``` + +**Response:** `WikiGraphV2` + +```json +{ + "nodes": [ + { "name": "Home", "title": "Home", "word_count": 250 }, + { "name": "Getting-Started", "title": "Getting Started", "word_count": 450 }, + { "name": "Installation", "title": "Installation Guide", "word_count": 890 }, + { "name": "Configuration", "title": "Configuration", "word_count": 320 } + ], + "edges": [ + { "source": "Home", "target": "Getting-Started" }, + { "source": "Home", "target": "Installation" }, + { "source": "Getting-Started", "target": "Installation" }, + { "source": "Getting-Started", "target": "Configuration" }, + { "source": "Installation", "target": "Configuration" } + ] +} +``` + +**Use Cases:** +- Build a visual wiki map +- Find navigation paths between pages +- Identify central/hub pages +- Detect isolated page clusters + +--- + +### Get Wiki Statistics + +Returns comprehensive wiki statistics and health metrics. + +```http +GET /api/v2/repos/{owner}/{repo}/wiki/stats +``` + +**Response:** `WikiStatsV2` + +```json +{ + "total_pages": 15, + "total_words": 12500, + "total_commits": 87, + "last_updated": "2026-01-09T10:30:00Z", + "contributors": 5, + "health": { + "orphaned_pages": [ + { "name": "Old-Feature", "word_count": 120 } + ], + "dead_links": [ + { "page": "Getting-Started", "broken_link": "Deprecated-Page" } + ], + "outdated_pages": [ + { "name": "Legacy-Setup", "last_edit": "2025-03-15T00:00:00Z", "days_old": 300 } + ], + "short_pages": [ + { "name": "TODO", "word_count": 25 } + ] + }, + "top_linked": [ + { "name": "Home", "incoming_links": 12 }, + { "name": "Installation", "incoming_links": 8 }, + { "name": "Configuration", "incoming_links": 6 } + ] +} +``` + +**Health Metrics:** + +| Metric | Description | +|--------|-------------| +| `orphaned_pages` | Pages with no incoming links (except Home) | +| `dead_links` | Links pointing to non-existent pages | +| `outdated_pages` | Pages not edited in 180+ days | +| `short_pages` | Pages with < 100 words | + +--- + +### Get Page Revisions + +Returns the revision history for a specific page. + +```http +GET /api/v2/repos/{owner}/{repo}/wiki/pages/{pageName}/revisions +``` + +**Query Parameters:** + +| Parameter | Type | Default | Description | +|-----------|------|---------|-------------| +| `page` | int | 1 | Page number | + +**Response:** `WikiRevisionsV2` + +```json +{ + "page_name": "Getting-Started", + "revisions": [ + { + "sha": "abc123...", + "message": "Add troubleshooting section", + "date": "2026-01-09T10:30:00Z", + "author": { + "name": "John Doe", + "email": "john@example.com" + } + }, + { + "sha": "def456...", + "message": "Fix typo in installation steps", + "date": "2026-01-08T14:22:00Z", + "author": { + "name": "Jane Smith", + "email": "jane@example.com" + } + } + ], + "total_count": 15 +} +``` + +--- + +## Data Models + +### C# Model Definitions + +```csharp +// Wiki Page (full details) +public class WikiPageV2 +{ + public string Name { get; set; } + public string Title { get; set; } + public string Path { get; set; } + public string Url { get; set; } + public string HtmlUrl { get; set; } + public string Content { get; set; } + public string ContentHtml { get; set; } + public int WordCount { get; set; } + public List{{ctx.Locale.Tr "repo.no_desc"}}
+ {{end}} +{{.Config.Hero.Tagline}}
+ {{end}} +{{.Config.Hero.Tagline}}
+ {{end}} +{{.Description}}
+{{.Config.Hero.Tagline}}
+ {{end}} +