Skip to content

ZHANGSHUNLIN/TTL-CLI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

11 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

ttl

Your Personal Knowledge Archive, Powered by AI

Go Version License MCP

็ฎ€ไฝ“ไธญๆ–‡ | ๆ—ฅๆœฌ่ชž | Espaรฑol | Franรงais | Portuguรชs


A lightweight CLI tool for personal data management. Store anything as key-value pairs, search instantly, and let AI manage it all with natural language.


๐Ÿ“– The Story

Every developer has been there:

"Wait, what was that Docker command I used last month?" "Where did my colleague share that config file?" "I know I read an article about this... but can't find it anywhere."

We store knowledge everywhere โ€” browser tabs, Slack messages, emails, bookmark folders, notes apps. When we actually need it, we waste time digging through endless tabs and scrolling through chat history.

This was my pain too.

So I built ttl.

The name comes from "Time to Live" โ€” but with a different meaning. Instead of expiring, it's about giving your knowledge a time to live forever.

  • Store everything in one place as key-value pairs
  • Tag it for easy organization
  • Search instantly by keyword
  • Use AI to manage it with natural language

No more searching through old emails or scrolling through Slack history. Just ttl get <keyword> and you have it.

ttl is your personal knowledge archive โ€” everything you need, when you need it.


โœจ Features

Feature Description
๐Ÿ—„๏ธ Local KV Storage Fast, zero-config embedded database (bbolt)
๐Ÿท๏ธ Tag System Organize resources with flexible, searchable tags
๐Ÿ” Fuzzy Search Find what you need instantly across keys and tags
๐Ÿค– AI Agent Manage data with natural language (OpenAI / DeepSeek / Ollama)
๐Ÿ“ Work Log Track daily work, generate weekly/monthly reports with AI
๐Ÿ”— MCP Protocol Let AI tools (Claude Code, Cursor) operate your data directly
โ˜๏ธ Cloud Sync Self-host multi-tenant server with per-user data isolation
๐Ÿ”’ Privacy First AI never sends your values โ€” only keys and tags
๐Ÿš€ Smart Open Open URLs and files with system default programs
๐Ÿ“ค Export Export data as JSON or CSV

๐Ÿš€ Quick Start

Installation

Linux / macOS

# Install from GitHub releases
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/ZHANGSHUNLIN/TTL-CLI/main/install.sh)"

# Or build from source
go build -o ttl .
sudo mv ttl /usr/local/bin/

Windows

# Install from GitHub releases
irm https://raw.githubusercontent.com/ZHANGSHUNLIN/TTL-CLI/main/install.ps1 | iex

Custom Download URL

For internal networks or custom mirrors:

# Linux/macOS
TTL_DOWNLOAD_URL="https://your-mirror.com/ttl-cli-v1.0.0-linux-amd64" /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/ZHANGSHUNLIN/TTL-CLI/main/install.sh)"
# Windows
$env:TTL_DOWNLOAD_URL="https://your-mirror.com/ttl-cli-v1.0.0-windows-amd64.zip"; irm https://raw.githubusercontent.com/ZHANGSHUNLIN/TTL-CLI/main/install.ps1 | iex

### Basic Usage

