| title | API Reference | ||
|---|---|---|---|
| description | Function signatures and behavior | ||
| author | zoobzio | ||
| published | 2026-01-19 | ||
| updated | 2026-01-19 | ||
| tags |
|
func New(providers ...Provider) *ChunkerCreates a new Chunker with the given providers. Each provider handles one language.
Panics: Never.
c := chisel.New(
golang.New(),
typescript.New(),
python.New(),
)func (c *Chunker) Chunk(ctx context.Context, lang Language, filename string, content []byte) ([]Chunk, error)Routes the request to the appropriate provider and returns chunks.
Errors:
- Returns error if no provider is registered for
lang - Returns error if the provider fails to parse
chunks, err := c.Chunk(ctx, chisel.Go, "main.go", source)
if err != nil {
// Handle parse error or missing provider
}func (c *Chunker) Register(p Provider)Adds a provider to the chunker. If a provider for the same language exists, it is replaced.
Panics: Never.
c := chisel.New()
c.Register(golang.New())
c.Register(typescript.New())func (c *Chunker) Languages() []LanguageReturns all registered languages. Order is not guaranteed.
Panics: Never.
c := chisel.New(golang.New(), typescript.New())
langs := c.Languages()
// langs contains chisel.Go and chisel.TypeScriptfunc (c *Chunker) HasProvider(lang Language) boolReturns true if a provider is registered for the language.
Panics: Never.
c := chisel.New(golang.New())
c.HasProvider(chisel.Go) // true
c.HasProvider(chisel.TypeScript) // falsePackage: github.com/zoobz-io/chisel/golang
func New() *ProviderCreates a new Go provider using stdlib go/parser.
Panics: Never.
provider := golang.New()func (p *Provider) Chunk(ctx context.Context, filename string, content []byte) ([]Chunk, error)Parses Go source and extracts semantic chunks.
Errors:
- Returns parse error if source is invalid Go
chunks, err := provider.Chunk(ctx, "main.go", source)func (p *Provider) Language() LanguageReturns chisel.Go.
Package: github.com/zoobz-io/chisel/typescript
func New() *ProviderCreates a TypeScript provider using tree-sitter.
provider := typescript.New()func NewJavaScript() *ProviderCreates a JavaScript provider (same parser, different language identifier).
provider := typescript.NewJavaScript()func (p *Provider) Chunk(ctx context.Context, filename string, content []byte) ([]Chunk, error)Parses TypeScript/JavaScript source and extracts chunks.
Errors:
- Returns error on tree-sitter failure (rare)
func (p *Provider) Language() LanguageReturns chisel.TypeScript or chisel.JavaScript depending on constructor.
Package: github.com/zoobz-io/chisel/python
func New() *ProviderCreates a Python provider using tree-sitter.
provider := python.New()func (p *Provider) Chunk(ctx context.Context, filename string, content []byte) ([]Chunk, error)Parses Python source and extracts chunks.
func (p *Provider) Language() LanguageReturns chisel.Python.
Package: github.com/zoobz-io/chisel/rust
func New() *ProviderCreates a Rust provider using tree-sitter.
provider := rust.New()func (p *Provider) Chunk(ctx context.Context, filename string, content []byte) ([]Chunk, error)Parses Rust source and extracts chunks.
func (p *Provider) Language() LanguageReturns chisel.Rust.
Package: github.com/zoobz-io/chisel/markdown
func New() *ProviderCreates a Markdown provider that splits on headers.
provider := markdown.New()func (p *Provider) Chunk(ctx context.Context, filename string, content []byte) ([]Chunk, error)Splits Markdown into sections based on headers.
Errors: Never returns error (simple string parsing).
func (p *Provider) Language() LanguageReturns chisel.Markdown.
Package: github.com/zoobz-io/chisel/testing
func AssertChunkCount(t *testing.T, chunks []Chunk, want int)Fails the test if chunk count doesn't match.
func AssertHasSymbol(t *testing.T, chunks []Chunk, symbol string)Fails the test if no chunk has the given symbol.
func AssertHasKind(t *testing.T, chunks []Chunk, kind Kind)Fails the test if no chunk has the given kind.
func FindBySymbol(chunks []Chunk, symbol string) *ChunkReturns first chunk with symbol, or nil if not found.
func FindByKind(chunks []Chunk, kind Kind) *ChunkReturns first chunk with kind, or nil if not found.
func CountByKind(chunks []Chunk, kind Kind) intReturns number of chunks with the given kind.