Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions kai-cli/cmd/kai/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3853,7 +3853,7 @@ func computeCaptureSummary(db *graph.DB, newSnapshotID []byte, matcher *module.M
case "json":
changes, _ = classify.DetectJSONChanges(path, beforeContent, afterContent)
case "ts", "js", "tsx", "jsx", "go", "py":
changes, _ = detector.DetectChanges(path, beforeContent, afterContent, "")
changes, _ = detector.DetectChanges(path, beforeContent, afterContent, "", lang)
default:
changes = []*classify.ChangeType{classify.NewFileChange(classify.FileContentChanged, path)}
}
Expand Down Expand Up @@ -8217,7 +8217,7 @@ func createChangesetFromSnapshots(db *graph.DB, baseSnapID, headSnapID []byte, m
changes, err = classify.DetectYAMLChanges(path, beforeContent, afterContent)
case "ts", "js":
// Use tree-sitter based detection
changes, err = detector.DetectChanges(path, beforeContent, afterContent, util.BytesToHex(changedFileIDs[i]))
changes, err = detector.DetectChanges(path, beforeContent, afterContent, util.BytesToHex(changedFileIDs[i]), lang)
default:
// Non-parseable files get FILE_CONTENT_CHANGED
changes = []*classify.ChangeType{classify.NewFileChange(classify.FileContentChanged, path)}
Expand Down
6 changes: 3 additions & 3 deletions kai-cli/internal/classify/classify.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ func (d *Detector) SetSymbols(fileID string, symbols []*coregraph.Node) {
}

// DetectChanges detects all change types between two versions of a file.
// Optional lang parameter specifies the language for proper parsing.
func (d *Detector) DetectChanges(path string, beforeContent, afterContent []byte, fileID string, lang ...string) ([]*ChangeType, error) {
return d.inner.DetectChanges(path, beforeContent, afterContent, fileID, lang...)
// The lang parameter specifies the language for proper parsing (e.g., "py", "js", "ts").
func (d *Detector) DetectChanges(path string, beforeContent, afterContent []byte, fileID string, lang string) ([]*ChangeType, error) {
return d.inner.DetectChanges(path, beforeContent, afterContent, fileID, lang)
}

// DetectFileChange creates a FILE_CONTENT_CHANGED for non-parseable files.
Expand Down
20 changes: 19 additions & 1 deletion kai-cli/internal/status/semantic.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,26 @@ func AnalyzeSemantic(db *graph.DB, statusResult *Result, opts SemanticOptions) (
continue
}

// Determine language from file extension
lang := "js" // default
ext := filepath.Ext(path)
switch ext {
case ".ts", ".tsx":
lang = "ts"
case ".py":
lang = "py"
case ".go":
lang = "go"
case ".rb":
lang = "rb"
case ".rs":
lang = "rs"
case ".js", ".jsx":
lang = "js"
}

// Detect changes
changes, err := detector.DetectChanges(path, beforeContent, afterContent, "")
changes, err := detector.DetectChanges(path, beforeContent, afterContent, "", lang)
if err != nil {
continue
}
Expand Down
Loading