MCPcopy
hub / github.com/github/spec-kit / update

Method update

src/specify_cli/presets/__init__.py:388–419  ·  view source on GitHub ↗

Update preset metadata in registry. Merges the provided updates with the existing entry, preserving any fields not specified. The installed_at timestamp is always preserved from the original entry. Args: pack_id: Preset ID updates: Partial me

(self, pack_id: str, updates: dict)

Source from the content-addressed store, hash-verified

386 self._save()
387
388 def update(self, pack_id: str, updates: dict):
389 """Update preset metadata in registry.
390
391 Merges the provided updates with the existing entry, preserving any
392 fields not specified. The installed_at timestamp is always preserved
393 from the original entry.
394
395 Args:
396 pack_id: Preset ID
397 updates: Partial metadata to merge into existing metadata
398
399 Raises:
400 KeyError: If preset is not installed
401 """
402 packs = self.data.get("presets")
403 if not isinstance(packs, dict) or pack_id not in packs:
404 raise KeyError(f"Preset '{pack_id}' not found in registry")
405 existing = packs[pack_id]
406 # Handle corrupted registry entries (e.g., string/list instead of dict)
407 if not isinstance(existing, dict):
408 existing = {}
409 # Merge: existing fields preserved, new fields override (deep copy to prevent caller mutation)
410 merged = {**existing, **copy.deepcopy(updates)}
411 # Always preserve original installed_at based on key existence, not truthiness,
412 # to handle cases where the field exists but may be falsy (legacy/corruption)
413 if "installed_at" in existing:
414 merged["installed_at"] = existing["installed_at"]
415 else:
416 # If not present in existing, explicitly remove from merged if caller provided it
417 merged.pop("installed_at", None)
418 packs[pack_id] = merged
419 self._save()
420
421 def restore(self, pack_id: str, metadata: dict):
422 """Restore preset metadata to registry without modifying timestamps.

Callers 15

_sha256_fileFunction · 0.45
run_selection_loopFunction · 0.45
removeMethod · 0.45
preset_set_priorityFunction · 0.45
preset_enableFunction · 0.45
preset_disableFunction · 0.45
initFunction · 0.45
executeMethod · 0.45
build_requestFunction · 0.45
_make_reqFunction · 0.45
_sha256Function · 0.45

Calls 2

_saveMethod · 0.95
getMethod · 0.45