terraphim-cli-1.0.0 is not a library.
terraphim-cli
Automation-friendly CLI for semantic knowledge graph search with JSON output.
Overview
terraphim-cli is a non-interactive command-line tool designed for scripting and automation. It provides the same semantic search capabilities as terraphim-repl but optimized for:
- JSON Output: Machine-readable output for scripts and pipelines
- Exit Codes: Proper exit codes (0 = success, 1 = error) for automation
- Shell Completions: Auto-completion for bash, zsh, and fish
- Piping: Works seamlessly in Unix pipelines
Installation
From crates.io
From Source
Quick Start
Basic Search
# Search with JSON output
Output:
Pretty JSON
Pipe to jq
|
Commands
search - Search Documents
Examples:
# Basic search
# With role and limit
# Extract titles only
|
config - Show Configuration
Output:
roles - List Available Roles
Output:
graph - Show Top Concepts
Example:
Output:
replace - Replace Terms with Links
Examples:
# Markdown links (default)
# HTML links
# Wiki links
Output:
find - Find Matched Terms
Example:
Output:
thesaurus - Show Knowledge Graph Terms
Example:
Output:
completions - Generate Shell Completions
Install Completions:
Bash:
Zsh:
Fish:
Global Options
)
Exit Codes
0- Success1- Error (invalid input, service failure, etc.)
Scripting Examples
Search and Extract URLs
|
Count Results
|
Filter by Rank
|
Loop Through Results
| | while ; do
done
Replace Text in Files
| while ; do
|
done
Check if Terms Exist
if | ; then
fi
CI/CD Integration
GitHub Actions
- name: Search Knowledge Graph
run: |
cargo install terraphim-cli
terraphim-cli search "deployment" --limit 10 > results.json
- name: Validate Results
run: |
COUNT=$(jq '.count' results.json)
if [ "$COUNT" -eq 0 ]; then
echo "No results found"
exit 1
fi
Shell Scripts
#!/bin/bash
# Search for specific terms
RESULTS=
# Check if we got results
if [; then
fi
# Extract URLs and fetch them
| |
Differences from terraphim-repl
| Feature | terraphim-cli | terraphim-repl |
|---|---|---|
| Mode | Non-interactive | Interactive |
| Output | JSON | Pretty tables + colored |
| Use Case | Automation/scripts | Human interaction |
| Exit Codes | Proper (0/1) | N/A |
| Completions | Yes (bash/zsh/fish) | Command completion in REPL |
| Piping | Designed for it | N/A |
| History | No | Yes |
Use terraphim-cli when:
- Writing scripts or automation
- Integrating with other tools via JSON
- CI/CD pipelines
- Batch processing
- Need machine-readable output
Use terraphim-repl when:
- Interactive exploration
- Learning the system
- Ad-hoc queries
- Human-readable output preferred
Configuration
Uses the same configuration as terraphim-repl:
~/.terraphim/config.json- Main configuration- Supports role-based search
- Works offline with embedded defaults
Troubleshooting
Command Not Found
# Make sure cargo bin is in PATH
JSON Parsing Errors
# Use --quiet to suppress non-JSON output
|
Completions Not Working
# Bash: Check completion directory
# Zsh: Check fpath includes ~/.zfunc
# Fish: Check completions directory
Building from Source
# Debug build
# Release build (optimized)
# Run tests
# Generate docs
Related Projects
- terraphim-repl: Interactive REPL interface
- terraphim_types: Core type definitions
- terraphim_automata: Text matching engine
- terraphim_rolegraph: Knowledge graph implementation
Support
- Discord: https://discord.gg/VPJXB6BGuY
- Discourse: https://terraphim.discourse.group
- Issues: https://github.com/terraphim/terraphim-ai/issues
License
Licensed under Apache-2.0. See LICENSE for details.
Changelog
See CHANGELOG.md for version history.