Skip to content

caspiras/Slice

Repository files navigation

πŸ•

β–„β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–„β–„    β–„β–„  β–„β–„β–„β–„ β–„β–„β–„β–„β–„
β–€β–€β–€β–„β–„β–„ β–ˆβ–ˆ    β–ˆβ–ˆ β–ˆβ–ˆβ–€β–€β–€ β–ˆβ–ˆβ–„β–„
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–€ β–ˆβ–ˆβ–„β–„β–„ β–ˆβ–ˆ β–€β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–„β–„β–„

A local-first IDE wrapper for Ollama models. Chat naturally. Edit code with diffs. Read/write documents. All permission-gated. All local.

Slice is a beautiful terminal IDE that wraps local Ollama models with practical coding tools. Built with Python and the Rich library, it provides streaming chat, code editing with diffs, document operations, and git integration - all sandboxed to your project directory.

πŸ†• What's New in v1.5.0

  • 🎯 Skills System - Create custom slash commands with predefined instructions
    • Define skills in slice-skills/ directory
    • Invoke with /skill-name for common workflows
    • Example skills included: /test, /hello, /status
    • Full documentation in slice-skills/README.md

Previous Updates

v1.4.0

  • 🎯 Enhanced Model Behavior - Major improvements to tool calling across models
    • Fixed critical system message issues preventing models from using tools correctly
    • Models now properly create Python apps with bash (not write_document)
    • Better tool calling behavior for gemma4, granite4, and other models
    • Added explicit guidance for creating executable files
    • Improved sequential tool execution (create file β†’ run file)
    • Note: llama3.1 8B has poor tool calling support; use gemma4 or granite4 instead

v1.3.2

  • πŸ“ Convert to Markdown - New convert_to_markdown tool for document conversion
    • Convert Excel, CSV, Word (with tables), and PDF files to Markdown format
    • Tables automatically formatted with Markdown table syntax (| separators)
    • Example: convert budget.xlsx to budget.md

v1.3.1

  • πŸ“Š Word Document Table Extraction - Tables in Word documents are now extracted alongside paragraphs
  • πŸš€ Large File Support - New convert_to_json tool handles massive files efficiently
  • πŸ”§ Dedicated Conversion Tool - Replaces error-prone bash one-liners with proper error handling

v1.3.0

  • πŸ”„ Universal File to JSON Conversion - Convert Excel, CSV, Word, and PDF files to JSON seamlessly
  • πŸ› Fixed UI Issues - Removed <tool_call> tags appearing in model output
  • πŸ’¬ Better Tool Response - Fixed models not responding after reading documents
  • 🧹 Cleaner UI - All spinners properly clean up after completion

v1.2.0

  • πŸ“ PDF Writing Enabled - Create and edit PDFs directly
  • πŸ“Š Enhanced Spreadsheet Support - Improved tool guidance for better Excel/CSV editing
  • πŸ”„ Universal Document Editing - ALL file types editable (PDF, Word, Excel, PowerPoint, CSV, Markdown, code)
  • ⚑ Cross-Format Operations - Move data between formats (PDFβ†’Excel, Wordβ†’Markdown, etc.)

What It Does

Slice brings IDE-like capabilities to local Ollama models through a permission-gated interface:

  • πŸ’¬ Natural conversation - Ask questions, discuss code, get explanations
  • ✏️ Code editing with diffs - Propose changes, review side-by-side diffs, apply with approval
  • πŸ“„ Universal document editing - Read/write PDF, Word, Excel, PowerPoint, CSV, Markdown, and ANY text-based file
  • πŸ”§ Bash execution - Run commands after approval
  • 🌳 Git integration - Stage, commit, create branches (never auto-pushes)
  • πŸ”’ Directory sandboxing - All operations confined to current directory
  • πŸ• Beautiful terminal UI - Streaming responses with Rich styling

Prerequisites

