CLI and TUI for managing Wiki.js instances.
- Multi-instance support: Manage multiple Wiki.js instances with encrypted configuration
- CLI commands: Direct command-line operations for automation
- Interactive TUI: Full-featured terminal user interface with React/Ink
- Page management: Browse, search, edit, move, and delete pages
- Navigation management: Create, edit, move, and delete navigation items
- User management: Create, edit, and manage Wiki.js users and profiles
- Group management: Manage groups, members, permissions, and page rules
- Bulk operations: Delete multiple pages or navigation items at once
- Content analysis: Analyze page structure, find orphaned pages, compare navigation
- Instance sync: Compare and synchronize configurations between instances
- Theme support: Multiple color themes with Nerd Font icon support
npm install -g @bryance/wikit
wikit --helpnpm install @bryance/wikitimport { listPages, syncPages, getStatus } from '@bryance/wikit/commands';
import { WikiConfig } from '@bryance/wikit/types';
const config: WikiConfig = {
// your config
};
const pages = await listPages({ instance: 'primary' });import { createClient, pagesQuery } from '@bryance/wikit/api';import type { Page, User, NavigationItem } from '@bryance/wikit/types';@bryance/wikit- Main CLI entry@bryance/wikit/commands- All command functions@bryance/wikit/api- GraphQL API layer@bryance/wikit/types- TypeScript types@bryance/wikit/utils- Utility functions@bryance/wikit/config- Configuration management
When you run Wikit for the first time, the built-in setup wizard will guide you through configuring your first Wiki.js instance:
wikit tuiThe wizard will prompt you for:
- Instance ID (e.g., 'mywiki')
- Display name
- Wiki.js API URL (e.g., 'https://your-wiki.com/graphql')
- API key
Your credentials are stored encrypted in ~/.config/wikit/config.json on Linux/macOS or C:\Users\<User>\.config\wikit\config.json on Windows.
- Log into your Wiki.js admin panel
- Go to Administration → API Access
- Create a new API key with appropriate permissions
- Copy the generated key when prompted by the setup wizard
Add additional Wiki.js instances using:
wikit config --addList all configured instances:
wikit config --listSwitch between instances using the -i/--instance flag:
wikit -i mywiki list /en/docsFor backwards compatibility, you can still use a .env file in the project root:
# First instance
WIKI1_API_URL=https://wiki1.example.com/graphql
WIKI1_API_KEY=your-api-key-here
# Second instance (optional)
WIKI2_API_URL=https://wiki2.example.com/graphql
WIKI2_API_KEY=your-api-key-hereThe encrypted configuration is recommended as it's more secure and supports unlimited instances.
-i, --instance <name>: Specify Wiki instance
List pages under a specific path prefix:
wikit list <prefix> [options]
# Examples
wikit list /en/docs # List pages under /en/docs
wikit list /en/docs --recursive # Include nested pages
wikit list /en/docs --limit 50 # Limit to 50 results
wikit list /en/docs --all # Show all pages if no matches
wikit -i wiki2 list /en/guides # Use different instanceOptions:
-l, --limit <number>: Limit number of results (0 = all, default: 0)--all: Show all pages if no matches found-r, --recursive: Include nested pages (default: only direct children)
Delete pages under a specific path prefix:
wikit delete <prefix> [options]
# Examples
wikit delete /en/old-docs # Delete with confirmation
wikit delete /en/temp --force # Skip confirmation promptOptions:
-f, --force: Skip confirmation prompt
Compare configurations and content between instances:
wikit compare [options]
# Examples
wikit compare --config # Compare site configuration
wikit compare --theme --assets # Compare theme and assets
wikit compare --pages --details # Compare pages with details
wikit compare --all # Compare everything
wikit compare --page-prefix /en/docs # Compare specific page prefix
wikit compare --from wiki1 --to wiki2 # Specify instancesOptions:
--from <instance>: Source instance--to <instance>: Target instance--config: Compare site configuration--theme: Compare theme configuration--assets: Compare asset configuration--pages: Compare page summaries--users: Compare user summaries--system: Compare system information--all: Compare all configurations--details: Show detailed comparison--page-prefix <prefix>: Compare pages under specific prefix
Show status and differences between instances:
wikit status [options]
# Examples
wikit status # Basic status comparison
wikit status --verbose # Detailed status information
wikit status --from wiki1 --to wiki2 # Specify instancesOptions:
--from <instance>: First instance--to <instance>: Second instance--verbose: Show verbose output
Synchronize configurations between instances:
wikit sync [options]
# Examples
wikit sync --config # Sync site configuration
wikit sync --theme --assets # Sync theme and assets
wikit sync --pages # Sync all pages
wikit sync --pages --page-prefix /en/docs # Sync specific pages
wikit sync --all --dry-run # Preview all changes
wikit sync --config --force # Skip confirmationOptions:
--from <instance>: Source instance--to <instance>: Target instance--config: Sync site configuration--theme: Sync theme configuration--assets: Sync asset configuration--pages: Sync pages content--page-prefix <prefix>: Only sync pages with this path prefix--all: Sync all configurations and pages--dry-run: Show what would be synced without making changes--force: Skip confirmation prompt
Launch the terminal user interface:
wikit tui
# Examples
wikit tui # Launch TUI with default instance
wikit -i wiki2 tui # Launch TUI with specific instanceThe TUI provides an interactive terminal interface with the following features:
The TUI follows consistent keyboard patterns across all interfaces:
Core Navigation:
- ↑↓ (Arrow Up/Down): Navigate through lists and menus
- →← (Arrow Right/Left): Expand/collapse tree items or navigate button groups
- Enter: Confirm selection, open items, or submit forms
- Space: Toggle selections in multi-select lists
- Esc: Go back, cancel, or exit current mode
Standard Patterns:
- Lists: ↑↓ to navigate, Enter to select, Esc to go back
- Multi-select: ↑↓ to navigate, Space to toggle, Enter to confirm, Esc to cancel
- Trees: ↑↓ to navigate, → to expand, ← to collapse, Enter to select
- Forms: ↑↓ to navigate fields, Enter to edit/submit, Esc to cancel
- Menus: ↑↓ to navigate options, Enter to select, Esc to close
Once in TUI mode, you can use these commands:
Page Management:
pages: Browse, search, and manage wiki pages with detailed viewssearch [query]: Search for pages by title or path
Navigation Management:
navornavigation: Manage navigation tree (add, edit, move, delete items)
User & Group Management:
users: Create, edit, and manage Wiki.js usersgroups: Manage groups, members, permissions, and page rules
Analysis & Comparison:
analyze: Analyze page structure, find orphaned pages, compare navigationcompare: Compare pages between instancesstatus: Show instance status and info
Instance Operations:
copy: Copy pages between instancessync: Synchronize configurations between instancesconfig: Manage instance configurations
Interface:
theme: Switch between color themesi [instance]: Switch Wiki.js instancehelp: Show help screen with keyboard shortcutsexitorquit: Exit TUI
Pages Interface:
- Browse all pages with virtualized scrolling
- View detailed page information (content, metadata, tags)
- Edit page properties and content
- Move pages to different paths
- Convert between editor types (markdown/code)
- Delete single or multiple pages
- Export pages to JSON
Navigation Interface:
- View and manage navigation tree structure
- Add new items (links, headers, dividers)
- Edit existing navigation items
- Move items with visual placement picker
- Delete navigation items (single or bulk)
- Import/export navigation configurations
Users Interface:
- List all Wiki.js users
- Create new users with group assignments
- Edit user details and passwords
- Manage user group memberships
- Delete users with confirmation
- Import/export user profiles
Groups Interface:
- View all groups and their members
- Create new groups with permissions
- Manage group membership (add/remove users)
- View and edit group permissions
- Configure page access rules
- Find orphaned users (not in any group)
Analysis Interface:
- Analyze page structure and relationships
- Find orphaned pages (no navigation links)
- Compare navigation between instances
- Compare page content and metadata
- Export analysis results
- Real-time search: Type to filter results instantly across all interfaces
- Bulk selection: Mark multiple items for batch operations
- Confirmation dialogs: Safe operations with detailed confirmation prompts
- Visual previews: See changes before applying (navigation placement, etc.)
- Async operations: Background processing with progress indicators
- Context-aware help: Footer shows relevant keyboard shortcuts for current screen
- Theme switching: Multiple color themes (Dracula, Tokyo Night, Monokai, etc.)
- Nerd Font support: Rich icons when Nerd Fonts are available
src/
├── index.ts # CLI entry point with Commander.js
├── api/ # GraphQL API layer
│ ├── index.ts # Core graphql() function
│ ├── pages.ts # Page queries/mutations
│ ├── navigation.ts # Navigation queries/mutations
│ ├── users.ts # User queries/mutations
│ ├── groups.ts # Group queries/mutations
│ └── config.ts # Configuration queries
├── commands/ # CLI command implementations
│ ├── pages.ts # Page management commands
│ ├── navigation.ts # Navigation commands
│ ├── users.ts # User management commands
│ ├── groups.ts # Group management commands
│ ├── analyze.ts # Analysis commands
│ ├── compare.ts # Comparison commands
│ ├── sync.ts # Synchronization commands
│ └── config.ts # Configuration commands
├── config/ # Configuration management
│ ├── configManager.ts # Core config CRUD operations
│ ├── dynamicConfig.ts # Runtime configuration
│ └── migration.ts # Config migration utilities
├── contexts/ # Global state management
│ └── InstanceContext.ts # Singleton instance manager
├── types/ # TypeScript type definitions
│ ├── page/ # Page-related types
│ ├── navigation/ # Navigation types
│ ├── user/ # User types
│ ├── group/ # Group types
│ └── ... # Other domain types
├── utils/ # Utility functions
│ ├── analyzer.ts # Page analysis utilities
│ ├── commandParser.ts # Command parsing
│ └── ... # Other utilities
└── tui/ # Terminal UI (React/Ink)
├── AppContent.tsx # Main TUI router
├── components/
│ ├── interfaces/ # Main feature interfaces
│ │ ├── pages/ # Pages interface
│ │ ├── navigation/ # Navigation interface
│ │ ├── users/ # Users interface
│ │ ├── groups/ # Groups interface
│ │ ├── analysis/ # Analysis interface
│ │ └── ... # Other interfaces
│ ├── ui/ # Reusable UI components
│ │ ├── VirtualizedList.tsx
│ │ ├── Table.tsx
│ │ └── ...
│ └── modals/ # Dialog components
├── contexts/ # React contexts
│ ├── ThemeContext.tsx # Theme management
│ ├── HeaderContext.tsx # Header state (stack-based)
│ ├── FooterContext.tsx # Footer help text
│ ├── EscapeContext.tsx # Escape key handlers
│ └── IconContext.tsx # Icon formatting
├── themes/ # Color theme definitions
└── hooks/ # Custom React hooks
bun run dev: Run in development mode (src/index.ts)bun run build: Build for production (outputs to dist/)bun run start: Run built version (dist/index.js)bun run typecheck: Run TypeScript type checkingbun run lint: Run ESLint
InstanceContext Singleton:
The application uses a global InstanceContext singleton to manage the current Wiki.js instance:
- CLI mode: A preAction hook in
src/index.tssets the instance before commands run - TUI mode:
AppContentsyncs instance state with the context via useEffect - API layer: The
graphql()function automatically usesInstanceContext.getInstance() - Benefits: Eliminates prop drilling, cleaner function signatures, centralized management
Context Stack Pattern: Several contexts use a stack-based approach:
HeaderContext: Components push header data, automatically restored on unmountFooterContext: Stack-based help text managementEscapeContext: Stacked escape handlers for nested modals/dialogs
Keyboard Navigation: Consistent patterns across all interfaces:
- Arrow keys for navigation
- Space for toggle/selection
- Enter for confirm/action
- Escape for back/cancel
- Defined in
src/tui/constants/keyboard.ts
Adding CLI Commands:
- Create command function in
src/commands/[feature].ts - Add command definition to
src/index.ts(Commander.js) - Define types in
src/types/[feature]/ - Create API functions in
src/api/[feature].ts
Adding TUI Interfaces:
- Create interface component in
src/tui/components/interfaces/[feature]/ - Add command to
src/tui/commands.ts - Update
AppContent.tsxmode handling - Use consistent keyboard navigation patterns
- Use context hooks (useHeaderData, useFooterHelp, useEscape)
Adding API Functions:
- Define GraphQL queries/mutations in
src/api/[feature].ts - Use the core
graphql()function fromsrc/api/index.ts - Define response types in
src/types/[feature]/ - No need to pass instance - it's handled by InstanceContext
Themes are defined in src/tui/themes/. The application includes:
- Dracula
- Tokyo Night
- Monokai
- Synthwave
- Duskfox
- Horizon
- Scarlet Protocol
- ILS Theme
Create new themes by implementing the Theme interface from src/tui/themes/types.ts.
API Connection Errors:
- Verify your API URL is correct and accessible
- Ensure API key has proper permissions
- Check that GraphQL endpoint is enabled in Wiki.js
Missing Environment Variables:
- Ensure
.envfile is in project root - Verify all required variables are set
- Check variable names match exactly (case-sensitive)
Permission Errors:
- API key must have admin privileges
- Some operations require specific permissions in Wiki.js
TUI Display Issues:
- Ensure terminal supports ANSI colors
- Try resizing terminal window
- Use
wikit --helpfor CLI-only mode
- Use
wikit --helpfor CLI help - Use
wikit tuithen typehelpfor TUI help - Check Wiki.js documentation for API configuration
- Verify GraphQL endpoint is working:
curl -X POST [your-api-url]
MIT License - see LICENSE file for details.
