taskctx

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package taskctx stores a working note per git branch so an agent can resume a task after a new chat or a branch switch.

Notes live in <git-common-dir>/kartograf/context/. Checkout does not touch that directory, and the files sit outside the working tree, so they stay put across branch switches and are not committed. The code index database is a rebuildable cache and is not used here.

Index

Constants

View Source
const MaxBody = 4 << 10

MaxBody is the maximum stored note size in bytes. A note is a handoff for a later chat (what was done, why, what is left), written once when work pauses. 4 KiB is enough for that in Russian, where each letter is two bytes, and small enough to inject once per session.

Variables

This section is empty.

Functions

func ChangedFiles added in v0.1.15

func ChangedFiles(root, branch string) (base string, files []string, err error)

ChangedFiles lists files this branch changed relative to the repository's default branch (origin/HEAD, else main, else master). An empty branch means the checkout at root. The returned paths are relative to root.

func CurrentBranch

func CurrentBranch(root string) (string, error)

CurrentBranch reports the branch checked out at root. A detached HEAD is reported as HEAD@<12-char sha> so unrelated detached states do not share one note.

func HandoffNudge added in v0.1.16

func HandoffNudge(root, sessionID string, stopHookActive bool) string

HandoffNudge is the Stop-hook reminder. It is empty when the note already covers the branch, when this session was already reminded for the branch, or when stopHookActive says this turn is itself the reminder. One reminder per session and branch, so it cannot loop.

func HookText

func HookText(root, sessionID string) string

HookText is the prompt-hook block for the current branch. sessionID scopes the injection to one chat: the handoff is shown on the first prompt of that session and not again, because a repeated block would stay in the transcript and be paid for on every later turn. Checking out a different branch shows that branch's handoff once. An empty sessionID injects nothing. Other branches' handoffs are listed by name so follow-up work on a new branch can find last week's note. The result is empty when there is nothing saved or git is unavailable — a hook must stay silent rather than fail the prompt.

func Repo added in v0.1.15

func Repo(root, rel string) (string, error)

Repo resolves a root-relative repository directory returned by FindTask. An empty rel is the serve root. The result must be a git checkout inside root.

func StaleFiles added in v0.1.15

func StaleFiles(root string, note Note) []string

StaleFiles returns paths named in the note whose latest commit is newer than the note. A later chat can see that the handoff is talking about code that has since moved.

Types

type Note

type Note struct {
	Branch    string
	UpdatedAt time.Time
	Body      string
}

Note is the full working note for one branch.

func Get

func Get(root, branch string) (Note, error)

Get returns the note for branch. An empty branch means the branch checked out at root. A missing note is an empty body and a nil error.

func Put

func Put(root, branch, body string) (Note, error)

Put replaces the note for branch. An empty branch means the branch checked out at root. A blank body deletes the note. The previous text is not merged: callers pass the full note they want kept.

type Summary

type Summary struct {
	Branch    string
	UpdatedAt time.Time
	Preview   string
}

Summary is one row of a branch listing.

func List

func List(root string) ([]Summary, error)

List returns notes stored for this repository, newest first.

type TaskMatch added in v0.1.15

type TaskMatch struct {
	Repo    string // root-relative repository directory; empty at the serve root
	Branch  string
	HasNote bool
	Preview string
}

TaskMatch is one branch whose name matches a task id.

func FindTask added in v0.1.15

func FindTask(root, id string) ([]TaskMatch, error)

FindTask searches git repositories under root for branches that match id. Each repository uses its own .kartograf.yml task.branch template when set; otherwise a branch matches when its name contains the id.

Jump to

Keyboard shortcuts

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