wiki

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

@index Built-in CCG Wiki eager/lazy tree construction and compatibility snapshot policy.

@index Built-in CCG Wiki tree, detail, search, and compatibility-index models.

@index Consumer-owned graph and compatibility-index ports for the built-in CCG Wiki.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SearchTextForAnnotation

func SearchTextForAnnotation(annotation *graph.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

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 Builder

type Builder struct {
	Repository  Repository
	IndexWriter IndexWriter
	OutDir      string
	Namespace   string
	ProjectDesc string
	Exclude     []string
}

Builder writes the wiki-index.json compatibility snapshot for ccg-server's browser UI. @intent derive a package/file/symbol presentation tree directly from graph nodes.

func (*Builder) Build

func (b *Builder) Build(ctx context.Context) (int, int, error)

Build creates the wiki-index.json compatibility snapshot and returns package and file counts. @intent generate a UI-oriented tree independent of community detection and PageIndex retrieval. @sideEffect reads graph tables and writes wiki-index.json.

func (*Builder) BuildSubtree

func (b *Builder) BuildSubtree(ctx context.Context, nodeID string, depth int) (*TreeNode, error)

BuildSubtree creates one Wiki tree node plus a bounded set of descendants directly from DB rows. @intent support GitHub-style lazy Wiki navigation without synthesizing the full tree for every folder expansion. @ensures depth > 0 limits descendants relative to the selected node; depth <= 0 preserves full-tree compatibility.

func (*Builder) BuildTree

func (b *Builder) BuildTree(ctx context.Context) (*TreeNode, int, int, error)

BuildTree creates the browser-facing package/file/symbol Wiki tree without writing wiki-index.json. @intent let runtime callers synthesize the same Wiki tree directly from DB rows when the JSON index has not been generated. @ensures successful calls return deterministic folder/package/file/symbol ordering matching Build output.

type DocTagDetail

type DocTagDetail struct {
	Kind    graph.TagKind  `json:"kind"`
	Type    string         `json:"type"`
	Name    string         `json:"name"`
	Value   string         `json:"value"`
	Ordinal int            `json:"ordinal"`
	Ref     *reference.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

func DocTagDetailFromModel(tag graph.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 GraphView

type GraphView struct {
	TotalNodes int64
	Nodes      []graph.Node
	Edges      []graph.Edge
}

GraphView is one bounded, deterministic graph projection for the Wiki viewer. @intent carry viewer graph facts without exposing database queries to HTTP handlers.

type GraphViewError

type GraphViewError struct {
	Stage GraphViewStage
	Err   error
}

GraphViewError carries a graph-view stage while preserving the underlying error text. @intent let inbound adapters retain stable stage-specific responses across persistence implementations.

func (*GraphViewError) Error

func (e *GraphViewError) Error() string

Error preserves the underlying persistence error detail. @intent satisfy error without leaking the application stage into the existing HTTP detail field.

func (*GraphViewError) Unwrap

func (e *GraphViewError) Unwrap() error

Unwrap exposes the underlying cause for cancellation and driver error classification. @intent preserve errors.Is and errors.As behavior through graph-view stage classification.

type GraphViewStage

type GraphViewStage string

GraphViewStage identifies the persistence stage that failed while building a viewer graph. @intent preserve stage-specific inbound error mapping without exposing database operations.

const (
	GraphViewStageCountNodes GraphViewStage = "count_nodes"
	GraphViewStageListNodes  GraphViewStage = "list_nodes"
	GraphViewStageListEdges  GraphViewStage = "list_edges"
)

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 디스크에 저장되는 문서 인덱스 루트 페이로드를 정의한다.

type IndexWriter

type IndexWriter interface {
	WriteWikiIndex(ctx context.Context, namespace string, index *Index) error
}

IndexWriter atomically persists the versioned Wiki compatibility snapshot. @intent let Wiki build policy choose namespace and payload without owning filesystem implementation.

type NodeDetails

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 Repository

type Repository interface {
	Namespaces(ctx context.Context) ([]string, error)
	NavigationNodes(ctx context.Context, kinds []graph.NodeKind) ([]graph.Node, error)
	PathNodes(ctx context.Context, folderPath string, kinds []graph.NodeKind) ([]graph.Node, error)
	StoredNode(ctx context.Context, kind graph.NodeKind, filePath string) (*graph.Node, error)
	SymbolNode(ctx context.Context, qualifiedName string, kinds []graph.NodeKind) (*graph.Node, error)
	FileSymbols(ctx context.Context, filePath string, kinds []graph.NodeKind) ([]graph.Node, error)
	Annotations(ctx context.Context, nodeIDs []uint) (map[uint]*graph.Annotation, error)
	HasSymbol(ctx context.Context, filePath string, kinds []graph.NodeKind) (bool, error)
	GraphView(ctx context.Context, limit int, edgeKinds []graph.EdgeKind) (GraphView, error)
	ResolveReference(ctx context.Context, ref *reference.Ref) (*graph.Node, error)
}

Repository supplies deterministic namespace-scoped graph facts for eager and lazy Wiki trees. @intent keep Wiki hierarchy and presentation policy independent of GORM query construction.

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