Help us shape the future of Go! Take the 2026 Go Developer Survey

intent

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package intent reads the proposals an agent writes and checks them against the closed catalogue (docs/spec/role-contract.md, "Intentions").

Index

Constants

This section is empty.

Variables

View Source
var Catalogue = map[string]bool{
	"commit-message": true,
	"patch":          true,
	"comment":        true,
	"label":          true,
	"issue":          true,
	"handoff":        true,
	"note":           true,
	"open":           true,
	"skip":           true,
	"milestone":      true,
	"order":          true,
	"effort":         true,
	"sources":        true,
	"close":          true,
	"keep":           true,
	"refine":         true,
	"ready":          true,
	"unready":        true,
	"ask":            true,
	"split":          true,
	"rename":         true,
	"depend":         true,
	"undepend":       true,
	"finding":        true,
	"claim":          true,
	"read":           true,
	"quote":          true,
}

Catalogue is every kind of intention the engine knows how to apply.

Functions

func Kinds

func Kinds(in []Intention) []string

Kinds lists the kinds of a set of intentions, in order.

func Marshal added in v0.9.0

func Marshal(in []Intention) ([]byte, error)

Marshal writes proposals as Read reads them: YAML, or JSON — which YAML reads too — when the YAML written would not read back: the YAML library writes a text starting with a tab as a block it then refuses ("found a tab character where an indentation space is expected"), and code quoted from a file often starts with one.

func NormalizeDiff

func NormalizeDiff(diff string) string

NormalizeDiff adds the `diff --git` line each file of a diff needs, when an agent left it out. git apply --recount relies on it to tell where a file ends: without it, a new file's `--- /dev/null` is read as a line removed from the file before. A file created or deleted also gets its mode line.

func PatchFiles

func PatchFiles(v any) []string

PatchFiles lists the files a patch names: its `file`, or the `+++` lines of its diff. It reads names only; whether the diff applies is checked later.

func Slug added in v0.28.0

func Slug(key string) string

Slug is the task a merge request's key names (out/merge-request.yaml), as the role's branch carries it, workline/<role>/<task>: lowercase letters, digits and dashes. A role tells by it whether a task of its own waits.

func SortForApply

func SortForApply(in []Intention)

SortForApply puts intentions in apply order, keeping the proposed order within a kind.

func Write

func Write(path string, in []Intention) error

Write saves proposals in the same shape Read expects. No proposals, no file.

Types

type Intention

type Intention struct {
	Kind  string
	Value any
}

Intention is one proposal: its kind and its value.

func Merge

func Merge(fallback, agent []Intention) []Intention

Merge returns the fallback proposals with the agent's in place of those of the same kind (docs/spec/role-contract.md, "One run"). A patch replaces only the fallback patches of the files it touches: the agent fixing one doc does not drop what the role regenerated in another. A fallback patch given as a diff replaces nothing and is never replaced: it holds only the lines it changes, and is applied after the agent's, beside them.

func Read

func Read(path string) ([]Intention, error)

Read loads out/intentions.yaml: a list of one-key maps, e.g. `- commit-message: "fix: ..."`. A missing file means no intentions.

Jump to

Keyboard shortcuts

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