Documentation
¶
Overview ¶
Package documents indexes managed local markdown roots for model-facing rediscovery, browse, search, and section retrieval.
The operator-facing contract for what counts as a managed document root lives in docs/understanding/document-roots.md. Keep that document in sync with behavioral changes here, especially when changing how config paths become indexed corpora or how the documents capability is meant to differ from raw file access.
Index ¶
- type Backlink
- type BrowseArgs
- type BrowseDirectory
- type BrowseResult
- type CopyArgs
- type CopyResult
- type DeleteArgs
- type DeleteResult
- type DocumentLink
- type DocumentRecord
- type DocumentSummary
- type EditArgs
- type JournalUpdateArgs
- type LinksArgs
- type LinksResult
- type MoveArgs
- type MoveResult
- type MutationResult
- type RefArgs
- type RootDocumentHint
- type RootSummary
- type SearchArgs
- type SearchQuery
- type Section
- type SectionArgs
- type SectionTransferArgs
- type SectionTransferResult
- type Store
- func (s *Store) Browse(ctx context.Context, root, prefix string, limit int) (*BrowseResult, error)
- func (s *Store) Copy(ctx context.Context, args CopyArgs) (*CopyResult, error)
- func (s *Store) CopySection(ctx context.Context, args SectionTransferArgs) (*SectionTransferResult, error)
- func (s *Store) Delete(ctx context.Context, args DeleteArgs) (*DeleteResult, error)
- func (s *Store) Edit(ctx context.Context, args EditArgs) (*MutationResult, error)
- func (s *Store) JournalUpdate(ctx context.Context, args JournalUpdateArgs) (*MutationResult, error)
- func (s *Store) Links(ctx context.Context, ref string, mode string, limit int, perBacklinkLimit int) (*LinksResult, error)
- func (s *Store) Move(ctx context.Context, args MoveArgs) (*MoveResult, error)
- func (s *Store) MoveSection(ctx context.Context, args SectionTransferArgs) (*SectionTransferResult, error)
- func (s *Store) Outline(ctx context.Context, ref string) ([]Section, error)
- func (s *Store) Read(ctx context.Context, ref string) (*DocumentRecord, error)
- func (s *Store) Refresh(ctx context.Context) error
- func (s *Store) Roots(ctx context.Context) ([]RootSummary, error)
- func (s *Store) RunRefresher(ctx context.Context)
- func (s *Store) Search(ctx context.Context, q SearchQuery) ([]DocumentSummary, error)
- func (s *Store) Section(ctx context.Context, ref string, selector string) (*Section, error)
- func (s *Store) Values(ctx context.Context, root, key string, limit int) ([]ValueCount, error)
- func (s *Store) Write(ctx context.Context, args WriteArgs) (*MutationResult, error)
- type Tools
- func (t *Tools) Browse(ctx context.Context, args BrowseArgs) (string, error)
- func (t *Tools) Copy(ctx context.Context, args CopyArgs) (string, error)
- func (t *Tools) CopySection(ctx context.Context, args SectionTransferArgs) (string, error)
- func (t *Tools) Delete(ctx context.Context, args DeleteArgs) (string, error)
- func (t *Tools) Edit(ctx context.Context, args EditArgs) (string, error)
- func (t *Tools) JournalUpdate(ctx context.Context, args JournalUpdateArgs) (string, error)
- func (t *Tools) Links(ctx context.Context, args LinksArgs) (string, error)
- func (t *Tools) Move(ctx context.Context, args MoveArgs) (string, error)
- func (t *Tools) MoveSection(ctx context.Context, args SectionTransferArgs) (string, error)
- func (t *Tools) Outline(ctx context.Context, args RefArgs) (string, error)
- func (t *Tools) Read(ctx context.Context, args RefArgs) (string, error)
- func (t *Tools) Roots(ctx context.Context) (string, error)
- func (t *Tools) Search(ctx context.Context, args SearchArgs) (string, error)
- func (t *Tools) Section(ctx context.Context, args SectionArgs) (string, error)
- func (t *Tools) Values(ctx context.Context, args ValuesArgs) (string, error)
- func (t *Tools) Write(ctx context.Context, args WriteArgs) (string, error)
- type ValueCount
- type ValuesArgs
- type WriteArgs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backlink ¶
type Backlink struct {
Ref string `json:"ref"`
Path string `json:"path"`
Title string `json:"title"`
ModifiedAt string `json:"modified_at"`
Targets []string `json:"targets,omitempty"`
TargetsTruncated bool `json:"targets_truncated,omitempty"`
}
Backlink is one indexed document that links to another document.
type BrowseArgs ¶
type BrowseArgs struct {
Root string `json:"root"`
PathPrefix string `json:"path_prefix,omitempty"`
Limit int `json:"limit,omitempty"`
}
BrowseArgs requests one rooted browse step through an indexed corpus.
type BrowseDirectory ¶
type BrowseDirectory struct {
Name string `json:"name"`
PathPrefix string `json:"path_prefix"`
DocumentCount int `json:"document_count"`
}
BrowseDirectory describes one child directory in a rooted browse view.
type BrowseResult ¶
type BrowseResult struct {
Root string `json:"root"`
PathPrefix string `json:"path_prefix,omitempty"`
Directories []BrowseDirectory `json:"directories,omitempty"`
Documents []DocumentSummary `json:"documents,omitempty"`
}
BrowseResult is the rooted "phone tree" view for one root/prefix.
type CopyArgs ¶
type CopyArgs struct {
Ref string `json:"ref"`
DestinationRef string `json:"destination_ref"`
Overwrite bool `json:"overwrite,omitempty"`
}
CopyArgs duplicates one managed document at a new semantic ref.
type CopyResult ¶
type CopyResult struct {
Action string `json:"action"`
FromRef string `json:"from_ref"`
ToRef string `json:"to_ref"`
FromRoot string `json:"from_root"`
FromPath string `json:"from_path"`
ToRoot string `json:"to_root"`
ToPath string `json:"to_path"`
Overwrote bool `json:"overwrote,omitempty"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
ModifiedAt string `json:"modified_at"`
WordCount int `json:"word_count"`
SizeBytes int64 `json:"size_bytes"`
}
CopyResult summarizes one managed document copy.
type DeleteArgs ¶
type DeleteArgs struct {
Ref string `json:"ref"`
}
DeleteArgs removes one managed document by semantic ref.
type DeleteResult ¶
type DeleteResult struct {
Action string `json:"action"`
DeletedRef string `json:"deleted_ref"`
Root string `json:"root"`
Path string `json:"path"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
ModifiedAt string `json:"modified_at"`
WordCount int `json:"word_count"`
SizeBytes int64 `json:"size_bytes"`
}
DeleteResult summarizes one managed document deletion.
type DocumentLink ¶
type DocumentLink struct {
Target string `json:"target"`
Kind string `json:"kind"`
Ref string `json:"ref,omitempty"`
Title string `json:"title,omitempty"`
URL string `json:"url,omitempty"`
Anchor string `json:"anchor,omitempty"`
}
DocumentLink is one outgoing link projected from an indexed document.
type DocumentRecord ¶
type DocumentRecord struct {
Root string `json:"root"`
Ref string `json:"ref"`
Path string `json:"path"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
Frontmatter map[string][]string `json:"frontmatter,omitempty"`
Body string `json:"body"`
Outline []Section `json:"outline,omitempty"`
ModifiedAt string `json:"modified_at"`
WordCount int `json:"word_count"`
SizeBytes int64 `json:"size_bytes"`
}
DocumentRecord is the full model-facing view of one managed document.
type DocumentSummary ¶
type DocumentSummary struct {
Root string `json:"root"`
Ref string `json:"ref"`
Path string `json:"path"`
Title string `json:"title"`
Summary string `json:"summary,omitempty"`
Tags []string `json:"tags,omitempty"`
Frontmatter map[string][]string `json:"frontmatter,omitempty"`
ModifiedAt string `json:"modified_at"`
WordCount int `json:"word_count"`
}
DocumentSummary is the compact search/browse view of a document.
type EditArgs ¶
type EditArgs struct {
Ref string `json:"ref"`
Mode string `json:"mode"`
Content string `json:"content,omitempty"`
Section string `json:"section,omitempty"`
Heading string `json:"heading,omitempty"`
Level int `json:"level,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
Frontmatter map[string][]string `json:"frontmatter,omitempty"`
}
EditArgs updates part of a managed document without leaving the semantic document abstraction.
type JournalUpdateArgs ¶
type JournalUpdateArgs struct {
Ref string `json:"ref"`
Entry string `json:"entry"`
Window string `json:"window,omitempty"`
MaxWindows int `json:"max_windows,omitempty"`
HeadingLevel int `json:"heading_level,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
Frontmatter map[string][]string `json:"frontmatter,omitempty"`
}
JournalUpdateArgs appends a timestamped note into a rolling window journal document while keeping window headings and timestamps stable.
type LinksArgs ¶
type LinksArgs struct {
Ref string `json:"ref"`
Mode string `json:"mode,omitempty"`
Limit int `json:"limit,omitempty"`
PerBacklinkLimit int `json:"per_backlink_limit,omitempty"`
}
LinksArgs requests outgoing links, backlinks, or both for one document.
type LinksResult ¶
type LinksResult struct {
Ref string `json:"ref"`
Mode string `json:"mode"`
Limit int `json:"limit,omitempty"`
PerBacklinkLimit int `json:"per_backlink_limit,omitempty"`
Outgoing []DocumentLink `json:"outgoing,omitempty"`
OutgoingTruncated bool `json:"outgoing_truncated,omitempty"`
Backlinks []Backlink `json:"backlinks,omitempty"`
BacklinksTruncated bool `json:"backlinks_truncated,omitempty"`
}
LinksResult is the outgoing/backlink view for one indexed document.
type MoveArgs ¶
type MoveArgs struct {
Ref string `json:"ref"`
DestinationRef string `json:"destination_ref"`
Overwrite bool `json:"overwrite,omitempty"`
}
MoveArgs relocates one managed document to a new semantic ref.
type MoveResult ¶
type MoveResult struct {
Action string `json:"action"`
FromRef string `json:"from_ref"`
ToRef string `json:"to_ref"`
FromRoot string `json:"from_root"`
FromPath string `json:"from_path"`
ToRoot string `json:"to_root"`
ToPath string `json:"to_path"`
Overwrote bool `json:"overwrote,omitempty"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
ModifiedAt string `json:"modified_at"`
WordCount int `json:"word_count"`
SizeBytes int64 `json:"size_bytes"`
}
MoveResult summarizes one managed document move/rename.
type MutationResult ¶
type MutationResult struct {
Action string `json:"action"`
Ref string `json:"ref"`
Root string `json:"root"`
Path string `json:"path"`
Existed bool `json:"existed"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
ModifiedAt string `json:"modified_at"`
WordCount int `json:"word_count"`
SizeBytes int64 `json:"size_bytes"`
Section string `json:"section,omitempty"`
Window string `json:"window,omitempty"`
}
MutationResult summarizes one managed document write/edit.
type RefArgs ¶
type RefArgs struct {
Ref string `json:"ref"`
}
RefArgs identifies one managed document by canonical semantic ref.
type RootDocumentHint ¶
type RootDocumentHint struct {
Ref string `json:"ref"`
Path string `json:"path"`
Title string `json:"title"`
ModifiedAt string `json:"modified_at"`
}
RootDocumentHint is a compact example document attached to a root summary.
type RootSummary ¶
type RootSummary struct {
Root string `json:"root"`
Path string `json:"-"`
DocumentCount int `json:"document_count"`
TotalSizeBytes int64 `json:"total_size_bytes"`
TotalWordCount int `json:"total_word_count"`
LastModifiedAt string `json:"last_modified_at,omitempty"`
TopTags []string `json:"top_tags,omitempty"`
TopDirectories []BrowseDirectory `json:"top_directories,omitempty"`
RecentDocuments []RootDocumentHint `json:"recent_documents,omitempty"`
}
RootSummary describes one indexed document root.
type SearchArgs ¶
type SearchArgs struct {
Root string `json:"root,omitempty"`
PathPrefix string `json:"path_prefix,omitempty"`
Query string `json:"query,omitempty"`
Tags []string `json:"tags,omitempty"`
Frontmatter map[string][]string `json:"frontmatter,omitempty"`
FrontmatterKeys []string `json:"frontmatter_keys,omitempty"`
ModifiedAfter string `json:"modified_after,omitempty"`
ModifiedBefore string `json:"modified_before,omitempty"`
Limit int `json:"limit,omitempty"`
}
SearchArgs requests structured document search over indexed roots.
type SearchQuery ¶
type SearchQuery struct {
Root string `json:"root,omitempty"`
PathPrefix string `json:"path_prefix,omitempty"`
Query string `json:"query,omitempty"`
Tags []string `json:"tags,omitempty"`
Frontmatter map[string][]string `json:"frontmatter,omitempty"`
FrontmatterKeys []string `json:"frontmatter_keys,omitempty"`
ModifiedAfter *time.Time `json:"-"`
ModifiedBefore *time.Time `json:"-"`
Limit int `json:"limit,omitempty"`
}
SearchQuery filters document search results.
type Section ¶
type Section struct {
Heading string `json:"heading"`
Slug string `json:"slug"`
Level int `json:"level"`
StartLine int `json:"start_line"`
EndLine int `json:"end_line"`
Content string `json:"content,omitempty"`
}
Section captures one heading-defined region in a markdown document.
type SectionArgs ¶
SectionArgs selects one document section by ref and optional heading.
type SectionTransferArgs ¶
type SectionTransferArgs struct {
Ref string `json:"ref"`
Section string `json:"section"`
DestinationRef string `json:"destination_ref"`
DestinationSection string `json:"destination_section,omitempty"`
DestinationLevel int `json:"destination_level,omitempty"`
}
SectionTransferArgs copies or moves one section into another managed doc.
type SectionTransferResult ¶
type SectionTransferResult struct {
Action string `json:"action"`
SourceRef string `json:"source_ref"`
SourceRoot string `json:"source_root"`
SourcePath string `json:"source_path"`
SourceSection string `json:"source_section"`
DestinationRef string `json:"destination_ref"`
DestinationRoot string `json:"destination_root"`
DestinationPath string `json:"destination_path"`
DestinationSection string `json:"destination_section"`
DestinationLevel int `json:"destination_level"`
DestinationExisted bool `json:"destination_existed"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
ModifiedAt string `json:"modified_at"`
WordCount int `json:"word_count"`
SizeBytes int64 `json:"size_bytes"`
}
SectionTransferResult summarizes one section-level copy or move.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store indexes managed markdown roots into the primary Thane SQLite DB.
func (*Store) Browse ¶
Browse returns the immediate child directories and documents for a rooted prefix.
func (*Store) CopySection ¶
func (s *Store) CopySection(ctx context.Context, args SectionTransferArgs) (*SectionTransferResult, error)
func (*Store) Delete ¶
func (s *Store) Delete(ctx context.Context, args DeleteArgs) (*DeleteResult, error)
func (*Store) JournalUpdate ¶
func (s *Store) JournalUpdate(ctx context.Context, args JournalUpdateArgs) (*MutationResult, error)
func (*Store) Links ¶
func (s *Store) Links(ctx context.Context, ref string, mode string, limit int, perBacklinkLimit int) (*LinksResult, error)
Links returns outgoing links, backlinks, or both for one indexed document.
func (*Store) MoveSection ¶
func (s *Store) MoveSection(ctx context.Context, args SectionTransferArgs) (*SectionTransferResult, error)
func (*Store) Roots ¶
func (s *Store) Roots(ctx context.Context) ([]RootSummary, error)
Roots returns the current indexed root summaries.
func (*Store) RunRefresher ¶
RunRefresher keeps the index warm in the background using the store's refresh interval. Errors are logged and retried on the next tick.
func (*Store) Search ¶
func (s *Store) Search(ctx context.Context, q SearchQuery) ([]DocumentSummary, error)
Search returns matching documents, sorted by relevance and recency.
func (*Store) Section ¶
Section returns one section by heading text or slug. An empty selector returns the whole document.
type Tools ¶
type Tools struct {
// contains filtered or unexported fields
}
Tools exposes model-facing document navigation tools.
func (*Tools) CopySection ¶
CopySection copies one section into another managed document.
func (*Tools) JournalUpdate ¶
JournalUpdate appends one journal-window entry to a managed document.
func (*Tools) MoveSection ¶
MoveSection moves one section into another managed document.
func (*Tools) Search ¶
Search returns compact summaries for documents matching the structured filters.
func (*Tools) Section ¶
Section returns one named section, or the whole body when no selector is given.
type ValueCount ¶
ValueCount counts observed frontmatter values.
type ValuesArgs ¶
type ValuesArgs struct {
Root string `json:"root,omitempty"`
Key string `json:"key"`
Limit int `json:"limit,omitempty"`
}
ValuesArgs requests observed values for one frontmatter key.
type WriteArgs ¶
type WriteArgs struct {
Ref string `json:"ref"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
Frontmatter map[string][]string `json:"frontmatter,omitempty"`
Body *string `json:"body,omitempty"`
JournalEntry string `json:"journal_entry,omitempty"`
}
WriteArgs creates or replaces a whole managed document.