Documentation
¶
Overview ¶
Package planservice stores and advances execution plans. A plan is a named sequence of steps built from a plain-text goal — it persists in SQLite across restarts so work resumes without re-explaining context.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Args ¶
Args controls Next execution behaviour.
WithShell is a hard gate enforced inside the task engine: when false, Next attaches a runtime tools allowlist ["*", "!local_shell"] to the execution context, so resolveToolsNames will remove local_shell from whatever the executor chain declared. A chain JSON that tries to invoke local_shell when the caller disallowed it fails at tools-dispatch time, regardless of what the chain author wrote. The flag can only further restrict; when true, the chain's own allowlist governs.
WithAuto is a telemetry/audit signal only: the caller claims this step is part of an unattended auto-run loop. It is NOT an execution gate — iteration is a client-loop concern (see contenoxcli runPlanNext). The flag is forwarded to the tracker so plan-run logs/metrics can distinguish interactive vs. auto-run steps.
type PlanStepMacroVars ¶
type PlanStepMacroVars struct {
PlanGoal string
PlanOverview string
PlanProgress string
StepOrdinal string
StepTotal string
CurrentStep string
NextStep string
PlanHandover string
PreviousOutput string
PreviousHandover string
PreviousArtifacts string
PreviousCaveats string
PriorFailureDetail string
// RepoContext is the rendered bullet block from the plan's persisted
// RepoContextJSON (see [planstore.RepoContext] / chain-plan-explorer.json).
// Empty when the plan was created without --explore.
RepoContext string
}
PlanStepMacroVars holds values for MacroEnv {{var:…}} expansion in the compiled noop seed (see plancompile.seedPromptTemplate). Use NewPlanStepMacroVars then PlanStepMacroVars.TemplateVars for taskengine.MergeTemplateVars.
PreviousOutput / PreviousHandover / PreviousArtifacts / PreviousCaveats are all rendered from the prior completed step's persisted Summary JSON. When the prior step's Summary is empty (legacy row or fallback path persisted only ExecutionResult), PreviousOutput falls back to the legacy string so existing plans keep working.
func NewPlanStepMacroVars ¶
func NewPlanStepMacroVars(plan *planstore.Plan, steps []*planstore.PlanStep, pending *planstore.PlanStep) PlanStepMacroVars
NewPlanStepMacroVars fills macro vars for the pending plan step (goal, full plan, next step, handover, etc.).
func (PlanStepMacroVars) TemplateVars ¶
func (v PlanStepMacroVars) TemplateVars() map[string]string
TemplateVars maps field names to MacroEnv keys expected by the seed prompt. Each summarizer-chain task that uses any of these macro keys must find them populated in ctx (MergeTemplateVars overlay), so we ALWAYS include every key — empty string when the prior step didn't populate it — to avoid "template var not set" errors on variants of the summarizer chain.
type ReplanScope ¶
ReplanScope selects what part of the plan to regenerate.
- OnlyOrdinal == 0: full replan of all remaining (pending) work — current Service.Replan semantics.
- OnlyOrdinal > 0: replace only that step with substeps. The targeted step is marked as skipped (audit-preserving) and the substeps are appended at the tail of the plan. The compile cache is invalidated.
Hint, when non-empty, is appended to the planner's user message so the model knows why we are replanning (e.g. "split into smaller steps; the previous attempt exceeded capacity").
type Service ¶
type Service interface {
// New generates a plan from goal using plannerChain, saves it as active.
New(ctx context.Context, goal string, plannerChain *taskengine.TaskChainDefinition) (*planstore.Plan, []*planstore.PlanStep, string, error)
// Replan replaces remaining pending steps using plannerChain.
Replan(ctx context.Context, plannerChain *taskengine.TaskChainDefinition) ([]*planstore.PlanStep, string, error)
// ReplanScoped is the generalized form of Replan: see [ReplanScope].
// Setting OnlyOrdinal>0 replaces only that step with substeps (the
// targeted step is marked skipped for audit; substeps are appended).
ReplanScoped(ctx context.Context, scope ReplanScope, plannerChain *taskengine.TaskChainDefinition) ([]*planstore.PlanStep, string, error)
// Next executes the next pending step using executorChain + summarizerChain.
// The summarizer runs graph-natively as the post-executor subgraph compiled
// by plancompile.Compile; it produces the typed JSON handover that the next
// step reads via {{var:previous_output}} / {{var:previous_handover}} / etc.
Next(ctx context.Context, args Args, executorChain, summarizerChain *taskengine.TaskChainDefinition) (string, string, error)
// Retry puts a failed/skipped step back to pending (ordinal is 1-based).
Retry(ctx context.Context, ordinal int) (string, error)
// Skip marks a step as intentionally bypassed (ordinal is 1-based).
Skip(ctx context.Context, ordinal int) (string, error)
// Active returns the current active plan and its steps.
Active(ctx context.Context) (*planstore.Plan, []*planstore.PlanStep, error)
// Show returns the active plan rendered as Markdown.
Show(ctx context.Context) (string, error)
// List returns all plans oldest-first.
List(ctx context.Context) ([]*planstore.Plan, error)
// SetActive makes the named plan active (archives the previous active one).
SetActive(ctx context.Context, planName string) error
// Delete permanently removes a plan by name.
Delete(ctx context.Context, planName string) error
// Clean removes all completed or archived plans; returns count removed.
Clean(ctx context.Context) (int, error)
// Explore runs explorerChain in read-only mode against the workspace and
// persists a typed [planstore.RepoContext] on the active plan (or on
// planID when non-empty). The returned RepoContext is also rendered into
// future step seed prompts via {{var:repo_context}}.
Explore(ctx context.Context, planID string, explorerChain *taskengine.TaskChainDefinition) (*planstore.RepoContext, error)
}
Service is the contract for managing plans.
func New ¶
func New(db libdb.DBManager, engine execservice.TasksEnvService, vfs vfsservice.Service, workspaceID string) Service
func WithActivityTracker ¶
func WithActivityTracker(svc Service, tracker libtracker.ActivityTracker) Service
WithActivityTracker wraps a Service with activity logging.