Documentation
¶
Overview ¶
Package agentic provides AI collaboration features for task management.
Package agentic provides AI collaboration features for task management.
Package agentic provides an API client for core-agentic, an AI-assisted task management service. It enables developers and AI agents to discover, claim, and complete development tasks.
Index ¶
- Constants
- func AutoCommit(ctx context.Context, task *Task, dir string, message string) error
- func CommitAndSync(ctx context.Context, client *Client, task *Task, dir string, message string, ...) error
- func ConfigPath() (string, error)
- func CreateBranch(ctx context.Context, task *Task, dir string) (string, error)
- func CreatePR(ctx context.Context, task *Task, dir string, opts PROptions) (string, error)
- func GetCurrentBranch(ctx context.Context, dir string) (string, error)
- func GetDiff(ctx context.Context, dir string, staged bool) (string, error)
- func HasUncommittedChanges(ctx context.Context, dir string) (bool, error)
- func NewService(opts ServiceOptions) func(*framework.Core) (any, error)
- func Prompt(name string) string
- func PushChanges(ctx context.Context, dir string) error
- func SaveConfig(cfg *Config) error
- func SyncStatus(ctx context.Context, client *Client, task *Task, update TaskUpdate) error
- type APIError
- type ClaimResponse
- type Client
- func (c *Client) ClaimTask(ctx context.Context, id string) (*Task, error)
- func (c *Client) CompleteTask(ctx context.Context, id string, result TaskResult) error
- func (c *Client) GetTask(ctx context.Context, id string) (*Task, error)
- func (c *Client) ListTasks(ctx context.Context, opts ListOptions) ([]Task, error)
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) UpdateTask(ctx context.Context, id string, update TaskUpdate) error
- type CompleteResponse
- type Config
- type FileContent
- type ListOptions
- type PROptions
- type Service
- type ServiceOptions
- type Task
- type TaskCommit
- type TaskContext
- type TaskPriority
- type TaskPrompt
- type TaskResult
- type TaskStatus
- type TaskUpdate
Constants ¶
const DefaultBaseURL = "https://api.core-agentic.dev"
DefaultBaseURL is the default API endpoint if none is configured.
Variables ¶
This section is empty.
Functions ¶
func AutoCommit ¶
AutoCommit creates a git commit with a task reference. The commit message follows the format:
feat(scope): description Task: #123 Co-Authored-By: Claude <noreply@anthropic.com>
func CommitAndSync ¶
func CommitAndSync(ctx context.Context, client *Client, task *Task, dir string, message string, progress int) error
CommitAndSync commits changes and syncs task status.
func ConfigPath ¶
ConfigPath returns the path to the config file in the user's home directory.
func CreateBranch ¶
CreateBranch creates a new branch for the task.
func GetCurrentBranch ¶
GetCurrentBranch returns the current git branch name.
func HasUncommittedChanges ¶
HasUncommittedChanges checks if there are uncommitted changes.
func NewService ¶
func NewService(opts ServiceOptions) func(*framework.Core) (any, error)
NewService creates an AI service factory.
func Prompt ¶
Prompt returns the content of an embedded prompt file. Name should be without the .md extension (e.g., "commit").
func PushChanges ¶
PushChanges pushes committed changes to the remote.
func SaveConfig ¶
SaveConfig saves the configuration to ~/.core/agentic.yaml.
func SyncStatus ¶
SyncStatus syncs the task status back to the agentic service.
Types ¶
type APIError ¶
type APIError struct {
// Code is the HTTP status code.
Code int `json:"code"`
// Message is the error description.
Message string `json:"message"`
// Details provides additional context about the error.
Details string `json:"details,omitempty"`
}
APIError represents an error response from the API.
type ClaimResponse ¶
type ClaimResponse struct {
// Task is the claimed task with updated fields.
Task *Task `json:"task"`
// Message provides additional context about the claim.
Message string `json:"message,omitempty"`
}
ClaimResponse is returned when a task is successfully claimed.
type Client ¶
type Client struct {
// BaseURL is the base URL of the API server.
BaseURL string
// Token is the authentication token.
Token string
// HTTPClient is the HTTP client used for requests.
HTTPClient *http.Client
// AgentID is the identifier for this agent when claiming tasks.
AgentID string
}
Client is the API client for the core-agentic service.
func NewClientFromConfig ¶
NewClientFromConfig creates a new client from a Config struct.
func (*Client) CompleteTask ¶
CompleteTask marks a task as completed with the given result.
func (*Client) UpdateTask ¶
UpdateTask updates a task with new status, progress, or notes.
type CompleteResponse ¶
type CompleteResponse struct {
// Task is the completed task with final status.
Task *Task `json:"task"`
// Message provides additional context about the completion.
Message string `json:"message,omitempty"`
}
CompleteResponse is returned when a task is completed.
type Config ¶
type Config struct {
// BaseURL is the URL of the core-agentic API server.
BaseURL string `yaml:"base_url" json:"base_url"`
// Token is the authentication token for API requests.
Token string `yaml:"token" json:"token"`
// DefaultProject is the project to use when none is specified.
DefaultProject string `yaml:"default_project" json:"default_project"`
// AgentID is the identifier for this agent (optional, used for claiming tasks).
AgentID string `yaml:"agent_id" json:"agent_id"`
}
Config holds the configuration for connecting to the core-agentic service.
func LoadConfig ¶
LoadConfig loads the agentic configuration from the specified directory. It first checks for a .env file, then falls back to ~/.core/agentic.yaml. If dir is empty, it checks the current directory first.
Environment variables take precedence:
- AGENTIC_BASE_URL: API base URL
- AGENTIC_TOKEN: Authentication token
- AGENTIC_PROJECT: Default project
- AGENTIC_AGENT_ID: Agent identifier
type FileContent ¶
type FileContent struct {
// Path is the relative path to the file.
Path string `json:"path"`
// Content is the file content.
Content string `json:"content"`
// Language is the detected programming language.
Language string `json:"language"`
}
FileContent represents the content of a file for AI context.
func GatherRelatedFiles ¶
func GatherRelatedFiles(task *Task, dir string) ([]FileContent, error)
GatherRelatedFiles reads files mentioned in the task.
type ListOptions ¶
type ListOptions struct {
// Status filters tasks by their current status.
Status TaskStatus `json:"status,omitempty"`
// Labels filters tasks that have all specified labels.
Labels []string `json:"labels,omitempty"`
// Priority filters tasks by priority level.
Priority TaskPriority `json:"priority,omitempty"`
// Limit is the maximum number of tasks to return.
Limit int `json:"limit,omitempty"`
// Project filters tasks by project.
Project string `json:"project,omitempty"`
// ClaimedBy filters tasks claimed by a specific agent.
ClaimedBy string `json:"claimed_by,omitempty"`
}
ListOptions specifies filters for listing tasks.
type PROptions ¶
type PROptions struct {
// Title is the PR title.
Title string `json:"title"`
// Body is the PR description.
Body string `json:"body"`
// Draft marks the PR as a draft.
Draft bool `json:"draft"`
// Labels are labels to add to the PR.
Labels []string `json:"labels"`
// Base is the base branch (defaults to main).
Base string `json:"base"`
}
PROptions contains options for creating a pull request.
type Service ¶
type Service struct {
*framework.ServiceRuntime[ServiceOptions]
}
Service provides AI/Claude operations as a Core service.
type ServiceOptions ¶
type ServiceOptions struct {
DefaultTools []string
AllowEdit bool // global permission for Write/Edit tools
}
ServiceOptions for configuring the AI service.
func DefaultServiceOptions ¶
func DefaultServiceOptions() ServiceOptions
DefaultServiceOptions returns sensible defaults.
type Task ¶
type Task struct {
// ID is the unique identifier for the task.
ID string `json:"id"`
// Title is the short description of the task.
Title string `json:"title"`
// Description provides detailed information about what needs to be done.
Description string `json:"description"`
// Priority indicates the urgency of the task.
Priority TaskPriority `json:"priority"`
// Status indicates the current state of the task.
Status TaskStatus `json:"status"`
// Labels are tags used to categorize the task.
Labels []string `json:"labels,omitempty"`
// Files lists the files that are relevant to this task.
Files []string `json:"files,omitempty"`
// CreatedAt is when the task was created.
CreatedAt time.Time `json:"created_at"`
// UpdatedAt is when the task was last modified.
UpdatedAt time.Time `json:"updated_at,omitempty"`
// ClaimedBy is the identifier of the agent or developer who claimed the task.
ClaimedBy string `json:"claimed_by,omitempty"`
// ClaimedAt is when the task was claimed.
ClaimedAt *time.Time `json:"claimed_at,omitempty"`
// Project is the project this task belongs to.
Project string `json:"project,omitempty"`
// Dependencies lists task IDs that must be completed before this task.
Dependencies []string `json:"dependencies,omitempty"`
// Blockers lists task IDs that this task is blocking.
Blockers []string `json:"blockers,omitempty"`
}
Task represents a development task in the core-agentic system.
type TaskCommit ¶
TaskCommit requests Claude to create a commit.
type TaskContext ¶
type TaskContext struct {
// Task is the task being worked on.
Task *Task `json:"task"`
// Files is a list of relevant file contents.
Files []FileContent `json:"files"`
// GitStatus is the current git status output.
GitStatus string `json:"git_status"`
// RecentCommits is the recent commit log.
RecentCommits string `json:"recent_commits"`
// RelatedCode contains code snippets related to the task.
RelatedCode []FileContent `json:"related_code"`
}
TaskContext contains gathered context for AI collaboration.
func BuildTaskContext ¶
func BuildTaskContext(task *Task, dir string) (*TaskContext, error)
BuildTaskContext gathers context for AI collaboration on a task.
func (*TaskContext) FormatContext ¶
func (tc *TaskContext) FormatContext() string
FormatContext formats the TaskContext for AI consumption.
type TaskPriority ¶
type TaskPriority string
TaskPriority represents the urgency level of a task.
const ( // PriorityCritical indicates the task requires immediate attention. PriorityCritical TaskPriority = "critical" // PriorityHigh indicates the task is important and should be addressed soon. PriorityHigh TaskPriority = "high" // PriorityMedium indicates the task has normal priority. PriorityMedium TaskPriority = "medium" // PriorityLow indicates the task can be addressed when time permits. PriorityLow TaskPriority = "low" )
type TaskPrompt ¶
TaskPrompt sends a custom prompt to Claude.
type TaskResult ¶
type TaskResult struct {
// Success indicates whether the task was completed successfully.
Success bool `json:"success"`
// Output is the result or summary of the completed work.
Output string `json:"output,omitempty"`
// Artifacts are files or resources produced by the task.
Artifacts []string `json:"artifacts,omitempty"`
// ErrorMessage contains details if the task failed.
ErrorMessage string `json:"error_message,omitempty"`
}
TaskResult contains the outcome of a completed task.
type TaskStatus ¶
type TaskStatus string
TaskStatus represents the state of a task in the system.
const ( // StatusPending indicates the task is available to be claimed. StatusPending TaskStatus = "pending" // StatusInProgress indicates the task has been claimed and is being worked on. StatusInProgress TaskStatus = "in_progress" // StatusCompleted indicates the task has been successfully completed. StatusCompleted TaskStatus = "completed" // StatusBlocked indicates the task cannot proceed due to dependencies. StatusBlocked TaskStatus = "blocked" )
type TaskUpdate ¶
type TaskUpdate struct {
// Status is the new status for the task.
Status TaskStatus `json:"status,omitempty"`
// Progress is a percentage (0-100) indicating completion.
Progress int `json:"progress,omitempty"`
// Notes are additional comments about the update.
Notes string `json:"notes,omitempty"`
}
TaskUpdate contains fields that can be updated on a task.