services

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindTemplate

func FindTemplate(all []types.Template, query string) *types.Template

FindTemplate returns the first template whose filename contains the query (case-insensitive, without extension). Empty query returns nil.

func LoadTemplates

func LoadTemplates(dir string) ([]types.Template, error)

LoadTemplates reads every *.md file in dir and parses YAML frontmatter. Files without frontmatter are skipped silently.

func ParseInto

func ParseInto(raw string, v any) error

ParseInto runs Extract on model text into v.

func Play

func Play(enabled bool, event SoundEvent)

Play emits an async terminal sound. It is a no-op when:

  • enabled is false
  • the platform has no supported sound command
  • the sound binary is not found

Types

type Agent

type Agent struct {
	O        *OllamaClient
	Template types.Template
	Title    string
	Brief    string
	History  []types.Turn
	MaxTurns int
	Debug    bool
}

Agent runs the multi-turn issue-drafting conversation with Ollama. Ported from agent.sh lines 740–897.

func (*Agent) Finalize

func (a *Agent) Finalize(ctx context.Context) (types.AgentResponse, error)

Finalize forces the agent to produce a ready answer immediately, used when the user opts out of more questions (agent.sh skip mode).

func (*Agent) NextTurn

func (a *Agent) NextTurn(ctx context.Context, turn int) (types.AgentResponse, error)

NextTurn sends the next prompt to Ollama and parses the response.

type GitHub

type GitHub struct {
	Repo string
}

func NewGitHub

func NewGitHub(repo string) *GitHub

func (*GitHub) AssignMe

func (g *GitHub) AssignMe(ctx context.Context, number int) error

func (*GitHub) CheckAuth

func (g *GitHub) CheckAuth(ctx context.Context) error

func (*GitHub) Close

func (g *GitHub) Close(ctx context.Context, number int) error

func (*GitHub) Comment

func (g *GitHub) Comment(ctx context.Context, number int, body string) error

func (*GitHub) Comments

func (g *GitHub) Comments(ctx context.Context, number int) ([]types.Comment, error)

func (*GitHub) Create

func (g *GitHub) Create(ctx context.Context, draft types.Draft) (string, error)

Create writes the body to a temp file and invokes `gh issue create`. Returns the URL of the new issue.

func (*GitHub) EditIssue

func (g *GitHub) EditIssue(ctx context.Context, number int, title, body string) error

EditIssue updates the title and/or body of an existing issue.

func (*GitHub) List

func (g *GitHub) List(ctx context.Context, state string, limit int) ([]types.Issue, error)

func (*GitHub) Reopen

func (g *GitHub) Reopen(ctx context.Context, number int) error

func (*GitHub) Unassign

func (g *GitHub) Unassign(ctx context.Context, number, _unused int) error

func (*GitHub) View

func (g *GitHub) View(ctx context.Context, number int) (*types.Issue, error)

type OllamaClient

type OllamaClient struct {
	Host    string
	Model   string
	Timeout time.Duration
	HTTP    *http.Client
}

func NewOllama

func NewOllama(host, model string, timeout time.Duration) *OllamaClient

func (*OllamaClient) GenerateJSON

func (c *OllamaClient) GenerateJSON(ctx context.Context, prompt string) (string, error)

GenerateJSON calls Ollama with format:json and stream:false, returns the model's text response (which is expected to be a JSON blob).

func (*OllamaClient) Ping

func (c *OllamaClient) Ping(ctx context.Context) error

Ping checks the /api/tags endpoint is reachable.

func (*OllamaClient) StreamCmd

func (c *OllamaClient) StreamCmd(ctx context.Context, prompt string, send func(tea.Msg)) tea.Cmd

StreamCmd launches a goroutine that POSTs to /api/generate with stream:true and returns a tea.Cmd that delivers a single StreamDoneMsg / StreamErrMsg. Token chunks are pushed to the Program via the provided Send function.

Using a send-channel keeps the API aligned with Bubble Tea's (*Program).Send — callers hold a program reference and pass its Send.

type SoundEvent

type SoundEvent int
const (
	SoundTick  SoundEvent = iota // AI finished a turn
	SoundDone                    // issue created
	SoundError                   // something went wrong
)

type StreamDoneMsg

type StreamDoneMsg struct {
	Full string
}

StreamDoneMsg is emitted once Ollama finishes sending.

type StreamErrMsg

type StreamErrMsg struct {
	Err error
}

StreamErrMsg is emitted on any transport or decode error.

type TokenMsg

type TokenMsg struct {
	Chunk string
}

TokenMsg is emitted for each streamed chunk.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL