163 lines
10 KiB
Python
163 lines
10 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
create_and_fix.py — Phase 2+3 der Review-Plane-Operation. IDEMPOTENT, default DRY-RUN, scharf: --apply
|
|
P2: neue David-Screen-Tickets anlegen (+ Cycle + Module David + Doc-Link) — nur was fehlt.
|
|
P3: Bündel auflösen (VD-2/3/4 rename→VD-P26/27/29; D-REST/VD-1/VD-5 cancel),
|
|
AK-P1c→R-P1c (rename+Owner+Module), Fixes (R-P8a Name, EXT-04 KWP-Nr, R-REFIT→Done).
|
|
"""
|
|
import json, os, re, sys, time, urllib.request, urllib.error
|
|
APPLY = "--apply" in sys.argv
|
|
TOK = {}
|
|
for line in open(os.path.expanduser("~/.cli-tokens/plane")):
|
|
line = line.strip()
|
|
if "=" in line and not line.startswith("#"):
|
|
k, v = line.split("=", 1); TOK[k.strip()] = v.strip()
|
|
BASE = TOK["PLANE_BASE_URL"].rstrip("/"); WS = TOK["PLANE_WORKSPACE"]; KEY = TOK["PLANE_API_KEY"]
|
|
PID = "35d0d968-8ab3-40cc-97b8-b81d917dc5df"
|
|
API = f"{BASE}/api/v1/workspaces/{WS}/projects/{PID}"
|
|
DOC = "https://git.tool-ctrl.de/toolctrl-labs/HiveGrid-Cloud/src/branch/main/.planning/ticket-docs/"
|
|
BRF = "https://git.tool-ctrl.de/toolctrl-labs/HiveGrid-Cloud/src/branch/main/.planning/designer-briefs/"
|
|
DAVID = "6c1fc63f-133d-4f40-86e4-7f658a6edcc7"; RAFFAEL = "8e34a88c-19c9-4565-b4f5-50415d623ce8"
|
|
bk = json.load(open(".planning/plane-sync/plane-backup-review.json"))
|
|
M = bk["meta"]
|
|
CYC = M["cycles"]; MOD = M["modules"]; ST = M["states"]; LB = M["labels"]
|
|
def A(cls, href, txt): return f'<a target="_blank" class="text-accent-secondary underline underline-offset-[3px] hover:text-accent-primary transition-colors cursor-pointer" href="{href}" rel="noopener noreferrer">{txt}</a>'
|
|
|
|
def http(method, path, body=None):
|
|
data = json.dumps(body).encode() if body is not None else None
|
|
r = urllib.request.Request(API + path, data=data, method=method)
|
|
r.add_header("X-API-Key", KEY)
|
|
if data: r.add_header("Content-Type", "application/json")
|
|
for _ in range(4):
|
|
try:
|
|
with urllib.request.urlopen(r, timeout=30) as resp:
|
|
raw = resp.read().decode(); return resp.status, (json.loads(raw) if raw else {})
|
|
except urllib.error.HTTPError as e:
|
|
if e.code == 429: time.sleep(5); continue
|
|
return e.code, {}
|
|
return 999, {}
|
|
|
|
def get_all(path):
|
|
out, c = [], None
|
|
while True:
|
|
st, d = http("GET", path + (("?per_page=100&cursor=" + c) if c else "?per_page=100"))
|
|
if st >= 400: break
|
|
if isinstance(d, list): out += d; break
|
|
out += d.get("results", [])
|
|
if d.get("next_page_results") and d.get("next_cursor"): c = d["next_cursor"]
|
|
else: break
|
|
return out
|
|
|
|
# aktueller Stand → Working-ID → issue
|
|
cur = get_all("/issues/")
|
|
wid2 = {re.split(r'\s*·\s*', i["name"])[0].strip(): i for i in cur}
|
|
|
|
def desc(wid, brief, blockedby, blocks, owner, fenster):
|
|
parts = ["<div><p><b>📚 Doku</b><br>",
|
|
A("", DOC + wid + ".md", f"📄 Ticket-Doku ({wid})"), "<br>"]
|
|
if brief: parts += [A("", BRF + brief + ".md", f"🎨 Designer-Brief {brief[:3]}"), "<br>"]
|
|
parts += [A("", "https://git.tool-ctrl.de/toolctrl-labs/HiveGrid-Cloud/src/branch/main/.planning/ENTITY-MODEL.md", "ENTITY-MODEL.md"), "</p>"]
|
|
parts += [f"<p><b>⛔ blocked-by:</b> {blockedby}<br><b>➡️ blocks:</b> {blocks}<br>",
|
|
f"<b>👤 Owner:</b> {owner} · <b>🗓 Fenster:</b> {fenster}</p>",
|
|
"<p><b>✅ Screens / Features / DoD:</b> siehe Ticket-Doku (oben).</p></div>"]
|
|
return "".join(parts)
|
|
|
|
# NEW: (wid, titel, brief, cycle, target, v2, blocks)
|
|
NEW = [
|
|
("D-P2","Screens P2 — Identität & Mandantentrennung","P02-identitaet-mandantentrennung","W1","2026-06-21",0,"R-P2a,R-P2b"),
|
|
("D-P3","Screens P3 — Querschnitts-Oberflächen","P03-querschnitts-oberflaechen","W2","2026-06-21",0,"AK-P3"),
|
|
("D-P4","Screens P4 — Files & Tasks","P04-files-tasks","W1","2026-06-19",0,"AK-P4a,AK-P4b"),
|
|
("D-P5","Screens P5 — Apps-Engine","P05-apps-engine-integrations-framework","W2","2026-06-21",0,"R-P5"),
|
|
("D-P7","Screens P7 — Lead-Inbox","P07-lead-inbox","W2","2026-06-26",0,"R-P7"),
|
|
("D-P8","Screens P8 — Projekt & Pipelines (Kern, ohne Kanban)","P08-projekt-pipelines-kern","W3","2026-06-29",0,"R-P8a,R-P8b"),
|
|
("D-P9","Screens P9 — Auftrags-Sub-Areas (ohne Plantafel/Abnahme)","P09-projekt-pipelines-auftrag","W3","2026-07-01",0,"R-P9a,R-P9b"),
|
|
("D-P12","Screens P12 — Automation (ohne Flow-Editor)","P12-automation-engine","W4","2026-07-07",0,"R-P12a,R-P12b"),
|
|
("D-P13","Screens P13 — KI-Layer (ex-D-REST)","P13-ki-layer","W4","2026-07-09",0,"R-P13"),
|
|
("D-P14","Screens P14 — Email & Marketing (ohne Kampagnen-Editor)","P14-email-marketing","W3","2026-06-29",0,"AK-P14a,AK-P14b"),
|
|
("D-P15","Screens P15 — Telefonie (ohne Chat)","P15-telefonie-chat","W3","2026-07-01",0,"AK-P15a"),
|
|
("D-P16","Screens P16 — Kalender/Signatur (ohne Form/Booking)","P16-kalender-booking-forms-signatur","W4","2026-07-07",0,"AK-P16a,AK-P16d"),
|
|
("D-P20","Screens P20 — Billing/Onboarding/Branding (ex-D-REST)","P20-billing-onboarding-branding","W4","2026-07-08",0,"AK-P20"),
|
|
("D-P21","Screens P21 — DSGVO/Launch (ex-D-REST)","P21-dsgvo-launch","W4","2026-07-09",0,"AK-P21"),
|
|
("VD-P22","Screens P22 — Public-API-Keys (ex-VD-5)","P22-public-api-webhooks","v2W1","2026-07-17",1,"VR-P22a,VR-P22b"),
|
|
("VD-P23","Screens P23 — Postfach-Inbox (ex-VD-1)","P23-postfach-sync","v2W1","2026-07-17",1,"VA-P23"),
|
|
("VD-P24","Screens P24 — Abo-Baukasten + Wizard (ex-VD-1)","P24-self-service-billing-wizard","v2W1","2026-07-15",1,"VA-P24a,VA-P24b"),
|
|
("VD-P25","Screens P25 — KI-Tiefe/HiveMind","P25-ki-tiefe-hivemind-rag","v2W1","2026-07-20",1,"VR-P25"),
|
|
("VD-P28","Screens P28 — Plattform-Admin-Tiefe (ex-VD-5)","P28-plattform-admin-tiefe","v2W3","2026-07-29",1,"VR-P28a,VA-P28b"),
|
|
("VD-P30","Screens P30 — Dashboard-Deluxe","P30-dashboard-deluxe-querschnitt","v2W3","2026-07-30",1,"VA-P30a,VA-P30b"),
|
|
("VD-P31","Screens P31 — DSGVO-Vollausbau","P31-dsgvo-vollausbau","v2W3","2026-07-31",1,"VR-P31"),
|
|
("VD-P32","Screens P32 — KWP-Setup (ex-VD-5)","P32-kwp-integration","v2W2","2026-07-22",1,"VR-P32a,VR-P32b,VR-P32c"),
|
|
]
|
|
CYK = {"W1":"W1 — Fundament & Identität","W2":"W2 — Plattform & CRM (Demo 1)","W3":"W3 — Kern-Kette & Kommunikation (Demo 2)","W4":"W4 — USP, Härtung & Launch","v2W1":"v2-W1 — Public-API/Postfach/Abo/KI-Start","v2W2":"v2-W2 — KWP/Portal/Mobile-Start","v2W3":"v2-W3 — Admin/Help/Dashboard/v2-Launch"}
|
|
|
|
created = skipped = 0
|
|
print(f"=== Phase 2 NEUE Tickets {'(SCHARF)' if APPLY else '(DRY-RUN)'} ===")
|
|
for wid, titel, brief, cyc, tgt, v2, blocks in NEW:
|
|
if wid in wid2:
|
|
skipped += 1; continue
|
|
name = f"{wid} · {titel}"
|
|
labels = [LB["typ:screen"]] + ([LB["v2"]] if v2 else [])
|
|
body = {"name": name, "description_html": desc(wid, brief, "D-D0a, D-D0b", blocks, "david", CYK[cyc].split(" — ")[0]),
|
|
"state": ST.get("Backlog"), "assignees": [DAVID], "labels": labels, "target_date": tgt}
|
|
if not APPLY:
|
|
print(f" + {wid:8} [{cyc}] → {titel[:40]}"); created += 1; continue
|
|
st, d = http("POST", "/issues/", body); time.sleep(1.1)
|
|
if st < 300 and d.get("id"):
|
|
iid = d["id"]
|
|
http("POST", f"/cycles/{CYC[CYK[cyc]]}/cycle-issues/", {"issues": [iid]}); time.sleep(1.0)
|
|
http("POST", f"/modules/{MOD['David (Screens)']}/module-issues/", {"issues": [iid]}); time.sleep(1.0)
|
|
print(f" ✓ angelegt {wid}"); created += 1
|
|
else:
|
|
print(f" ✗ {wid}: HTTP {st}")
|
|
print(f"angelegt: {created} | schon vorhanden (skip): {skipped}")
|
|
|
|
# ---- Phase 3 ----
|
|
def add_doclink(html, wid):
|
|
if f"ticket-docs/{wid}.md" in html: return html
|
|
link = A("", DOC + wid + ".md", f"📄 Ticket-Doku ({wid})") + "<br>"
|
|
return re.sub(r'(📚 Doku</(?:b|strong)><br\s*/?>)', lambda m: m.group(1) + link, html, count=1)
|
|
|
|
RENAME = [("VD-2","VD-P26","Screens P26 — Customer-Portal"),
|
|
("VD-3","VD-P27","Screens P27 — Mobile-PWA-Shell (PWA-only)"),
|
|
("VD-4","VD-P29","Screens P29 — Help-Center")]
|
|
CANCEL = [("D-REST","aufgelöst → D-P13/D-P20/D-P21"),
|
|
("VD-1","aufgelöst → VD-P23/VD-P24"),
|
|
("VD-5","aufgelöst → VD-P22/VD-P28/VD-P32")]
|
|
print(f"\n=== Phase 3 Rename/Cancel/Fix {'(SCHARF)' if APPLY else '(DRY-RUN)'} ===")
|
|
def pat(wid, body, note):
|
|
i = wid2.get(wid)
|
|
if not i: print(f" ⚠ {wid} nicht gefunden"); return
|
|
print(f" ~ {wid}: {note}")
|
|
if APPLY:
|
|
st, _ = http("PATCH", f"/issues/{i['id']}/", body); time.sleep(1.1)
|
|
if st >= 300: print(f" ✗ HTTP {st}")
|
|
|
|
for old, new, titel in RENAME:
|
|
i = wid2.get(old)
|
|
if i: pat(old, {"name": f"{new} · {titel}", "description_html": add_doclink(i["description_html"], new)}, f"rename → {new}")
|
|
for wid, note in CANCEL:
|
|
i = wid2.get(wid)
|
|
if i:
|
|
nm = i["name"] if "aufgelöst" in i["name"] else i["name"] + f" ({note})"
|
|
pat(wid, {"name": nm, "state": ST["Cancelled"]}, f"CANCEL ({note})")
|
|
# AK-P1c → R-P1c (rename + Owner Raffael + Module-Wechsel)
|
|
i = wid2.get("AK-P1c")
|
|
if i:
|
|
nm = "R-P1c · " + re.split(r'\s*·\s*', i["name"], maxsplit=1)[1] if "·" in i["name"] else "R-P1c · P1 Hot-Swap-Maschine + Walking-Skeleton + PWA"
|
|
pat("AK-P1c", {"name": nm, "assignees": [RAFFAEL], "description_html": add_doclink(i["description_html"].replace("AK-P1c","R-P1c"), "R-P1c")}, "→ R-P1c (Owner Raffael)")
|
|
if APPLY:
|
|
http("POST", f"/modules/{MOD['Raffael (Dev)']}/module-issues/", {"issues": [i["id"]]}); time.sleep(1.0)
|
|
http("DELETE", f"/modules/{MOD['Akeshan (Dev)']}/module-issues/{i['id']}/"); time.sleep(1.0)
|
|
# R-P8a Name-Fix (Deal→Projekt)
|
|
i = wid2.get("R-P8a")
|
|
if i and "Deal-CRUD" in i["name"]:
|
|
pat("R-P8a", {"name": i["name"].replace("Deal-CRUD", "Projekt-CRUD")}, "Name Deal-CRUD→Projekt-CRUD")
|
|
# EXT-04 KWP-Nummer
|
|
i = wid2.get("EXT-04")
|
|
if i and "v2-P10" in i["description_html"]:
|
|
pat("EXT-04", {"description_html": i["description_html"].replace("v2-P10", "P32 (v2)")}, "KWP-Nummer v2-P10→P32")
|
|
# R-REFIT → Done
|
|
i = wid2.get("R-REFIT")
|
|
if i and i["state"] != ST["Done"]:
|
|
pat("R-REFIT", {"state": ST["Done"]}, "→ Done (erledigt 16.06.)")
|
|
print("\n" + ("✅ Phase 2+3 scharf ausgeführt." if APPLY else "→ scharf: python3 .planning/plane-sync/create_and_fix.py --apply"))
|