pynydus.engine.merger¶
Egg merge operations: apply ADD/SET/REMOVE directives to a base egg.
Implements local-only egg inheritance: load a base .egg archive, then apply merge operations to produce a modified EggPartial.
Module Contents¶
Functions¶
Load a base .egg archive from a local file path. |
|
Apply merge operations to a base egg and return the resulting EggPartial. |
|
Add a new record to the specified bucket. |
|
Replace all records matching the selector. |
|
Remove records matching the key/selector. |
|
Return True if |
|
If value looks like a file path, read its contents. Otherwise return as-is. |
|
Parse |
|
Check if a record matches a selector (attribute == value). |
|
Extract label from a key like ‘label=fact’. |
|
Infer a skill name from a file path or text. |
Data¶
API¶
- pynydus.engine.merger.logger¶
‘getLogger(…)’
- pynydus.engine.merger.load_base_egg(egg_path: str) pynydus.api.schemas.Egg¶
Load a base .egg archive from a local file path.
Args: egg_path: Path to the
.eggfile on disk.Returns: Loaded Egg with structured modules.
Raises: HatchError: If the file does not exist or cannot be unpacked.
- pynydus.engine.merger.merge(base_egg: pynydus.api.schemas.Egg, ops: list[pynydus.engine.nydusfile.MergeOp], *, base_dir: pathlib.Path | None = None) pynydus.api.schemas.EggPartial¶
Apply merge operations to a base egg and return the resulting EggPartial.
Args: base_egg: Loaded base Egg. ops: Parsed
ADD/SET/REMOVEoperations. base_dir: Nydusfile directory. relative paths in values resolve here.Returns: Partial egg with merged modules.
- pynydus.engine.merger._apply_add(partial: pynydus.api.schemas.EggPartial, op: pynydus.engine.nydusfile.MergeOp, base_dir: pathlib.Path | None) None¶
Add a new record to the specified bucket.
- pynydus.engine.merger._apply_set(partial: pynydus.api.schemas.EggPartial, op: pynydus.engine.nydusfile.MergeOp, base_dir: pathlib.Path | None) None¶
Replace all records matching the selector.
- pynydus.engine.merger._apply_remove(partial: pynydus.api.schemas.EggPartial, op: pynydus.engine.nydusfile.MergeOp) None¶
Remove records matching the key/selector.
Identifier comparisons are case-insensitive but otherwise exact. For skills, the key may match either the skill
nameor the file stem ofmetadata['source_file']. Logs a warning when no records matched.
- pynydus.engine.merger._skill_matches_remove_key(skill: pynydus.api.schemas.AgentSkill, key_lower: str) bool¶
Return True if
skillshould be dropped by a REMOVE skillkey.Matches case-insensitively on either the skill
nameor the file stem ofmetadata['source_file'](e.g.db-creationmatches a skill extracted fromskills/db-creation.md).
- pynydus.engine.merger._resolve_value(value: str, base_dir: pathlib.Path | None = None) str¶
If value looks like a file path, read its contents. Otherwise return as-is.
Relative paths are resolved against base_dir (the Nydusfile’s directory). Raises
NydusfileErrorif the value looks like a path but the file does not exist.
- pynydus.engine.merger._parse_selector(selector: str) tuple[str, str]¶
Parse
key=valueselector string.
- pynydus.engine.merger._matches_selector(record: object, key: str, value: str) bool¶
Check if a record matches a selector (attribute == value).