-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.go
More file actions
65 lines (52 loc) · 1.62 KB
/
api.go
File metadata and controls
65 lines (52 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Package chisel provides AST-aware code chunking for semantic search and embeddings.
package chisel
import "context"
// Language identifies a programming language.
type Language string
// Supported languages.
const (
Go Language = "go"
TypeScript Language = "typescript"
JavaScript Language = "javascript"
Python Language = "python"
Rust Language = "rust"
Markdown Language = "markdown"
)
// Kind categorizes a chunk.
type Kind string
// Chunk kinds.
const (
KindFunction Kind = "function"
KindMethod Kind = "method"
KindClass Kind = "class"
KindInterface Kind = "interface"
KindType Kind = "type"
KindEnum Kind = "enum"
KindConstant Kind = "constant"
KindVariable Kind = "variable"
KindSection Kind = "section" // For markdown headers
KindModule Kind = "module" // Package/file level
)
// Chunk represents a semantic unit of code or documentation.
type Chunk struct {
// Content is the actual code or text.
Content string
// Symbol is the name of the function, class, type, or section.
Symbol string
// Kind categorizes this chunk.
Kind Kind
// StartLine is the 1-indexed starting line number.
StartLine int
// EndLine is the 1-indexed ending line number.
EndLine int
// Context is the parent chain for this chunk.
// Example: ["class UserService", "method getUser"]
Context []string
}
// Provider parses a specific language into chunks.
type Provider interface {
// Chunk parses content and returns semantic chunks.
Chunk(ctx context.Context, filename string, content []byte) ([]Chunk, error)
// Language returns the supported language.
Language() Language
}