parser

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package parser bridges Grove's storage-aware projection to the shared astkit tree-sitter extraction layer. The actual per-language extraction logic lives in astkit/strategies; this file only:

  1. Maps Grove's language strings (e.g. "javascript") → astkit.LanguageKey.
  2. Drives the shared parser/registry.
  3. Projects each astkit.Symbol → core.SymbolRecord, attaching Grove-only fields (ID, FilePath, BlobSHA, Language, Imports, TokenEstimate) and renaming Body→RawText, Exported→Exports, ParentName→ParentSymbol.

Index

Constants

View Source
const (
	// PlaintextFTSLimit is the maximum bytes stored in the docstring column,
	// which is FTS5-indexed. 64 KB covers nearly all real-world docs and
	// configs while preventing unbounded FTS5 table growth.
	PlaintextFTSLimit = 64 * 1024

	// PlaintextRawLimit is the maximum bytes stored in raw_text.
	// Prism uses raw_text for progressive disclosure; 1 MB is sufficient
	// for the largest policy/swagger/OpenAPI files teams encounter in practice.
	PlaintextRawLimit = 1024 * 1024
)
View Source
const MaxFileSizeBytes int64 = 10 * 1024 * 1024
View Source
const PlaintextLanguage = "plaintext"

PlaintextLanguage is the language tag assigned to non-code documents (markdown, YAML, JSON, XML, shell scripts, etc.) that Grove indexes as whole-file FTS5 records rather than extracted symbol trees.

Variables

This section is empty.

Functions

func DetectLanguage

func DetectLanguage(path string) string

DetectLanguage returns the Grove language tag for a file path. Returns "" for unsupported or security-excluded files.

func ExtractPlaintext

func ExtractPlaintext(relPath, blobSHA string, content []byte) []core.SymbolRecord

ExtractPlaintext produces a single whole-file SymbolRecord for non-code documents. The record kind is KindDocument and the language is "plaintext".

Content layout:

  • docstring — full text, capped at PlaintextFTSLimit (FTS5 searchable)
  • raw_text — full text, capped at PlaintextRawLimit (Prism disclosure)
  • signature — first meaningful line (title / heading / top-level key)
  • name — base filename
  • qualified_name — repo-relative path (used for path-based queries)

func FileBlobSHA

func FileBlobSHA(path string) (string, error)

func IsPlaintext

func IsPlaintext(lang string) bool

IsPlaintext reports whether the language tag belongs to the plaintext family.

func Supported

func Supported(path string) bool

Supported reports whether Grove can index the file at path.

Types

type Engine

type Engine struct{}

func NewEngine

func NewEngine() *Engine

func (*Engine) ExtractFile

func (e *Engine) ExtractFile(path string, root string) ([]core.SymbolRecord, error)

func (*Engine) ParseTree

func (e *Engine) ParseTree(language string, src []byte) error

ParseTree validates that src is syntactically valid for the given language. Returns nil on success, a wrapped error if the language is unsupported or the parser reported syntax errors.

func (*Engine) Walk

func (e *Engine) Walk(root string) ([]core.SymbolRecord, int, error)

Jump to

Keyboard shortcuts

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