feat(my-deepagent): v0.4 — workflow generator UI + hot-reload + UX polish

브라우저에서 YAML 안 쓰고도 새 워크플로우 템플릿 만들기 + 즉시 등록.
+ /new.html / index.html / new-workflow.html / runs.html / conversation.html
의 nav·copy·empty-state 정비.

A. /new.html UX:
- 제목 "새 Run" → "워크플로우 실행 (고급)"
- 상단 info-box: "자유 대화는 여기가 아닙니다 → 메인 페이지"
- 모든 필드에 한 줄 hint
- Persona 오버라이드 <details> 접힘

B. Nav 재정렬 (5 페이지):
- "대화" nav-primary, 나머지 nav-secondary (작고 dim)

C. 메인 안내 + CSS:
- 메인 / 에 "👋 my-deepagent" info-box 추가
- .info-box / .nav-primary / .nav-secondary / .wf-* 신규 스타일

D. Workflow hot-reload:
- api/deps.py get_workflows 가 매 요청 mtime 튜플 검사 후 변경 시 reload
- lifespan 도 user dir 포함하도록 _load_workflows_combined

E. Workflow generator:
- POST /api/workflows: CreateWorkflowRequest → WorkflowTemplate validate →
  <data_dir>/workflows/<name>@<version>.yaml 저장.  중복 409, validation 422.
- static/new-workflow.html: 기본 정보 / Roles / Phases / YAML preview
- app.js bootstrapWorkflowGenerator: capability chip 토글, role select 동적,
  실시간 YAML preview, XSS 정책 유지

테스트 (test_workflow_generator.py, 7 신규):
- 페이지 200 + 마크업
- POST happy / 422 (empty roles) / 422 (unknown role) / 409 (dup)
- GET hot-reload after POST
- GET hot-reload after external file drop

게이트:
- ruff / format / mypy: PASS (142 source files)
- pytest -q --ignore=tests/integration/test_e2e_workflow.py
  --ignore=tests/integration/test_openrouter_smoke.py: 709 passed (+7 신규)
- 라이브 smoke: / / new.html / new-workflow.html 모두 200, screenshot OK

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
chungyeong
2026-05-18 00:38:46 +09:00
parent 40ef833ad3
commit 6d371afadd
14 changed files with 1007 additions and 52 deletions

View File

@@ -3,6 +3,12 @@
Pulls singletons stashed in `app.state` by the lifespan handler. Database is
created ONCE per uvicorn process; per-request creation would defeat
connection pooling.
Workflows are different — they live in YAML files that the user can edit /
create at runtime via the workflow generator UI. `get_workflows` does a
cheap mtime check on every call and reloads when any file in the seed or
user workflow directory has changed. No file watcher / inotify needed —
the directories are tiny (≤ dozens of files) and stat is cheap.
"""
from __future__ import annotations
@@ -14,6 +20,7 @@ from fastapi import Request
from ..config import Config
from ..persistence.db import Database
from ..user_dirs import load_combined_workflows, user_workflows_dir
if TYPE_CHECKING:
from ..persona import Persona
@@ -36,9 +43,41 @@ def get_personas(request: Request) -> list[Persona]:
return request.app.state.personas # type: ignore[no-any-return]
def _workflow_dir_signature(config: Config) -> tuple[tuple[str, float], ...]:
"""Cheap mtime-tuple fingerprint of all YAMLs in seed + user dirs.
Two stat calls per file; the fingerprint changes when any file is
created / modified / deleted. Used as the cache key for
:func:`get_workflows` so the API picks up new templates without a
process restart.
"""
sig: list[tuple[str, float]] = []
for d in (_DOCS_SCHEMAS / "workflows", user_workflows_dir(config)):
if not d.is_dir():
continue
for p in sorted(d.glob("*.yaml")):
try:
sig.append((str(p), p.stat().st_mtime))
except OSError:
continue
return tuple(sig)
def get_workflows(request: Request) -> list[tuple[Path, WorkflowTemplate]]:
"""Return a list of (yaml_path, WorkflowTemplate) for all seed workflows."""
return request.app.state.workflows # type: ignore[no-any-return]
"""Return (path, template) list with mtime-based hot-reload.
On every request, computes the mtime fingerprint of the workflow dirs.
If it differs from the cached signature, calls
:func:`load_combined_workflows` again to pick up new / edited files.
"""
app = request.app
config: Config = app.state.config
current_sig = _workflow_dir_signature(config)
cached_sig: tuple[tuple[str, float], ...] | None = getattr(app.state, "workflows_sig", None)
if cached_sig != current_sig:
app.state.workflows = load_combined_workflows(config, _DOCS_SCHEMAS / "workflows")
app.state.workflows_sig = current_sig
return app.state.workflows # type: ignore[no-any-return]
def seed_root() -> Path: