1
0
Fork 0
mirror of https://github.com/imjasonh/cnotes synced 2026-07-18 06:39:02 +00:00

Add configurable emojis for user and assistant messages

This commit is contained in:
Jason Hall 2025-07-21 14:41:19 -04:00
parent c2927548f9
commit cc4541b256
Failed to extract signature
6 changed files with 52 additions and 12 deletions

View file

@ -6,6 +6,7 @@ import (
"os/exec"
"strings"
"github.com/imjasonh/cnotes/internal/config"
"github.com/imjasonh/cnotes/internal/notes"
"github.com/spf13/cobra"
)
@ -101,7 +102,8 @@ If no commit is specified, shows notes for HEAD.`,
}
// Pretty-print in Markdown format
printConversationMarkdown(*note, commit)
cfg := config.LoadNotesConfig(".")
printConversationMarkdown(*note, commit, cfg)
return nil
},
}
@ -138,7 +140,7 @@ var listCmd = &cobra.Command{
}
// printConversationMarkdown formats a conversation note as readable Markdown
func printConversationMarkdown(note notes.ConversationNote, commit string) {
func printConversationMarkdown(note notes.ConversationNote, commit string, cfg *config.NotesConfig) {
fmt.Printf("# Claude Conversation Notes\n\n")
// Get commit info
@ -155,7 +157,7 @@ func printConversationMarkdown(note notes.ConversationNote, commit string) {
if note.ConversationExcerpt != "" {
fmt.Printf("## Conversation Transcript\n\n")
// Clean up and format the conversation excerpt for better readability
formatted := formatConversationExcerpt(note.ConversationExcerpt)
formatted := formatConversationExcerpt(note.ConversationExcerpt, cfg)
fmt.Printf("%s\n\n", formatted)
}
@ -164,7 +166,7 @@ func printConversationMarkdown(note notes.ConversationNote, commit string) {
}
// formatConversationExcerpt cleans up the conversation excerpt for better readability
func formatConversationExcerpt(excerpt string) string {
func formatConversationExcerpt(excerpt string, cfg *config.NotesConfig) string {
// Replace escaped newlines with actual newlines
formatted := strings.ReplaceAll(excerpt, "\\n", "\n")
@ -195,11 +197,11 @@ func formatConversationExcerpt(excerpt string) string {
}
switch {
case strings.HasPrefix(line, "User:"):
case strings.HasPrefix(line, "User:") || (cfg != nil && cfg.UserEmoji != "" && strings.HasPrefix(line, cfg.UserEmoji)):
// Bold user prompts
formattedLines = append(formattedLines, "**"+line+"**")
case strings.HasPrefix(line, "Claude:"):
case strings.HasPrefix(line, "Claude:") || (cfg != nil && cfg.AssistantEmoji != "" && strings.HasPrefix(line, cfg.AssistantEmoji)):
// Keep Claude responses as-is
formattedLines = append(formattedLines, line)

View file

@ -132,7 +132,7 @@ func processGitCommit(ctx context.Context, input HookInput, bashInput BashToolIn
return fmt.Errorf("could not extract commit hash")
}
// Create notes manager
// Create notes manager and load config
notesManager := notes.NewNotesManager(input.CWD)
cfg := config.LoadNotesConfig(input.CWD)
notesManager.SetNotesRef(cfg.NotesRef)
@ -149,7 +149,7 @@ func processGitCommit(ctx context.Context, input HookInput, bashInput BashToolIn
time.Sleep(100 * time.Millisecond)
// Extract conversation context since the last commit
contextExtractor := conv.NewContextExtractor()
contextExtractor := conv.NewContextExtractor(cfg)
conversationContext, err := contextExtractor.ExtractContextSince(input.TranscriptPath, input.SessionID, previousCommitTime)
if err != nil {
return fmt.Errorf("failed to extract conversation context: %w", err)