MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / ImportSnapshot

Method ImportSnapshot

skills/persistence.go:189–263  ·  view source on GitHub ↗
(snapshot map[string]any)

Source from the content-addressed store, hash-verified

187}
188
189func (p *SkillPersistence) ImportSnapshot(snapshot map[string]any) {
190 if p == nil {
191 return
192 }
193 if snapshot == nil {
194 p.ClearAll()
195 return
196 }
197 if !snapshotVersionMatchesPython(snapshot["version"]) {
198 return
199 }
200 rawScopes, ok := snapshot["agent_scopes"].(map[string]any)
201 if !ok {
202 return
203 }
204 restored := map[string]map[string]InvokedSkillRecord{}
205 restoredOrder := map[string][]string{}
206 for scope, rawRecords := range rawScopes {
207 recordMap, ok := rawRecords.(map[string]any)
208 if !ok {
209 continue
210 }
211 scopeRecords := map[string]InvokedSkillRecord{}
212 for name, rawRecord := range recordMap {
213 recordFields, ok := rawRecord.(map[string]any)
214 if !ok {
215 continue
216 }
217 content := truthyStringFromSnapshot(recordFields["content"])
218 if content == "" {
219 continue
220 }
221 invokedAt, ok := floatFromSnapshot(recordFields["invoked_at"])
222 if !ok {
223 continue
224 }
225 lastTurnIndex, ok := intFromSnapshot(recordFields["last_turn_index"])
226 if !ok {
227 continue
228 }
229 invocationCount, ok := intFromSnapshot(recordFields["invocation_count"])
230 if !ok {
231 continue
232 }
233 if invocationCount < 1 {
234 invocationCount = 1
235 }
236 recordName := truthyStringFromSnapshot(recordFields["name"])
237 if recordName == "" {
238 recordName = name
239 }
240 recordScope := truthyStringFromSnapshot(recordFields["agent_scope"])
241 if recordScope == "" {
242 recordScope = scope
243 }
244 scopeRecords[name] = InvokedSkillRecord{
245 Name: recordName,
246 Path: truthyStringFromSnapshot(recordFields["path"]),

Calls 5

ClearAllMethod · 0.95
truthyStringFromSnapshotFunction · 0.85
floatFromSnapshotFunction · 0.85
intFromSnapshotFunction · 0.85