cacheMemoryDirFor returns the canonical runtime directory for the given cache ID. Default cache → /tmp/gh-aw/cache-memory Named cache → /tmp/gh-aw/cache-memory-{id} The returned path has no trailing slash. Callers that display the path as a directory (e.g. in LLM prompt context) should append "/"
(cacheID string)
| 40 | // this function. This function panics on invalid IDs as a defence-in-depth measure |
| 41 | // (the parser should have rejected them first). |
| 42 | func cacheMemoryDirFor(cacheID string) string { |
| 43 | if cacheID == "default" || cacheID == "" { |
| 44 | return defaultCacheMemoryDir |
| 45 | } |
| 46 | if !isValidCacheID(cacheID) { |
| 47 | // This should never happen: parseCacheMemoryEntry validates IDs at parse time. |
| 48 | // Panic here to surface a clear programming error rather than silently producing |
| 49 | // a dangerous path. |
| 50 | panic(fmt.Sprintf("cacheMemoryDirFor called with invalid cache ID %q; IDs must match [A-Za-z0-9_-]{1,64}", cacheID)) |
| 51 | } |
| 52 | return cacheMemoryDirPrefix + cacheID |
| 53 | } |
| 54 | |
| 55 | // validCacheMemoryScopes defines the allowed values for cache-memory scope |
| 56 | var validCacheMemoryScopes = []string{"workflow", "repo"} |