Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions seme/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# seme - Second-Me CLI Tool

`seme` is a command-line tool written in Golang to manage the lifecycle of Second-Me application services. It replaces the original set of shell scripts with a more consistent interface and better error handling.

## Installation

### Building from Source

```bash
git clone https://github.com/bitliu/Second-Me.git
cd Second-Me/seme
go build -o seme
```

You can then move the compiled binary to a directory in your system path, for example:

```bash
sudo mv seme /usr/local/bin/
```

## Usage

`seme` provides the following commands:

### Setting Up the Environment

```bash
# Set up the complete environment (Python, llama.cpp, and frontend)
seme setup

# Set up specific components only
seme setup python
seme setup llama
seme setup frontend

# Skip confirmation steps
seme setup --skip-confirmation
```

### Starting Services

```bash
# Start all services (frontend and backend)
seme start

# Start backend service only
seme start --backend-only
```

### Stopping Services

```bash
# Stop all services
seme stop
```

### Restarting Services

```bash
# Restart all services
seme restart

# Restart backend service only
seme restart --backend-only

# Force restart (terminate all related processes)
seme restart --force
```

### Checking Service Status

```bash
# Check the status of all services
seme status
```

## Configuration

`seme` will search for a `.env` file in the current directory and its parent directories to load environment variables. You can also specify the location of the environment variable file using command-line arguments:

```bash
seme --env-file /path/to/.env start
```

You can also specify the project root directory:

```bash
seme --base-path /path/to/project start
```

## Global Options

The following options are available for all commands:

- `--base-path string`: Specify the project root directory
- `--env-file string`: Specify the path to the environment variable file
- `-v, --verbose`: Enable verbose output mode
- `-h, --help`: Show help information

## Shell Completion

`seme` supports generating shell completion scripts for different shells:

```bash
# Generate bash completion script
seme completion bash > ~/.bash_completion.d/seme

# Generate zsh completion script
seme completion zsh > "${fpath[1]}/_seme"

# Generate fish completion script
seme completion fish > ~/.config/fish/completions/seme.fish
```
92 changes: 92 additions & 0 deletions seme/cmd/helpers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Second-Me CLI Interface Enhancement

The Second-Me CLI interface has been enhanced with emojis and improved formatting to provide a better user experience.

## Command Structure

Each command now includes specific emojis and color-coded output:

| Command | Emoji | Description |
|---------|-------|-------------|
| `seme start` | πŸš€ | Start Second-Me services |
| `seme stop` | πŸ›‘ | Stop all services |
| `seme restart` | πŸ”„ | Restart services |
| `seme status` | πŸ“Š | Check services status |
| `seme setup` | βš™οΈ | Set up environment |

## Improved Logging

Log messages have been enhanced with appropriate emojis:

- ℹ️ [INFO] - Informational messages
- βœ… [SUCCESS] - Success messages
- ⚠️ [WARNING] - Warning messages
- ❌ [ERROR] - Error messages

## Section Headers

Section headers now use a consistent format with emojis:

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
πŸ”· SECTION NAME
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

## Status Command Example

The status command now provides a more visual representation of service status:

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
πŸ”· πŸ“Š SERVICE STATUS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Backend Service:
PID File: Running βœ… (PID: 12345, Process: python)
β–Ά python server.py

Frontend Service:
PID File: Running βœ… (PID: 12346, Process: node)
β–Ά node --watch app.js

LLM Server Status:
Port 8080: In use βœ… (PID: 12347, Process: llama-server)
β–Ά ./llama-server --model models/7B.gguf

Summary:
πŸ–₯️ Backend: Running βœ…
🌐 Frontend: Running βœ…
πŸ¦™ LLM Server: Running βœ…
```

## Setup Command Example

The setup command provides clear progress indicators:

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
πŸ”· βš™οΈ SETTING UP PYTHON ENVIRONMENT
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

[2023-08-10 12:34:56] ℹ️ [INFO] Using conda environment: second-me
[2023-08-10 12:34:56] ℹ️ [INFO] Creating Conda environment: second-me
[2023-08-10 12:35:12] βœ… [SUCCESS] Conda environment second-me created successfully βœ“
[2023-08-10 12:35:12] ℹ️ [INFO] Installing Python dependencies...
[2023-08-10 12:36:05] βœ… [SUCCESS] Python environment setup completed βœ“

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
πŸ”· πŸ¦™ BUILDING LLAMA.CPP
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

## Additional Emojis

Component-specific emojis make it easier to identify what's being processed:

- 🐍 Python environment
- 🌐 Frontend services
- πŸ¦™ LLama.cpp and LLM services
- βœ“ Check mark for completed tasks

These enhancements create a more engaging and informative command-line experience for users of the Second-Me CLI tool.
42 changes: 42 additions & 0 deletions seme/cmd/restart.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package cmd

import (
"github.com/spf13/cobra"
)

var (
force bool
backendOnlyRestart bool
)

// restartCmd represents the restart command
var restartCmd = &cobra.Command{
Use: "restart",
Short: "Restart Second-Me services",
Long: `Stop and restart Second-Me services, including backend and frontend.`,
Run: restartServices,
}

func init() {
RootCmd.AddCommand(restartCmd)
restartCmd.Flags().BoolVar(&force, "force", false, "Force restart, killing all related processes")
restartCmd.Flags().BoolVar(&backendOnlyRestart, "backend-only", false, "Restart backend service only")
}

// restartServices is the handler for the restart command
func restartServices(cmd *cobra.Command, args []string) {
logSection(restartEmoji + " RESTARTING SERVICES")

// Execute stop command
logInfo(stopEmoji + " Stopping services...")
stopCmd.Run(cmd, args)

// Execute start command, with backend-only flag if specified
logInfo(startEmoji + " Starting services...")
if backendOnlyRestart {
backendOnly = true
}
startCmd.Run(cmd, args)

logSuccess("Services restarted successfully " + successEmoji)
}
Loading