This commit is contained in:
1 parent
23b1cb2966
commit
e9532e8878
30 files changed
+1835
-542
No files matched your search
+63
-28
@@ -1,39 +1,74 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Script: scripts/export_markdown.py — Qdrant → Markdown (Vault)
|
||||
Version: 1.4.1
|
||||
Datum: 2025-09-10
|
||||
FILE: scripts/export_markdown.py
|
||||
VERSION: 2.1.0 (2025-12-15)
|
||||
STATUS: Active
|
||||
COMPATIBILITY: v2.9.1 (Post-WP14/WP-15b)
|
||||
|
||||
Funktion
|
||||
--------
|
||||
Exportiert Notes (Frontmatter + Body) aus Qdrant in einen Zielordner. Der Body wird
|
||||
bevorzugt aus dem Feld `fulltext` rekonstruiert; falls leer/nicht vorhanden, aus Chunks
|
||||
(Sortierung: seq → chunk_index → Nummer in chunk_id). Pfade werden **relativ** geschrieben.
|
||||
Zweck:
|
||||
-------
|
||||
Exportiert Notes (Frontmatter + Body) aus Qdrant zurück in Markdown-Dateien.
|
||||
Nützlich für Backup, Migration oder Notfall-Wiederherstellung.
|
||||
|
||||
Optionen
|
||||
--------
|
||||
--out PATH Zielordner (erforderlich)
|
||||
--prefix TEXT Collection-Prefix (CLI überschreibt ENV COLLECTION_PREFIX)
|
||||
--note-id ID Nur eine Note exportieren
|
||||
--overwrite Existierende Dateien überschreiben
|
||||
--include-edges MODE none|yaml|footer (Default: none)
|
||||
--flatten-paths Alle Dateien flach schreiben; Originalpfad in FM: orig_path
|
||||
Funktionsweise:
|
||||
---------------
|
||||
1. Liest alle Notes aus Qdrant (Collection: {prefix}_notes)
|
||||
2. Für jede Note:
|
||||
- Rekonstruiert Frontmatter aus Payload-Feldern
|
||||
- Rekonstruiert Body:
|
||||
* Primär: aus `fulltext` Feld (falls vorhanden)
|
||||
* Fallback: aus Chunks (sortiert nach seq → chunk_index → chunk_id)
|
||||
- Optional: Fügt Edges als Links hinzu (yaml/footer)
|
||||
3. Schreibt Markdown-Dateien mit relativen Pfaden
|
||||
|
||||
ENV
|
||||
---
|
||||
Ergebnis-Interpretation:
|
||||
------------------------
|
||||
- Ausgabe: JSON pro Datei mit note_id, path, decision (write/skip-exists)
|
||||
- Abschluss: "Done. Exported notes: X"
|
||||
- Exit-Code 0: Erfolgreich
|
||||
|
||||
Verwendung:
|
||||
-----------
|
||||
- Backup vor größeren Änderungen
|
||||
- Migration zwischen Instanzen
|
||||
- Notfall-Wiederherstellung bei Vault-Verlust
|
||||
- Analyse der in Qdrant gespeicherten Daten
|
||||
|
||||
Hinweise:
|
||||
---------
|
||||
- Pfade werden relativ geschrieben (wie im Original-Vault)
|
||||
- --flatten-paths: Alle Dateien in einen Ordner (orig_path in Frontmatter)
|
||||
- Body-Rekonstruktion aus Chunks kann bei sehr langen Dokumenten unvollständig sein
|
||||
- Edge-Export optional (none/yaml/footer)
|
||||
|
||||
Aufruf:
|
||||
-------
|
||||
python3 -m scripts.export_markdown --out ./_exportVault
|
||||
python3 -m scripts.export_markdown --out ./_exportVault --note-id concept-alpha --include-edges yaml
|
||||
python3 -m scripts.export_markdown --out ./_exportVault --flatten-paths --overwrite
|
||||
|
||||
Parameter:
|
||||
----------
|
||||
--out PATH Zielordner für exportierte Markdown-Dateien (erforderlich)
|
||||
--prefix TEXT Collection-Präfix (überschreibt ENV COLLECTION_PREFIX)
|
||||
--note-id ID Nur eine bestimmte Note-ID exportieren (optional)
|
||||
--overwrite Existierende Dateien überschreiben (sonst skip)
|
||||
--include-edges MODE none|yaml|footer (Default: none)
|
||||
- none: Keine Edges
|
||||
- yaml: Als YAML-Feld 'references' im Frontmatter
|
||||
- footer: Als Markdown-Links am Ende
|
||||
--flatten-paths Alle Dateien flach schreiben (orig_path in Frontmatter)
|
||||
|
||||
Umgebungsvariablen:
|
||||
-------------------
|
||||
COLLECTION_PREFIX, QDRANT_URL | QDRANT_HOST/QDRANT_PORT | QDRANT_API_KEY
|
||||
|
||||
Beispiele
|
||||
---------
|
||||
export COLLECTION_PREFIX="mindnet"
|
||||
python3 -m scripts.export_markdown --out ./_exportVault
|
||||
|
||||
# Nur eine Note, Edges als YAML-Feld 'references'
|
||||
python3 -m scripts.export_markdown --out ./_exportVault --note-id concept-alpha --include-edges yaml
|
||||
|
||||
# Flach schreiben mit Überschreiben
|
||||
python3 -m scripts.export_markdown --out ./_exportVault --flatten-paths --overwrite
|
||||
Änderungen:
|
||||
-----------
|
||||
v2.1.0 (2025-12-15): Kompatibilität mit WP-14 Modularisierung
|
||||
- Aktualisiert: Import-Pfade für neue Struktur
|
||||
v1.4.1 (2025-09-10): Initial Release
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
Reference in new issue
Block a user