hookPreCompact saves hub state before context compaction
(root string)
| 1080 | |
| 1081 | // hookPreCompact saves hub state before context compaction |
| 1082 | func hookPreCompact(root string) error { |
| 1083 | codemapDir := filepath.Join(root, ".codemap") |
| 1084 | if err := os.MkdirAll(codemapDir, 0755); err != nil { |
| 1085 | return err |
| 1086 | } |
| 1087 | |
| 1088 | info := getHubInfoNoFallback(root) |
| 1089 | if info == nil || len(info.Hubs) == 0 { |
| 1090 | return nil |
| 1091 | } |
| 1092 | |
| 1093 | // Write hub state |
| 1094 | hubsFile := filepath.Join(codemapDir, "hubs.txt") |
| 1095 | f, err := os.Create(hubsFile) |
| 1096 | if err != nil { |
| 1097 | return err |
| 1098 | } |
| 1099 | defer f.Close() |
| 1100 | |
| 1101 | fmt.Fprintf(f, "# Hub files at %s\n", time.Now().Format(time.RFC3339)) |
| 1102 | for _, hub := range info.Hubs { |
| 1103 | fmt.Fprintln(f, hub) |
| 1104 | } |
| 1105 | |
| 1106 | fmt.Println() |
| 1107 | fmt.Printf("💾 Saved hub state to .codemap/hubs.txt before compact\n") |
| 1108 | fmt.Printf(" (%d hub files tracked)\n", len(info.Hubs)) |
| 1109 | fmt.Println() |
| 1110 | |
| 1111 | return nil |
| 1112 | } |
| 1113 | |
| 1114 | // hookSessionStop summarizes what changed in the session and stops the daemon |
| 1115 | func hookSessionStop(root string) error { |