Skip to content
Merged
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
16 changes: 12 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ['1.20', '1.21']
go-version: ['1.21', '1.22']

steps:
- uses: actions/checkout@v4
Expand All @@ -29,6 +29,14 @@ jobs:
restore-keys: |
${{ runner.os }}-go-

- name: Fix go.mod for older Go versions
if: matrix.go-version == '1.21'
run: |
# Remove toolchain directive for Go 1.21
sed -i '/^toolchain/d' go.mod
# Update go version format
sed -i 's/go 1\.22\.0/go 1.21/' go.mod

- name: Download dependencies
run: go mod download

Expand Down Expand Up @@ -56,7 +64,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
go-version: '1.22'

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
Expand All @@ -71,7 +79,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
go-version: '1.22'

- name: Run Gosec Security Scanner
uses: securego/gosec@master
Expand All @@ -94,7 +102,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
go-version: '1.22'

- name: Build for ${{ matrix.goos }}/${{ matrix.goarch }}
env:
Expand Down
178 changes: 171 additions & 7 deletions .workie.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,183 @@
# Workie Configuration
# Workie Configuration File
# =========================
# This file defines how Workie manages your development worktrees.
# Uncomment and customize the settings below for your project.

# Core Configuration - Files to Copy to New Worktrees
# ====================================================
files_to_copy:
# Environment files (commonly needed in all worktrees)
- .env.example
- README.md
# - .env.dev.example
# - .env.test.example
# - .env.local.example

# Configuration files
# - config/development.yaml
# - config/testing.yaml
# - config/staging.yaml
# - .editorconfig
# - .gitignore

# Documentation
# - README.md
# - docs/setup.md
# - docs/development.md
# - CONTRIBUTING.md

# Scripts and tools (use trailing slash for directories)
# - scripts/
# - tools/
# - bin/

# Language-specific files
# Node.js/JavaScript
# - package.json
# - package-lock.json
# - yarn.lock
# - .eslintrc.js
# - .prettierrc
# - tsconfig.json
# - jest.config.js

# Python
# - requirements.txt
# - requirements-dev.txt
# - pyproject.toml
# - setup.py
# - tox.ini
# - .flake8

# Go
# - go.mod
# - go.sum
# - Makefile

# Ruby
# - Gemfile
# - Gemfile.lock
# - .ruby-version

# Docker files
# - Dockerfile
# - Dockerfile.dev
# - docker-compose.yml
# - docker-compose.dev.yml
# - docker-compose.test.yml
# - .dockerignore

# Default provider for issue commands
default_provider: github
# CI/CD files
# - .github/
# - .gitlab-ci.yml
# - .travis.yml
# - circle.yml

# IDE/Editor settings (uncomment if your team uses these)
# - .vscode/
# - .idea/
# - .sublime-project

# Post-creation hooks (uncomment and customize as needed)
# hooks:
# post_create:
# - "echo 'Setting up new worktree...'"
# - "npm install"
# - "make setup"
# pre_remove:
# - "echo 'Cleaning up worktree...'"
# - "npm run cleanup"

# AI Configuration (Ollama-based Assistant)
# =========================================
# Configure AI features for intelligent code assistance
ai:
enabled: true
model:
provider: "ollama"
name: "zephyr"
temperature: 0.7
max_tokens: 2048
# ollama:
# base_url: "http://localhost:11434"
# keep_alive: "5m"
# features:
# code_analysis: true
# code_generation: true
# commit_message_generation: true
# documentation_generation: true

# Tips for Customizing Your Configuration:
# ========================================
# 1. Start simple - uncomment just the files you need most
# 2. Use relative paths from your repository root
# 3. For directories, include the trailing slash (/)
# 4. Test your configuration with a temporary branch first
# 5. Add comments to explain project-specific choices
# 6. Consider different needs for different branch types
# 7. Keep the file under version control so your team can share it

# Common Patterns:
# ===============
# - Always copy environment examples and config files
# - Include package manager files for dependency installation
# - Copy scripts and tools that help with development
# - Include documentation that developers need to reference
# - Add IDE settings if your team standardizes on specific tools
# - Be selective with CI/CD files to avoid conflicts

# Troubleshooting:
# ===============
# - If a file doesn't exist, Workie will show a warning but continue
# - Use 'workie --verbose' to see detailed copy operations
# - Check file permissions if copies fail
# - Use 'workie --list' to see all your worktrees
# - Use 'workie finish <branch>' to clean up test worktrees

# Issue Provider Configuration (Optional)
# ======================================
# Connect to GitHub, Jira, or Linear to work with issues

# Default provider to use when no provider is specified in issue commands
# default_provider: github

providers:
github:
enabled: true
settings:
token_env: "WORKIE_GITHUB_TOKEN"
owner: "agoodway"
repo: "workie"
token_env: "WORKIE_GITHUB_TOKEN" # Environment variable containing GitHub personal access token
owner: "agoodway" # Repository owner/organization
repo: "workie" # Repository name
branch_prefix:
bug: "fix/"
feature: "feat/"
default: "issue/"
#
# jira:
# enabled: false
# settings:
# base_url: "https://your-company.atlassian.net"
# email_env: "JIRA_EMAIL" # Environment variable for Jira email
# api_token_env: "JIRA_TOKEN" # Environment variable for Jira API token
# project: "PROJ" # Default project key
# branch_prefix:
# bug: "bugfix/"
# story: "feature/"
# task: "task/"
# default: "jira/"
#
# linear:
# enabled: false
# settings:
# api_key_env: "LINEAR_API_KEY" # Environment variable for Linear API key
# team_id: "TEAM" # Optional: filter by team
# branch_prefix:
# bug: "fix/"
# feature: "feat/"
# default: "linear/"

# Issue Provider Usage:
# ===================
# - List issues: workie issues
# - View issue: workie issues github:123
# - Create worktree from issue: workie issues github:123 --create
# - Filter issues: workie issues --assignee me --status open
65 changes: 56 additions & 9 deletions cmd/ask.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,45 @@ import (

"github.com/spf13/cobra"
"github.com/agoodway/workie/config"
"github.com/agoodway/workie/tools"
"github.com/tmc/langchaingo/llms/ollama"
)

var (
useTools bool
askVerbose bool
)

func init() {
askCmd.Flags().BoolVarP(&useTools, "tools", "t", false, "Enable tool/function calling for system commands")
askCmd.Flags().BoolVarP(&askVerbose, "verbose", "v", false, "Show verbose output including tool calls")
rootCmd.AddCommand(askCmd)
}

var askCmd = &cobra.Command{
Use: "ask [question]",
Short: "Ask a question to the AI model based on the current configuration",
Long: `This command sends a question to the configured AI model and returns the response.`,
Args: cobra.ExactArgs(1),
Long: `This command sends a question to the configured AI model and returns the response.

With the --tools flag, the AI can execute system commands to answer questions like:
- "What is the current git branch?"
- "List files in the current directory"
- "Show the contents of README.md"
- "What is the current working directory?"
- "Create a commit message based on the files changed"
- "Generate a detailed commit message"`,
Example: ` # Simple question without tools
workie ask "What is Git?"

# Question with tool execution
workie ask --tools "What is the current branch name?"

# Verbose mode to see tool calls
workie ask --tools --verbose "Show me the last 5 git commits"

# Generate commit message
workie ask --tools "Create a commit message based on the files changed"`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
question := args[0]

Expand Down Expand Up @@ -46,14 +73,34 @@ var askCmd = &cobra.Command{
os.Exit(1)
}

// Send question to model
ctx := context.Background()
response, err := llm.Call(ctx, question)
if err != nil {
fmt.Printf("Failed to get response: %v\n", err)
os.Exit(1)
}

fmt.Println("AI Response:", response)
if useTools {
// Set up tool registry
registry := tools.NewToolRegistry()
registry.Register(tools.NewGitTool())
registry.Register(tools.NewShellTool())
registry.Register(tools.NewFileSystemTool())
registry.Register(tools.NewCommitMessageTool())

// Use SimpleAgent for better handling
agent := tools.NewSimpleAgent(llm, registry, askVerbose)

// Execute with tools
response, err := agent.Execute(ctx, question)
if err != nil {
fmt.Printf("Failed to execute with tools: %v\n", err)
os.Exit(1)
}
fmt.Println(response)
} else {
// Direct LLM call without tools
response, err := llm.Call(ctx, question)
if err != nil {
fmt.Printf("Failed to get response: %v\n", err)
os.Exit(1)
}
fmt.Println("AI Response:", response)
}
},
}
Loading
Loading