cli/pkg/help/search.go

394 lines
8.7 KiB
Go
Raw Normal View History

feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
package help
import (
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
"regexp"
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
"sort"
"strings"
"unicode"
)
// SearchResult represents a search match.
type SearchResult struct {
Topic *Topic
Section *Section // nil if topic-level match
Score float64
Snippet string // Context around match
}
// searchIndex provides full-text search.
type searchIndex struct {
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
topics map[string]*Topic // topicID -> Topic
index map[string][]string // word -> []topicID
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
}
// newSearchIndex creates a new empty search index.
func newSearchIndex() *searchIndex {
return &searchIndex{
topics: make(map[string]*Topic),
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
index: make(map[string][]string),
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
}
}
// Add indexes a topic for searching.
func (i *searchIndex) Add(topic *Topic) {
i.topics[topic.ID] = topic
// Index title words with boost
for _, word := range tokenize(topic.Title) {
i.addToIndex(word, topic.ID)
}
// Index content words
for _, word := range tokenize(topic.Content) {
i.addToIndex(word, topic.ID)
}
// Index section titles and content
for _, section := range topic.Sections {
for _, word := range tokenize(section.Title) {
i.addToIndex(word, topic.ID)
}
for _, word := range tokenize(section.Content) {
i.addToIndex(word, topic.ID)
}
}
// Index tags
for _, tag := range topic.Tags {
for _, word := range tokenize(tag) {
i.addToIndex(word, topic.ID)
}
}
}
// addToIndex adds a word-to-topic mapping.
func (i *searchIndex) addToIndex(word, topicID string) {
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
// Avoid duplicates
for _, id := range i.index[word] {
if id == topicID {
return
}
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
}
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
i.index[word] = append(i.index[word], topicID)
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
}
// Search finds topics matching the query.
func (i *searchIndex) Search(query string) []*SearchResult {
queryWords := tokenize(query)
if len(queryWords) == 0 {
return nil
}
// Track scores per topic
scores := make(map[string]float64)
for _, word := range queryWords {
// Exact matches
if topicIDs, ok := i.index[word]; ok {
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
for _, topicID := range topicIDs {
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
scores[topicID] += 1.0
}
}
// Prefix matches (partial word matching)
for indexWord, topicIDs := range i.index {
if strings.HasPrefix(indexWord, word) && indexWord != word {
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
for _, topicID := range topicIDs {
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
scores[topicID] += 0.5 // Lower score for partial matches
}
}
}
}
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
// Pre-compile regexes for snippets
var res []*regexp.Regexp
for _, word := range queryWords {
if len(word) >= 2 {
if re, err := regexp.Compile("(?i)" + regexp.QuoteMeta(word)); err == nil {
res = append(res, re)
}
}
}
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
// Build results with title boost and snippet extraction
var results []*SearchResult
for topicID, score := range scores {
topic := i.topics[topicID]
if topic == nil {
continue
}
// Title boost: if query words appear in title
titleLower := strings.ToLower(topic.Title)
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
hasTitleMatch := false
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
for _, word := range queryWords {
if strings.Contains(titleLower, word) {
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
hasTitleMatch = true
break
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
}
}
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
if hasTitleMatch {
score += 10.0
}
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
// Find matching section and extract snippet
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
section, snippet := i.findBestMatch(topic, queryWords, res)
// Section title boost
if section != nil {
sectionTitleLower := strings.ToLower(section.Title)
hasSectionTitleMatch := false
for _, word := range queryWords {
if strings.Contains(sectionTitleLower, word) {
hasSectionTitleMatch = true
break
}
}
if hasSectionTitleMatch {
score += 5.0
}
}
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
results = append(results, &SearchResult{
Topic: topic,
Section: section,
Score: score,
Snippet: snippet,
})
}
// Sort by score (highest first)
sort.Slice(results, func(a, b int) bool {
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
if results[a].Score != results[b].Score {
return results[a].Score > results[b].Score
}
return results[a].Topic.Title < results[b].Topic.Title
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
})
return results
}
// findBestMatch finds the section with the best match and extracts a snippet.
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
func (i *searchIndex) findBestMatch(topic *Topic, queryWords []string, res []*regexp.Regexp) (*Section, string) {
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
var bestSection *Section
var bestSnippet string
bestScore := 0
// Check topic title
titleScore := countMatches(topic.Title, queryWords)
if titleScore > 0 {
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
bestSnippet = extractSnippet(topic.Content, res)
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
}
// Check sections
for idx := range topic.Sections {
section := &topic.Sections[idx]
sectionScore := countMatches(section.Title, queryWords)
contentScore := countMatches(section.Content, queryWords)
totalScore := sectionScore*2 + contentScore // Title matches worth more
if totalScore > bestScore {
bestScore = totalScore
bestSection = section
if contentScore > 0 {
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
bestSnippet = extractSnippet(section.Content, res)
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
} else {
bestSnippet = extractSnippet(section.Content, nil)
}
}
}
// If no section matched, use topic content
if bestSnippet == "" && topic.Content != "" {
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
bestSnippet = extractSnippet(topic.Content, res)
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
}
return bestSection, bestSnippet
}
// tokenize splits text into lowercase words for indexing/searching.
func tokenize(text string) []string {
text = strings.ToLower(text)
var words []string
var word strings.Builder
for _, r := range text {
if unicode.IsLetter(r) || unicode.IsDigit(r) {
word.WriteRune(r)
} else if word.Len() > 0 {
w := word.String()
if len(w) >= 2 { // Skip single-character words
words = append(words, w)
}
word.Reset()
}
}
// Don't forget the last word
if word.Len() >= 2 {
words = append(words, word.String())
}
return words
}
// countMatches counts how many query words appear in the text.
func countMatches(text string, queryWords []string) int {
textLower := strings.ToLower(text)
count := 0
for _, word := range queryWords {
if strings.Contains(textLower, word) {
count++
}
}
return count
}
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
// extractSnippet extracts a short snippet around the first match and highlights matches.
func extractSnippet(content string, res []*regexp.Regexp) string {
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
if content == "" {
return ""
}
const snippetLen = 150
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
// If no regexes, return start of content without highlighting
if len(res) == 0 {
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
lines := strings.Split(content, "\n")
for _, line := range lines {
line = strings.TrimSpace(line)
if line != "" && !strings.HasPrefix(line, "#") {
runes := []rune(line)
if len(runes) > snippetLen {
return string(runes[:snippetLen]) + "..."
}
return line
}
}
return ""
}
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
// Find first match position (byte-based)
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
matchPos := -1
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
for _, re := range res {
loc := re.FindStringIndex(content)
if loc != nil && (matchPos == -1 || loc[0] < matchPos) {
matchPos = loc[0]
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
}
}
// Convert to runes for safe slicing
runes := []rune(content)
runeLen := len(runes)
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
var start, end int
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
if matchPos == -1 {
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
// No match found, use start of content
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
start = 0
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
end = snippetLen
if end > runeLen {
end = runeLen
}
} else {
// Convert byte position to rune position
matchRunePos := len([]rune(content[:matchPos]))
// Extract snippet around match (rune-based)
start = matchRunePos - 50
if start < 0 {
start = 0
}
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
end = start + snippetLen
if end > runeLen {
end = runeLen
}
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
}
snippet := string(runes[start:end])
// Trim to word boundaries
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
prefix := ""
suffix := ""
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
if start > 0 {
if idx := strings.Index(snippet, " "); idx != -1 {
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
snippet = snippet[idx+1:]
prefix = "..."
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
}
}
if end < runeLen {
if idx := strings.LastIndex(snippet, " "); idx != -1 {
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
snippet = snippet[:idx]
suffix = "..."
}
}
snippet = strings.TrimSpace(snippet)
if snippet == "" {
return ""
}
// Apply highlighting
highlighted := highlight(snippet, res)
return prefix + highlighted + suffix
}
// highlight wraps matches in **bold**.
func highlight(text string, res []*regexp.Regexp) string {
if len(res) == 0 {
return text
}
type match struct {
start, end int
}
var matches []match
for _, re := range res {
indices := re.FindAllStringIndex(text, -1)
for _, idx := range indices {
matches = append(matches, match{idx[0], idx[1]})
}
}
if len(matches) == 0 {
return text
}
// Sort matches by start position
sort.Slice(matches, func(i, j int) bool {
if matches[i].start != matches[j].start {
return matches[i].start < matches[j].start
}
return matches[i].end > matches[j].end
})
// Merge overlapping or adjacent matches
var merged []match
if len(matches) > 0 {
curr := matches[0]
for i := 1; i < len(matches); i++ {
if matches[i].start <= curr.end {
if matches[i].end > curr.end {
curr.end = matches[i].end
}
} else {
merged = append(merged, curr)
curr = matches[i]
}
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
}
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
merged = append(merged, curr)
}
// Build highlighted string from back to front to avoid position shifts
result := text
for i := len(merged) - 1; i >= 0; i-- {
m := merged[i]
result = result[:m.end] + "**" + result[m.end:]
result = result[:m.start] + "**" + result[m.start:]
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
}
feat(help): Implement full-text search (#294) * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with markdown bold highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Ensured all project files are correctly formatted. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections as specified. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized performance by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import in `internal/cmd/help/cmd.go`. - Verified that `tokenize` is correctly defined and used within `pkg/help`. * feat(help): implement full-text search with ranking and highlighting - Implemented inverted index for help topics and sections. - Added weighted scoring: Title (10.0), Section (5.0), Content (1.0). - Implemented snippet extraction with robust markdown highlighting. - Optimized search by pre-compiling regexes for match finding. - Updated CLI help command to display matched sections and snippets with ANSI bold. - Added comprehensive tests for search accuracy and highlighting. - Fixed missing `strings` import and added `--repo` flag to `auto-merge` workflow.
2026-02-05 10:26:16 +00:00
return result
feat(help): add markdown parsing and section extraction (#174) * feat(help): add markdown parsing and section extraction Implements #137: markdown parsing and section extraction for help system. - Add Topic and Section types for help content structure - Add Frontmatter type for YAML metadata parsing - Add ParseTopic() to parse markdown files into Topic structs - Add ExtractFrontmatter() to extract YAML frontmatter - Add ExtractSections() to extract headings and content - Add GenerateID() to create URL-safe anchor IDs - Add comprehensive tests following _Good/_Bad naming convention This is the foundation for the display-agnostic help system (#133). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality (#175) * fix(test): use manual cleanup for TestDevOps_Boot_Good_FreshWithNoExisting Fixes flaky test that fails with "TempDir RemoveAll cleanup: directory not empty" by using os.MkdirTemp with t.Cleanup instead of t.TempDir(). This is the same fix applied to TestDevOps_Boot_Good_Success in 3423e48. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(help): add full-text search functionality Implements #139: full-text search for help topics. - Add searchIndex with inverted index for fast lookups - Add tokenize() for case-insensitive word extraction - Add Search() with relevance ranking: - Exact word matches score 1.0 - Prefix matches score 0.5 - Title matches get 2.0 boost - Add snippet extraction for search result context - Add section-level matching for precise results - Add comprehensive tests following _Good/_Bad naming Search features: - Case-insensitive matching - Partial word matching (prefix) - Title boost (matches in title rank higher) - Section-level results - Snippet extraction with context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): address CodeRabbit review feedback - Add CRLF line ending support to frontmatter regex - Add empty frontmatter block support - Use filepath.Base/Ext for cross-platform path handling - Add tests for CRLF and empty frontmatter cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use rune-based slicing for UTF-8 safe snippets Address CodeRabbit feedback: byte-based slicing can corrupt multi-byte UTF-8 characters. Now uses rune-based indexing for snippet extraction. - Convert content to []rune before slicing - Convert byte position to rune position for match location - Add UTF-8 validation tests with Japanese text Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(help): use correct string for byte-to-rune conversion in extractSnippet strings.ToLower can change byte lengths for certain Unicode characters (e.g., K U+212A 3 bytes → k 1 byte). Since matchPos is a byte index from strings.Index(contentLower, word), the rune conversion must also use contentLower to maintain correct index alignment. Fixes CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:07:32 +00:00
}