@blackbelt-technology/pi-dashboard-document-converter 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.pi/skills/document-converter/SKILL.md +79 -0
- package/README.md +106 -0
- package/engine/.dockerignore +4 -0
- package/engine/Dockerfile +75 -0
- package/engine/IMAGE_VERSION +1 -0
- package/engine/README.md +65 -0
- package/engine/VENDOR.md +40 -0
- package/engine/build-image.sh +29 -0
- package/engine/document_converter/LICENSE +21 -0
- package/engine/document_converter/__init__.py +365 -0
- package/engine/document_converter/__main__.py +5 -0
- package/engine/document_converter/asciidoc_converter.py +534 -0
- package/engine/document_converter/cli.py +751 -0
- package/engine/document_converter/code_renderer.py +356 -0
- package/engine/document_converter/converter.py +928 -0
- package/engine/document_converter/cover_page.py +448 -0
- package/engine/document_converter/diagram_resizer.py +311 -0
- package/engine/document_converter/diagram_sizing.py +357 -0
- package/engine/document_converter/docx_reader.py +627 -0
- package/engine/document_converter/field_updater.py +277 -0
- package/engine/document_converter/font_manager.py +850 -0
- package/engine/document_converter/frontmatter_parser.py +644 -0
- package/engine/document_converter/graphviz_renderer.py +354 -0
- package/engine/document_converter/image_extractor.py +281 -0
- package/engine/document_converter/image_style.py +237 -0
- package/engine/document_converter/logo_manager.py +1021 -0
- package/engine/document_converter/manifest_manager.py +288 -0
- package/engine/document_converter/mermaid_renderer.py +371 -0
- package/engine/document_converter/meta_mapper.py +398 -0
- package/engine/document_converter/pandoc_styles.py +222 -0
- package/engine/document_converter/pdf_converter.py +735 -0
- package/engine/document_converter/pdf_server.py +283 -0
- package/engine/document_converter/plantuml_renderer.py +460 -0
- package/engine/document_converter/plantuml_server.py +273 -0
- package/engine/document_converter/pyproject.toml +80 -0
- package/engine/document_converter/round_trip.py +312 -0
- package/engine/document_converter/spacing_applier.py +332 -0
- package/engine/document_converter/spacing_config.py +323 -0
- package/engine/document_converter/style_extractor.py +420 -0
- package/engine/document_converter/svg_embedder.py +294 -0
- package/engine/document_converter/system_variables.py +158 -0
- package/engine/document_converter/table_formatter.py +450 -0
- package/engine/document_converter/template_extractor.py +1334 -0
- package/engine/document_converter/template_manager.py +427 -0
- package/engine/document_converter/textbox_extractor.py +551 -0
- package/engine/document_converter/toc_generator.py +559 -0
- package/engine/document_converter/toc_style.py +290 -0
- package/engine/document_converter/tree_renderer.py +328 -0
- package/engine/document_converter/utils.py +134 -0
- package/engine/document_converter/variable_manager.py +394 -0
- package/engine/engine_cli.py +371 -0
- package/engine/frontmatter_filler/doc-meta.sample.yaml +106 -0
- package/engine/frontmatter_filler/fill.py +517 -0
- package/engine/markdown_table_profiler/profile.py +442 -0
- package/engine/nano-banana-styles.yaml +59 -0
- package/engine/tests/test_styled_diagrams.py +109 -0
- package/package.json +32 -0
- package/src/__tests__/engine.test.ts +72 -0
- package/src/__tests__/facade.test.ts +120 -0
- package/src/__tests__/integration.test.ts +101 -0
- package/src/__tests__/ocr.test.ts +34 -0
- package/src/__tests__/provenance.test.ts +89 -0
- package/src/__tests__/routing.test.ts +40 -0
- package/src/engine.ts +187 -0
- package/src/errors.ts +43 -0
- package/src/index.ts +179 -0
- package/src/ocr.ts +43 -0
- package/src/provenance.ts +79 -0
- package/src/routing.ts +49 -0
- package/src/schema.json +69 -0
- package/src/schema.ts +107 -0
- package/src/types.ts +90 -0
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""pi-doc-engine command boundary.
|
|
3
|
+
|
|
4
|
+
The ONLY entry the TypeScript facade invokes. Contract:
|
|
5
|
+
|
|
6
|
+
stdin : one JSON request {"command": "<name>", ...params}
|
|
7
|
+
stdout : one JSON response {"ok": true, ...} | {"ok": false, "error": {...}}
|
|
8
|
+
exit : 0 on success, non-zero on failure (TS maps to typed errors)
|
|
9
|
+
|
|
10
|
+
All paths in requests/responses are CONTAINER paths. The TS facade bind-mounts a
|
|
11
|
+
work dir and rewrites host paths to container paths before calling.
|
|
12
|
+
|
|
13
|
+
Commands:
|
|
14
|
+
convertToMarkdown ingest any format -> Markdown body (docling). TS stamps provenance.
|
|
15
|
+
renderDocx Markdown -> templated DOCX (document_converter; styled-diagram pre-pass).
|
|
16
|
+
renderPdf Markdown|DOCX -> PDF (document_converter convert-pdf).
|
|
17
|
+
extractForEdit DOCX -> editable Markdown (+ document_meta.xml).
|
|
18
|
+
mergeBack original DOCX + edited Markdown -> merged DOCX.
|
|
19
|
+
fillFrontmatter fill/refresh YAML frontmatter across files (frontmatter_filler).
|
|
20
|
+
profileTables inject table_profiles into frontmatter (markdown_table_profiler).
|
|
21
|
+
"""
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
import hashlib
|
|
25
|
+
import json
|
|
26
|
+
import os
|
|
27
|
+
import re
|
|
28
|
+
import subprocess
|
|
29
|
+
import sys
|
|
30
|
+
import traceback
|
|
31
|
+
from datetime import datetime, timezone
|
|
32
|
+
from pathlib import Path
|
|
33
|
+
|
|
34
|
+
ENGINE_DIR = Path(__file__).resolve().parent
|
|
35
|
+
sys.path.insert(0, str(ENGINE_DIR))
|
|
36
|
+
|
|
37
|
+
# ---------------------------------------------------------------------------
|
|
38
|
+
# Error envelope
|
|
39
|
+
# ---------------------------------------------------------------------------
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class EngineError(Exception):
|
|
43
|
+
"""Carries a stable error code + optional captured stderr."""
|
|
44
|
+
|
|
45
|
+
def __init__(self, code: str, message: str, stderr: str = "", exit_code: int = 1):
|
|
46
|
+
super().__init__(message)
|
|
47
|
+
self.code = code
|
|
48
|
+
self.message = message
|
|
49
|
+
self.stderr = stderr
|
|
50
|
+
self.exit_code = exit_code
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _ok(**payload) -> dict:
|
|
54
|
+
return {"ok": True, **payload}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# ---------------------------------------------------------------------------
|
|
58
|
+
# Ingest: any format -> Markdown (docling)
|
|
59
|
+
# ---------------------------------------------------------------------------
|
|
60
|
+
|
|
61
|
+
# Canonical OCR engine name -> docling options class. The TS facade already maps
|
|
62
|
+
# canonical language NAMES to per-engine CODES, so this only routes the engine.
|
|
63
|
+
_OCR_ENGINES = {"easyocr", "tesseract", "rapidocr", "ocrmac"}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _build_pipeline_options(ocr: dict, tables: str):
|
|
67
|
+
from docling.datamodel.pipeline_options import PdfPipelineOptions
|
|
68
|
+
|
|
69
|
+
opts = PdfPipelineOptions()
|
|
70
|
+
mode = (ocr or {}).get("mode", "auto")
|
|
71
|
+
engine = (ocr or {}).get("engine", "easyocr").lower()
|
|
72
|
+
codes = (ocr or {}).get("codes") or [] # already per-engine codes from TS
|
|
73
|
+
|
|
74
|
+
if engine not in _OCR_ENGINES:
|
|
75
|
+
raise EngineError("OCR_ENGINE_UNKNOWN", f"unknown OCR engine: {engine}")
|
|
76
|
+
|
|
77
|
+
# tables: off escape hatch for huge PDFs that hang TableFormer
|
|
78
|
+
opts.do_table_structure = tables != "off"
|
|
79
|
+
|
|
80
|
+
# native-first: auto WITHOUT an explicit language set does not init OCR
|
|
81
|
+
# (digital PDFs extract via native text; avoids loading an OCR engine).
|
|
82
|
+
if mode == "off" or (mode == "auto" and not codes):
|
|
83
|
+
opts.do_ocr = False
|
|
84
|
+
return opts
|
|
85
|
+
|
|
86
|
+
opts.do_ocr = True
|
|
87
|
+
# force == full-page OCR; auto == native-first (docling only OCRs bitmap regions)
|
|
88
|
+
from docling.datamodel.pipeline_options import (
|
|
89
|
+
EasyOcrOptions,
|
|
90
|
+
TesseractOcrOptions,
|
|
91
|
+
RapidOcrOptions,
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
force = mode == "force"
|
|
95
|
+
if engine == "easyocr":
|
|
96
|
+
opts.ocr_options = EasyOcrOptions(lang=codes or ["en"], force_full_page_ocr=force)
|
|
97
|
+
elif engine == "tesseract":
|
|
98
|
+
opts.ocr_options = TesseractOcrOptions(lang=codes or ["eng"], force_full_page_ocr=force)
|
|
99
|
+
elif engine == "rapidocr":
|
|
100
|
+
opts.ocr_options = RapidOcrOptions(force_full_page_ocr=force)
|
|
101
|
+
elif engine == "ocrmac":
|
|
102
|
+
from docling.datamodel.pipeline_options import OcrMacOptions
|
|
103
|
+
|
|
104
|
+
opts.ocr_options = OcrMacOptions(lang=codes or ["en-US"], force_full_page_ocr=force)
|
|
105
|
+
return opts
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def cmd_convert_to_markdown(req: dict) -> dict:
|
|
109
|
+
src = Path(req["input"])
|
|
110
|
+
if not src.exists():
|
|
111
|
+
raise EngineError("INPUT_NOT_FOUND", f"input not found: {src}")
|
|
112
|
+
ocr = req.get("ocr") or {}
|
|
113
|
+
tables = req.get("tables", "on")
|
|
114
|
+
|
|
115
|
+
try:
|
|
116
|
+
from docling.document_converter import DocumentConverter, PdfFormatOption
|
|
117
|
+
from docling.datamodel.base_models import InputFormat
|
|
118
|
+
except Exception as e: # noqa: BLE001
|
|
119
|
+
raise EngineError("DOCLING_UNAVAILABLE", f"docling import failed: {e}")
|
|
120
|
+
|
|
121
|
+
pipeline_options = _build_pipeline_options(ocr, tables)
|
|
122
|
+
converter = DocumentConverter(
|
|
123
|
+
format_options={
|
|
124
|
+
InputFormat.PDF: PdfFormatOption(pipeline_options=pipeline_options)
|
|
125
|
+
}
|
|
126
|
+
)
|
|
127
|
+
try:
|
|
128
|
+
result = converter.convert(str(src))
|
|
129
|
+
markdown = result.document.export_to_markdown()
|
|
130
|
+
except Exception as e: # noqa: BLE001
|
|
131
|
+
raise EngineError("INGEST_FAILED", f"docling conversion failed: {e}", traceback.format_exc())
|
|
132
|
+
|
|
133
|
+
out = req.get("output")
|
|
134
|
+
if out:
|
|
135
|
+
Path(out).write_text(markdown, encoding="utf-8")
|
|
136
|
+
return _ok(markdown=markdown, output=out)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
# ---------------------------------------------------------------------------
|
|
140
|
+
# Styled-diagram pre-pass (nano-banana, md5 cache, mmdc fallback)
|
|
141
|
+
# ---------------------------------------------------------------------------
|
|
142
|
+
|
|
143
|
+
_MERMAID_BLOCK = re.compile(r"```mermaid\n(.*?)\n```", re.DOTALL)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def _render_styled_diagrams(md_path: Path, style: str, cache_dir: Path) -> Path:
|
|
147
|
+
"""Replace each ```mermaid block with a cached <md5>.png, generating misses
|
|
148
|
+
via nano-banana CLI; fall back to mmdc per-diagram on any failure. Returns a
|
|
149
|
+
rewritten temp .md placed IN THE SAME DIR so relative image paths resolve."""
|
|
150
|
+
text = md_path.read_text(encoding="utf-8")
|
|
151
|
+
cache_dir.mkdir(parents=True, exist_ok=True)
|
|
152
|
+
have_key = bool(os.environ.get("GEMINI_API_KEY"))
|
|
153
|
+
|
|
154
|
+
def _replace(m: re.Match) -> str:
|
|
155
|
+
source = m.group(1)
|
|
156
|
+
digest = hashlib.md5(source.encode("utf-8")).hexdigest()
|
|
157
|
+
png = cache_dir / f"{digest}.png"
|
|
158
|
+
if not png.exists():
|
|
159
|
+
generated = False
|
|
160
|
+
if have_key and style:
|
|
161
|
+
generated = _nano_banana(source, style, png)
|
|
162
|
+
if not generated:
|
|
163
|
+
_mmdc(source, png) # fallback; raises on hard failure
|
|
164
|
+
rel = os.path.relpath(png, md_path.parent)
|
|
165
|
+
return f""
|
|
166
|
+
|
|
167
|
+
rewritten = _MERMAID_BLOCK.sub(_replace, text)
|
|
168
|
+
tmp = md_path.with_suffix(".styled.md")
|
|
169
|
+
tmp.write_text(rewritten, encoding="utf-8")
|
|
170
|
+
return tmp
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def _nano_banana(source: str, style: str, png: Path) -> bool:
|
|
174
|
+
"""Best-effort styled render. Returns True on success, False to trigger mmdc."""
|
|
175
|
+
styles_yaml = ENGINE_DIR / "nano-banana-styles.yaml"
|
|
176
|
+
# Prompt = the diagram source (describes the content) + the named STYLE block
|
|
177
|
+
# appended after it, matching the nano-banana-styles.yaml contract.
|
|
178
|
+
prompt = source
|
|
179
|
+
try:
|
|
180
|
+
import yaml # type: ignore
|
|
181
|
+
|
|
182
|
+
if styles_yaml.exists():
|
|
183
|
+
doc = yaml.safe_load(styles_yaml.read_text(encoding="utf-8")) or {}
|
|
184
|
+
name = style or doc.get("default")
|
|
185
|
+
spec = (doc.get("styles") or {}).get(name) or {}
|
|
186
|
+
if spec.get("prompt"):
|
|
187
|
+
prompt = f"{source}\n\n{spec['prompt']}"
|
|
188
|
+
if spec.get("negative"):
|
|
189
|
+
prompt = f"{prompt}\n\nAVOID: {spec['negative']}"
|
|
190
|
+
except Exception: # noqa: BLE001
|
|
191
|
+
pass
|
|
192
|
+
try:
|
|
193
|
+
proc = subprocess.run(
|
|
194
|
+
["npx", "@the-focus-ai/nano-banana", "generate", "-o", str(png), prompt],
|
|
195
|
+
capture_output=True,
|
|
196
|
+
text=True,
|
|
197
|
+
timeout=180,
|
|
198
|
+
)
|
|
199
|
+
return proc.returncode == 0 and png.exists()
|
|
200
|
+
except Exception: # noqa: BLE001
|
|
201
|
+
return False
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def _mmdc(source: str, png: Path) -> None:
|
|
205
|
+
blk = png.with_suffix(".mmd")
|
|
206
|
+
blk.write_text(source, encoding="utf-8")
|
|
207
|
+
env = dict(os.environ)
|
|
208
|
+
# Use the baked headless shell; never the host Chrome.
|
|
209
|
+
shell = os.environ.get("PUPPETEER_EXECUTABLE_PATH")
|
|
210
|
+
proc = subprocess.run(
|
|
211
|
+
["mmdc", "-i", str(blk), "-o", str(png), "-b", "white", "-w", "1400", "-s", "2"],
|
|
212
|
+
capture_output=True,
|
|
213
|
+
text=True,
|
|
214
|
+
env=env,
|
|
215
|
+
)
|
|
216
|
+
if proc.returncode != 0 or not png.exists():
|
|
217
|
+
raise EngineError("MMDC_FAILED", "mermaid render failed", proc.stderr)
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
# ---------------------------------------------------------------------------
|
|
221
|
+
# Produce: DOCX / PDF via document_converter CLI
|
|
222
|
+
# ---------------------------------------------------------------------------
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def _run_dc(args: list[str]) -> subprocess.CompletedProcess:
|
|
226
|
+
cmd = [sys.executable, "-m", "document_converter.cli", *args]
|
|
227
|
+
proc = subprocess.run(cmd, capture_output=True, text=True, cwd=str(ENGINE_DIR))
|
|
228
|
+
if proc.returncode != 0:
|
|
229
|
+
raise EngineError("PRODUCE_FAILED", f"document_converter exited {proc.returncode}", proc.stderr, proc.returncode)
|
|
230
|
+
return proc
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def cmd_render_docx(req: dict) -> dict:
|
|
234
|
+
inp = Path(req["input"])
|
|
235
|
+
out = req["output"]
|
|
236
|
+
nano = req.get("nano_banana") or {}
|
|
237
|
+
src_md = inp
|
|
238
|
+
if nano.get("enabled"):
|
|
239
|
+
cache_dir = Path(req.get("cacheDir") or (inp.parent / ".mermaid-cache"))
|
|
240
|
+
src_md = _render_styled_diagrams(inp, nano.get("style", ""), cache_dir)
|
|
241
|
+
|
|
242
|
+
args = ["convert", str(src_md), out]
|
|
243
|
+
if req.get("template"):
|
|
244
|
+
args += ["--template-name", req["template"]]
|
|
245
|
+
if req.get("templatesDir"):
|
|
246
|
+
args += ["--templates-dir", req["templatesDir"]]
|
|
247
|
+
if req.get("language"):
|
|
248
|
+
args += ["--language", req["language"]]
|
|
249
|
+
if req.get("noToc"):
|
|
250
|
+
args += ["--no-update-fields"]
|
|
251
|
+
args += ["--non-interactive"]
|
|
252
|
+
_run_dc(args)
|
|
253
|
+
return _ok(output=out)
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def cmd_render_pdf(req: dict) -> dict:
|
|
257
|
+
inp = Path(req["input"])
|
|
258
|
+
out = req["output"]
|
|
259
|
+
args = ["convert-pdf", str(inp), out]
|
|
260
|
+
if req.get("pageSize"):
|
|
261
|
+
args += ["--page-size", req["pageSize"]]
|
|
262
|
+
if req.get("template"):
|
|
263
|
+
args += ["--template", req["template"]]
|
|
264
|
+
_run_dc(args)
|
|
265
|
+
return _ok(output=out)
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
def cmd_extract_for_edit(req: dict) -> dict:
|
|
269
|
+
out = req["output"]
|
|
270
|
+
args = ["extract", req["input"], out, "--include-meta"]
|
|
271
|
+
_run_dc(args)
|
|
272
|
+
meta = str(Path(out).with_name("document_meta.xml"))
|
|
273
|
+
return _ok(output=out, meta=meta)
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
def cmd_merge_back(req: dict) -> dict:
|
|
277
|
+
out = req["output"]
|
|
278
|
+
args = ["merge", req["original"], req["edited"], out]
|
|
279
|
+
if req.get("meta"):
|
|
280
|
+
args += ["--meta", req["meta"]]
|
|
281
|
+
_run_dc(args)
|
|
282
|
+
return _ok(output=out)
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
# ---------------------------------------------------------------------------
|
|
286
|
+
# Frontmatter tooling
|
|
287
|
+
# ---------------------------------------------------------------------------
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
def cmd_fill_frontmatter(req: dict) -> dict:
|
|
291
|
+
args = [sys.executable, str(ENGINE_DIR / "frontmatter_filler" / "fill.py"), *req["paths"]]
|
|
292
|
+
if req.get("apply", True):
|
|
293
|
+
args.append("--apply")
|
|
294
|
+
if req.get("mode"):
|
|
295
|
+
args += ["--mode", req["mode"]]
|
|
296
|
+
if req.get("config"):
|
|
297
|
+
args += ["--config", req["config"]]
|
|
298
|
+
if req.get("language"):
|
|
299
|
+
args += ["--language", req["language"]]
|
|
300
|
+
for kv in req.get("set", []):
|
|
301
|
+
args += ["--set", kv]
|
|
302
|
+
proc = subprocess.run(args, capture_output=True, text=True)
|
|
303
|
+
if proc.returncode != 0:
|
|
304
|
+
raise EngineError("FILL_FAILED", "frontmatter fill failed", proc.stderr, proc.returncode)
|
|
305
|
+
return _ok(stdout=proc.stdout)
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
def cmd_profile_tables(req: dict) -> dict:
|
|
309
|
+
args = [sys.executable, str(ENGINE_DIR / "markdown_table_profiler" / "profile.py"), *req["paths"]]
|
|
310
|
+
args.append("--apply" if req.get("apply", True) else "--dry-run")
|
|
311
|
+
if req.get("percentile") is not None:
|
|
312
|
+
args += ["--percentile", str(req["percentile"])]
|
|
313
|
+
if req.get("smoothing"):
|
|
314
|
+
args += ["--smoothing", req["smoothing"]]
|
|
315
|
+
proc = subprocess.run(args, capture_output=True, text=True)
|
|
316
|
+
if proc.returncode != 0:
|
|
317
|
+
raise EngineError("PROFILE_FAILED", "table profile failed", proc.stderr, proc.returncode)
|
|
318
|
+
return _ok(stdout=proc.stdout)
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
# ---------------------------------------------------------------------------
|
|
322
|
+
# Dispatch
|
|
323
|
+
# ---------------------------------------------------------------------------
|
|
324
|
+
|
|
325
|
+
_COMMANDS = {
|
|
326
|
+
"convertToMarkdown": cmd_convert_to_markdown,
|
|
327
|
+
"renderDocx": cmd_render_docx,
|
|
328
|
+
"renderPdf": cmd_render_pdf,
|
|
329
|
+
"extractForEdit": cmd_extract_for_edit,
|
|
330
|
+
"mergeBack": cmd_merge_back,
|
|
331
|
+
"fillFrontmatter": cmd_fill_frontmatter,
|
|
332
|
+
"profileTables": cmd_profile_tables,
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
def main() -> int:
|
|
337
|
+
try:
|
|
338
|
+
req = json.load(sys.stdin)
|
|
339
|
+
except Exception as e: # noqa: BLE001
|
|
340
|
+
json.dump({"ok": False, "error": {"code": "BAD_REQUEST", "message": str(e)}}, sys.stdout)
|
|
341
|
+
return 2
|
|
342
|
+
|
|
343
|
+
command = req.get("command")
|
|
344
|
+
handler = _COMMANDS.get(command)
|
|
345
|
+
if handler is None:
|
|
346
|
+
json.dump(
|
|
347
|
+
{"ok": False, "error": {"code": "UNKNOWN_COMMAND", "message": f"unknown command: {command}"}},
|
|
348
|
+
sys.stdout,
|
|
349
|
+
)
|
|
350
|
+
return 2
|
|
351
|
+
|
|
352
|
+
try:
|
|
353
|
+
result = handler(req)
|
|
354
|
+
json.dump(result, sys.stdout)
|
|
355
|
+
return 0
|
|
356
|
+
except EngineError as e:
|
|
357
|
+
json.dump(
|
|
358
|
+
{"ok": False, "error": {"code": e.code, "message": e.message, "stderr": e.stderr}},
|
|
359
|
+
sys.stdout,
|
|
360
|
+
)
|
|
361
|
+
return e.exit_code
|
|
362
|
+
except Exception as e: # noqa: BLE001
|
|
363
|
+
json.dump(
|
|
364
|
+
{"ok": False, "error": {"code": "INTERNAL", "message": str(e), "stderr": traceback.format_exc()}},
|
|
365
|
+
sys.stdout,
|
|
366
|
+
)
|
|
367
|
+
return 1
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
if __name__ == "__main__":
|
|
371
|
+
sys.exit(main())
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Sample frontmatter-filler config.
|
|
2
|
+
# Place as `.doc-meta.yaml` or `.agents/doc-meta.yaml` at the project root.
|
|
3
|
+
# The script walks up from each source file to find the nearest config.
|
|
4
|
+
|
|
5
|
+
# -----------------------------------------------------------------------------
|
|
6
|
+
# DEFAULTS — applied to every markdown file in scope.
|
|
7
|
+
# -----------------------------------------------------------------------------
|
|
8
|
+
defaults:
|
|
9
|
+
# Document-conversion template-selection keys
|
|
10
|
+
template: default
|
|
11
|
+
enable_cover_page: true
|
|
12
|
+
enable_toc: true
|
|
13
|
+
|
|
14
|
+
# Logos block — paths are resolved RELATIVE TO THIS CONFIG FILE,
|
|
15
|
+
# then rewritten per-file to a relative path reaching that location.
|
|
16
|
+
logos:
|
|
17
|
+
company: images/thefence-logo.png
|
|
18
|
+
|
|
19
|
+
# Identity / branding
|
|
20
|
+
client_name: "XS Matrix Security Solutions Ltd. (TheFence™)"
|
|
21
|
+
company_info: "BlackBelt Technology Zrt"
|
|
22
|
+
contact_info: "Contact: robert.csakany@blackbelt.hu"
|
|
23
|
+
author: "Robert Csakany (robert.csakany@blackbelt.hu)"
|
|
24
|
+
|
|
25
|
+
# Defaults for every doc unless overridden
|
|
26
|
+
version: "Draft"
|
|
27
|
+
|
|
28
|
+
# Diagram render settings consumed by document-conversion
|
|
29
|
+
diagram_format: png
|
|
30
|
+
diagram_width: 1200
|
|
31
|
+
diagram_scale: 2
|
|
32
|
+
|
|
33
|
+
# -----------------------------------------------------------------------------
|
|
34
|
+
# LANGUAGE PACKS — detected from filename (*.hu.md, *.en.md) or --language.
|
|
35
|
+
# Higher priority than `defaults`. Override any key declared in defaults.
|
|
36
|
+
# -----------------------------------------------------------------------------
|
|
37
|
+
languages:
|
|
38
|
+
en:
|
|
39
|
+
toc_heading: "Table of Contents"
|
|
40
|
+
document_type: "TECHNICAL SPECIFICATION"
|
|
41
|
+
hu:
|
|
42
|
+
toc_heading: "Tartalomjegyzék"
|
|
43
|
+
document_type: "MŰSZAKI SPECIFIKÁCIÓ"
|
|
44
|
+
de:
|
|
45
|
+
toc_heading: "Inhaltsverzeichnis"
|
|
46
|
+
document_type: "TECHNISCHE SPEZIFIKATION"
|
|
47
|
+
fr:
|
|
48
|
+
toc_heading: "Table des matières"
|
|
49
|
+
document_type: "SPÉCIFICATION TECHNIQUE"
|
|
50
|
+
|
|
51
|
+
# -----------------------------------------------------------------------------
|
|
52
|
+
# FILE-LEVEL OVERRIDES — fnmatch-style glob, relative to THIS config file.
|
|
53
|
+
# Every matching entry is merged (later declarations win on conflicts).
|
|
54
|
+
# -----------------------------------------------------------------------------
|
|
55
|
+
files:
|
|
56
|
+
"spec/DAPP-specifikacio-v1.0*.md":
|
|
57
|
+
document_id: DAPP-SPEC
|
|
58
|
+
version: "Version 1.0"
|
|
59
|
+
project_name: "DAPP — Functional & Architectural Specification"
|
|
60
|
+
project_description: "Consolidated v1.0 handover document"
|
|
61
|
+
|
|
62
|
+
"spec/DAPP-domain-architecture-v0.2*.md":
|
|
63
|
+
document_id: DAPP-ARC
|
|
64
|
+
version: "Version 0.2"
|
|
65
|
+
project_name: "DAPP — Domain Architecture"
|
|
66
|
+
project_description: "JUDO-aligned architecture blueprint (v0.2)"
|
|
67
|
+
|
|
68
|
+
"spec/DAPP-model-spec-v0.1*.md":
|
|
69
|
+
document_id: DAPP-MOD
|
|
70
|
+
version: "Version 0.1"
|
|
71
|
+
project_name: "DAPP — ESM Model Specification"
|
|
72
|
+
project_description: "JUDO ESM YAML model (v0.1)"
|
|
73
|
+
|
|
74
|
+
"spec/DAPP-operations-spec-v0.1*.md":
|
|
75
|
+
document_id: DAPP-OPS
|
|
76
|
+
version: "Version 0.1"
|
|
77
|
+
project_name: "DAPP — Custom Operations Specification"
|
|
78
|
+
project_description: "Custom Java operations contracts (v0.1)"
|
|
79
|
+
|
|
80
|
+
"spec/DAPP-extractor-lifecycle-v0.1*.md":
|
|
81
|
+
document_id: DAPP-EXT
|
|
82
|
+
version: "Version 0.1"
|
|
83
|
+
project_name: "DAPP — Extractor Image Lifecycle"
|
|
84
|
+
project_description: "Extractor container images & Docker management (v0.1)"
|
|
85
|
+
|
|
86
|
+
"spec/DAPP-connector-lifecycle-v0.1*.md":
|
|
87
|
+
document_id: DAPP-CON
|
|
88
|
+
version: "Version 0.1"
|
|
89
|
+
project_name: "DAPP — Connector Image Lifecycle"
|
|
90
|
+
project_description: "Inbound & outbound connector container images (v0.1)"
|
|
91
|
+
|
|
92
|
+
"spec/DAPP-ui-spec-v0.1*.md":
|
|
93
|
+
document_id: DAPP-UI
|
|
94
|
+
version: "Version 0.1"
|
|
95
|
+
project_name: "DAPP — UI Specification"
|
|
96
|
+
project_description: "JUDO-native UI screen mapping (v0.1)"
|
|
97
|
+
|
|
98
|
+
"spec/notes/JUDO-capabilities-for-DAPP*.md":
|
|
99
|
+
document_id: DAPP-JUDO
|
|
100
|
+
version: "Version 0.1"
|
|
101
|
+
project_name: "DAPP — JUDO Capability Cheat-sheet"
|
|
102
|
+
project_description: "Platform capabilities & constraints feeding the DAPP spec"
|
|
103
|
+
# Override document_type per language for a "NOTE" feel
|
|
104
|
+
document_type_override:
|
|
105
|
+
en: "TECHNICAL NOTE"
|
|
106
|
+
hu: "MŰSZAKI JEGYZET"
|