```bash
# Add a resource
ttl add my-link https://example.com

# Add with tags
ttl add docker-cmd "docker run -d -p 8080:80 nginx"
ttl tag docker-cmd dev ops

# Search resources
ttl get docker

# Open in browser
ttl open my-link

# Delete
ttl del old-key

๐Ÿค– AI Agent

One command replaces ten. Just describe what you want in natural language.

# Configure AI first
ttl config ai

# Then use natural language
ttl ai "save this nginx config: port 8080 changed to 443"
ttl ai "find all my docker related resources"
ttl ai "open the sugar dashboard"
ttl ai "what did I store recently?"
ttl ai "tag nginx-config with ops and deploy"

Privacy by Design

The AI Agent only sends resource keys and tags to the LLM. Your values โ€” which may contain passwords, tokens, internal URLs, or sensitive data โ€” never leave your machine. Only work log content is sent in full for summarization.

Compatible Models

  • OpenAI (GPT-4, GPT-4o, GPT-4o-mini)
  • DeepSeek
  • Moonshot
  • Ollama (local models)
  • Any OpenAI Chat Completions API compatible model

๐Ÿ“ Work Log

Track your daily work and let AI generate reports.

# Write a log entry
ttl log write "Finished user module refactoring" --tags "projectA,dev"

# View logs
ttl log list                    # Today's logs
ttl log list --range week       # This week
ttl log list --range month      # This month

# AI-powered weekly report
ttl ai "summarize my work logs this week"
ttl ai "generate a weekly report in markdown format"

๐Ÿ”— MCP Protocol Integration

Let AI tools operate your data via Model Context Protocol.

Start MCP Server

ttl mcp

Claude Code Integration

Add to ~/.claude/claude_code_config.json:

{
  "mcpServers": {
    "ttl": {
      "command": "ttl",
      "args": ["mcp"]
    }
  }
}

Now Claude Code can read, write, and manage your resources directly!

Available MCP Tools:

  • ttl_get โ€” Retrieve resources
  • ttl_add โ€” Add new resources
  • ttl_update โ€” Update existing resources
  • ttl_delete โ€” Delete resources
  • ttl_tag โ€” Add tags
  • ttl_dtag โ€” Remove tags
  • ttl_open โ€” Open resources
  • ttl_rename โ€” Rename resources

โ˜๏ธ Cloud Server & Sync

Start Your Server

# Create a user
ttl server user add alice

# Start multi-tenant server
ttl server start --port 8080

Sync Your Data

# Configure remote server
ttl config
# Edit the server section with your endpoint and API key

# Sync local <-> remote
ttl sync

Architecture:

  • Multi-tenant design with per-user isolated databases
  • API Key authentication
  • REST API for programmatic access
  • MCP HTTP endpoint at /mcp for AI clients

โš™๏ธ Configuration

Config file: ~/.ttl/ttl.ini

[default]
db_path = ~/.ttl/data.db

[ai]
api_key   = your-api-key-here
base_url  = https://api.openai.com
model     = gpt-4o-mini
timeout   = 30

[server]
endpoint  = https://your-server.com
api_key   = your-user-api-key
# View current config
ttl config

# Configure AI interactively
ttl config ai

๐Ÿ“ค Export Your Data

# Export as JSON
ttl export --format json

# Export as CSV
ttl export --format csv

# Export to specific file
ttl export --format json --output backup.json

๐Ÿ—๏ธ Project Structure

ttl
โ”œโ”€โ”€ main.go              # Entry point, CLI setup (cobra)
โ”œโ”€โ”€ command/             # CLI command definitions
โ”‚   โ”œโ”€โ”€ commands.go      # Core commands (get/add/del/tag/open...)
โ”‚   โ”œโ”€โ”€ ai.go            # AI Agent command
โ”‚   โ”œโ”€โ”€ log.go           # Work log commands
โ”‚   โ”œโ”€โ”€ export.go        # Export command
โ”‚   โ””โ”€โ”€ server.go        # Server commands
โ”œโ”€โ”€ ai/                  # AI Agent (ReAct loop)
โ”‚   โ”œโ”€โ”€ client.go        # LLM HTTP client
โ”‚   โ”œโ”€โ”€ agent.go         # ReAct engine + tool execution
โ”‚   โ””โ”€โ”€ prompt.go        # System prompt
โ”œโ”€โ”€ db/                  # Storage layer (bbolt)
โ”‚   โ”œโ”€โ”€ db.go            # Database initialization
โ”‚   โ”œโ”€โ”€ storage.go       # Local storage implementation
โ”‚   โ”œโ”€โ”€ tenant_storage.go# Multi-tenant storage router
โ”‚   โ”œโ”€โ”€ user_store.go    # User CRUD (users.json)
โ”‚   โ””โ”€โ”€ context.go       # Request-scoped storage
โ”œโ”€โ”€ api/                 # HTTP server
โ”‚   โ”œโ”€โ”€ server.go        # Server startup
โ”‚   โ”œโ”€โ”€ handlers.go      # REST API handlers
โ”‚   โ””โ”€โ”€ middleware.go     # Auth middleware
โ”œโ”€โ”€ mcp/                 # MCP protocol
โ”‚   โ”œโ”€โ”€ tools.go         # MCP tool definitions
โ”‚   โ””โ”€โ”€ handlers.go      # MCP tool handlers
โ”œโ”€โ”€ sync/                # Data sync logic
โ”œโ”€โ”€ models/              # Shared data models
โ”œโ”€โ”€ conf/                # Config file (INI) handling
โ””โ”€โ”€ util/                # Utility functions

๐Ÿ”ง Tech Stack

Component Technology
Language Go 1.23
CLI Framework cobra
Storage bbolt
Configuration ini.v1
MCP Protocol mcp-go
AI API OpenAI Chat Completions API (compatible)

๐ŸŒ Translations


๐Ÿค Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

For major changes, please open an issue first to discuss what you'd like to change.


๐Ÿ“„ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.


๐Ÿ™ Acknowledgments

  • cobra for the excellent CLI framework
  • bbolt for the reliable embedded key-value store
  • mcp-go for MCP protocol support
  • The open-source community

Made with โค๏ธ by developers who hate searching for lost knowledge

About

Your personal knowledge archive, powered by AI. Store anything as key-value pairs, search instantly, and let AI manage it all with natural language.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors