chatwork

package
v0.16.397 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: AGPL-3.0 Imports: 18 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 chatwork keeps the work of the machine's chats: which git worktrees a chat changed or committed to, on which branch, from which commit, with which commits and merge request (hubproto.ChatWorkEntry). The runtime registers the work as the chat runs (Observer) or, for a chat older than the registry, from its transcript (Scan); the records are kept in one file under the runtime's data folder and handed to the hub over the replica socket.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoteProject

func RemoteProject(remote string) (host, project string)

RemoteProject is the host and project path of a remote: gitlab.example.com, group/project.

func Subtree

func Subtree(root string, chats []Chat) []string

Subtree are the chat and the chats delegated from it, at any depth, of the given list.

Types

type Chat

type Chat struct {
	ID         string
	Parent     string
	Cwd        string
	CreatedAt  int64 // epoch ms
	Transcript string
}

Chat is what the observer needs to know of a chat.

type Entry

type Entry = hubproto.ChatWorkEntry

Entry is one worktree of one chat.

type Observer

type Observer struct {
	Reg  *Registry
	Chat func(id string) (Chat, bool)
	Home string
	Now  func() time.Time
	// contains filtered or unexported fields
}

Observer registers the work of the chats as their feeds go: a file a tool wrote registers its worktree at once; a folder a shell command named, when the command changed git (a commit, a new worktree or branch, a push…); and when a turn ends every worktree of the chat is looked at again, together with the chat's own folder if the chat committed there. All of it runs on one goroutine off a bounded queue: the feed never waits for git.

func NewObserver

func NewObserver(reg *Registry, chat func(id string) (Chat, bool), home string) *Observer

NewObserver makes an observer; Run starts it.

func (*Observer) Frame

func (o *Observer) Frame(ch string, frame []byte)

Frame takes a frame of the runtime's hub (wire.Hub.Tap): the tool steps and the ends of turns of the chats. It is called under the hub's lock, so it only looks for the words of such a frame and queues it; the frame is read on the observer's goroutine.

func (*Observer) Run

func (o *Observer) Run(done <-chan struct{})

Run handles the queue until done closes.

func (*Observer) Scan

func (o *Observer) Scan(conv string, wait time.Duration) bool

Scan looks through a chat's transcript once (see scan.go) and waits until it is done or the time is out; false when it did not finish in time (it goes on in the background).

func (*Observer) Step

func (o *Observer) Step(conv, tool, summary string, finished bool, output string)

Step takes a tool call of a chat's feed: its tool, its summary, whether it finished and its output. It never waits.

func (*Observer) TurnEnded

func (o *Observer) TurnEnded(conv string)

TurnEnded looks again at every worktree of the chat when its turn is over.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry is the machine's records. Its methods are safe for concurrent use.

func Open

func Open(path string) *Registry

Open reads the registry kept at path ("" keeps nothing on disk). A file that does not read starts an empty registry.

func (*Registry) All

func (r *Registry) All() []Entry

All are every record, the newest look first.

func (*Registry) MarkScanned

func (r *Registry) MarkScanned(conv string)

MarkScanned remembers that a chat's transcript was looked through.

func (*Registry) Of

func (r *Registry) Of(convs ...string) []Entry

Of are the records of the given chats, the newest look first.

func (*Registry) Put

func (r *Registry) Put(e Entry) bool

Put records e (merged into the record of the same chat and worktree) and reports whether anything changed. The first touch, the base and the merge request are kept from the older record when e has none; a live record is not turned into a scanned one.

func (*Registry) Scanned

func (r *Registry) Scanned(conv string) bool

Scanned reports whether a chat's transcript was already looked through.

func (*Registry) Watch

func (r *Registry) Watch(fn func([]Entry)) (stop func())

Watch calls fn with every record that changes from now on, outside the registry's lock. stop ends it.

func (*Registry) WatchWork

func (r *Registry) WatchWork(fn func(frame []byte)) (stop func())

WatchWork calls fn with a replica frame of every record that changes from now on.

func (*Registry) WorkFrames

func (r *Registry) WorkFrames() [][]byte

WorkFrames are the replica socket's frames of every record ({"k":"work","entries":[…]}), at most hubproto.ChatWorkFrameMax records each.

Jump to

Keyboard shortcuts

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