Before installing Slice, you need:

  1. Python 3.9 or higher

    python3 --version  # Should show 3.9+
  2. Ollama installed and running

    • Download from ollama.ai
    • Install for your OS (macOS, Linux, Windows)
  3. At least one Ollama model downloaded

    # Recommended models for best results:
    ollama pull gemma4      # Best for mixed chat/actions
    ollama pull mistral     # Fast and reliable
    ollama pull qwen2       # Great multilingual support
    
    # Or try llama3.1 (works well for code tasks)
    ollama pull llama3.1

Installation

# Clone the repository
git clone https://github.com/caspiras/Slice.git
cd Slice

# Install Python package
pip install -e .

Uninstall

# Uninstall the package
pip uninstall slice

Upgrading from v1.0 (slice-agent)?

# Uninstall old version first
pip uninstall slice-agent -y

# Then install new version
pip install -e .

Quick Start

# Start Slice
slice
  1. Select a model using arrow keys (↑/↓) and press Enter
  2. Start chatting at the πŸ• prompt
  3. Ask it to do things - it will request permission before executing
  4. Switch models anytime by typing /model
  5. Exit gracefully with Ctrl+C (twice)

Skills - Custom Slash Commands

Slice v1.5.0 introduces skills - custom slash commands that provide the AI with predefined instructions for common tasks.

What are Skills?

Skills are instruction sets stored in markdown files that you can invoke with /skill-name. When invoked, Slice feeds the instructions to the AI model, guiding it through specific workflows.

Using Skills

Built-in example skills:

πŸ• /hello      # Greeting with system information
πŸ• /test       # Test the skills system
πŸ• /status     # Git repository status

Create your own skills:

  1. Create a slice-skills/ directory in your project
  2. Add a .md file with this format:
---
name: deploy
description: Deploy the application
---

# Deployment Instructions

When invoked:
1. Run tests with `pytest`
2. Build with `npm run build`
3. Deploy with `./deploy.sh`
4. Verify deployment
  1. Invoke with /deploy in Slice

See slice-skills/README.md for complete documentation.

Usage Examples

Just Chat

πŸ• what is Python?

The AI answers directly from knowledge - no commands, just conversation.

Ask It to Do Something

πŸ• create a file called notes.txt

You'll see:

πŸ”§ Action Requested
To create a new text file

β”Œβ”€ Command ────────────┐
β”‚ touch notes.txt      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Execute this command? (y/N): y
βœ“ Command completed successfully

Common Use Cases

Code editing with diffs:

πŸ• read main.py and fix the typo where it says "resposne" instead of "response"

Shows a syntax-highlighted diff for your approval before applying changes.

Document operations:

πŸ• what's the total in the budget.xlsx file for Q2?
πŸ• create a PDF report called summary.pdf with our Q1 findings
πŸ• read contract.pdf and extract the key terms into a spreadsheet

Read/write ANY document type - PDF, Excel, Word, CSV, Markdown, etc.

File format conversion:

πŸ• convert budget.xlsx to budget.json
πŸ• convert report.docx to report.json
πŸ• convert contract.pdf to contract.json
πŸ• convert data.csv to data.json

Seamlessly convert Excel, Word, PDF, and CSV files to JSON format.

Git workflows:

πŸ• check git status and create a commit with my changes

Stages files and creates commits (never auto-pushes without explicit request).

File operations:

  • "Create a folder called src"
  • "List all Python files in this directory"
  • "Search for TODO comments in my code"

Code exploration:

  • "Find all functions that use the requests library"
  • "Show me files modified in the last 24 hours"
  • "What's the overall structure of this project?"

Switch Models Mid-Session

πŸ• /model

Use arrow keys to pick a new model. Your conversation history is preserved!

Security & Safety

Slice is designed with security first. Multiple layers protect your system:

πŸ”’ Directory Sandboxing (Primary Protection)

By default, all commands are restricted to the directory where you started slice.

πŸ’‘ Best Practice: Always start Slice inside a specific project folder, not in your home directory or system root. This provides natural boundaries for operations:

# βœ… Good - Start in a specific project
cd ~/projects/my-app
slice

# ❌ Avoid - Starting in home directory or root
cd ~
slice

Commands attempting to access files outside trigger a red warning:

