MCPcopy Create free account
hub / github.com/github/gh-aw / extractRepoMemoryConfig

Method extractRepoMemoryConfig

pkg/workflow/repo_memory.go:78–488  ·  view source on GitHub ↗

extractRepoMemoryConfig extracts repo-memory configuration from tools section. workflowID is used to qualify the default branch name (e.g. "memory/{workflowID}").

(toolsConfig *ToolsConfig, workflowID string)

Source from the content-addressed store, hash-verified

76// extractRepoMemoryConfig extracts repo-memory configuration from tools section.
77// workflowID is used to qualify the default branch name (e.g. "memory/{workflowID}").
78func (c *Compiler) extractRepoMemoryConfig(toolsConfig *ToolsConfig, workflowID string) (*RepoMemoryConfig, error) {
79 // Check if repo-memory tool is configured
80 if toolsConfig == nil || toolsConfig.RepoMemory == nil {
81 return nil, nil
82 }
83
84 repoMemoryLog.Print("Extracting repo-memory configuration from ToolsConfig")
85
86 config := &RepoMemoryConfig{
87 BranchPrefix: "memory", // Default branch prefix
88 }
89 repoMemoryValue := toolsConfig.RepoMemory.Raw
90
91 // defaultMemoryBranchID returns workflowID when set, otherwise "default".
92 // This qualifies the default branch name by workflow, e.g. "memory/repo-assist".
93 defaultMemoryBranchID := func() string {
94 if workflowID != "" {
95 return workflowID
96 }
97 return "default"
98 }
99
100 // Handle nil value (simple enable with defaults) - same as true
101 if repoMemoryValue == nil {
102 repoMemoryLog.Print("Using default repo-memory configuration (nil value)")
103 config.Memories = []RepoMemoryEntry{
104 {
105 ID: "default",
106 BranchName: generateDefaultBranchName(defaultMemoryBranchID(), config.BranchPrefix),
107 MaxFileSize: defaultRepoMemoryMaxFileSize, // 100KB
108 MaxFileCount: 100,
109 MaxPatchSize: defaultRepoMemoryMaxPatchSize, // 10KB
110 CreateOrphan: true,
111 AllowedExtensions: constants.DefaultAllowedMemoryExtensions,
112 },
113 }
114 return config, nil
115 }
116
117 // Handle boolean value (simple enable/disable)
118 if boolValue, ok := repoMemoryValue.(bool); ok {
119 if boolValue {
120 repoMemoryLog.Print("Using default repo-memory configuration (boolean true)")
121 // Create a single default memory entry
122 config.Memories = []RepoMemoryEntry{
123 {
124 ID: "default",
125 BranchName: generateDefaultBranchName(defaultMemoryBranchID(), config.BranchPrefix),
126 MaxFileSize: defaultRepoMemoryMaxFileSize, // 100KB
127 MaxFileCount: 100,
128 MaxPatchSize: defaultRepoMemoryMaxPatchSize, // 10KB
129 CreateOrphan: true,
130 AllowedExtensions: constants.DefaultAllowedMemoryExtensions,
131 },
132 }
133 } else {
134 repoMemoryLog.Print("Repo-memory disabled (boolean false)")
135 }

Calls 6

validateBranchPrefixFunction · 0.85
validateIntRangeFunction · 0.85
PrintMethod · 0.80
PrintfMethod · 0.45