MCPcopy Create free account
hub / github.com/diillson/chatcli / Cleanup

Method Cleanup

cli/agent/session_workspace.go:203–236  ·  view source on GitHub ↗

Cleanup removes the session workspace unless CHATCLI_AGENT_KEEP_TMPDIR=true. Safe to call multiple times.

()

Source from the content-addressed store, hash-verified

201// Cleanup removes the session workspace unless CHATCLI_AGENT_KEEP_TMPDIR=true.
202// Safe to call multiple times.
203func (ws *SessionWorkspace) Cleanup() {
204 if ws == nil {
205 return
206 }
207
208 sessionWorkspaceMu.Lock()
209 defer sessionWorkspaceMu.Unlock()
210
211 // Unregister first so a late tool call can't land a file into a
212 // directory we're about to delete.
213 UnregisterAuxReadPath(ws.Root)
214 engine.UnregisterAuxPath(ws.Root)
215 SetBudgetResultDir("") // fall back to default
216 fireResultDirSetters("")
217
218 if ws.keep {
219 if ws.logger != nil {
220 ws.logger.Info("Keeping session workspace (CHATCLI_AGENT_KEEP_TMPDIR=true)",
221 zap.String("root", ws.Root))
222 }
223 } else {
224 if err := os.RemoveAll(ws.Root); err != nil && ws.logger != nil {
225 ws.logger.Warn("Failed to remove session workspace",
226 zap.String("root", ws.Root),
227 zap.Error(err))
228 }
229 }
230
231 _ = os.Unsetenv("CHATCLI_AGENT_TMPDIR")
232
233 if sessionWorkspace == ws {
234 sessionWorkspace = nil
235 }
236}
237
238// AuxAllowedPaths returns paths the engine and read validator should treat as
239// inside the boundary, in addition to the workspace root. Includes the

Calls 10

UnregisterAuxPathFunction · 0.92
UnregisterAuxReadPathFunction · 0.85
SetBudgetResultDirFunction · 0.85
fireResultDirSettersFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80
WarnMethod · 0.80
InfoMethod · 0.65
ErrorMethod · 0.65
StringMethod · 0.45