⚠️  SANDBOX ESCAPE DETECTED
This command tries to access paths outside: /your/current/directory
Suspicious paths:
  β€’ /etc/hosts (absolute path)
  β€’ ~/Documents (home directory)
  β€’ ../../../file.txt (parent directory)

⚠️  Are you SURE you want to execute this? (yes/N):

Protected patterns:

  • βœ‹ Absolute paths: /tmp/file, /etc/hosts
  • βœ‹ Home directory: ~/Documents/file
  • βœ‹ Parent traversal: ../../sensitive/file
  • βœ‹ Directory changes: cd /tmp

Override when needed:

  • Normal commands: Type y to approve
  • Sandbox escapes: Type yes (full word) to explicitly approve
  • Slice can't silently access files outside your starting directory

πŸ›‘οΈ Additional Safety Layers

  1. Permission prompts for EVERY command

    • See exactly what will run before it executes
    • Includes the reason/context from the AI
    • Easy to review and deny
  2. Dangerous command detection

    • Patterns like rm -rf /, mkfs, dd if= trigger warnings
    • Requires explicit "yes" confirmation
  3. 30-second execution timeout

    • Prevents runaway or hanging commands
    • Automatically kills commands that take too long
  4. No automatic execution

    • The AI can't run anything without your approval
    • Even if the model tries, you see the prompt first

πŸ” Privacy & Data

  • βœ… 100% local: Everything runs on your machine via Ollama
  • βœ… No cloud API calls: Your conversations never leave your computer
  • βœ… No data persistence: Conversation history only exists while running
  • βœ… No telemetry: No tracking, logging, or data collection

How It Works (Technical)

Slice is built entirely in Python using the Rich library for beautiful terminal UX:

Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Slice (Python)                      β”‚
β”‚  β”œβ”€ Rich Terminal UI ✨              β”‚
β”‚  β”œβ”€ Ollama API Client                β”‚
β”‚  β”œβ”€ Chat Session Manager             β”‚
β”‚  β”œβ”€ Code Editor (with diffs)         β”‚
β”‚  β”œβ”€ Document Reader/Writer           β”‚
β”‚  β”œβ”€ Command Executor & Sandboxing    β”‚
β”‚  └─ Permission Prompt System         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Core capabilities:

  • Rich terminal UI - Beautiful panels, spinners, syntax highlighting
  • Ollama integration - Streaming chat with tool calling support
  • Skills system - Custom slash commands with predefined instructions
  • Code editing - Read files, generate diffs, apply changes with approval
  • Document operations - Read/write PDF, Word, Excel, PowerPoint, CSV
  • Command execution - Sandboxed bash with 30-second timeout
  • Git operations - Stage, commit, branch (never auto-pushes)
  • Permission gates - Every action requires explicit user approval

Project Structure

slice_agent/
β”œβ”€β”€ src/slice/
β”‚   β”œβ”€β”€ main.py              # CLI entry point & startup
β”‚   β”œβ”€β”€ ui.py                # Rich terminal UI components
β”‚   β”œβ”€β”€ chat.py              # Chat session & tool execution
β”‚   β”œβ”€β”€ skills.py            # Skills loader & parser
β”‚   β”œβ”€β”€ executor.py          # Command executor & sandboxing
β”‚   β”œβ”€β”€ document_reader.py   # PDF/Word/Excel/CSV reading
β”‚   └── document_writer.py   # Document writing operations
β”œβ”€β”€ slice-skills/            # Custom slash commands (optional)
β”‚   β”œβ”€β”€ README.md            # Skills documentation
β”‚   └── *.md                 # Skill definition files
└── pyproject.toml           # Python dependencies & metadata

Development

# Install Python dependencies with dev tools
pip install -e ".[dev]"

# Run Python tests
pytest

# Format Python code
black src/

# Lint Python code
ruff check src/

Key Dependencies

Python:

  • rich - Beautiful terminal UI with panels, spinners, syntax highlighting
  • prompt-toolkit - Interactive prompts with command history
  • ollama - Python client for Ollama API
  • pypdf, reportlab - PDF reading and writing
  • python-docx, openpyxl, python-pptx - Word, Excel, PowerPoint operations

Features

  • 🎯 Skills System (NEW in v1.5.0)

    • Create custom slash commands with predefined instructions
    • Store skills in slice-skills/ directory as markdown files
    • Invoke with /skill-name for common workflows
    • Example skills included: /hello, /test, /status
    • Full documentation in slice-skills/README.md
  • ✏️ Code Editing with Diffs

    • Read source files and propose changes
    • Syntax-highlighted diff preview before applying
    • User approval required for every edit
  • πŸ“„ Document Operations

    • Read: PDF, Word (.docx), Excel (.xlsx), PowerPoint, CSV, text
    • Write: PDF, Word, Excel, PowerPoint, CSV, text
    • All document types in the directory are editable
    • Truncates large documents automatically for efficiency
  • 🌳 Git Integration

    • Safe read-only operations (status, log, diff)
    • Local operations with approval (add, commit, branch)
    • Never auto-pushes without explicit user request
  • πŸ• Beautiful Terminal UI

    • Pizza emoji (πŸ•) prompt cursor
    • "baking..." spinner while AI thinks
    • Streaming responses (see text appear word-by-word)
    • Clean panels for commands and output
  • πŸ”„ Model Switching

    • Interactive arrow-key selection at startup
    • Switch models anytime with /model command
    • Conversation history preserved when switching
  • ⌨️ Great UX

    • Double Ctrl+C to exit (with warning on first press)
    • Interruption support during streaming
    • Clear success/failure indicators
  • πŸ”’ Security First

    • Directory sandboxing with escape detection
    • Permission gates for all commands
    • Dangerous pattern warnings
    • 30-second command timeout

Model Recommendations

Different models behave differently. Choose based on your task:

Best for Mixed Chat + Actions

  • gemma4 - Excellent at knowing when to chat vs. execute commands
  • mistral - Fast, reliable, good tool calling judgment
  • qwen2 - Great multilingual support with smart tool use
ollama pull gemma4

Best for Code Tasks

  • llama3.1, llama3.2, llama3.3 - Trained heavily for tool use
  • May try to execute commands for general knowledge questions
  • Works perfectly for file operations and coding workflows
ollama pull llama3.1

πŸ’‘ Tip: Models marked with [tools βœ“] in the selector support function calling.

Troubleshooting

"No local Ollama models found"

  • Make sure Ollama is running: ollama list should show your models
  • Download a model: ollama pull gemma4
  • Verify Ollama service is active

Command stuck on "baking..."

  • This usually means a permission prompt is waiting
  • The latest version fixes display issues - update if needed
  • Try pressing Ctrl+C to cancel and restart

Model tries to run commands for chat questions

  • This is model-specific behavior (common with llama3.1/3.2/3.3)
  • These models are trained heavily for tool use
  • Switch to gemma4, mistral, or qwen2 for better chat/action balance
  • Use /model command to switch without restarting

"Command timed out after 30 seconds"

  • The command took too long and was automatically killed for safety
  • Try breaking the task into smaller commands
  • Some operations (large builds, downloads) may need to be run manually

Exit not working

  • Press Ctrl+C twice (first shows warning, second exits)
  • If stuck in a prompt, Ctrl+C cancels it first, then exit normally
  • Make sure you're pressing Ctrl+C, not Ctrl+D

Permission prompt not visible

  • Update to the latest version - older versions had display issues
  • The prompt should appear after the "baking..." spinner stops

Contributing

Contributions are welcome! This is an open-source project.

Ideas for contributions:

  • Support for additional Ollama models
  • New safety/security features
  • UI/UX improvements
  • Bug fixes and performance improvements
  • Documentation improvements

To contribute:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

License

This project is open source. See the repository for license details.

Acknowledgments

  • Built with Ollama for local AI model hosting
  • Beautiful terminal UI powered by Rich
  • Interactive prompts via prompt-toolkit
  • Document handling with pypdf, reportlab, python-docx, openpyxl, python-pptx
  • Inspired by the need for safe, permission-gated AI coding tools

Made with πŸ• by the community

About

Agentic interface for Ollama-hosted models with permission-gated commands

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages