@@ -38,12 +38,27 @@ Actions performed:
3838 - Remove empty sections from context files
3939 - Report on potential duplicates
4040
41- Use --archive to create .context/archive/ for old content.` ,
41+ Use --archive to create .context/archive/ for old content.
42+
43+ Examples:
44+ ctx compact # Clean up context, move completed tasks
45+ ctx compact --archive # Also archive old tasks to .context/archive/
46+ ctx compact --no-auto-save # Skip pre-compact session snapshot` ,
4247 RunE : runCompact ,
4348 }
4449
45- cmd .Flags ().BoolVar (& compactArchive , "archive" , false , "Create .context/archive/ for old content" )
46- cmd .Flags ().BoolVar (& compactNoAutoSave , "no-auto-save" , false , "Skip auto-saving session before compact" )
50+ cmd .Flags ().BoolVar (
51+ & compactArchive ,
52+ "archive" ,
53+ false ,
54+ "Create .context/archive/ for old content" ,
55+ )
56+ cmd .Flags ().BoolVar (
57+ & compactNoAutoSave ,
58+ "no-auto-save" ,
59+ false ,
60+ "Skip auto-saving session before compact" ,
61+ )
4762
4863 return cmd
4964}
@@ -106,7 +121,9 @@ func runCompact(cmd *cobra.Command, _ []string) error {
106121 return nil
107122}
108123
109- func compactTasks (cmd * cobra.Command , ctx * context.Context , archive bool ) (int , error ) {
124+ func compactTasks (
125+ cmd * cobra.Command , ctx * context.Context , archive bool ,
126+ ) (int , error ) {
110127 var tasksFile * context.FileInfo
111128 for i := range ctx .Files {
112129 if ctx .Files [i ].Name == "TASKS.md" {
@@ -147,7 +164,10 @@ func compactTasks(cmd *cobra.Command, ctx *context.Context, archive bool) (int,
147164 matches := completedPattern .FindStringSubmatch (line )
148165 if len (matches ) > 1 {
149166 completedTasks = append (completedTasks , matches [1 ])
150- cmd .Printf ("%s Moving completed task: %s\n " , green ("✓" ), truncateString (matches [1 ], 50 ))
167+ cmd .Printf (
168+ "%s Moving completed task: %s\n " , green ("✓" ),
169+ truncateString (matches [1 ], 50 ),
170+ )
151171 changes ++
152172 continue // Don't add to newLines
153173 }
@@ -163,7 +183,8 @@ func compactTasks(cmd *cobra.Command, ctx *context.Context, archive bool) (int,
163183 if strings .HasPrefix (line , "## Completed" ) {
164184 // Find the next line that's either empty or another section
165185 insertIdx := i + 1
166- for insertIdx < len (newLines ) && newLines [insertIdx ] != "" && ! strings .HasPrefix (newLines [insertIdx ], "## " ) {
186+ for insertIdx < len (newLines ) && newLines [insertIdx ] != "" &&
187+ ! strings .HasPrefix (newLines [insertIdx ], "## " ) {
167188 insertIdx ++
168189 }
169190
0 commit comments