c783fff040
Aggiunge la generazione di documenti Word coerenti con l'identità
visiva Tielogic, in parallelo al render PDF già esistente. Il flusso
completo è ora `bullet input → Markdown formattato → PDF e/o DOCX`
in una singola chiamata MCP.
- docx_renderer.py: subprocess Pandoc che legge il Markdown da stdin,
emette il binario .docx su stdout. Strippa il YAML frontmatter e i
blocchi `<style>` (presenti per il PDF, irrilevanti in DOCX) prima
della conversione.
- mcp_tools.py: nuovo tool `document_to_docx(markdown)` che ritorna
`{docx_b64, size_bytes}`; `document_generate` esteso con
`output_format ∈ {md, pdf, docx, all}`. La firma di
`build_mcp_server` accetta ora `docx_reference_path` opzionale.
- config.py: `Settings.docx_reference_path` (default
/app/themes/tielogic-reference.docx).
- main.py: passa la nuova setting a `build_mcp_server`.
- mcp-docugen.Dockerfile: installazione di pandoc accanto alle libs
Chromium.
- themes/tielogic-reference.docx: reference Word (10 KB) con stili
Tielogic — heading colors blu/dark, font Inter, dimensioni allineate
al CSS web. Generato da `scripts/build-reference-docx.py` che parte
dal reference.docx di default di Pandoc e riscrive `word/styles.xml`
con regex sui blocchi `<w:style>`. Pandoc lo applica in automatico
agli output DOCX prodotti dal servizio.
- 9 nuovi test unit per docx_renderer (strip frontmatter/style,
preprocess combinato, error empty input, smoke skippato in
ambienti senza Pandoc): 92 test totali.
Smoke E2E via MCP: una sola chiamata `document_generate` con
`output_format=all` produce MD (14 KB), PDF (137 KB, 4 pagine A4) e
DOCX (12.7 KB) coerenti tra loro.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
43 lines
1.4 KiB
Docker
43 lines
1.4 KiB
Docker
ARG BASE_TAG=latest
|
|
|
|
FROM arca-base:${BASE_TAG} AS builder
|
|
COPY services/mcp-docugen ./services/mcp-docugen
|
|
COPY themes ./themes
|
|
RUN uv sync --frozen --no-dev --package mcp-docugen
|
|
|
|
FROM python:3.11-slim AS runtime
|
|
LABEL org.opencontainers.image.source="https://git.tielogic.xyz/Adriano/ArcaSuite" \
|
|
arca.service="mcp-docugen"
|
|
|
|
WORKDIR /app
|
|
COPY --from=builder /app /app
|
|
ENV PATH="/app/.venv/bin:$PATH"
|
|
|
|
# Chromium runtime libs + Playwright browser bundle for PDF rendering;
|
|
# Pandoc for DOCX rendering.
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
ca-certificates wget xdg-utils \
|
|
libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 \
|
|
libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 \
|
|
libgbm1 libasound2 libatspi2.0-0 libpangocairo-1.0-0 \
|
|
libpango-1.0-0 libcairo2 libgtk-3-0 fonts-liberation fonts-inter \
|
|
pandoc \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
ENV PLAYWRIGHT_BROWSERS_PATH=/opt/ms-playwright
|
|
RUN python -m playwright install chromium
|
|
|
|
RUN useradd -m -u 1000 app && \
|
|
mkdir -p /data && chown app:app /data && \
|
|
chown -R app:app /opt/ms-playwright
|
|
USER app
|
|
VOLUME ["/data"]
|
|
|
|
ENV HOST=0.0.0.0 PORT=9100 DATA_DIR=/data
|
|
EXPOSE 9100
|
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --retries=3 --start-period=15s \
|
|
CMD python -c "import httpx, os; httpx.get(f'http://localhost:{os.environ.get(\"PORT\",\"9100\")}/health').raise_for_status()"
|
|
|
|
CMD ["mcp-docugen"]
|