ragindex

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

@index ragindex 패키지는 Wiki 트리와 문서 검색 결과에 사용하는 공용 DTO와 탐색 helper를 제공한다.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SearchTextForAnnotation added in v0.10.0

func SearchTextForAnnotation(annotation *model.Annotation) string

SearchTextForAnnotation assembles non-displayed text used by docs search and retrieval. @intent include annotation summary, context, tag kinds, names, types, and values without indexing source or generic node metadata.

Types

type AnnotationDetail added in v0.10.0

type AnnotationDetail struct {
	Summary string         `json:"summary"`
	Context string         `json:"context"`
	Tags    []DocTagDetail `json:"tags"`
}

AnnotationDetail preserves structured annotation data for Wiki symbol detail views. @intent serialize annotation summary, context, and tags in a UI-friendly shape.

type DocTagDetail added in v0.10.0

type DocTagDetail struct {
	Kind    model.TagKind `json:"kind"`
	Type    string        `json:"type"`
	Name    string        `json:"name"`
	Value   string        `json:"value"`
	Ordinal int           `json:"ordinal"`
	Ref     *ccgref.Ref   `json:"ref,omitempty"`
}

DocTagDetail describes one annotation tag in a JSON-safe index payload. @intent keep tag kind, type, name, and ordering available to browser renderers.

func DocTagDetailFromModel added in v0.10.0

func DocTagDetailFromModel(tag model.DocTag) DocTagDetail

DocTagDetailFromModel converts a stored annotation tag into an index-safe DTO. @intent attach parsed ccg:// metadata to @see tags without changing stored annotation rows.

type Index

type Index struct {
	Version int       `json:"version"`
	BuiltAt time.Time `json:"built_at"`
	Root    *TreeNode `json:"root"`
}

Index는 wiki-index.json 호환 snapshot의 전체 포맷이다. @intent 디스크에 저장되는 문서 인덱스 루트 페이로드를 정의한다.

func LoadIndex

func LoadIndex(path string) (*Index, error)

LoadIndex reads a persisted Index (e.g. wiki-index.json) from disk. @intent let the wiki index round-trip its written tree without the RAG-index builder.

type NodeDetails added in v0.10.0

type NodeDetails struct {
	QualifiedName string            `json:"qualified_name"`
	FilePath      string            `json:"file_path"`
	StartLine     int               `json:"start_line"`
	EndLine       int               `json:"end_line"`
	Language      string            `json:"language"`
	Annotation    *AnnotationDetail `json:"annotation,omitempty"`
}

NodeDetails carries browser-facing metadata for a graph node in the Wiki tree. @intent let presentation indexes expose symbol annotations without requiring a generated file doc.

type RetrieveResult

type RetrieveResult struct {
	ID            string         `json:"id"`
	Label         string         `json:"label"`
	Kind          string         `json:"kind"`
	Summary       string         `json:"summary"`
	DocPath       string         `json:"doc_path"`
	Path          []string       `json:"path"`
	Score         int            `json:"score"`
	MatchedTerms  []string       `json:"matched_terms"`
	MatchedFields []string       `json:"matched_fields"`
	Matches       []SearchResult `json:"matches,omitempty"`
	// contains filtered or unexported fields
}

RetrieveResult represents one document candidate selected from tree-aware query matching. @intent return file-level doc candidates with the matched tree evidence that caused the hit, including which annotation buckets contributed.

type SearchResult

type SearchResult struct {
	ID      string       `json:"id"`
	Label   string       `json:"label"`
	Kind    string       `json:"kind"`
	Summary string       `json:"summary"`
	DocPath string       `json:"doc_path,omitempty"`
	Details *NodeDetails `json:"details,omitempty"`
	Path    []string     `json:"path"` // root부터 해당 노드까지의 Label 경로
}

SearchResult는 Search 함수가 반환하는 단일 매칭 결과이다. @intent 검색 UI나 MCP 응답에서 표시할 최소 결과 정보를 담는다.

func Search(root *TreeNode, query string, maxResults int) []SearchResult

Search는 root 트리를 DFS로 순회하며 query를 label, summary, search_text에서 case-insensitive 검색하여 최대 maxResults개의 결과를 반환한다. root 노드 자체는 결과에 포함하지 않는다. @intent 문서 인덱스 트리에서 제목, 요약, 구조화 annotation 기반 키워드 탐색을 제공한다. @requires query가 비어 있지 않아야 의미 있는 결과가 나온다.

type TreeNode

type TreeNode struct {
	ID          string `json:"id"`
	Label       string `json:"label"`
	Kind        string `json:"kind"`
	Summary     string `json:"summary"`
	DocPath     string `json:"doc_path,omitempty"` // file 노드만 설정
	SearchText  string `json:"search_text,omitempty"`
	HasChildren bool   `json:"has_children,omitempty"`
	// @intent expose annotation-derived text bucketed by retrieval field so Retrieve scoring weights @intent/@domainRule/etc. independently of flat SearchText recall.
	FieldTexts map[string]string `json:"field_texts,omitempty"`
	Details    *NodeDetails      `json:"details,omitempty"`
	Children   []*TreeNode       `json:"children"`
}

TreeNode는 Wiki 탐색 트리의 단일 노드이다. @intent Wiki 탐색 트리에서 디렉터리, 패키지, 파일, 심볼을 동일 구조로 표현한다.

func FindNode

func FindNode(root *TreeNode, id string) *TreeNode

FindNode는 root 트리에서 id와 일치하는 TreeNode를 재귀적으로 찾아 반환한다. 없으면 nil을 반환한다. @intent 인덱스 트리에서 특정 노드를 ID로 직접 찾을 수 있게 한다.

Jump to

Keyboard shortcuts

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