@misaka09982/code-wiki
v0.7.8
Published
TypeScript backend for CodeWiki with repository analysis, graph APIs, wiki drafts, and Q&A endpoints.
Downloads
143
Maintainers
Readme
@misaka09982/code-wiki
TypeScript backend for CodeWiki. It provides the HTTP API, CLI commands, stdio MCP server, SQLite storage, repository scanning, lightweight graph analysis, wiki drafts, source-grounded Q&A endpoints, and optional OpenAI-compatible Q&A answers plus wiki catalog/page generation with cached LLM runs.
Install
npm install -g @misaka09982/code-wikiThis installs three binaries:
codewiki: main CLI for repositories, analysis, wiki, graph, Q&A, and server mode.codewiki-backend: alias for the same CLI, useful when anothercodewikibinary exists.codewiki-mcp: stdio MCP server for editor and agent integrations.
Check the install:
codewiki --version
codewiki --helpCodeWiki requires Node.js 22.13 or newer. SQLite storage uses Node's built-in
node:sqlite module, so Windows installs do not need Visual Studio Build Tools
or a native better-sqlite3 compile step.
First Run
Start the bundled web app and API:
codewiki serveThen open:
http://127.0.0.1:8000From the UI you can register a repository, analyze it, inspect the graph, generate wiki pages, and ask source-grounded questions.
By default CodeWiki stores data in a local SQLite database backed by
node:sqlite. You can choose a database location with:
export CODEWIKI_DATABASE_URL="sqlite:///$HOME/.codewiki/codewiki.sqlite3"CLI Walkthrough
Register the current repository:
cd /path/to/your/repo
codewiki repos add . --name my-repoRun analysis:
codewiki analyze my-repoGenerate a provider-backed wiki catalog and pages after configuring catalog/page LLM profiles:
codewiki wiki catalog my-repo
codewiki wiki pages my-repoList and read generated pages:
codewiki wiki list my-repo
codewiki wiki read overview my-repoAsk a question:
codewiki ask "How does the main request flow work?" my-repoInspect graph data:
codewiki graph status my-repo
codewiki graph search "handler" my-repo
codewiki graph explore my-repo --jsonAfter code changes, refresh the index and regenerate stale wiki pages:
codewiki update my-repoMost repository arguments accept a registered name, id, id prefix, filesystem path,
or Git URL. Add --json to most commands for machine-readable output.
Agent-Generated Wiki
CodeWiki can also act as a local evidence engine for Codex, Claude Code, or other agents. In this mode CodeWiki does not call an external LLM for catalog or page writing. It returns bounded local evidence, lets the agent write the catalog and Markdown, saves the results, and validates citations.
Install the Codex skill:
codewiki skill install codexThen use the local workflow:
codewiki repos add . --name my-repo --json
codewiki analyze my-repo --json
codewiki wiki catalog-evidence my-repo --language en --json
# Write catalog JSON with title/items, then save it:
cat catalog.json | codewiki wiki catalog-save my-repo --language en --stdin --json
codewiki wiki catalog-validate my-repo --language en --json
codewiki wiki plan my-repo --language en --json
codewiki wiki evidence src my-repo --language en --json
printf '# Src\n\nThis page is grounded in returned evidence. [[S1]]\n' \
| codewiki wiki save src my-repo --language en --title Src --stdin --json
codewiki wiki validate src my-repo --language en --json
codewiki wiki read src my-repoAgents must cite returned allowed_source_refs with [[S#]]. Pages with missing
citations or unknown slugs are saved as drafts and reported by wiki validate.
Claude Code can use the same capability through codewiki-mcp. Configure the MCP
server and call:
codewiki_wiki_catalog_evidencecodewiki_wiki_catalog_savecodewiki_wiki_catalog_validatecodewiki_wiki_plancodewiki_wiki_evidencecodewiki_wiki_page_savecodewiki_wiki_page_validate
LLM Configuration
CodeWiki works without an LLM: analysis, graph search, deterministic retrieval, and basic wiki drafts still run locally. To enable provider-backed answers, community names, wiki catalogs, and richer pages, configure an OpenAI-compatible profile:
codewiki config --init
codewiki config --model openai/gpt-4.1 --api-key "$OPENAI_API_KEY"Or use environment variables:
export CODEWIKI_LLM__DEFAULT__MODEL="openai/gpt-4.1"
export CODEWIKI_LLM__DEFAULT__API_KEY="$OPENAI_API_KEY"Use separate task profiles when you want different models for wiki pages, Q&A, or community naming:
export CODEWIKI_LLM__PROFILES__CATALOG__MODEL="openai/gpt-4.1"
export CODEWIKI_LLM__PROFILES__CATALOG__API_KEY="$OPENAI_API_KEY"
export CODEWIKI_LLM__PROFILES__PAGE__MODEL="openai/gpt-4.1"
export CODEWIKI_LLM__PROFILES__PAGE__API_KEY="$OPENAI_API_KEY"
export CODEWIKI_LLM__PROFILES__COMMUNITY_SUMMARY__MODEL="openai/gpt-4.1"
export CODEWIKI_LLM__PROFILES__COMMUNITY_SUMMARY__API_KEY="$OPENAI_API_KEY"Check configured values:
codewiki config list
codewiki config modelsWiki Translation
Generate the base English wiki first, then translate to another language:
codewiki wiki pages my-repo --language en
codewiki wiki translate zh my-repo
codewiki wiki list my-repo --language zhThe web UI has language tabs for reading and generating wiki pages. When generating a non-English wiki, CodeWiki ensures the base English pages exist and then stores translated pages under the selected language.
MCP Usage
Run the shared database MCP server:
codewiki-mcpFor editor projects, lite mode keeps a project-local database under .codewiki/:
codewiki mcp --lite --path .codewiki mcp --lite uses a project-local .codewiki/codewiki-lite.sqlite3
database and registers the selected project automatically, which is convenient
for editor MCP clients that should not depend on a shared global CodeWiki DB.
You can also use lite mode directly from the CLI:
codewiki lite init --name my-repo
codewiki lite index
codewiki lite query "handler"
codewiki lite context "authentication flow"
codewiki lite statusCommon Commands
codewiki serve --host 127.0.0.1 --port 8000
codewiki repos list
codewiki repos tree --repo my-repo
codewiki files list --repo my-repo --source-only
codewiki graph affected my-repo src/main.ts --json
codewiki graphrag build my-repo
codewiki graphrag retrieve "startup flow" my-repo
codewiki wiki update my-repo
codewiki wiki page root my-repo
codewiki wiki translate zh my-repoTroubleshooting
- If
codewikiis not found, ensure your npm global bin directory is onPATH.npm bin -gornpm config get prefixcan help locate it. - If
npm publishor install commands mention scoped package access, usenpm publish --access publicfor this package. - If analysis finds too few files, check
.gitignoreand generated/vendor folders. - If LLM-backed commands fall back to deterministic output, run
codewiki config listand verify the model, endpoint, and API key. - If the server port is busy, run
codewiki serve --port 8001.
Library Imports
The npm package can also be embedded from Node.js:
import {
createServer,
CodeWikiStore,
RepoScanner,
} from "@misaka09982/code-wiki";
import { CodeWikiMCPServer } from "@misaka09982/code-wiki/mcp";Development
npm install
npm run build
npm test
npm pack --dry-run
npm run pack:smokeThe package keeps the established CodeWiki SQLite table names where practical, so existing local CodeWiki databases can be read by the TypeScript service.
