Skip to content

About

AI-powered PWA for querying and editing the NITC Wiki from any device — no backend needed

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

NITC Wiki PWA

A Progressive Web App for interacting with the NITC Wiki through AI chat, search, and direct editing — a fully static, client-side app. There is no backend: everything runs in your browser.

Features

  • AI Chat — Ask questions in natural language. The AI has 15 tools to read, search, and edit the wiki.
  • Wiki Reader — Search and browse wiki pages in a mobile-optimized view.
  • Write support — Create, edit, delete, and rename pages through AI using BotPasswords login.
  • Installable — Add to home screen.

Wiki server prerequisites (for editing — blocking)

The app is served from its own Pages domain, so every authenticated MediaWiki call is cross-origin. Writes do not work until these are applied in the wiki's LocalSettings.php:

  1. $wgCrossSiteAJAXdomains must include the Pages origin(s):
    $wgCrossSiteAJAXdomains = [
        'nitc-wiki.pages.dev',        // production domain (adjust to actual)
        '*.nitc-wiki.pages.dev',      // preview deployments, if desired
    ];
    Status: NOT configured (verified 2026-08-23 — every external origin gets mediawiki-cors-rejection: Origin mismatch from api.php).
  2. $wgCookieSameSite = 'None'; — without this the login session cookie is not sent on cross-origin fetch calls. Status: NOT configured (verified 2026-08-23 — session cookie is set without any SameSite attribute, so browsers default to Lax).
  3. HTTPS-only wiki ($wgForceHTTPS) — required for SameSite=None cookies to be honored. Status: satisfied (wiki serves HTTPS-only; session cookie already carries Secure).

Reads are unaffected: they use JSONP and need no server config.

AI Tools

The PWA exposes the following tools to the AI model via OpenAI-compatible function calling:

Read tools

Tool Description
wiki_search Full-text search across wiki pages
get_page Rendered text content of a page
get_page_wikitext Raw wikitext with templates and tables
get_page_history Revision history with editors and timestamps
get_links_here Pages that link to a given page
get_recent_changes Recent edits across the entire wiki
get_site_info Wiki metadata, statistics, and extensions
get_file_info File metadata (images, PDFs, etc.)
parse_wikitext Preview wikitext as rendered HTML
cargo_query Query structured Cargo database tables
list_category List pages in a wiki category

Write tools

Tool Description
edit_page Update an existing wiki page
create_page Create a new wiki page
delete_page Delete a wiki page
move_page Rename a wiki page

Quick Start

  1. Open the hosted PWA
  2. Tap Settings and enter your AI API credentials:
    • API Base URL — any CORS-enabled OpenAI-compatible endpoint (e.g. https://openrouter.ai/api/v1, https://api.groq.com/openai/v1)
    • API Key — your key for that provider
    • Model — any model ID
  3. Start asking questions!
  4. (Optional) Set bot credentials in Settings to enable editing

Note: providers that block browser CORS requests (e.g. NVIDIA NIM) cannot be used — there is no relay anymore. OpenRouter, Groq, and local Ollama work directly.

Local models (Ollama)

Run a model locally and point the PWA at it:

ollama pull gemma4:e4b     # 10 GB — decent function calling
ollama pull llama3.2:3b    # 2 GB — lightweight
ollama pull qwen2.5:7b     # 4.7 GB — good general purpose

Then set API Base URL to http://localhost:11434/v1, turn Ollama Mode ON, and set the model name.

Development & Deploy

npm install
npm run dev        # local dev server
npm run build      # static output in dist/
npx wrangler pages deploy dist   # or connect the repo in the Cloudflare dashboard:
                                 # Framework: Vite → build `npm run build`, output `dist`

How it works

The PWA is a static site (Vite + hono/jsx/dom). Everything runs client-side:

  • Reads: JSONP (format=json&callback=fn) against the MediaWiki API — works from any origin, no CORS needed
  • Writes: real MediaWiki CORS flow — login token → action=login with BotPasswords → CSRF token → write action, all with origin=<app origin> and credentials: 'include' (requires the wiki-side config above)
  • AI: streaming chat completions straight from the browser to the provider; your API key stays in localStorage
  • Tool loop: the model calls tools, the browser executes them, results are fed back — no server involved

File Structure

/                       # repo root = app root
├── index.html          # Vite entry
├── package.json
├── vite.config.ts      # esbuild jsxImportSource: hono/jsx/dom
├── public/
│   ├── manifest.json   # PWA manifest (scope/start_url = "/")
│   └── icons/          # App icons
└── src/
    ├── main.tsx        # render(<App/>, #root)
    ├── app.tsx         # hash router + nav (chat / reader / settings)
    ├── style.css       # Mobile-first dark-mode styles
    ├── lib/
    │   ├── wiki-api.ts # MediaWiki client: JSONP reads, CORS login/write flow
    │   ├── ai-orchestrator.ts # Streaming function-calling loop, 15 tools
    │   ├── settings.ts # localStorage-backed settings
    │   └── ui.ts       # Toast, theme, hash-param helpers
    └── components/
        ├── Chat.tsx    # Chat UI with incremental streaming + tool results
        ├── Reader.tsx  # Wiki reader view
        └── Settings.tsx # Settings form

Tech Stack

  • Vite + TypeScript — bundler/build
  • hono/jsx/dom — UI runtime (hooks from hono/jsx, render from hono/jsx/dom)
  • Marked.js (bundled) — markdown rendering
  • MediaWiki API — JSONP for reads, authenticated CORS for writes
  • OpenAI-compatible API — any CORS-enabled provider that speaks the chat completions format

About

AI-powered PWA for querying and editing the NITC Wiki from any device — no backend needed

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages