mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-18 18:04:17 +00:00
* fix(config): keep YAML anchors and aliases when a command writes the config Every writer re-encodes the in-memory struct, which has no anchors, so a command such as `target a --add-exclude` expanded `&shared` / `*shared` under targets and projects and the lists stopped following each other. The comment pass added for #525 already pairs each old node with the one that replaced it; relinkAliases uses the same pairs to put anchors back and turn unedited alias values into aliases again. An anchored node keeps its anchor and the aliases that still hold its old value follow its new value, as the file declares. An alias that was edited keeps its own list and leaves the anchored one alone. Output is sorted by name, so the anchor moves to the first place the group appears: an alias may not precede its anchor. Fixes #546 * fix(config): keep YAML merge keys when a command writes the config A command rewrites config.yaml from the Go struct, which holds the merged keys of `<<: *base` and not the merge itself, so every merge key was written out expanded and later edits of the anchored mapping no longer reached the mappings that merged it. relinkAliases already restored anchors and aliases from the old/new node pairing; relinkMerge now does the same for merge keys, including `<<: [*a, *b]`, merges in nested mappings and in project-config target items. A key stays written out when the old mapping set it itself, or when its value is no longer the one its merge source gives it. yaml.v3 merges are shallow, so such a key replaces the merged value as a whole and what is written always decodes to the config the command meant to save. A source that was removed, or that holds a key the mapping no longer has, is not merged back. Output order is not the old file's order, so an anchor that would follow its first merge key moves onto it (`<<: &base`). The next write pairs that mapping with the alias that still shows its value, so the file stays stable. The runbook steps for anchors now write their own config: mdproof re-runs the setup before each step, so step 7 and 8 never saw the config of step 6 (Codex review on #551). Steps for merge keys are added the same way. * fix(config): let edits of an anchored mapping that add or remove a key reach its mergers A command that added a key to an anchored mapping (the first `agents:` block via `target base --agent-mode copy`) made relinkMerge refuse the merge source: the merging mapping's pre-edit data lacked the key, which was read as "the command removed it". The merge key was dropped and the merger written out expanded, so later edits of the anchor no longer reached it. A source is now refused only when the merging mapping had a key before the write and the command removed it. A key the source gained does not count. The symmetric case is fixed with it: a key removed from the anchored mapping stayed written out under a merger that still held the old merged value. An unedited key that the merger did not set itself now follows the source that gave it, whatever that source now says (a changed value, a removed key, or the next source of `<<: [*a, *b]`). A key the merger set itself, or that the command edited, stays written out. Tests cover add, remove and change of a key on the anchored mapping and on the merging mapping, a key from either source of a merge list, nested merges, projects, project-config target items and chained merges. Runbook step 11 covers the real binary. * fix(config): keep every comment when a write relinks merge keys and aliases Rewriting a merge key replaced the original merge items and covered keys with new nodes and carried over only the comments of the key and the list itself, so a comment on an item of `<<:` followed by `- *a # note` was lost on any write, and so was the trailing comment of a removed key when the mapping was left with keys the merge supplies. Comments now follow the entry they were on: a merge item's to the alias that replaces it, those of an item that is no longer merged to the next item, and those of a key the merge supplies to the next key still written, or in front of the merge key when none is. The merge list keeps its flow or block style so item comments stay on their lines. Sweeping the rest of the relink paths for the same loss found more places where yaml.v3 drops or moves a comment: the comment after an anchor on a block mapping collided with its first key's comment, a line comment on a block collection or on a key with an empty value is not written, and an anchored collection's head comment moved on the next write. These are settled once on the written tree, and the body of an inline merge source gets its comments paired too.