plan

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package plan implements the plan-management tools (create_plan, add_ticket, ..., research_codebase). Each tool lives in its own file holding its model-facing name constant, its provider-neutral definition, and a tool.Tool implementation that owns the tool's logic. Every tool shares one set of Deps (the plan Store, the agent runner, and the worktree/repo paths), resolved lazily so the session manager can attach it after toolexec.New; deps.go wires them up via Tools(). This file collects the definitions for advertisement via ToolDefs. The Store, plan domain types, and markdown rendering live in core/planengine; the git-backed tools call core/git directly.

Index

Constants

View Source
const ToolAddPhase = "add_phase"

ToolAddPhase is the model-facing name of the add_phase tool.

View Source
const ToolAddTicket = "add_ticket"

ToolAddTicket is the model-facing name of the add_ticket tool.

View Source
const ToolCommitPhase = "commit_phase"

ToolCommitPhase is the model-facing name of the commit_phase tool.

View Source
const ToolCreate = "create_plan"

ToolCreate is the model-facing name of the create_plan tool.

View Source
const ToolGet = "get_plan"

ToolGet is the model-facing name of the get_plan tool.

View Source
const ToolPushTicket = "push_ticket"

ToolPushTicket is the model-facing name of the push_ticket tool.

View Source
const ToolRenderMarkdown = "render_plan_markdown"

ToolRenderMarkdown is the model-facing name of the render_plan_markdown tool.

View Source
const ToolResearch = "research_codebase"

ToolResearch is the model-facing name of the research_codebase tool.

View Source
const ToolReviewTicket = "review_ticket"

ToolReviewTicket is the model-facing name of the review_ticket tool.

View Source
const ToolStartTicket = "start_ticket"

ToolStartTicket is the model-facing name of the start_ticket tool.

View Source
const ToolSubmitTicketForReview = "submit_ticket_for_review"

ToolSubmitTicketForReview is the model-facing name of the submit_ticket_for_review tool.

View Source
const ToolUpdatePhase = "update_phase"

ToolUpdatePhase is the model-facing name of the update_phase tool. There was no earlier phase-status tool: phases previously had no lifecycle to generalize from.

View Source
const ToolUpdatePlan = "update_plan"

ToolUpdatePlan is the model-facing name of the update_plan tool. It replaces the narrower update_plan_status: any subset of intent, slug, branch, and status can be changed in one call.

View Source
const ToolUpdateTicket = "update_ticket"

ToolUpdateTicket is the model-facing name of the update_ticket tool. It replaces the narrower update_ticket_status: any subset of name, slug, skills, status, and position can be changed in one call. The reviewed/completed statuses still route through the dedicated lifecycle methods (and fire their hooks); dropped/pending are structural edits with no hook.

Variables

This section is empty.

Functions

func ResearchToolDefs added in v0.2.0

func ResearchToolDefs() []tooldef.Definition

ResearchToolDefs returns the research_codebase tool definition. Advertised only when the plan.research_subagent model is configured.

func ReviewTicketToolDefs added in v0.2.0

func ReviewTicketToolDefs() []tooldef.Definition

ReviewTicketToolDefs returns the review_ticket tool definition. Advertised only when the review.reviewer_subagent model is configured.

func ToolDefs

func ToolDefs() []tooldef.Definition

ToolDefs returns the plan-store tool definitions exposed by the plan package. Session.Manager appends these to the tool list when the session is hosted in a git repo (so .jungi/state/ can be written and git ops can run against the worktree). It excludes research_codebase and review_ticket, which are gated separately since each depends on its own subagent model being configured.

func Tools

func Tools(deps func() *Deps) map[string]tool.Tool

Tools returns one tool.Tool per plan model-facing name, each sharing the given lazy Deps accessor. The map is keyed by model-facing name for toolexec's dispatch map; every entry advertises its own definition (the same one ToolDefs lists) and routes through the shared Deps.

Types

type AgentRunner

type AgentRunner interface {
	// Research runs a read-only research subagent with the given
	// instructions and returns its final text response, plus the
	// subagent's usage — pre-costed against the subagent's own model
	// schedule — so the caller can fold it into the parent session.
	Research(ctx context.Context, instructions string) (string, usage.SessionUsage, error)

	// ReviewDiff runs all reviewer agents concurrently against the diff
	// from baseSHA to HEAD in the session's working directory and returns
	// the findings plus the aggregated subagent usage — pre-costed against
	// the subagents' own model schedule — so the caller can fold it into
	// the parent session.
	ReviewDiff(ctx context.Context, baseSHA string) (ReviewResults, usage.SessionUsage, error)
}

AgentRunner is the slim contract the research_codebase and review_ticket tools need to invoke subagents. It is defined here rather than imported from agentreg so the plan tools carry no dependency on the agent runtime; session.Manager adapts the real runner into this interface when building Deps.

type Deps

type Deps struct {
	Store    *planengine.Store
	Runner   AgentRunner
	WorkDir  string
	RepoRoot string
	// HooksRegistry, when non-nil, receives lifecycle events fired by the
	// plan tools (plan.created, plan.completed, ticket.started,
	// ticket.completed). A nil registry silently skips all hook calls.
	HooksRegistry *hooksreg.Registry
}

Deps is the session-specific state every plan tool shares: the plan store, the agent runner (used only by research_codebase), and the worktree/repo paths used by the git-backed tools (start_ticket, commit_phase, push_ticket). The session manager builds it and attaches it to the executor after toolexec.New, so the tools resolve it lazily through a closure. A nil Deps (or nil Store) means the session has no plan store — every tool then returns a clean "unavailable" error rather than nil-dereferencing. WorkDir/RepoRoot may be empty, which disables the git-backed tools while the rest keep working.

type PhaseCommittedEvent

type PhaseCommittedEvent struct {
	PhaseName     string
	CommitSHA     string
	CommitMessage string
	TicketSlug    string
	TicketName    string
	BranchName    string
	PlanSlug      string
	Dir           string
}

PhaseCommittedEvent implements hooksreg.Payload for phase.committed. Its fields are exactly the keys hooksreg's catalog declares for that event.

func (PhaseCommittedEvent) Env

func (e PhaseCommittedEvent) Env() map[string]string

Env implements hooksreg.Payload.

func (PhaseCommittedEvent) Event

Event implements hooksreg.Payload.

func (PhaseCommittedEvent) WorkDir

func (e PhaseCommittedEvent) WorkDir() string

WorkDir implements hooksreg.Payload.

type PlanCompletedEvent

type PlanCompletedEvent struct {
	PlanSlug string
	RepoRoot string
	Dir      string
}

PlanCompletedEvent implements hooksreg.Payload for plan.completed. Its fields are exactly the keys hooksreg's catalog declares for that event: the plan's slug and the repo root.

func (PlanCompletedEvent) Env

func (e PlanCompletedEvent) Env() map[string]string

Env implements hooksreg.Payload.

func (PlanCompletedEvent) Event

Event implements hooksreg.Payload.

func (PlanCompletedEvent) WorkDir

func (e PlanCompletedEvent) WorkDir() string

WorkDir implements hooksreg.Payload.

type PlanCreatedEvent

type PlanCreatedEvent struct {
	PlanSlug string
	RepoRoot string
	Dir      string
}

PlanCreatedEvent implements hooksreg.Payload for plan.created. Its fields are exactly the keys hooksreg's catalog declares for that event: the plan's slug and the repo root.

func (PlanCreatedEvent) Env

func (e PlanCreatedEvent) Env() map[string]string

Env implements hooksreg.Payload.

func (PlanCreatedEvent) Event

Event implements hooksreg.Payload.

func (PlanCreatedEvent) WorkDir

func (e PlanCreatedEvent) WorkDir() string

WorkDir implements hooksreg.Payload.

type ReviewResults

