127 lines
5.1 KiB
Python
127 lines
5.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Phase-21: undo-stack, snippets, smart-rounding, color-coded-rows, templates-page."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import asyncio, datetime, json, sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
from phase2_features import Feature, FileGen, ROOT, log, log_section
|
|
from phase3_features import run_feature_v2
|
|
|
|
PHASE_STATE = ROOT / ".phase21-state.json"
|
|
|
|
FEATURES: list[Feature] = [
|
|
Feature(
|
|
name="keyboard-undo-stack",
|
|
description="Ctrl+Z für letzte delete-Action (in-memory undo-stack)",
|
|
files=[FileGen(
|
|
path="apps/web/src/components/UndoStack.tsx",
|
|
purpose=(
|
|
"UndoStack-Component (global). useEffect window keydown ctrl+z (oder cmd+z). "
|
|
"Maintains array of {description, undoFn}. Bei trigger: poppt letzte und ruft undoFn. "
|
|
"Export auch useUndoStack() hook für andere Components zum push()."
|
|
),
|
|
)],
|
|
),
|
|
Feature(
|
|
name="snippet-shortcuts",
|
|
description="Snippet-Expander: ';daily' → 'Daily standup', ';mtg' → 'Meeting'",
|
|
files=[FileGen(
|
|
path="apps/web/src/components/SnippetInput.tsx",
|
|
purpose=(
|
|
"Drop-in-Input mit snippet-expansion. Snippets-map inline: {';daily':'Daily standup', "
|
|
"';mtg':'Meeting', ';review':'Code review', ';bug':'Bugfix '}. "
|
|
"Auf input-change: ersetze trailing ;keyword durch expansion. Props: value, onChange, ...rest."
|
|
),
|
|
)],
|
|
),
|
|
Feature(
|
|
name="smart-rounding-on-input",
|
|
description="Bei Time-Entry-Submit: round endTime auf appSettings.roundingMinutes",
|
|
files=[FileGen(
|
|
path="apps/web/src/pages/TimeEntries.tsx",
|
|
purpose=(
|
|
"ERWEITERT — behalte alles. Im handleSubmit: vor mutate, runde endTime auf nächste roundingMinutes (aus api.getSettings(), useQuery cache'd). "
|
|
"Wenn rounding=0: kein rounding. Toast info nach Rundung 'Auf 15min gerundet'."
|
|
),
|
|
refs=["apps/web/src/pages/TimeEntries.tsx"],
|
|
)],
|
|
),
|
|
Feature(
|
|
name="color-coded-customer-rows",
|
|
description="Customer-Rows mit Hash-basierter Pastell-Background-Color",
|
|
files=[FileGen(
|
|
path="apps/web/src/pages/Customers.tsx",
|
|
purpose=(
|
|
"ERWEITERT — behalte alles. Pro Customer-Row left-border-Color basierend auf hash(name) modulo palette "
|
|
"['border-l-4 border-rose-300', 'border-l-4 border-amber-300', 'border-l-4 border-emerald-300', "
|
|
"'border-l-4 border-sky-300', 'border-l-4 border-violet-300']."
|
|
),
|
|
refs=["apps/web/src/pages/Customers.tsx"],
|
|
)],
|
|
),
|
|
Feature(
|
|
name="time-entry-templates-page",
|
|
description="UI-Page für TimeEntry-Templates CRUD",
|
|
files=[FileGen(
|
|
path="apps/web/src/pages/TimeEntryTemplates.tsx",
|
|
purpose=(
|
|
"TimeEntryTemplates-Page. Liste + Create-Form (name, description, projectId optional, defaultDurationMinutes optional). "
|
|
"Verwende api.listTimeEntryTemplates() / createTimeEntryTemplate() / deleteTimeEntryTemplate()."
|
|
),
|
|
refs=["apps/web/src/pages/Customers.tsx"],
|
|
)],
|
|
),
|
|
Feature(
|
|
name="router-phase21",
|
|
description="Mount /templates Route + Nav-Link + UndoStack global",
|
|
files=[
|
|
FileGen(
|
|
path="apps/web/src/App.tsx",
|
|
purpose="ERWEITERT — füge /time-entry-templates Route + mount <UndoStack /> global. Behalte alles.",
|
|
refs=["apps/web/src/App.tsx"],
|
|
),
|
|
FileGen(
|
|
path="apps/web/src/components/Nav.tsx",
|
|
purpose="ERWEITERT — füge Templates-Link in Nav. Behalte alles.",
|
|
refs=["apps/web/src/components/Nav.tsx"],
|
|
),
|
|
],
|
|
),
|
|
]
|
|
|
|
|
|
def load_state():
|
|
if PHASE_STATE.exists():
|
|
return json.loads(PHASE_STATE.read_text())
|
|
return {"completed_features": [], "current_feature": None, "started_at": datetime.datetime.now().isoformat()}
|
|
|
|
|
|
def save_state(state):
|
|
PHASE_STATE.write_text(json.dumps(state, indent=2))
|
|
|
|
|
|
async def main():
|
|
log_section("🚀 Phase-21 Codegen-Run gestartet")
|
|
state = load_state()
|
|
for feature in FEATURES:
|
|
if feature.name in state.get("completed_features", []):
|
|
continue
|
|
state["current_feature"] = feature.name; save_state(state)
|
|
try:
|
|
success = await run_feature_v2(feature)
|
|
(state.setdefault("completed_features" if success else "attempted_features", [])).append(feature.name)
|
|
save_state(state)
|
|
except Exception as e:
|
|
log(f"❌ {feature.name} crashed: {e}", level="ERROR")
|
|
state.setdefault("attempted_features", []).append(feature.name); save_state(state)
|
|
log_section("Phase-21 Run beendet")
|
|
log(f"OK: {len(state.get('completed_features', []))}, Attempted: {len(state.get('attempted_features', []))}, Total: {len(FEATURES)}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(asyncio.run(main()))
|