tools

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ReviewStatePending indicates that the review or pre-review is in progress.
	ReviewStatePending = "⏳"
	// ReviewStateApproved indicates that the review concluded with an approval.
	ReviewStateApproved = "✅"
	// ReviewStateRejected indicates that the review concluded with a rejection.
	ReviewStateRejected = "❎"
	// ReviewStateElse indicates non-blocking feedback, uncertain outcome, or general completion.
	ReviewStateElse = "✳️"
)

Variables

View Source
var ErrDiffTooLarge = errors.New("PR diff exceeds GitHub API limit (406)")

ErrDiffTooLarge is returned when GitHub rejects a PR diff request with HTTP 406 (e.g. diff exceeds limit).

Functions

func CleanThreadTitle added in v0.8.0

func CleanThreadTitle(title string) string

CleanThreadTitle strips existing review status emoji prefixes (and following spaces) from a thread title.

func ContextWithStateWriter added in v0.6.0

func ContextWithStateWriter(ctx context.Context, w io.Writer) context.Context

ContextWithStateWriter returns a new context carrying the given state writer. This is retained for test assertions and potential downstream integrations where state is logged directly via context (rather than through reporter callbacks).

func FetchGitCommits

func FetchGitCommits(ctx context.Context, workingDir, base, head string) (string, error)

FetchGitCommits returns a bulleted list of commit subjects (first line of message) between base and head, excluding merge commits.

func FetchGitDiff

func FetchGitDiff(ctx context.Context, workingDir, base, head string, ignoredLockFiles []string) (string, []string, error)

func FetchPRDiff added in v0.8.0

func FetchPRDiff(ctx context.Context, client *github.Client, owner, repo string, prNumber int, paths []string, ignoredLockFiles []string) (string, error)

FetchPRDiff fetches the git diff for a PR. If paths are supplied, only diffs for those paths are returned. Lockfiles in ignoredLockFiles are omitted.

func FetchPRFiles added in v0.8.0

func FetchPRFiles(ctx context.Context, client *github.Client, owner, repo string, prNumber int, ignoredLockFiles []string) ([]string, error)

FetchPRFiles fetches the list of changed files for a pull request, excluding ignored lock files.

func FormatThreadTitle added in v0.8.0

func FormatThreadTitle(emoji, baseTitle string) string

FormatThreadTitle formats a thread title with the specified review status emoji prefix.

func GetCurrentThreadTitle added in v0.8.0

func GetCurrentThreadTitle(ctx context.Context) (string, error)

GetCurrentThreadTitle returns the title of the current T3 thread if running in a T3 session.

func IsT3Session added in v0.8.0

func IsT3Session() bool

IsT3Session returns true if Cassandra is currently running inside a T3 Code environment.

func ParseRepoSlug added in v0.8.0

func ParseRepoSlug(raw string) (owner, repo string, err error)

ParseRepoSlug parses owner and repo from an owner/repo slug or git URL.

func RegisterLocalTools

func RegisterLocalTools(r *Registry, root, base, head string, ignoredLockFiles []string, wishlistDir string, allowAskDeveloper bool, allowPRComment bool, notifier UserNotifier, diffMapProvider func() map[string]string, metadataJSONFile ...string)

func RegisterToolWithArgs added in v0.5.0

func RegisterToolWithArgs[T any](r *Registry, def llm.ToolDef, handler func(ctx context.Context, args T) (string, error))

func StateWriterFromContext added in v0.6.0

func StateWriterFromContext(ctx context.Context) io.Writer

StateWriterFromContext extracts the state writer from the context, if present.

func UpdateThreadTitlePrefix added in v0.8.0

func UpdateThreadTitlePrefix(ctx context.Context, emoji string) error

UpdateThreadTitlePrefix updates the current T3 thread title with the specified review status emoji prefix. If not in a T3 session, it is a no-op and returns nil.

func WithAskDeveloperTimeout added in v0.6.0

func WithAskDeveloperTimeout(ctx context.Context, d time.Duration) context.Context

WithAskDeveloperTimeout wraps a context to override the ask_developer timeout.

func WithTestStreams added in v0.6.0

func WithTestStreams(ctx context.Context, in io.Reader, out io.Writer) context.Context

WithTestStreams wraps a context to override standard input/output of ask_developer.

