Skip to content

GhostInTheToast/GhostCoderV2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

19 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ‘ป GhostCoder V2

Your AI coding assistant that actually writes code, not just explanations!

GhostCoder is a Python tool that connects to your local Ollama server to help you write, modify, and understand code. Unlike other AI assistants that often just explain things, GhostCoder is designed to generate actual code and modify your files directly.

โšก Quick Start

Prerequisites

  • Python 3.8 or higher
  • Ollama installed and running

Setup (3 steps)

# 1. Create virtual environment
python3 -m venv venv && source venv/bin/activate

# 2. Install dependencies  
pip3 install -r requirements.txt

# 3. Run setup wizard
python ghostcoder.py --setup

๐Ÿ’ก Pro tip: Always activate your virtual environment (source venv/bin/activate) before using GhostCoder!

๐Ÿš€ Installation & Setup

Option 1: Automatic Setup (Recommended)

The setup wizard automates everything:

python3 ghostcoder.py --setup

What it does:

  • Detects your shell (zsh or bash)
  • Configures environment variables
  • Creates ghost and ghostcoder aliases
  • Updates your shell RC file

Option 2: Manual Setup

  1. Install Ollama from https://ollama.ai
  2. Pull a coding model:
    ollama pull deepseek-coder:6.7b-instruct
  3. Set environment variables in your ~/.zshrc or ~/.bashrc:
    export OLLAMA_BASE_URL="http://localhost:11434"
    export OLLAMA_MODEL="deepseek-coder:6.7b-instruct"
  4. Create an alias:
    alias ghost="python /path/to/ghostcoder.py"

๐Ÿ“– Usage

Basic Commands

# Generate code
ghost "create a web scraper"

# Modify a specific file
ghost "fix the bug in @main.py"

# Modify multiple files
ghost "add logging to @main.py @utils.py @config.py"

# Force code generation (recommended!)
ghost --code "implement user authentication"

# Auto-apply changes without asking
ghost --skip-confirm "add logging to @utils.py"

# Just get explanations (no code changes)
ghost --no-apply "explain how this function works"

File Modifications

The @filename syntax lets you reference files for modification:

# Single file
ghost "add input validation to @app.py"

# Multiple files at once
ghost "add logging to @main.py @utils.py @config.py"
ghost "update error handling in @auth.py @user.py @middleware.py"

Multifile Processing: When you reference multiple files, GhostCoder processes each file individually with progress tracking and individual confirmations.

Interactive Mode

Run ghost without arguments to enter interactive mode:

ghost
# You: add a function to calculate square roots
# Ghost: [generates code]
# You: modify @math.py to use this function
# Ghost: [modifies the file]
# You: exit

๐ŸŽฏ Key Features

--code Flag

The most important feature! Forces GhostCoder to generate actual code instead of explanations:

# Without --code (might just explain)
ghost "implement a calculator"

# With --code (guaranteed to generate code)
ghost --code "implement a calculator"

File References with @filename

Reference any file in your project for modification:

# Single file modifications
ghost "add error handling to @main.py"
ghost "optimize the algorithm in @utils.py"

# Multiple file modifications
ghost "add logging to @main.py @utils.py @config.py"
ghost "add type hints to @auth.py @user.py @middleware.py"

Auto-apply with --skip-confirm

Skip the confirmation prompt:

ghost --skip-confirm "add comments to @script.py"

Explanation Mode with --no-apply

When you only want explanations, not code changes:

ghost --no-apply "explain how this sorting algorithm works"

๐Ÿ“ Examples

Example 1: Create New Code

ghost --code "create a function that validates email addresses"

Output:

def validate_email(email):
    import re
    pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
    return re.match(pattern, email) is not None

Example 2: Modify Existing File

ghost "add logging to @app.py"

GhostCoder will:

  1. Read your app.py file
  2. Show you the proposed changes
  3. Ask for confirmation
  4. Apply the changes if you approve

Example 3: Interactive Session

ghost
# You: create a simple web server
# Ghost: [generates Flask server code]
# You: add error handling to it
# Ghost: [modifies the code with error handling]
# You: exit

๐Ÿ› ๏ธ Troubleshooting

Common Issues

"python: command not found"

  • Use python3 instead of python on macOS/Linux
  • Make sure Python 3.8+ is installed: python3 --version

"externally-managed-environment" Error

  • Solution: Always use a virtual environment:
    python3 -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt

"Cannot reach the spectral realm"

  • Make sure Ollama is running: ollama serve
  • Check the URL: curl http://localhost:11434

"No code blocks detected"

  • Use the --code flag: ghost --code "your request"
  • Be more specific: ghost --code "write a function that..."

Virtual Environment Best Practices

  • Always activate your virtual environment before running GhostCoder
  • Never install packages globally with pip
  • Keep your virtual environment in the project directory

๐ŸŽญ The Ghost's Personality

GhostCoder maintains a fun, spooky theme:

  • ๐Ÿ‘ป "Spectral changes" = file modifications
  • ๐Ÿ”ฎ "Interactive sรฉance" = interactive mode
  • ๐Ÿ’€ "Banish the ghost" = exit command
  • โœจ "Manifested changes" = successful file updates

๐Ÿค Contributing

Feel free to contribute improvements! The ghost is always learning new tricks.


Happy coding with your spectral assistant! ๐Ÿ‘ปโœจ

About

Enhanced GhostCoder with agentic behavior - Python port with --force-code flag and improved LLM prompting

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages