autocrossbow/issues/vikunja/vikunja.go

48 lines
1.2 KiB
Go
Raw Normal View History

initial commit yessss feat: add Vikunja issues provider and integrate tasks retrieval Co-authored-by: aider (openai/qwen2.5-coder:32b-instruct-q4_0) <aider@aider.chat> feat: add Vikunja handler to main file Co-authored-by: aider (openai/qwen2.5-coder:32b-instruct-q4_0) <aider@aider.chat> refactor: Move Jira user from positional arg to flag parameter Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat> fix: replace manual argument parsing with Go flags package Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat> feat: replace positional arguments with flags in main function Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat> fix: enforce mandatory start/end dates and at least one identifier flag Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat> fix: only call relevant tools based on flag presence Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat> feat: add vikunja task support to summarize function feat: add flag to pass custom prompt with default prompt as fallback Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat> Minor fix fix: comment out vikunja tasks integration for now fix: check for OpenAI environment variables before calling Summarize Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat> feat: add timestamped prompt file generation for summarization refactor: remove duplicate os.Getenv calls for OpenAI env vars in SummarizeData Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat> refactor: pass OpenAI env vars from main to SummarizeData instead of calling os.Getenv inside the function Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat> feat: add file prompt support with fallback to literal prompt string Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat> fix: remove single quotes around JIRA user assignee and add debug printing feat: implement accountID lookup for Jira user search in GetIssues function Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat> fix: remove debug print statement in Jira user search function fix: Replace user parameter with JIRA_USER environment variable in SetBasicAuth calls Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat> fix: add missing os import in summarize.go refactor: split SummarizeData into buildPrompt and callSummarizationEndpoint functions Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat> fix: always call SummarizeData to ensure prompt file is created for debugging, but only call OpenAI endpoint if env vars are set Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat> refactor: extract callSummarizationEndpoint into Summarizer interface for multiple implementations Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat> refactor: move OpenAI variable checks into OpenAISummarizer's Summarize method and always call the summarizer's method Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat> feat: implement Ollama Summarizer using official SDK as per article example Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat> refactor: simplify OpenAI and Ollama summarizer implementations refactor: simplify Summarizer interface by moving endpoint, token, and model to struct properties Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat> feat: add Ollama summarizer support to main command fix: remove extraneous parameters from SummarizeData call and use properly initialized OllamaSummarizer Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat> feat: add AnthropicSummarizer implementation using anthropic-sdk-go package Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat> fix: change summarizer call condition to check if summarizer is nil instead of environment variables Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat> fix: correct client reference and update Anthropic summarizer implementation feat: extract PR rendering to String() method using text/template Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat> Some cleanup
2025-09-13 08:40:40 -04:00
package vikunja
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
)
type Task struct {
Title string `json:"title"`
Description string `json:"description"`
Status int `json:"status"` // Assuming 1 is for completed tasks
}
func GetTasks(instance, user, from, to string) ([]Task, error) {
req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("https://%s/api/v1/user/tasks", instance), nil)
if err != nil {
return nil, fmt.Errorf("error building vikunja request: %w", err)
}
q := req.URL.Query()
q.Add("user_id", user)
q.Add("status", "1") // Assuming 1 is for completed tasks
req.URL.RawQuery = q.Encode()
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", os.Getenv("VIKUNJA_TOKEN")))
resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, fmt.Errorf("error executing vikunja request: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode >= 400 {
b := bytes.NewBuffer(nil)
io.Copy(b, resp.Body)
return nil, fmt.Errorf("error talking to vikunja: %s", b.String())
}
var tasks []Task
err = json.NewDecoder(resp.Body).Decode(&tasks)
if err != nil {
return nil, fmt.Errorf("error decoding vikunja response: %w", err)
}
return tasks, nil
}