gaps

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 12 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 gaps records the questions kb_ask could not answer confidently, so people can see what agents needed that the vault does not say yet.

The log is per machine and lives outside the vault (the user cache directory by default), so it is never committed: questions can carry details of the work an agent was doing. Every okvault process serving the same vault on this machine appends to the same file.

Index

Constants

View Source
const MaxQuestion = 500

MaxQuestion caps a recorded question, in runes.

View Source
const SameQuestion = 0.6

SameQuestion is the similarity from which two phrasings form one group: kb_ask's own FAQ threshold.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath(vaultRoot string) (string, error)

DefaultPath is the per-machine log for a vault: the user cache directory, keyed by the vault's absolute path.

Types

type Entry

type Entry struct {
	At       time.Time `json:"at"`
	Question string    `json:"q,omitempty"`
	Client   string    `json:"client,omitempty"`  // MCP client name, e.g. claude-code
	Dismiss  string    `json:"dismiss,omitempty"` // a person hid this group (its ID)
}

Entry is one line of the log: a question an agent asked, or a dismissal.

type Group

type Group struct {
	ID        string    // stable: derived from the earliest phrasing
	Phrasings []string  // distinct phrasings, most asked first
	Counts    []int     // how often each phrasing was asked
	Asked     int       // total
	First     time.Time // first asked
	Last      time.Time // last asked
	Clients   []string  // who asked (MCP client names)
}

Group is a set of questions asking the same thing in different words.

func GroupQuestions

func GroupQuestions(entries []Entry, sim Similar, norm Normalize) []*Group

GroupQuestions groups entries (oldest first) whose phrasings are at least SameQuestion alike, in order of first appearance.

type Log

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

Log is an append-only JSON Lines file.

func Open

func Open(path string) *Log

Open returns the log at path (created on the first write).

func (*Log) Dismiss

func (l *Log) Dismiss(id string, at time.Time) error

Dismiss hides a group from now on.

func (*Log) Path

func (l *Log) Path() string

Path is where the log is written.

func (*Log) Read

func (l *Log) Read() ([]Entry, map[string]bool, error)

Read returns the recorded questions (oldest first) and the dismissed group IDs. A missing log is empty; unreadable lines are skipped.

func (*Log) Record

func (l *Log) Record(question, client string, at time.Time) error

Record appends a question.

type Normalize

type Normalize func(string) string

Similar reports how alike two questions are (0..1); Normalize gives a question's canonical form. search.Similarity and search.Normalize in practice.

type Similar

type Similar func(a, b string) float64

Similar reports how alike two questions are (0..1); Normalize gives a question's canonical form. search.Similarity and search.Normalize in practice.

Jump to

Keyboard shortcuts

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