@clipboard-health/ai-rules 2.29.2 → 2.29.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Rename Hex cells via the cellId-swap pattern.
4
+
5
+ `cellLabel` is treated as immutable by Hex's YAML import — changing it in-place is
6
+ silently ignored. The workaround: assign each renamed cell a fresh UUID v7, drop the
7
+ old cellId entry, and rewrite every appLayout reference to point at the new ID.
8
+
9
+ Usage:
10
+ 1. hex project export <project_id> -o exported.yaml
11
+ 2. Edit the RENAMES dict below.
12
+ 3. python3 rename_cells.py exported.yaml renamed.yaml
13
+ 4. hex project import renamed.yaml
14
+ """
15
+ import os
16
+ import sys
17
+ import time
18
+ import uuid
19
+
20
+ import yaml
21
+
22
+
23
+ RENAMES = {
24
+ # "Old Cell Label": "New Cell Label",
25
+ }
26
+
27
+
28
+ def uuidv7():
29
+ ts_ms = int(time.time() * 1000)
30
+ rand = os.urandom(10)
31
+ b = bytearray(16)
32
+ b[0] = (ts_ms >> 40) & 0xFF
33
+ b[1] = (ts_ms >> 32) & 0xFF
34
+ b[2] = (ts_ms >> 24) & 0xFF
35
+ b[3] = (ts_ms >> 16) & 0xFF
36
+ b[4] = (ts_ms >> 8) & 0xFF
37
+ b[5] = ts_ms & 0xFF
38
+ b[6] = (0x70 | (rand[0] & 0x0F)) & 0xFF
39
+ b[7] = rand[1]
40
+ b[8] = (0x80 | (rand[2] & 0x3F)) & 0xFF
41
+ b[9:16] = rand[3:10]
42
+ return str(uuid.UUID(bytes=bytes(b)))
43
+
44
+
45
+ def main(in_path, out_path):
46
+ with open(in_path) as f:
47
+ doc = yaml.safe_load(f)
48
+
49
+ id_swap = {} # old_id -> new_id
50
+ new_cells = []
51
+
52
+ # First pass: emit non-renamed cells as-is. Renamed cells get appended at the end
53
+ # with the new cellId + cellLabel.
54
+ for c in doc["cells"]:
55
+ if c.get("cellLabel") in RENAMES:
56
+ old_id = c["cellId"]
57
+ new_id = uuidv7()
58
+ id_swap[old_id] = new_id
59
+ renamed = dict(c)
60
+ renamed["cellId"] = new_id
61
+ renamed["cellLabel"] = RENAMES[c["cellLabel"]]
62
+ new_cells.append(renamed)
63
+ print(f" {c['cellLabel']} → {RENAMES[c['cellLabel']]} (cellId {old_id} → {new_id})")
64
+ else:
65
+ new_cells.append(c)
66
+
67
+ doc["cells"] = new_cells
68
+
69
+ # Rewrite every appLayout element that referenced an old cellId
70
+ for tab in doc.get("appLayout", {}).get("tabs", []):
71
+ for row in tab.get("rows", []):
72
+ for col in row.get("columns", []):
73
+ for el in col.get("elements", []):
74
+ if el.get("cellId") in id_swap:
75
+ el["cellId"] = id_swap[el["cellId"]]
76
+
77
+ with open(out_path, "w") as f:
78
+ yaml.safe_dump(doc, f, allow_unicode=True, width=4096, sort_keys=False)
79
+
80
+ print(f"\nWrote {out_path}. Renamed {len(id_swap)} cells.")
81
+ print("Run: hex project import " + out_path)
82
+
83
+
84
+ if __name__ == "__main__":
85
+ if len(sys.argv) < 3:
86
+ print("Usage: rename_cells.py <in.yaml> <out.yaml>")
87
+ sys.exit(1)
88
+ main(sys.argv[1], sys.argv[2])