ctxedit

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package ctxedit builds, annotates, persists, and loads context overrides for PM tasks. It gives power users surgical control over what context is sent to the AI before a task runs.

Index

Constants

View Source
const OverrideDir = ".cloop"

OverrideDir is the subdirectory under workDir where override files are stored.

Variables

This section is empty.

Functions

func Build

func Build(plan *pm.Plan, task *pm.Task, workDir string, injectCtx bool, pruneTokenBudget int) string

Build constructs the exact prompt string the orchestrator would send for task, mirroring the logic in pkg/pm.ExecuteTaskPrompt. workDir is used to load adaptive prompt hints; pass "" to skip. pruneTokenBudget mirrors the orchestrator's context-pruning budget (0 = no pruning).

func ClearAllOverrides

func ClearAllOverrides(workDir string) (int, error)

ClearAllOverrides removes all context_override_*.txt files in workDir/.cloop/.

func ClearOverride

func ClearOverride(workDir string, taskID int) error

ClearOverride removes the context override for taskID. Returns nil if the file does not exist.

func LoadOverride

func LoadOverride(workDir string, taskID int) (string, error)

LoadOverride reads the context override file for taskID from workDir. Returns ("", nil) if no override exists.

Capped at maxOverrideBytes so a corrupt or runaway override file cannot OOM the process or balloon the next AI prompt.

func OverridePath

func OverridePath(workDir string, taskID int) string

OverridePath returns the absolute path for the context override file of a given task.

func SaveOverride

func SaveOverride(workDir string, taskID int, content string) error

SaveOverride writes content as the context override for taskID.

Types

type Section

type Section struct {
	Header  string // e.g. "## PROJECT GOAL"
	Content string // text under the header (excluding next header)
	Tokens  int    // estimated token count for this section
}

Section represents a named section of the prompt with its content.

func Annotate

func Annotate(prompt string) (annotated string, sections []Section)

Annotate splits prompt into sections by "## " headers and annotates each with an estimated token count. Returns the annotated string and section metadata.

Jump to

Keyboard shortcuts

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