@@ -151,6 +151,12 @@ func runInit(cmd *cobra.Command, _ []string) error {
151151
152152 cmd .Printf ("\n %s initialized in %s/\n " , green ("Context" ), contextDir )
153153
154+ // Create entry templates in .context/templates/
155+ if err := createEntryTemplates (cmd , contextDir , initForce ); err != nil {
156+ // Non-fatal: warn but continue
157+ cmd .Printf (" %s Entry templates: %v\n " , color .YellowString ("⚠" ), err )
158+ }
159+
154160 // Create IMPLEMENTATION_PLAN.md in project root (orchestrator directive)
155161 if err := createImplementationPlan (cmd , initForce ); err != nil {
156162 // Non-fatal: warn but continue
@@ -493,6 +499,47 @@ func updateCtxSection(cmd *cobra.Command, existing string, newTemplate []byte, g
493499 return nil
494500}
495501
502+ // createEntryTemplates creates .context/templates/ with entry templates for rich entries.
503+ // These templates help users format detailed learnings and decisions using --file flag.
504+ func createEntryTemplates (cmd * cobra.Command , contextDir string , force bool ) error {
505+ green := color .New (color .FgGreen ).SprintFunc ()
506+ yellow := color .New (color .FgYellow ).SprintFunc ()
507+
508+ templatesDir := filepath .Join (contextDir , "templates" )
509+ if err := os .MkdirAll (templatesDir , 0755 ); err != nil {
510+ return fmt .Errorf ("failed to create %s: %w" , templatesDir , err )
511+ }
512+
513+ // Get list of entry templates
514+ entryTemplates , err := templates .ListEntryTemplates ()
515+ if err != nil {
516+ return fmt .Errorf ("failed to list entry templates: %w" , err )
517+ }
518+
519+ for _ , name := range entryTemplates {
520+ targetPath := filepath .Join (templatesDir , name )
521+
522+ // Check if file exists and --force not set
523+ if _ , err := os .Stat (targetPath ); err == nil && ! force {
524+ cmd .Printf (" %s templates/%s (exists, skipped)\n " , yellow ("○" ), name )
525+ continue
526+ }
527+
528+ content , err := templates .GetEntryTemplate (name )
529+ if err != nil {
530+ return fmt .Errorf ("failed to read entry template %s: %w" , name , err )
531+ }
532+
533+ if err := os .WriteFile (targetPath , content , 0644 ); err != nil {
534+ return fmt .Errorf ("failed to write %s: %w" , targetPath , err )
535+ }
536+
537+ cmd .Printf (" %s templates/%s\n " , green ("✓" ), name )
538+ }
539+
540+ return nil
541+ }
542+
496543// checkCtxInPath verifies that ctx is available in PATH.
497544// The hooks use "ctx" expecting it to be in PATH, so init should fail
498545// if the user hasn't installed ctx globally yet.
0 commit comments