diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..796e108 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +.venv/ +storage/ +.claude-data/ +frontend/node_modules/ +frontend/dist/ +frontend/mock/ +__pycache__/ +.env +.git/ diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..e4e810b --- /dev/null +++ b/.env.example @@ -0,0 +1,5 @@ +# Auth für die Agenten im Container (eines von beiden): +# Token aus `claude setup-token` (Claude-Abo) +CLAUDE_CODE_OAUTH_TOKEN= +# oder ein API-Key +ANTHROPIC_API_KEY= diff --git a/.gitignore b/.gitignore index 757393e..16541d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .venv/ storage/ +.claude-data/ frontend/node_modules/ frontend/dist/ __pycache__/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9eed20f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +# Stage 1: Frontend bauen +FROM node:20-alpine AS frontend +WORKDIR /build +COPY frontend/package.json frontend/package-lock.json ./ +RUN npm ci +COPY frontend/ ./ +RUN npm run build + +# Stage 2: Laufzeit (die Claude-Code-CLI bringt das SDK als Binary mit, Node ist nicht nötig) +FROM python:3.12-slim + +RUN apt-get update && apt-get install -y --no-install-recommends \ + git curl ca-certificates unzip \ + libpango-1.0-0 libpangoft2-1.0-0 libharfbuzz0b libcairo2 libgdk-pixbuf-2.0-0 libffi8 fonts-dejavu \ + && rm -rf /var/lib/apt/lists/* + +RUN useradd -m -u 1000 app +WORKDIR /app +COPY backend/requirements.txt backend/requirements.txt +RUN pip install --no-cache-dir -r backend/requirements.txt + +COPY backend/ backend/ +COPY prompts/ prompts/ +COPY API.md README.md ./ +COPY --from=frontend /build/dist frontend/dist +RUN mkdir -p storage && chown -R app:app /app + +USER app +ENV PYTHONUNBUFFERED=1 +EXPOSE 8020 +CMD ["python", "-m", "uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8020"] diff --git a/README.md b/README.md index 313fc69..fc42dea 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,18 @@ make build # Frontend bauen make run # http://localhost:8020 ``` -Auth: der Agent SDK nutzt den Claude-Code-Login des Rechners (oder ANTHROPIC_API_KEY, falls gesetzt). +Auth lokal: der Agent SDK nutzt den Claude-Code-Login des Rechners (oder ANTHROPIC_API_KEY, falls gesetzt). + +Produktion (Docker, Traefik-Netz `web`, https://buchwerk.marha.de): + +```bash +cp .env.example .env # CLAUDE_CODE_OAUTH_TOKEN eintragen (claude setup-token) oder ANTHROPIC_API_KEY +make prod # docker compose up -d --build +make logs / make stop +``` + +`storage/` und `.claude-data/` (Sitzungen der CLI) werden als Volumes eingebunden; die Claude-Code-CLI +liegt als Binary im SDK, Node wird im Container nicht gebraucht. Ablauf (backend/pipeline.py): Stufen seriell, innerhalb einer Stufe bis zu `PARALLEL` Agenten gleichzeitig. Jeder Agent arbeitet im Themenverzeichnis `storage//`; sein Abschlussbericht landet unter `berichte/` diff --git a/backend/requirements.txt b/backend/requirements.txt index 208daf5..d92feb3 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -3,3 +3,4 @@ fastapi uvicorn[standard] markdown pygments +weasyprint diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..da9da27 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,24 @@ +services: + buchwerk: + build: + context: . + container_name: buchwerk + restart: unless-stopped + environment: + - CLAUDE_CODE_OAUTH_TOKEN=${CLAUDE_CODE_OAUTH_TOKEN:-} + - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-} + networks: + - web + volumes: + - ./storage:/app/storage + - ./.claude-data:/home/app/.claude + labels: + - "traefik.enable=true" + - "traefik.http.routers.buchwerk.rule=Host(`buchwerk.marha.de`)" + - "traefik.http.routers.buchwerk.entrypoints=websecure" + - "traefik.http.routers.buchwerk.tls.certresolver=letsencrypt" + - "traefik.http.services.buchwerk.loadbalancer.server.port=8020" + +networks: + web: + external: true diff --git a/frontend/src/markdown.js b/frontend/src/markdown.js index 1b3e342..a625df2 100644 --- a/frontend/src/markdown.js +++ b/frontend/src/markdown.js @@ -44,5 +44,5 @@ export function render(text) { export function zeit(min) { const m = Math.max(1, Math.round(min)) - return m < 60 ? `~${m} min` : `~${Math.floor(m / 60)} h ${m % 60} min` + return m < 60 ? `~${m} min` : m % 60 ? `~${Math.floor(m / 60)} h ${m % 60} min` : `~${Math.floor(m / 60)} h` } diff --git a/frontend/src/style.css b/frontend/src/style.css index 80f26d1..0c0ea64 100644 --- a/frontend/src/style.css +++ b/frontend/src/style.css @@ -136,7 +136,7 @@ a.knopf { display: inline-block; text-decoration: none; line-height: normal; } .guide-nav .teil { margin: 14px 0 2px; font: 600 11px system-ui, sans-serif; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); } .lese { flex: 1; overflow-y: auto; background: var(--lese-bg); color: var(--lese-text); } -.buch { max-width: 68ch; margin: 0 auto; padding: 36px 28px 120px; font-family: "Charter", "Bitstream Charter", "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 1.125rem; line-height: 1.65; hyphens: auto; hyphenate-limit-chars: 8 4 4; } +.buch { max-width: 68ch; margin: 0 auto; padding: 36px 28px 120px; font-family: "Charter", "Bitstream Charter", "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 1.125rem; line-height: 1.65; hyphens: auto; } .buch h1 { font-size: 2rem; line-height: 1.2; margin: 0 0 10px; } .buch .untertitel { color: var(--lese-text); font-style: italic; font-size: 1.1rem; margin-bottom: 6px; } .buch .meta { color: var(--lese-dim); margin-bottom: 26px; font-size: 0.95rem; } @@ -148,15 +148,18 @@ a.knopf { display: inline-block; text-decoration: none; line-height: normal; } .buch h2 .badge { font: 11.5px system-ui, sans-serif; vertical-align: middle; margin-left: 10px; } .buch .kap-meta { color: var(--lese-dim); font-size: 0.85rem; margin-bottom: 14px; } .buch .kap-intro { color: var(--lese-text); margin-bottom: 24px; } -.buch h3 { font-size: 1.22rem; margin: 34px 0 4px; line-height: 1.3; scroll-margin-top: 16px; } +/* Abschnittstitel (aus dem Template) groß; Zwischenüberschriften aus dem Markdown (###/####) klein */ +.buch section > h3 { font-size: 1.38rem; margin: 44px 0 8px; line-height: 1.3; scroll-margin-top: 16px; } +.buch section div h3, .buch section div h4, .lm-screen div h3, .lm-screen div h4 { font-size: 1.02rem; margin: 28px 0 4px; line-height: 1.3; } +.buch section div h4, .lm-screen div h4 { font-style: italic; font-weight: 600; } .buch p { margin: 0 0 1em; } .buch ul, .buch ol { padding-left: 1.4em; margin: 0 0 1em; } .buch li { margin: 0.25em 0; } -.buch code { font-family: "SF Mono", Consolas, Menlo, monospace; font-size: 0.86em; background: var(--code-bg); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; } +.buch code { font-family: "SF Mono", Consolas, Menlo, monospace; font-size: 0.86em; background: color-mix(in srgb, var(--code-bg) 60%, transparent); padding: 0 4px; border-radius: 3px; overflow-wrap: anywhere; hyphens: manual; } .buch p, .buch li { overflow-wrap: anywhere; } -.buch pre { background: var(--code-bg); color: var(--code-fg); padding: 12px 14px; border-radius: 8px; overflow-x: auto; font-size: 0.86em; line-height: 1.5; } +.buch pre { background: var(--code-bg); color: var(--code-fg); padding: 12px 14px; border-radius: 8px; font-size: 0.86em; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; hyphens: manual; } .buch pre code { background: none; padding: 0; } -.buch table { border-collapse: collapse; margin: 0 0 1em; font-size: 0.92em; display: block; max-width: 100%; overflow-x: auto; } +.buch table { border-collapse: collapse; margin: 0 0 1em; font-size: 0.92em; display: block; max-width: 100%; overflow-x: auto; hyphens: manual; } .buch th, .buch td { border: 1px solid var(--lese-rand); padding: 4px 9px; text-align: left; } .buch .hinweis { background: var(--karte); border-radius: 6px; padding: 8px 12px; font-size: 0.85rem; color: var(--dim); font-family: system-ui, sans-serif; margin: 0 0 14px; } .buch .teil-titel { font: 600 0.78rem system-ui, sans-serif; letter-spacing: 0.1em; text-transform: uppercase; color: var(--lese-dim); margin: 40px 0 6px; } @@ -178,7 +181,7 @@ a.knopf { display: inline-block; text-decoration: none; line-height: normal; } .lm-kopf .balken i { display: block; height: 100%; background: var(--gruen); } .lm-kopf button { background: transparent; color: var(--lese-dim); font-size: 18px; padding: 2px 8px; } .lm-buehne { flex: 1; overflow-y: auto; } -.lm-screen { max-width: 66ch; margin: 0 auto; padding: 40px 28px 80px; font-family: "Charter", "Bitstream Charter", "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 1.15rem; line-height: 1.65; hyphens: auto; hyphenate-limit-chars: 8 4 4; } +.lm-screen { max-width: 66ch; margin: 0 auto; padding: 40px 28px 80px; font-family: "Charter", "Bitstream Charter", "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 1.15rem; line-height: 1.65; hyphens: auto; } .lm-label { font: 600 11.5px system-ui, sans-serif; letter-spacing: 0.08em; text-transform: uppercase; color: var(--lese-dim); margin-bottom: 8px; } .lm-screen h1 { font-size: 2.1rem; line-height: 1.2; margin: 0 0 12px; } .lm-screen h2 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 6px; } @@ -186,10 +189,10 @@ a.knopf { display: inline-block; text-decoration: none; line-height: normal; } .lm-screen .stats { color: var(--lese-dim); font: 13px system-ui, sans-serif; margin-top: 14px; } .lm-screen p { margin: 0 0 1em; } .lm-screen code { font-family: "SF Mono", Consolas, monospace; font-size: 0.86em; background: var(--code-bg); padding: 1px 5px; border-radius: 4px; } -.lm-screen pre { background: var(--code-bg); color: var(--code-fg); padding: 12px 14px; border-radius: 8px; overflow-x: auto; font-size: 0.86em; } +.lm-screen pre { background: var(--code-bg); color: var(--code-fg); padding: 12px 14px; border-radius: 8px; font-size: 0.86em; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; hyphens: manual; } .lm-screen pre code { background: none; padding: 0; } .lm-screen ul, .lm-screen ol { padding-left: 1.4em; } -.lm-screen table { border-collapse: collapse; margin: 0 0 1em; font-size: 0.92em; display: block; max-width: 100%; overflow-x: auto; } +.lm-screen table { border-collapse: collapse; margin: 0 0 1em; font-size: 0.92em; display: block; max-width: 100%; overflow-x: auto; hyphens: manual; } .lm-screen th, .lm-screen td { border: 1px solid var(--lese-rand); padding: 4px 9px; text-align: left; } .lm-screen.ende { text-align: center; padding-top: 120px; } .lm-fuss { display: flex; justify-content: space-between; padding: 10px 18px; border-top: 1px solid var(--lese-rand); font-family: system-ui, sans-serif; } @@ -207,10 +210,13 @@ kbd { font: 11px system-ui, sans-serif; border: 1px solid var(--rand); border-ra .sidebar:not(.offen) { display: none; } .burger { display: inline-block; } .guide-nav { display: none; } - .guide-nav.offen { display: block; position: fixed; inset: 0 auto 0 0; z-index: 25; width: 82vw; } + .guide-nav.offen { display: block; position: fixed; inset: 0 auto 0 0; z-index: 25; width: 82vw; font-size: 14.5px; } + .guide-nav.offen a.kap { padding: 10px 8px; } + .guide-nav.offen a.abs { padding: 8px 8px 8px 24px; } .buch { padding: 22px 16px 100px; font-size: 1.02rem; } .lm-screen { padding: 24px 16px 60px; font-size: 1.05rem; } .lm-kopf, .lm-fuss { padding: 8px 12px; } + .lm-fuss button { padding: 11px 18px; font-size: 15px; } .stufe { grid-template-columns: 26px 1fr; } .stufe .rechts { grid-column: 2; } .ereignis { grid-template-columns: 64px 1fr; }