knowledge

package
v2.11.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 11 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 knowledge implements docs/spec/workflow.md §8.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(p *project.Project, e Entry) error

Add appends an entry to the inbox.

func InboxCount

func InboxCount(p *project.Project) int

InboxCount returns the number of inbox entries.

func Normalize

func Normalize(s string) string

Normalize prepares text for duplicate detection: lowercase letters and digits only, except that punctuation between two letters or digits stays ("1.5s", "v2.4", "e-mail"), so findings that differ only in that punctuation are not merged ("1.5s" vs "15s").

func Pin

func Pin(p *project.Project, query string) (int, error)

Pin sets the pin flag on entries whose text contains query (case-insensitive), editing only those entry blocks.

Types

type CompactResult

type CompactResult struct {
	Moved      int            `json:"moved"`
	Duplicates int            `json:"duplicates"`
	Archived   int            `json:"archived"`
	Topics     map[string]int `json:"topics"`
}

CompactResult reports what compaction did.

func Compact

func Compact(p *project.Project, archiveAfterDays int, dryRun bool) (*CompactResult, error)

Compact files inbox entries by topic, drops exact (normalized) duplicates arriving in the inbox, and archives old unpinned entries (docs/spec/workflow.md §8). It edits entry blocks only: headings, comments, and prose in any file are kept byte for byte, and no entry text is deleted (a duplicate is only dropped when the same text already exists).

type Entry

type Entry struct {
	Text   string   `json:"text"`
	Date   string   `json:"date"`
	Topic  string   `json:"topic"`
	Task   string   `json:"task,omitempty"`
	Tags   []string `json:"tags,omitempty"`
	Pinned bool     `json:"pinned,omitempty"`
	Source string   `json:"source,omitempty"`
	File   string   `json:"file,omitempty"`
}

Entry is one knowledge bullet (schemas/knowledge-entry.schema.json).

func LoadAll

func LoadAll(p *project.Project) []Entry

LoadAll reads every knowledge file (topics and inbox; not the archive).

func Parse

func Parse(content, topic, file, fallbackDate string) []Entry

Parse extracts entries from one knowledge file.

func (Entry) Render

func (e Entry) Render() string

Render formats an entry as one Markdown bullet (continuation lines indented).

type Scored

type Scored struct {
	Entry
	Score float64 `json:"score"`
}

Scored is a search hit.

func Rank added in v2.1.1

func Rank(entries []Entry, query string, tags []string, limit int) []Scored

Rank orders every entry by relevance and then recency without dropping any, so the brief fills its slots with the most relevant entries first and the newest ones after.

func Search(entries []Entry, query string, tags []string, limit int) []Scored

Search ranks entries by term overlap, pin, tag/topic match, and recency, dropping entries that match nothing (for explicit searches).

Jump to

Keyboard shortcuts

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