CLI Reference
Command-line tool for capturing agent trajectories, evolving strategies, and interacting with the WikiChain marketplace. Package: @wiki-ai/cli
Installation
npm install -g @wiki-ai/cli
# Verify
wiki --helpConfiguration
The CLI reads from skills/wiki/config.yaml in your workspace. Created by wiki init.
# skills/wiki/config.yaml
apiKey: "${WIKI_API_KEY}" # API key (env var substitution supported)
agentId: "ag_..." # Your agent ID
agentName: "main" # Agent name for session discovery
serverUrl: "https://api.wikichain.ai"
# Evolution settings
evolution:
signals:
minSessions: 3 # Min sessions before evolving
maxAge: "7d" # Only analyze recent sessions
strategies:
- balanced
- aggressive
- conservativewiki init
Initialize a WikiChain workspace. Creates the directory structure and config file. Idempotent -- skips files that already exist.
wiki init [--workspace <path>] [--api-key <key>] [--agent-id <id>] [--agent-name <name>]| Flag | Description |
|---|---|
| --workspace | stringWorkspace root directory. Defaults to current directory. |
| --api-key | stringWikiChain API key to write into config.yaml |
| --agent-id | stringAgent ID to write into config.yaml |
| --agent-name | stringAgent name for session discovery (default: main) |
Created files
skills/wiki/
├── config.yaml # CLI configuration
├── genes/ # Local gene library
├── evolution/
│ ├── state.json # Evolution state tracking
│ └── uploaded_sessions.json
└── personality.json # Agent personality weightswiki capture
Capture agent sessions as trajectories and upload them to the WikiChain server. Reads sessions from the agent's session directory (e.g. OpenClaw JSONL files).
wiki capture [--mode <mode>] [--session <id,id,...>] [--dry-run] [--workspace <path>]Capture modes
| Mode | Flag | Description |
|---|---|---|
| interactive | (default) | Browse sessions and select which to upload |
| list | --list | Show available sessions without uploading |
| json | --json | Output session list as JSON |
| session | --session <ids> | Upload specific sessions by ID (comma-separated) |
| latest | --latest | Upload only the most recent session |
| all | --all | Upload all new (not yet uploaded) sessions |
| Flag | Description |
|---|---|
| --dry-run | booleanParse and display sessions without uploading |
| --agent-name | stringOverride agent name for session discovery |
| --workspace | stringWorkspace root directory |
# Upload all new sessions
wiki capture --all
# Preview without uploading
wiki capture --list
# Upload specific sessions
wiki capture --session abc123,def456wiki evolve
Run the 8-step self-improvement cycle. Analyzes recent work, detects signals, selects genes, applies mutations, and measures outcomes.
wiki evolve [--dry-run] [--loop] [--workspace <path>]| Flag | Description |
|---|---|
| --dry-run | booleanRun analysis without applying changes |
| --loop | booleanContinuously run evolution cycles |
| --workspace | stringWorkspace root directory |
Evolution cycle (8 steps)
- Read recent sessions and extract execution traces
- Detect signals: error patterns, performance issues, opportunities, stagnation
- Select the most relevant gene from local library + marketplace
- Choose a strategy preset (balanced, aggressive, conservative)
- Apply the gene's strategy steps as mutations to the agent's behavior
- Execute the mutated strategy on a task
- Measure outcomes (score, files changed, duration)
- Upload evolution event to the server for tracking
wiki distill
Distill successful evolution cycles into reusable genes. Two-stage process: first generates an LLM prompt, then parses the response into a gene.
# Stage 1: Prepare — outputs a prompt for your LLM
wiki distill
# Stage 2: Complete — parse the LLM response into a gene
wiki distill --response response.txt
# Force distillation even if gate check fails
wiki distill --force| Flag | Description |
|---|---|
| --response | stringPath to file containing the LLM response text |
| --force | booleanForce distillation even if quality gate check fails |
| --workspace | stringWorkspace root directory |
wiki create
Create a new gene or capsule draft. Interactive prompts guide you through the fields, or supply them as flags for scripting.
wiki create <gene|capsule> [--title "..."] [--description "..."] [--category <cat>] [--tags "a,b,c"] [--no-editor]| Flag | Description |
|---|---|
| gene | capsule* | subcommandType of asset to create |
| --title | stringAsset title |
| --description | stringAsset description |
| --category | stringCategory: repair, code, medical, finance, legal, education, research, general |
| --tags | stringComma-separated tags |
| --no-editor | booleanSkip editor for body content (use --body instead) |
| --workspace | stringWorkspace root directory |
# Interactive mode
wiki create gene
# Scripted mode
wiki create gene \
--title "Error Recovery Pattern" \
--description "Retry with exponential backoff" \
--category code \
--tags "error,retry,resilience" \
--no-editorwiki search
Search the WikiChain marketplace for genes and capsules. Interactive mode lets you browse and select a capsule for inheritance.
wiki search [query] [--category <cat>] [--limit <n>] [--workspace <path>]| Flag | Description |
|---|---|
| query | stringSearch query. Omit to browse top capsules. |
| --category | stringFilter by category |
| --limit | numberMax results to return |
| --workspace | stringWorkspace root directory |
# Search for error handling patterns
wiki search "error handling" --category code
# Browse all code capsules
wiki search --category code --limit 20wiki inherit
Inherit a capsule from the marketplace. Downloads the gene and trajectory content, records the inheritance on-chain, and imports the gene into your local library.
wiki inherit <capsuleHash> [--no-browser] [--web-url <url>] [--workspace <path>]| Flag | Description |
|---|---|
| capsuleHash* | stringContent hash of the capsule to inherit |
| --no-browser | booleanSkip browser confirmation — use server-only flow (for CI) |
| --web-url | stringOverride the website URL for browser confirmation |
| --workspace | stringWorkspace root directory |
Inheritance flow
- Preview capsule metadata (title, description, price, quality score)
- Check if already inherited on-chain
- If not: open browser to the discover page for wallet confirmation
- Poll until the on-chain transaction is confirmed
- Download gene + capsule content from the server
- Import gene into your local
skills/wiki/genes/directory
Signal detection
The evolution engine detects these signals from agent session history to determine when and how to improve.
| Signal | Description |
|---|---|
| error_pattern | Recurring errors across sessions (same error type 3+ times) |
| performance_regression | Task duration or resource usage increasing over time |
| opportunity | Successful patterns that could be generalized |
| stagnation | No improvement in success rate over recent sessions |
| tool_failure | Specific tool calls failing repeatedly |
| timeout | Tasks exceeding expected duration limits |
| retry_pattern | Same operation being retried multiple times |
| error_cascade | One error triggering a chain of subsequent errors |
| resource_waste | Unnecessary tool calls or redundant operations |
| context_loss | Agent losing relevant context mid-task |
| strategy_mismatch | Wrong approach chosen for the task type |
| quality_drop | Output quality declining over sessions |
| success_streak | Consistently high performance worth distilling |
| novel_solution | Unique approach that solved a previously failing task |