/ go / internal / agents / writer.go
writer.go
  1  package agents
  2  
  3  import (
  4  	"time"
  5  
  6  	"github.com/TransformerOS/kamaji-go/internal/memory"
  7  	"github.com/TransformerOS/kamaji-go/internal/tools"
  8  	"github.com/TransformerOS/kamaji-go/internal/types"
  9  )
 10  
 11  // WriterAgent - Expert level agent for creative and technical writing
 12  func NewWriterAgent(llm types.LLMProvider, agentTools []tools.Tool) *SpecializedAgent {
 13  	return &SpecializedAgent{
 14  		ID:    "writer-001",
 15  		Name:  "Literary Writer",
 16  		Type:  "writer",
 17  		Level: Expert,
 18  		Personality: AgentPersonality{
 19  			Name:        "The Wordsmith",
 20  			Traits:      []string{"eloquent", "imaginative", "meticulous", "empathetic", "observant"},
 21  			Tone:        "articulate and expressive",
 22  			Approach:    "craft-focused with deep literary understanding",
 23  			Specialties: []string{
 24  				"narrative structure", "character development", "prose style", 
 25  				"poetry", "dialogue", "technical writing", "editing", "literary analysis",
 26  			},
 27  		},
 28  		Capabilities: []AgentCapability{
 29  			{
 30  				Name:        "Creative Writing",
 31  				Description: "Craft compelling fiction, poetry, and creative non-fiction using established literary techniques",
 32  				Tools:       []string{"file_write", "edit", "multiedit", "view"},
 33  				MinLevel:    Expert,
 34  			},
 35  			{
 36  				Name:        "Technical Documentation",
 37  				Description: "Create clear, comprehensive technical documentation and guides",
 38  				Tools:       []string{"file_write", "edit", "view", "grep", "glob"},
 39  				MinLevel:    Advanced,
 40  			},
 41  			{
 42  				Name:        "Literary Analysis",
 43  				Description: "Analyze texts for literary devices, themes, and structural elements",
 44  				Tools:       []string{"file_read", "view", "grep", "sourcegraph"},
 45  				MinLevel:    Expert,
 46  			},
 47  			{
 48  				Name:        "Style Adaptation",
 49  				Description: "Adapt writing style to match different authors, genres, or requirements",
 50  				Tools:       []string{"file_read", "file_write", "edit", "view"},
 51  				MinLevel:    Expert,
 52  			},
 53  			{
 54  				Name:        "Content Editing",
 55  				Description: "Edit and refine existing content for clarity, flow, and impact",
 56  				Tools:       []string{"edit", "multiedit", "view", "grep"},
 57  				MinLevel:    Advanced,
 58  			},
 59  		},
 60  		Tools:  agentTools,
 61  		LLM:    llm,
 62  		Config: getWriterConfig(),
 63  		Status: types.AgentStatus{
 64  			ID:         "writer-001",
 65  			Status:     "ready",
 66  			LastActive: time.Now(),
 67  		},
 68  		Memory: memory.NewSimpleMemory(),
 69  	}
 70  }
 71  
 72  // getWriterConfig returns configuration optimized for creative writing tasks
 73  func getWriterConfig() AgentConfig {
 74  	return AgentConfig{
 75  		MaxIterations:     18,
 76  		Timeout:           12 * time.Minute,
 77  		EnableMemory:      true,
 78  		EnableLearning:    true,
 79  		Verbose:           false,
 80  		SelfImprovement:   true,
 81  		CollaborationMode: true,
 82  		CreativityLevel:   0.9,  // High creativity for literary work
 83  		RiskTolerance:     0.6,  // Moderate risk for experimental techniques
 84  		PrecisionLevel:    0.85, // High precision for language use
 85  	}
 86  }
 87  
 88  // WritingPrompts contains structured prompts for different writing tasks
 89  var WritingPrompts = map[string]string{
 90  	"character_development": `
 91  Develop this character using the following framework:
 92  1. External characteristics (appearance, mannerisms, speech patterns)
 93  2. Internal landscape (fears, desires, contradictions, backstory)
 94  3. Character arc potential (growth, change, revelation)
 95  4. Relationships and social dynamics
 96  5. Unique voice and perspective
 97  
 98  Consider psychological depth and avoid stereotypes. Draw from literary traditions while creating something fresh.
 99  `,
100  	
101  	"narrative_structure": `
102  Structure this narrative considering:
103  1. Opening hook and inciting incident
104  2. Rising action with escalating conflict
105  3. Climactic moment and resolution
106  4. Pacing and rhythm throughout
107  5. Thematic coherence
108  
109  Choose appropriate narrative techniques (POV, tense, structure) that serve the story's emotional core.
110  `,
111  	
112  	"dialogue_crafting": `
113  Craft dialogue that:
114  1. Reveals character through subtext and speech patterns
115  2. Advances plot while feeling natural
116  3. Creates distinct voices for each character
117  4. Uses appropriate dialect and register
118  5. Balances exposition with authenticity
119  
120  Remember: people rarely say exactly what they mean.
121  `,
122  	
123  	"prose_style": `
124  Develop prose style considering:
125  1. Sentence rhythm and variety
126  2. Word choice precision and connotation
127  3. Imagery and sensory details
128  4. Metaphorical language and symbolism
129  5. Overall voice and tone
130  
131  Match style to content - let form serve function.
132  `,
133  	
134  	"technical_writing": `
135  Create technical documentation that:
136  1. Identifies target audience and their needs
137  2. Organizes information logically
138  3. Uses clear, concise language
139  4. Includes relevant examples and illustrations
140  5. Provides actionable next steps
141  
142  Prioritize clarity and usability over literary flourish.
143  `,
144  }
145  
146  // LiteraryTechniques contains detailed information about writing craft
147  var LiteraryTechniques = map[string]map[string]string{
148  	"point_of_view": {
149  		"first_person": "Intimate access to narrator's thoughts; limited perspective; potential for unreliability",
150  		"third_limited": "Close character focus while maintaining narrative distance; flexible intimacy",
151  		"third_omniscient": "God-like perspective; access to all characters; requires careful management",
152  		"second_person": "Direct reader address; experimental; creates immediacy or alienation",
153  	},
154  	
155  	"narrative_time": {
156  		"chronological": "Linear progression; clear causality; traditional structure",
157  		"flashback": "Reveals backstory; creates dramatic irony; requires smooth transitions",
158  		"flash_forward": "Creates tension; foreshadows events; disrupts linear expectation",
159  		"circular": "Thematic reinforcement; sense of fate or inevitability; structural elegance",
160  	},
161  	
162  	"conflict_types": {
163  		"person_vs_person": "External antagonist; clear opposition; dramatic confrontation",
164  		"person_vs_self": "Internal struggle; psychological depth; character growth potential",
165  		"person_vs_society": "Social commentary; systemic issues; broader implications",
166  		"person_vs_nature": "Survival themes; human limitations; environmental consciousness",
167  		"person_vs_technology": "Modern anxieties; progress questions; ethical dilemmas",
168  	},
169  	
170  	"literary_devices": {
171  		"symbolism": "Objects/actions representing deeper meanings; thematic reinforcement",
172  		"metaphor": "Direct comparison creating new understanding; emotional resonance",
173  		"foreshadowing": "Hints at future events; creates anticipation; structural unity",
174  		"irony": "Contrast between expectation and reality; adds complexity and depth",
175  		"allegory": "Extended metaphor; abstract concepts made concrete; political/moral commentary",
176  	},
177  }
178  
179  // AuthorStyles contains analysis of famous authors' techniques
180  var AuthorStyles = map[string]map[string]interface{}{
181  	"hemingway": {
182  		"prose_style": "Iceberg theory - surface simplicity hiding emotional depth",
183  		"dialogue": "Realistic, understated, revealing character through subtext",
184  		"themes": []string{"war", "death", "love", "loss", "masculinity", "grace_under_pressure"},
185  		"techniques": []string{"omission", "repetition", "understatement", "objective_narration"},
186  		"example_works": []string{"The Sun Also Rises", "A Farewell to Arms", "The Old Man and the Sea"},
187  	},
188  	
189  	"virginia_woolf": {
190  		"prose_style": "Stream of consciousness, lyrical, psychological realism",
191  		"narrative": "Interior monologue, temporal shifts, subjective experience",
192  		"themes": []string{"time", "memory", "consciousness", "gender", "class", "mental_health"},
193  		"techniques": []string{"free_indirect_discourse", "epiphany", "symbolic_imagery"},
194  		"example_works": []string{"Mrs. Dalloway", "To the Lighthouse", "The Waves"},
195  	},
196  	
197  	"gabriel_garcia_marquez": {
198  		"prose_style": "Magical realism, lush descriptions, cyclical narratives",
199  		"narrative": "Multi-generational sagas, mythical elements, non-linear time",
200  		"themes": []string{"solitude", "memory", "history", "politics", "love", "death"},
201  		"techniques": []string{"magical_realism", "hyperbole", "circular_time", "oral_tradition"},
202  		"example_works": []string{"One Hundred Years of Solitude", "Love in the Time of Cholera"},
203  	},
204  	
205  	"toni_morrison": {
206  		"prose_style": "Poetic language, African American vernacular, historical consciousness",
207  		"narrative": "Multiple perspectives, fragmented chronology, oral storytelling",
208  		"themes": []string{"slavery", "trauma", "identity", "community", "memory", "healing"},
209  		"techniques": []string{"call_and_response", "biblical_allusion", "ancestral_voices"},
210  		"example_works": []string{"Beloved", "Song of Solomon", "The Bluest Eye"},
211  	},
212  	
213  	"jorge_luis_borges": {
214  		"prose_style": "Precise, philosophical, labyrinthine concepts in brief forms",
215  		"narrative": "Metafiction, infinite recursion, library/maze metaphors",
216  		"themes": []string{"infinity", "reality", "knowledge", "time", "identity", "literature"},
217  		"techniques": []string{"mise_en_abyme", "false_documents", "philosophical_fiction"},
218  		"example_works": []string{"Labyrinths", "Ficciones", "The Aleph"},
219  	},
220  }