Types

type ModelSelection added in v0.8.0

type ModelSelection struct {
	InstanceID string `json:"instanceId,omitempty"`
	Model      string `json:"model"`
	Options    any    `json:"options,omitempty"`
	Provider   string `json:"provider,omitempty"`
}

ModelSelection specifies provider instance and model parameters for thread launch.

type NoOpUserNotifier added in v0.6.0

type NoOpUserNotifier struct{}

func (NoOpUserNotifier) NotifyUser added in v0.6.0

func (NoOpUserNotifier) NotifyUser()

type PRStackItem added in v0.8.0

type PRStackItem struct {
	PRNumber int    `json:"pr_number"`
	Title    string `json:"title"`
	Branch   string `json:"branch"`
	Base     string `json:"base"`
	Head     string `json:"head"`
}

PRStackItem represents a pull request in a stacked PR chain.

func FetchPRStack added in v0.8.0

func FetchPRStack(ctx context.Context, client *github.Client, owner, repo string, prNumber int) ([]PRStackItem, error)

FetchPRStack fetches the stacked PR chain for the given PR number using GitHub's native Stacks API. If the PR is not part of a stack (or if stacks are not enabled/available), it returns (nil, nil).

type PRSummary added in v0.8.0

type PRSummary struct {
	PRNumber     int      `json:"pr_number"`
	RepoFullName string   `json:"repo_full_name"`
	Title        string   `json:"title"`
	Description  string   `json:"description"`
	Author       string   `json:"author"`
	Branch       string   `json:"branch"`
	Base         string   `json:"base"`
	Head         string   `json:"head"`
	ChangedFiles []string `json:"changed_files"`
}

PRSummary represents pull request details and changed files for agent tools.

func FetchPRMetadata added in v0.8.0

func FetchPRMetadata(ctx context.Context, client *github.Client, owner, repo string, prNumber int, ignoredLockFiles []string) (*PRSummary, error)

FetchPRMetadata fetches the PR summary including title, description, author, branch refs, and changed files.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

func NewRegistry

func NewRegistry() *Registry

func (*Registry) HandleCall

func (r *Registry) HandleCall(ctx context.Context, tc llm.ToolCall) (string, error)

func (*Registry) RegisterTool

func (r *Registry) RegisterTool(def llm.ToolDef, handler ToolHandler)

func (*Registry) SetVerdictChangeListener added in v0.8.0

func (r *Registry) SetVerdictChangeListener(l VerdictChangeListener)

func (*Registry) ToTools

func (r *Registry) ToTools() []llm.ToolDef

type ThreadLaunchArgs added in v0.8.0

type ThreadLaunchArgs struct {
	Title             string             `json:"title"`
	Message           string             `json:"message,omitempty"`
	ModelSelection    *ModelSelection    `json:"modelSelection,omitempty"`
	WorkspaceStrategy *WorkspaceStrategy `json:"workspaceStrategy,omitempty"`
	RuntimeMode       string             `json:"runtimeMode,omitempty"`
	InteractionMode   string             `json:"interactionMode,omitempty"`
	ProjectID         string             `json:"projectId,omitempty"`
	Scratch           *bool              `json:"scratch,omitempty"`
}

ThreadLaunchArgs represents arguments passed to t3_thread_launch.

type ToolHandler

type ToolHandler func(ctx context.Context, tc llm.ToolCall) (string, error)

type UserNotifier added in v0.6.0

type UserNotifier interface {
	NotifyUser()
}

type VerdictChangeListener added in v0.8.0

type VerdictChangeListener func(ctx context.Context, verdict string, rationale string) error

VerdictChangeListener is invoked whenever the review verdict is updated via update_review_verdict.

type WorkspaceStrategy added in v0.8.0

type WorkspaceStrategy struct {
	Type            string `json:"type"`
	BaseRef         string `json:"baseRef,omitempty"`
	Branch          string `json:"branch,omitempty"`
	StartFromOrigin *bool  `json:"startFromOrigin,omitempty"`
	WorktreePath    string `json:"worktreePath,omitempty"`
}

WorkspaceStrategy specifies workspace configuration for a launched thread.

Directories

Path Synopsis
mcp_servers

Jump to

Keyboard shortcuts

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