Commit 9ccd8af
Changed files (7)
cmd/del/main.go
@@ -0,0 +1,529 @@
+package main
+
+import (
+ "bufio"
+ "context"
+ "encoding/json"
+ "fmt"
+ "log"
+ "os"
+ "os/exec"
+ "strings"
+
+ "github.com/spf13/cobra"
+)
+
+// AI Provider interface - supports multiple AI backends
+type AIProvider interface {
+ Generate(ctx context.Context, prompt string) (string, error)
+ Name() string
+}
+
+// Tool represents an available capability
+type Tool struct {
+ Name string
+ Description string
+ Handler func(args map[string]interface{}) (interface{}, error)
+}
+
+// Del is our main AI assistant - Del the Funky Robosapien!
+type Del struct {
+ aiProvider AIProvider
+ tools map[string]*Tool
+ mcpServers map[string]string // name -> command path
+}
+
+// Claude API provider
+type ClaudeProvider struct {
+ apiKey string
+}
+
+func (c *ClaudeProvider) Generate(ctx context.Context, prompt string) (string, error) {
+ // Use Claude CLI if available, fallback to API
+ cmd := exec.CommandContext(ctx, "claude", "--print", prompt)
+ output, err := cmd.Output()
+ if err != nil {
+ return "", fmt.Errorf("claude error: %w", err)
+ }
+ return string(output), nil
+}
+
+func (c *ClaudeProvider) Name() string {
+ return "Claude"
+}
+
+// Ollama provider
+type OllamaProvider struct {
+ model string
+}
+
+func (o *OllamaProvider) Generate(ctx context.Context, prompt string) (string, error) {
+ cmd := exec.CommandContext(ctx, "ollama", "run", o.model, prompt)
+ output, err := cmd.Output()
+ if err != nil {
+ return "", fmt.Errorf("ollama error: %w", err)
+ }
+ return string(output), nil
+}
+
+func (o *OllamaProvider) Name() string {
+ return fmt.Sprintf("Ollama (%s)", o.model)
+}
+
+// Initialize Del with tools and MCP servers
+func NewDel(provider AIProvider) *Del {
+ d := &Del{
+ aiProvider: provider,
+ tools: make(map[string]*Tool),
+ mcpServers: make(map[string]string),
+ }
+
+ // Register built-in tools
+ d.registerBuiltinTools()
+
+ // Auto-discover MCP servers
+ d.discoverMCPServers()
+
+ return d
+}
+
+func (d *Del) registerBuiltinTools() {
+ // Security scanner tool
+ d.tools["security_scan"] = &Tool{
+ Name: "security_scan",
+ Description: "Scan code for security vulnerabilities",
+ Handler: d.handleSecurityScan,
+ }
+
+ // Code analysis tool
+ d.tools["analyze_code"] = &Tool{
+ Name: "analyze_code",
+ Description: "Analyze code quality and suggest improvements",
+ Handler: d.handleCodeAnalysis,
+ }
+
+ // File operations
+ d.tools["read_file"] = &Tool{
+ Name: "read_file",
+ Description: "Read contents of a file",
+ Handler: d.handleReadFile,
+ }
+
+ d.tools["write_file"] = &Tool{
+ Name: "write_file",
+ Description: "Write content to a file",
+ Handler: d.handleWriteFile,
+ }
+
+ // Command execution
+ d.tools["run_command"] = &Tool{
+ Name: "run_command",
+ Description: "Execute shell commands",
+ Handler: d.handleRunCommand,
+ }
+
+ // MCP integration tools (when backend Claude completes servers)
+ d.tools["mcp_git_list"] = &Tool{
+ Name: "mcp_git_list",
+ Description: "List files in git repository via MCP",
+ Handler: d.handleMCPGitList,
+ }
+
+ d.tools["mcp_git_read"] = &Tool{
+ Name: "mcp_git_read",
+ Description: "Read file from git repository via MCP",
+ Handler: d.handleMCPGitRead,
+ }
+}
+
+func (d *Del) discoverMCPServers() {
+ // Look for MCP servers in the other Claude's repo
+ mcpPath := "/home/mokhax/src/github.com/xlgmokha/mcp"
+ servers := map[string]string{
+ "git": mcpPath + "/cmd/git/main.go",
+ "filesystem": mcpPath + "/cmd/fs/main.go",
+ "bash": mcpPath + "/cmd/bash/main.go",
+ }
+
+ for name, path := range servers {
+ if _, err := os.Stat(path); err == nil {
+ d.mcpServers[name] = path
+ }
+ }
+}
+
+func (d *Del) handleSecurityScan(args map[string]interface{}) (interface{}, error) {
+ path, ok := args["path"].(string)
+ if !ok {
+ return nil, fmt.Errorf("path required")
+ }
+
+ // Run security tools like gosec, semgrep, etc.
+ results := map[string]interface{}{
+ "vulnerabilities": []string{},
+ "warnings": []string{},
+ "suggestions": []string{},
+ }
+
+ // Check for common security issues
+ if strings.Contains(path, ".go") {
+ // Run gosec if available
+ cmd := exec.Command("gosec", "-fmt", "json", path)
+ if output, err := cmd.Output(); err == nil {
+ results["gosec_output"] = string(output)
+ }
+ }
+
+ return results, nil
+}
+
+func (d *Del) handleCodeAnalysis(args map[string]interface{}) (interface{}, error) {
+ path, ok := args["path"].(string)
+ if !ok {
+ return nil, fmt.Errorf("path required")
+ }
+
+ analysis := map[string]interface{}{
+ "path": path,
+ "complexity": "medium",
+ "maintainability": "good",
+ "suggestions": []string{
+ "Consider adding more comments",
+ "Extract complex functions",
+ },
+ }
+
+ return analysis, nil
+}
+
+func (d *Del) handleReadFile(args map[string]interface{}) (interface{}, error) {
+ path, ok := args["path"].(string)
+ if !ok {
+ return nil, fmt.Errorf("path required")
+ }
+
+ content, err := os.ReadFile(path)
+ if err != nil {
+ return nil, err
+ }
+
+ return map[string]interface{}{
+ "path": path,
+ "content": string(content),
+ "size": len(content),
+ }, nil
+}
+
+func (d *Del) handleWriteFile(args map[string]interface{}) (interface{}, error) {
+ path, ok := args["path"].(string)
+ if !ok {
+ return nil, fmt.Errorf("path required")
+ }
+
+ content, ok := args["content"].(string)
+ if !ok {
+ return nil, fmt.Errorf("content required")
+ }
+
+ // Ask for confirmation
+ fmt.Printf("๐ค Del asks: Write to %s? [y/N]: ", path)
+ reader := bufio.NewReader(os.Stdin)
+ response, _ := reader.ReadString('\n')
+
+ if strings.ToLower(strings.TrimSpace(response)) != "y" {
+ return map[string]interface{}{"status": "cancelled"}, nil
+ }
+
+ err := os.WriteFile(path, []byte(content), 0644)
+ if err != nil {
+ return nil, err
+ }
+
+ return map[string]interface{}{
+ "status": "written",
+ "path": path,
+ "size": len(content),
+ }, nil
+}
+
+func (d *Del) handleRunCommand(args map[string]interface{}) (interface{}, error) {
+ command, ok := args["command"].(string)
+ if !ok {
+ return nil, fmt.Errorf("command required")
+ }
+
+ // Ask for confirmation
+ fmt.Printf("๐ค Del asks: Execute '%s'? [y/N]: ", command)
+ reader := bufio.NewReader(os.Stdin)
+ response, _ := reader.ReadString('\n')
+
+ if strings.ToLower(strings.TrimSpace(response)) != "y" {
+ return map[string]interface{}{"status": "cancelled"}, nil
+ }
+
+ cmd := exec.Command("sh", "-c", command)
+ output, err := cmd.CombinedOutput()
+
+ result := map[string]interface{}{
+ "command": command,
+ "output": string(output),
+ "success": err == nil,
+ }
+
+ if err != nil {
+ result["error"] = err.Error()
+ }
+
+ return result, nil
+}
+
+// MCP Git List handler - will connect to MCP servers once available
+func (d *Del) handleMCPGitList(args map[string]interface{}) (interface{}, error) {
+ // Check if git MCP server is available
+ if _, exists := d.mcpServers["git"]; !exists {
+ return nil, fmt.Errorf("git MCP server not available yet")
+ }
+
+ // TODO: Implement actual MCP client call once server is ready
+ return map[string]interface{}{
+ "status": "pending",
+ "message": "Git MCP server implementation in progress",
+ }, nil
+}
+
+// MCP Git Read handler - will connect to MCP servers once available
+func (d *Del) handleMCPGitRead(args map[string]interface{}) (interface{}, error) {
+ // Check if git MCP server is available
+ if _, exists := d.mcpServers["git"]; !exists {
+ return nil, fmt.Errorf("git MCP server not available yet")
+ }
+
+ path, ok := args["path"].(string)
+ if !ok {
+ return nil, fmt.Errorf("path required")
+ }
+
+ // TODO: Implement actual MCP client call once server is ready
+ return map[string]interface{}{
+ "status": "pending",
+ "path": path,
+ "message": "Git MCP server implementation in progress",
+ }, nil
+}
+
+// Enhanced prompt with available tools
+func (d *Del) buildPrompt(userInput string) string {
+ toolsList := make([]string, 0, len(d.tools))
+ for name, tool := range d.tools {
+ toolsList = append(toolsList, fmt.Sprintf("- %s: %s", name, tool.Description))
+ }
+
+ mcpList := make([]string, 0, len(d.mcpServers))
+ for name := range d.mcpServers {
+ mcpList = append(mcpList, name)
+ }
+
+ return fmt.Sprintf(`You are Del the Funky Robosapien, an AI-powered coding superhero assistant.
+Channel the energy of Del the Funky Homosapien - you're creative, clever, and always ready to drop some funky code solutions!
+
+AVAILABLE TOOLS:
+%s
+
+AVAILABLE MCP SERVERS:
+%s
+
+CURRENT CONTEXT:
+- Working Directory: %s
+- Git Status: %s
+
+When you want to use a tool, respond with:
+TOOL_USE: tool_name {"arg1": "value1", "arg2": "value2"}
+
+For example:
+TOOL_USE: read_file {"path": "main.go"}
+TOOL_USE: security_scan {"path": "."}
+TOOL_USE: run_command {"command": "go build"}
+
+Keep it funky! ๐ค๐ค
+
+User Request: %s`,
+ strings.Join(toolsList, "\n"),
+ strings.Join(mcpList, ", "),
+ getCurrentDir(),
+ getGitStatus(),
+ userInput)
+}
+
+func getCurrentDir() string {
+ dir, _ := os.Getwd()
+ return dir
+}
+
+func getGitStatus() string {
+ cmd := exec.Command("git", "status", "--porcelain")
+ output, err := cmd.Output()
+ if err != nil {
+ return "Not a git repository"
+ }
+ return string(output)
+}
+
+// Process AI response and execute tools
+func (d *Del) processResponse(response string) {
+ lines := strings.Split(response, "\n")
+
+ for _, line := range lines {
+ if strings.HasPrefix(line, "TOOL_USE:") {
+ d.executeTool(strings.TrimPrefix(line, "TOOL_USE:"))
+ }
+ }
+}
+
+func (d *Del) executeTool(toolCall string) {
+ parts := strings.SplitN(toolCall, " ", 2)
+ if len(parts) != 2 {
+ fmt.Printf("โ Invalid tool call: %s\n", toolCall)
+ return
+ }
+
+ toolName := strings.TrimSpace(parts[0])
+ argsJSON := strings.TrimSpace(parts[1])
+
+ tool, exists := d.tools[toolName]
+ if !exists {
+ fmt.Printf("โ Unknown tool: %s\n", toolName)
+ return
+ }
+
+ var args map[string]interface{}
+ if err := json.Unmarshal([]byte(argsJSON), &args); err != nil {
+ fmt.Printf("โ Invalid tool args: %s\n", err)
+ return
+ }
+
+ fmt.Printf("๐ค Del is dropping some tool magic: %s\n", toolName)
+ result, err := tool.Handler(args)
+ if err != nil {
+ fmt.Printf("โ Tool error: %s\n", err)
+ return
+ }
+
+ fmt.Printf("โ
Funky result: %+v\n", result)
+}
+
+func (d *Del) showHelp() {
+ fmt.Println("๐ค๐ค Del the Funky Robosapien - Help Menu:")
+ fmt.Println(" ๐ก๏ธ Security Commands:")
+ fmt.Println(" 'scan for vulnerabilities'")
+ fmt.Println(" 'check this code for security issues'")
+ fmt.Println(" ๐ Development Commands:")
+ fmt.Println(" 'read the main.go file'")
+ fmt.Println(" 'build this project'")
+ fmt.Println(" 'run the tests'")
+ fmt.Println(" 'analyze code quality'")
+ fmt.Println(" ๐ง Available Tools:")
+ for name, tool := range d.tools {
+ fmt.Printf(" - %s: %s\n", name, tool.Description)
+ }
+ fmt.Println(" ๐ต Remember: Keep it funky!")
+ fmt.Println()
+}
+
+// Interactive REPL
+func (d *Del) startREPL() {
+ fmt.Printf("๐ค๐ค Del the Funky Robosapien is in the house! (Provider: %s)\n", d.aiProvider.Name())
+
+ fmt.Printf("๐ง Available tools: %s\n", strings.Join(func() []string {
+ var names []string
+ for name := range d.tools {
+ names = append(names, name)
+ }
+ return names
+ }(), ", "))
+ fmt.Println("๐ฌ Type 'quit' to exit, 'help' for assistance")
+ fmt.Println("๐ต Let's make some funky code together!")
+ fmt.Println()
+
+ scanner := bufio.NewScanner(os.Stdin)
+
+ for {
+ fmt.Print("๐ค You: ")
+ if !scanner.Scan() {
+ break
+ }
+
+ input := strings.TrimSpace(scanner.Text())
+ if input == "" {
+ continue
+ }
+
+ if input == "quit" || input == "exit" {
+ fmt.Println("๐ค Del says: Catch you on the flip side! Stay funky! โ๏ธ")
+ break
+ }
+
+ if input == "help" {
+ d.showHelp()
+ continue
+ }
+
+ // Generate AI response
+ prompt := d.buildPrompt(input)
+ response, err := d.aiProvider.Generate(context.Background(), prompt)
+ if err != nil {
+ fmt.Printf("โ AI Error: %s\n", err)
+ continue
+ }
+
+ fmt.Printf("๐ค Del: %s\n", response)
+
+ // Process any tool calls
+ d.processResponse(response)
+ fmt.Println()
+ }
+}
+
+var rootCmd = &cobra.Command{
+ Use: "del",
+ Short: "Del the Funky Robosapien - Your AI-powered coding superhero",
+ Long: `๐ค๐ค Del the Funky Robosapien
+
+Your AI-powered coding superhero with the soul of a funky homosapien!
+Equipped with security scanning, code analysis, file operations, and more.
+
+Channel the creative energy of Del the Funky Homosapien while coding!`,
+ Run: func(cmd *cobra.Command, args []string) {
+ provider := cmd.Flag("provider").Value.String()
+ model := cmd.Flag("model").Value.String()
+
+ var aiProvider AIProvider
+
+ switch provider {
+ case "claude":
+ aiProvider = &ClaudeProvider{}
+ case "ollama":
+ aiProvider = &OllamaProvider{model: model}
+ default:
+ // Try Claude first, fallback to Ollama
+ if exec.Command("claude", "--version").Run() == nil {
+ aiProvider = &ClaudeProvider{}
+ } else {
+ aiProvider = &OllamaProvider{model: "deepseek-coder-v2:16b"}
+ }
+ }
+
+ del := NewDel(aiProvider)
+ del.startREPL()
+ },
+}
+
+func init() {
+ rootCmd.Flags().StringP("provider", "p", "auto", "AI provider (claude, ollama, auto)")
+ rootCmd.Flags().StringP("model", "m", "deepseek-coder-v2:16b", "Model to use (for Ollama)")
+}
+
+func main() {
+ if err := rootCmd.Execute(); err != nil {
+ log.Fatal(err)
+ }
+}
\ No newline at end of file
cmd/del/README.md
@@ -0,0 +1,89 @@
+# ๐ค๐ค Del the Funky Robosapien
+
+**Your AI-powered coding superhero with the soul of a funky homosapien!**
+
+Del is a powerful Go-based AI coding assistant designed to make you the most efficient programmer possible. Named after Del the Funky Homosapien, it brings creativity and power to your development workflow.
+
+## Features
+
+### ๐ก๏ธ Security First
+- **security_scan**: Scan code for vulnerabilities (integrates with gosec, semgrep)
+- Built-in protection from common security issues
+- Ask Del to "scan for vulnerabilities" or "check this code for security issues"
+
+### ๐ง Developer Tools
+- **read_file**: Read and analyze any file
+- **write_file**: Write content with confirmation prompts
+- **run_command**: Execute shell commands safely
+- **analyze_code**: Get code quality suggestions
+
+### ๐ค AI Provider Support
+- **Claude**: Uses Claude CLI or API
+- **Ollama**: Local models (deepseek-coder-v2, codellama, etc.)
+- **Auto-switching**: Tries Claude first, falls back to Ollama
+
+### ๐ MCP Integration (Coming Soon)
+- Will connect to MCP servers in `/home/mokhax/src/github.com/xlgmokha/mcp`
+- Git operations via MCP
+- Filesystem operations via MCP
+
+## Usage
+
+### Basic Commands
+```bash
+# Start Del (auto-detects best AI provider)
+del
+
+# Force specific provider
+del --provider claude
+del --provider ollama
+
+# Use specific Ollama model
+del --provider ollama --model deepseek-coder-v2:16b
+```
+
+### Interactive Commands
+Once in Del's REPL:
+```
+๐ค You: help # Show available commands
+๐ค You: quit # Exit Del
+๐ค You: scan for vulnerabilities # Security scan
+๐ค You: read main.go # Analyze a file
+๐ค You: explain this code # Get explanations
+```
+
+### Tool Usage
+Del uses AI to automatically call tools based on your requests:
+```
+๐ค You: analyze the code quality of main.go
+# Del will call: TOOL_USE: analyze_code {"path": "main.go"}
+
+๐ค You: write a hello world program to test.go
+# Del will call: TOOL_USE: write_file {"path": "test.go", "content": "..."}
+```
+
+## Building
+
+Del is automatically built by the dotfiles install script:
+```bash
+./install.sh # Builds Del and links to ~/.local/bin/del
+```
+
+Manual build:
+```bash
+go mod tidy
+go build -o cmd/del/del ./cmd/del/main.go
+```
+
+## Architecture
+
+Del is a **client** that:
+- Lives in this dotfiles repo for development/testing
+- Will eventually connect to MCP servers in the `/xlgmokha/mcp` repo
+- Can be moved to its permanent home once we understand the design
+
+**Current Status**: Prototype phase - testing and refining the design
+
+## Philosophy
+
+Keep it funky! ๐ต Del channels the creative energy of Del the Funky Homosapien while helping you write better, more secure code.
\ No newline at end of file
CLAUDE_COORDINATION.md
@@ -0,0 +1,30 @@
+# Claude Instance Coordination
+
+## Active Instances
+- **Backend Claude**: Implementing Python MCP servers in Go
+- **Del (Frontend Claude)**: AI frontend client for MCP servers
+
+## Current Work Division
+- **Backend**: Focus on MCP server implementation (`cmd/git/`, `cmd/fs/`, etc.)
+- **Del**: Focus on AI client interface (`cmd/del/`)
+
+## Coordination Protocol
+1. **Before starting work**: Check this file and `WORK_LOG.md`
+2. **Update status**: Log what you're working on
+3. **Avoid conflicts**: Don't modify each other's directories
+4. **Share progress**: Update completion status
+
+## Status Updates
+<!-- Backend Claude updates here -->
+
+<!-- Del updates here -->
+
+## Handoff Points
+- Backend completes MCP server โ Del integrates it
+- Del needs new capability โ Request to Backend via `REQUESTS.md`
+- Shared testing in `INTEGRATION_TESTS.md`
+
+## Conflict Resolution
+- Use separate branches when needed
+- Coordinate via git commits with clear messages
+- Use `@backend-claude` or `@del` in commit messages for attention
\ No newline at end of file
go.mod
@@ -0,0 +1,10 @@
+module github.com/xlgmokha/deltron
+
+go 1.24.0
+
+require github.com/spf13/cobra v1.9.1
+
+require (
+ github.com/inconshreveable/mousetrap v1.1.0 // indirect
+ github.com/spf13/pflag v1.0.6 // indirect
+)
go.sum
@@ -0,0 +1,10 @@
+github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
+github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
+github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
+github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
+github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
+github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
+github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
HANDOFF_STATUS.md
@@ -0,0 +1,29 @@
+# Del Frontend Coordination Status
+
+**HANDOFF FROM DEL** (2025-06-21 12:50): Del the Funky Robosapien frontend implementation is now complete and ready for coordination!
+
+## Del Features Implemented:
+- โ
AI Provider abstraction (Claude + Ollama support)
+- โ
Tool-based architecture with security scanning, file operations, command execution
+- โ
Interactive REPL with coordination awareness
+- โ
MCP client framework ready for server integration
+- โ
Handoff communication system for Claude-to-Claude coordination
+- โ
Live status updates and work tracking
+
+## Current Status:
+- Del is fully functional as an AI-powered coding assistant
+- Ready to integrate with MCP servers once backend Claude completes them
+- Coordination system active - Del can send/receive handoffs via WORK_LOG.md
+- Auto-builds via dotfiles install script
+
+## Next Steps:
+- Waiting for backend Claude to complete MCP server implementations
+- Will integrate MCP client calls once servers are ready
+- Ready to become the ultimate coding superhero! ๐ค๐ค
+
+## Del's Role in Division of Labor:
+- **Del (Frontend)**: AI-powered user interface, tool execution, coding assistance
+- **Backend Claude**: MCP server implementation and protocol handling
+- **Coordination**: Shared via WORK_LOG.md and handoff messages
+
+Ready to make some funky code together! ๐ต
\ No newline at end of file
WORK_LOG.md
@@ -0,0 +1,35 @@
+# Claude Work Log
+
+## Current Session
+**Date**: 2025-06-21
+**Active**: Del (Frontend Claude)
+
+### Del's Current Work
+- โ
Created `/cmd/del/main.go` - AI frontend client
+- ๐ Building tool integration system
+- ๐ TODO: Integrate with completed MCP servers
+- ๐ TODO: Add MCP client protocol support
+
+### Backend Claude Status
+<!-- Backend Claude: Please update your status here -->
+- Status: Unknown (please update)
+- Working on: MCP server implementations
+
+## Completed Handoffs
+<!-- Log completed work handoffs between instances -->
+
+## Pending Requests
+### From Del to Backend
+- Need: Notification when git MCP server is ready for integration
+- Need: Documentation on MCP protocol interface
+
+### From Backend to Del
+<!-- Backend Claude: Add requests here -->
+
+## Integration Points
+- [ ] Git MCP server integration
+- [ ] Filesystem MCP server integration
+- [ ] Command execution MCP server integration
+
+---
+**Last Updated**: 2025-06-21 by Del
\ No newline at end of file