type ReviewResults struct {
	// Findings maps perspective name (e.g. "security") to the agent's raw
	// text output.
	Findings map[string]string
	// Errors maps perspective name to the error message when that agent
	// failed, so the synthesis step can surface which perspectives are
	// missing.
	Errors map[string]string
}

ReviewResults holds the raw findings returned by the parallel reviewer agents. Each entry maps a perspective name to the agent's text output. Errors from individual agents are collected separately so a partial failure does not discard successful findings.

type TicketCompletedEvent

type TicketCompletedEvent struct {
	TicketSlug string
	TicketName string
	BranchName string
	BaseRef    string
	PhaseNames string
	PlanSlug   string
	Dir        string
}

TicketCompletedEvent implements hooksreg.Payload for ticket.completed. Its fields are exactly the keys hooksreg's catalog declares for that event.

func (TicketCompletedEvent) Env

func (e TicketCompletedEvent) Env() map[string]string

Env implements hooksreg.Payload.

func (TicketCompletedEvent) Event

Event implements hooksreg.Payload.

func (TicketCompletedEvent) WorkDir

func (e TicketCompletedEvent) WorkDir() string

WorkDir implements hooksreg.Payload.

type TicketReadyForReviewEvent

type TicketReadyForReviewEvent struct {
	TicketSlug string
	TicketName string
	BranchName string
	BaseRef    string
	PhaseNames string
	PlanSlug   string
	Dir        string
}

TicketReadyForReviewEvent implements hooksreg.Payload for ticket.ready_for_review. Its fields are exactly the keys hooksreg's catalog declares for that event.

func (TicketReadyForReviewEvent) Env

Env implements hooksreg.Payload.

func (TicketReadyForReviewEvent) Event

Event implements hooksreg.Payload.

func (TicketReadyForReviewEvent) WorkDir

func (e TicketReadyForReviewEvent) WorkDir() string

WorkDir implements hooksreg.Payload.

type TicketReviewedEvent

type TicketReviewedEvent struct {
	TicketSlug string
	TicketName string
	BranchName string
	BaseRef    string
	PhaseNames string
	PlanSlug   string
	Dir        string
}

TicketReviewedEvent implements hooksreg.Payload for ticket.reviewed. Its fields are exactly the keys hooksreg's catalog declares for that event.

func (TicketReviewedEvent) Env

func (e TicketReviewedEvent) Env() map[string]string

Env implements hooksreg.Payload.

func (TicketReviewedEvent) Event

Event implements hooksreg.Payload.

func (TicketReviewedEvent) WorkDir

func (e TicketReviewedEvent) WorkDir() string

WorkDir implements hooksreg.Payload.

type TicketStartedEvent

type TicketStartedEvent struct {
	TicketSlug string
	TicketName string
	BranchName string
	BaseRef    string
	PlanSlug   string
	Dir        string
}

TicketStartedEvent implements hooksreg.Payload for ticket.started. Its fields are exactly the keys hooksreg's catalog declares for that event — notably no PHASE_NAMES, since a ticket has no phases yet when it starts. PLAN_SLUG closes the gap where githubpr.BuildBody reads it but ticket events never emitted it.

func (TicketStartedEvent) Env

func (e TicketStartedEvent) Env() map[string]string

Env implements hooksreg.Payload.

func (TicketStartedEvent) Event

Event implements hooksreg.Payload.

func (TicketStartedEvent) WorkDir

func (e TicketStartedEvent) WorkDir() string

WorkDir implements hooksreg.Payload.

Source Files

  • add_phase.go
  • add_ticket.go
  • commit_phase.go
  • create_plan.go
  • deps.go
  • get_plan.go
  • helpers.go
  • hookevents.go
  • preview.go
  • push_ticket.go
  • render_plan_markdown.go
  • research_codebase.go
  • review_ticket.go
  • start_ticket.go
  • submit_ticket_for_review.go
  • tool.go
  • update_phase.go
  • update_plan.go
  • update_ticket.go

Jump to

Keyboard shortcuts

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