attachments

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package attachments computes per-turn <system-reminder>-wrapped messages the agent loop prepends to the user's incoming prompts.

Today the only attachment the package produces is the plan-mode reminder family (full / sparse / exit / re-entry). The package is scoped to that responsibility on purpose — every "this state should be re-injected on every user prompt" feature in the future (e.g. a transcript-classifier reminder, an auto-mode reminder, an MCP-server status reminder) can sit alongside as a sibling computer and the state_machine wiring stays one call.

Ports the design of ref/src/utils/attachments.ts:getPlanModeAttachments and ref/src/utils/messages.ts:getPlanModeInstructions, adapted to evva's per-agent PlanModeState (internal/permission). The throttle and reminder-cycle defaults match ref: TURNS_BETWEEN_ATTACHMENTS=4, FULL_REMINDER_EVERY_N=5.

Index

Constants

View Source
const (
	// TurnsBetweenAttachments is the throttle window. After the first
	// reminder fires, the next reminder waits until at least this many
	// user-prompt turns have elapsed without one. Keeps the per-turn
	// token cost bounded on long plan-mode sessions.
	TurnsBetweenAttachments = 4

	// FullReminderEveryN is the cycle window. Reminder #1, #1+N, #1+2N…
	// are FULL; every other reminder is the sparse one-liner. The first
	// turn in plan mode is always FULL by construction (state's
	// attachmentsSinceExit==0 on entry).
	FullReminderEveryN = 5
)

Tunables. Default values mirror ref's PLAN_MODE_ATTACHMENT_CONFIG.

Variables

This section is empty.

Functions

func ComputePlanMode

func ComputePlanMode(in Input) []string

ComputePlanMode returns the <system-reminder>-wrapped reminder texts to prepend to the next user prompt. May return nil. Mutates Input.State to record what was emitted, and to advance throttle / one-shot counters.

Order (when multiple fire on the same turn):

  1. Exit reminder (if a pending exit reminder is queued from a plan→non-plan transition).
  2. Re-entry reminder (if HasExited was true and we're back in plan mode; one-shot).
  3. Plan-mode workflow reminder (FULL or sparse, subject to the throttle).

Each returned string is already wrapped in <system-reminder> tags; callers append them as individual RoleUser messages to the session.

Types

type Input

type Input struct {
	State           *permission.PlanModeState
	Mode            permission.Mode
	PlanFilePath    string
	PlanExists      bool
	WorkflowVariant Workflow
}

Input is the snapshot ComputePlanMode reads on each user-prompt turn. State holds the cycle / throttle counters and the one-shot flags (pending-exit, has-exited). Mode + PlanFilePath + PlanExists feed the reminder text. WorkflowVariant chooses between interview / v2 prompt bodies; empty defaults to interview.

type Workflow

type Workflow string

Workflow chooses which plan-mode workflow the reminders describe. "interview" — the iterative pair-planning workflow: explore code, update the plan file as understanding grows, ask the user when you hit ambiguity, repeat. Fewer moving parts, default for evva. "v2" — the 5-phase workflow from ref Claude Code: Explore subagents in parallel, Plan subagents for design, then Review, Final Plan, ExitPlanMode. Better for very large refactors with multiple valid approaches. Opt-in via config.PlanModeWorkflow.

const (
	WorkflowInterview Workflow = "interview"
	WorkflowV2        Workflow = "v2"
)

Jump to

Keyboard shortcuts

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