Enhance interview configuration and documentation for WP-26 integration
- Added the `Interview_Config_Guide.md` for comprehensive instructions on creating interview profiles and utilizing various note types. - Updated `00_Dokumentations_Index.md` to include links to the new guide and improved navigation for WP-26 related resources. - Enhanced `06_Konfigurationsdateien_Referenz.md` with references to the new guide and clarified YAML structure for interview configurations. - Introduced `audit_geburtsdatei.md` for detailed analysis of section connections and edge types, highlighting critical issues and recommendations for improvement. - Improved renderer tests to ensure proper handling of section types and edge generation, aligning with the new WP-26 features.
This commit is contained in:
1 parent
b99416b67d
commit
8186ca5ce0
13 files changed
+2805
-282
No files matched your search
@@ -46,8 +46,6 @@ describe("WP-26 Interview Renderer", () => {
|
||||
|
||||
it("sollte keine Selbstreferenz bei automatischen Edges generieren", () => {
|
||||
const profile: InterviewProfile = {
|
||||
version: "2.0",
|
||||
frontmatterWhitelist: [],
|
||||
key: "test",
|
||||
label: "Test",
|
||||
note_type: "experience",
|
||||
@@ -80,7 +78,7 @@ describe("WP-26 Interview Renderer", () => {
|
||||
const result = renderProfileToMarkdown(profile, answers, mockOptions);
|
||||
|
||||
// Prüfe, dass keine Selbstreferenz vorhanden ist
|
||||
const contextSection = result.match(/## Kontext.*?## Einsicht/s)?.[0];
|
||||
const contextSection = result.match(/## Kontext[\s\S]*?## Einsicht/)?.[0];
|
||||
expect(contextSection).toBeDefined();
|
||||
|
||||
// Prüfe, dass keine Edge auf sich selbst zeigt
|
||||
@@ -94,8 +92,6 @@ describe("WP-26 Interview Renderer", () => {
|
||||
|
||||
it("sollte Edge-Types aus graph_schema verwenden", () => {
|
||||
const profile: InterviewProfile = {
|
||||
version: "2.0",
|
||||
frontmatterWhitelist: [],
|
||||
key: "test",
|
||||
label: "Test",
|
||||
note_type: "experience",
|
||||
@@ -150,8 +146,6 @@ describe("WP-26 Interview Renderer", () => {
|
||||
|
||||
it("sollte Backlinks automatisch generieren", () => {
|
||||
const profile: InterviewProfile = {
|
||||
version: "2.0",
|
||||
frontmatterWhitelist: [],
|
||||
key: "test",
|
||||
label: "Test",
|
||||
note_type: "experience",
|
||||
@@ -193,8 +187,6 @@ describe("WP-26 Interview Renderer", () => {
|
||||
|
||||
it("sollte keine Selbstreferenz bei expliziten Referenzen erlauben", () => {
|
||||
const profile: InterviewProfile = {
|
||||
version: "2.0",
|
||||
frontmatterWhitelist: [],
|
||||
key: "test",
|
||||
label: "Test",
|
||||
note_type: "experience",
|
||||
@@ -232,8 +224,6 @@ describe("WP-26 Interview Renderer", () => {
|
||||
|
||||
it("sollte Section-Type-Callout direkt nach Heading platzieren", () => {
|
||||
const profile: InterviewProfile = {
|
||||
version: "2.0",
|
||||
frontmatterWhitelist: [],
|
||||
key: "test",
|
||||
label: "Test",
|
||||
note_type: "experience",
|
||||
@@ -258,14 +248,12 @@ describe("WP-26 Interview Renderer", () => {
|
||||
const result = renderProfileToMarkdown(profile, answers, mockOptions);
|
||||
|
||||
// Prüfe, dass Section-Type-Callout direkt nach Heading steht
|
||||
const sectionPattern = /## Kontext.*?\n> \[!section\] experience/s;
|
||||
const sectionPattern = /## Kontext[\s\S]*?\n> \[!section\] experience/;
|
||||
expect(result).toMatch(sectionPattern);
|
||||
});
|
||||
|
||||
it("sollte Edges am Ende der Sektion platzieren", () => {
|
||||
const profile: InterviewProfile = {
|
||||
version: "2.0",
|
||||
frontmatterWhitelist: [],
|
||||
key: "test",
|
||||
label: "Test",
|
||||
note_type: "experience",
|
||||
@@ -298,7 +286,7 @@ describe("WP-26 Interview Renderer", () => {
|
||||
const result = renderProfileToMarkdown(profile, answers, mockOptions);
|
||||
|
||||
// Prüfe, dass Edges am Ende der Einsicht-Sektion stehen (nach dem Text)
|
||||
const insightSection = result.match(/## Einsicht.*?Einsicht-Text\n\n(> \[!edge\].*)/s)?.[1];
|
||||
const insightSection = result.match(/## Einsicht[\s\S]*?Einsicht-Text\n\n(> \[!edge\][\s\S]*)/)?.[1];
|
||||
expect(insightSection).toBeDefined();
|
||||
expect(insightSection).toMatch(/> \[!edge\]/);
|
||||
});
|
||||
|
||||
+617
-113
@@ -23,6 +23,7 @@ export interface RenderOptions {
|
||||
graphSchema?: GraphSchema | null;
|
||||
vocabulary?: Vocabulary | null;
|
||||
noteType?: string; // Fallback für effective_type
|
||||
sectionEdgeTypes?: Map<string, Map<string, string>>; // fromBlockId -> (toBlockId -> edgeType) für manuell geänderte Edge-Types
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,13 +36,20 @@ export function renderProfileToMarkdown(
|
||||
answers: RenderAnswers,
|
||||
options?: RenderOptions
|
||||
): string {
|
||||
const output: string[] = [];
|
||||
|
||||
// WP-26: Verwende übergebene Section-Sequenz oder erstelle neue
|
||||
// Die Section-Sequenz wird während des interaktiven Wizard-Durchlaufs getrackt
|
||||
const sectionSequence: SectionInfo[] = answers.sectionSequence ? [...answers.sectionSequence] : [];
|
||||
const generatedBlockIds = new Map<string, SectionInfo>();
|
||||
|
||||
console.log(`[WP-26] renderProfileToMarkdown:`, {
|
||||
sectionSequenceLength: sectionSequence.length,
|
||||
sectionSequence: sectionSequence.map(s => ({
|
||||
stepKey: s.stepKey,
|
||||
blockId: s.blockId,
|
||||
sectionType: s.sectionType,
|
||||
})),
|
||||
});
|
||||
|
||||
// WP-26: Wenn Section-Sequenz übergeben wurde, fülle generatedBlockIds aus der Sequenz
|
||||
if (answers.sectionSequence && answers.sectionSequence.length > 0) {
|
||||
for (const sectionInfo of answers.sectionSequence) {
|
||||
@@ -51,24 +59,125 @@ export function renderProfileToMarkdown(
|
||||
}
|
||||
}
|
||||
|
||||
// WP-26: Track Section-Sequenz während des Renderns (für Steps, die noch nicht getrackt wurden)
|
||||
const context: RenderContext = {
|
||||
profile,
|
||||
sectionSequence,
|
||||
generatedBlockIds,
|
||||
options: options || {},
|
||||
};
|
||||
|
||||
// WP-26: Erster Durchlauf: Rendere alle Steps und sammle gerenderte Sections
|
||||
const renderedSections: Array<{ sectionInfo: SectionInfo; content: string }> = [];
|
||||
const output: string[] = [];
|
||||
|
||||
for (const step of profile.steps) {
|
||||
const stepOutput = renderStep(
|
||||
step,
|
||||
answers,
|
||||
{
|
||||
profile,
|
||||
sectionSequence,
|
||||
generatedBlockIds,
|
||||
options: options || {},
|
||||
}
|
||||
);
|
||||
// WP-26: Debug-Log für Steps mit WP-26 Feldern
|
||||
if (step.type === "capture_text" || step.type === "capture_text_line") {
|
||||
const captureStep = step as CaptureTextStep | CaptureTextLineStep;
|
||||
console.log(`[WP-26] Renderer: Step ${step.key} hat WP-26 Felder:`, {
|
||||
section_type: captureStep.section_type,
|
||||
block_id: captureStep.block_id,
|
||||
generate_block_id: captureStep.generate_block_id,
|
||||
references: captureStep.references,
|
||||
});
|
||||
}
|
||||
|
||||
const stepOutput = renderStep(step, answers, context);
|
||||
|
||||
if (stepOutput) {
|
||||
// WP-26: Prüfe, ob diese Step eine Section mit Block-ID erzeugt hat
|
||||
if (step.type === "capture_text" || step.type === "capture_text_line") {
|
||||
const captureStep = step as CaptureTextStep | CaptureTextLineStep;
|
||||
let blockId: string | null = null;
|
||||
if (captureStep.block_id) {
|
||||
blockId = captureStep.block_id;
|
||||
} else if (captureStep.generate_block_id) {
|
||||
blockId = slugify(captureStep.key);
|
||||
}
|
||||
|
||||
if (blockId && generatedBlockIds.has(blockId)) {
|
||||
const sectionInfo = generatedBlockIds.get(blockId)!;
|
||||
renderedSections.push({ sectionInfo, content: stepOutput });
|
||||
}
|
||||
}
|
||||
|
||||
output.push(stepOutput);
|
||||
}
|
||||
}
|
||||
|
||||
return output.join("\n\n").trim();
|
||||
// WP-26: Zweiter Durchlauf: Füge Backward-Edges zu den entsprechenden Sections hinzu
|
||||
// Backward-Edges werden in der Ziel-Sektion (vorherige Section) eingefügt
|
||||
// Wenn Section A -> Section B (Forward-Edge), dann wird Backward-Edge (B -> A) in Section A eingefügt
|
||||
// Spezifikation: Zu jedem Forward-Link wird automatisch ein Rückwärts-Edge in der Ziel-Section generiert
|
||||
const updatedOutput: string[] = [];
|
||||
const backwardEdgesMap = new Map<string, string>(); // blockId der prevSection -> backwardEdges
|
||||
|
||||
// Sammle Backward-Edges für ALLE vorherigen Sections
|
||||
// Für jede aktuelle Section generiere Backward-Edges zu allen vorherigen Sections
|
||||
for (const rendered of renderedSections) {
|
||||
const currentIndex = context.sectionSequence.findIndex(
|
||||
s => s.blockId === rendered.sectionInfo.blockId && s.stepKey === rendered.sectionInfo.stepKey
|
||||
);
|
||||
|
||||
if (currentIndex > 0 && rendered.sectionInfo.blockId) {
|
||||
// ALLE vorherigen Sections (nicht nur die direkt vorherige)
|
||||
const prevSections = context.sectionSequence.slice(0, currentIndex);
|
||||
|
||||
// Für jede vorherige Section generiere eine Backward-Edge
|
||||
for (let prevIdx = 0; prevIdx < prevSections.length; prevIdx++) {
|
||||
const prevSection = prevSections[prevIdx];
|
||||
if (!prevSection || !prevSection.blockId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const backwardEdge = renderSingleBackwardEdge(
|
||||
rendered.sectionInfo,
|
||||
prevSection,
|
||||
currentIndex,
|
||||
prevIdx,
|
||||
context
|
||||
);
|
||||
if (backwardEdge) {
|
||||
const existing = backwardEdgesMap.get(prevSection.blockId) || "";
|
||||
const combined = existing ? `${existing}\n${backwardEdge}` : backwardEdge;
|
||||
backwardEdgesMap.set(prevSection.blockId, combined);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Füge Backward-Edges zu den entsprechenden Sections hinzu
|
||||
for (let i = 0; i < output.length; i++) {
|
||||
const currentOutput = output[i];
|
||||
if (!currentOutput) {
|
||||
updatedOutput.push("");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Prüfe, ob diese Output eine Section mit Block-ID ist
|
||||
let sectionInfo: SectionInfo | null = null;
|
||||
for (const rendered of renderedSections) {
|
||||
if (rendered.content === currentOutput) {
|
||||
sectionInfo = rendered.sectionInfo;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sectionInfo && sectionInfo.blockId) {
|
||||
const backwardEdges = backwardEdgesMap.get(sectionInfo.blockId);
|
||||
if (backwardEdges) {
|
||||
// Füge Backward-Edges zum abstract wrapper hinzu
|
||||
const updatedContent = addEdgesToAbstractWrapper(currentOutput, backwardEdges);
|
||||
updatedOutput.push(updatedContent);
|
||||
} else {
|
||||
updatedOutput.push(currentOutput);
|
||||
}
|
||||
} else {
|
||||
updatedOutput.push(currentOutput);
|
||||
}
|
||||
}
|
||||
|
||||
return updatedOutput.join("\n\n").trim();
|
||||
}
|
||||
|
||||
// WP-26: Render-Kontext für Section-Types und Block-IDs
|
||||
@@ -126,6 +235,17 @@ function renderCaptureText(
|
||||
|
||||
const text = String(value);
|
||||
|
||||
console.log(`[WP-26] renderCaptureText für Step ${step.key}:`, {
|
||||
hasBlockId: !!step.block_id,
|
||||
blockId: step.block_id,
|
||||
hasGenerateBlockId: !!step.generate_block_id,
|
||||
generateBlockId: step.generate_block_id,
|
||||
hasSectionType: !!step.section_type,
|
||||
sectionType: step.section_type,
|
||||
hasSection: !!step.section,
|
||||
section: step.section,
|
||||
});
|
||||
|
||||
// WP-26: Block-ID-Generierung
|
||||
let blockId: string | null = null;
|
||||
if (step.block_id) {
|
||||
@@ -134,6 +254,8 @@ function renderCaptureText(
|
||||
blockId = slugify(step.key);
|
||||
}
|
||||
|
||||
console.log(`[WP-26] Generierte Block-ID für Step ${step.key}:`, blockId);
|
||||
|
||||
// WP-26: Heading mit Block-ID erweitern
|
||||
let heading = step.section || "";
|
||||
if (heading && blockId) {
|
||||
@@ -158,6 +280,13 @@ function renderCaptureText(
|
||||
// WP-26: Block-ID tracken
|
||||
if (blockId) {
|
||||
context.generatedBlockIds.set(blockId, sectionInfo);
|
||||
|
||||
// WP-26: Auch Basis-Block-ID tracken (für Referenzen ohne Index bei Loop-Items)
|
||||
// Z.B. "action_heading-1" wird auch als "action_heading" getrackt
|
||||
const baseBlockId = blockId.replace(/-\d+$/, "");
|
||||
if (baseBlockId !== blockId && !context.generatedBlockIds.has(baseBlockId)) {
|
||||
context.generatedBlockIds.set(baseBlockId, sectionInfo);
|
||||
}
|
||||
}
|
||||
|
||||
// WP-26: Section-Sequenz aktualisieren (nur wenn Section vorhanden)
|
||||
@@ -165,11 +294,15 @@ function renderCaptureText(
|
||||
context.sectionSequence.push(sectionInfo);
|
||||
}
|
||||
|
||||
// WP-26: Referenzen generieren (am Ende der Sektion)
|
||||
// WP-26: Referenzen generieren (Forward-Edges zu anderen Sections)
|
||||
const references = renderReferences(step.references || [], context, sectionInfo);
|
||||
|
||||
// WP-26: Automatische Edge-Vorschläge generieren (am Ende der Sektion)
|
||||
const autoEdges = renderAutomaticEdges(sectionInfo, context);
|
||||
// WP-26: Automatische Forward-Edges generieren (prevSection -> currentSection)
|
||||
const forwardEdges = renderForwardEdges(sectionInfo, context);
|
||||
|
||||
// WP-26: Automatische Backward-Edges generieren (currentSection -> nachfolgende Sections)
|
||||
// Diese werden später in einem zweiten Durchlauf hinzugefügt
|
||||
const backwardEdges = ""; // Wird später hinzugefügt
|
||||
|
||||
// Use template if provided
|
||||
if (step.output?.template) {
|
||||
@@ -180,12 +313,12 @@ function renderCaptureText(
|
||||
});
|
||||
|
||||
// WP-26: Template mit Heading, Section-Type und Edges kombinieren
|
||||
return combineSectionParts(heading, sectionTypeCallout, templateText, references, autoEdges);
|
||||
return combineSectionParts(heading, sectionTypeCallout, templateText, references, forwardEdges, backwardEdges);
|
||||
}
|
||||
|
||||
// Default: use section if provided, otherwise just the text
|
||||
if (step.section) {
|
||||
return combineSectionParts(heading, sectionTypeCallout, text, references, autoEdges);
|
||||
return combineSectionParts(heading, sectionTypeCallout, text, references, forwardEdges, backwardEdges);
|
||||
}
|
||||
|
||||
return text;
|
||||
@@ -223,6 +356,7 @@ function renderCaptureTextLine(
|
||||
}
|
||||
|
||||
// WP-26: Block-ID-Generierung
|
||||
// Für Loop-Items kann die Block-ID bereits nummeriert sein (z.B. "action_heading-1")
|
||||
let blockId: string | null = null;
|
||||
if (step.block_id) {
|
||||
blockId = step.block_id;
|
||||
@@ -245,28 +379,9 @@ function renderCaptureTextLine(
|
||||
? `> [!section] ${step.section_type}`
|
||||
: "";
|
||||
|
||||
// WP-26: Section-Info für Tracking (nur wenn Heading vorhanden)
|
||||
if (headingPrefix) {
|
||||
const sectionInfo: SectionInfo = {
|
||||
stepKey: step.key,
|
||||
sectionType: step.section_type || null,
|
||||
heading: heading || text,
|
||||
blockId: blockId,
|
||||
noteType: context.options.noteType || context.profile.note_type,
|
||||
};
|
||||
|
||||
// WP-26: Block-ID tracken
|
||||
if (blockId) {
|
||||
context.generatedBlockIds.set(blockId, sectionInfo);
|
||||
}
|
||||
|
||||
// WP-26: Section-Sequenz aktualisieren
|
||||
context.sectionSequence.push(sectionInfo);
|
||||
}
|
||||
|
||||
// WP-26: Section-Info für Tracking (nur wenn Heading vorhanden)
|
||||
let sectionInfo: SectionInfo | null = null;
|
||||
if (headingPrefix) {
|
||||
if (headingPrefix && blockId) {
|
||||
sectionInfo = {
|
||||
stepKey: step.key,
|
||||
sectionType: step.section_type || null,
|
||||
@@ -275,23 +390,28 @@ function renderCaptureTextLine(
|
||||
noteType: context.options.noteType || context.profile.note_type,
|
||||
};
|
||||
|
||||
// WP-26: Block-ID tracken
|
||||
if (blockId) {
|
||||
context.generatedBlockIds.set(blockId, sectionInfo);
|
||||
// WP-26: Block-ID tracken (auch wenn nummeriert für Loop-Items)
|
||||
context.generatedBlockIds.set(blockId, sectionInfo);
|
||||
|
||||
// WP-26: Auch Basis-Block-ID tracken (für Referenzen ohne Index)
|
||||
// Z.B. "action_heading-1" wird auch als "action_heading" getrackt
|
||||
const baseBlockId = blockId.replace(/-\d+$/, "");
|
||||
if (baseBlockId !== blockId && !context.generatedBlockIds.has(baseBlockId)) {
|
||||
context.generatedBlockIds.set(baseBlockId, sectionInfo);
|
||||
}
|
||||
|
||||
// WP-26: Section-Sequenz aktualisieren
|
||||
context.sectionSequence.push(sectionInfo);
|
||||
}
|
||||
|
||||
// WP-26: Referenzen generieren (am Ende der Sektion)
|
||||
// WP-26: Referenzen generieren (Forward-Edges zu anderen Sections)
|
||||
const references = sectionInfo
|
||||
? renderReferences(step.references || [], context, sectionInfo)
|
||||
: "";
|
||||
|
||||
// WP-26: Automatische Edge-Vorschläge generieren (nur wenn Heading vorhanden)
|
||||
const autoEdges = sectionInfo
|
||||
? renderAutomaticEdges(sectionInfo, context)
|
||||
// WP-26: Automatische Forward-Edges generieren (prevSection -> currentSection)
|
||||
const forwardEdges = sectionInfo
|
||||
? renderForwardEdges(sectionInfo, context)
|
||||
: "";
|
||||
|
||||
// Use template if provided
|
||||
@@ -305,7 +425,8 @@ function renderCaptureTextLine(
|
||||
|
||||
// WP-26: Template mit Heading, Section-Type und Edges kombinieren (wenn Heading vorhanden)
|
||||
if (headingPrefix) {
|
||||
return combineSectionParts(heading, sectionTypeCallout, "", references, autoEdges);
|
||||
// Backward-Edges werden später im zweiten Durchlauf hinzugefügt
|
||||
return combineSectionParts(heading, sectionTypeCallout, "", references, forwardEdges, "");
|
||||
}
|
||||
|
||||
return templateText;
|
||||
@@ -313,7 +434,8 @@ function renderCaptureTextLine(
|
||||
|
||||
// WP-26: Wenn Heading vorhanden, mit Section-Type und Edges kombinieren
|
||||
if (headingPrefix) {
|
||||
return combineSectionParts(heading, sectionTypeCallout, "", references, autoEdges);
|
||||
// Backward-Edges werden später im zweiten Durchlauf hinzugefügt
|
||||
return combineSectionParts(heading, sectionTypeCallout, "", references, forwardEdges, "");
|
||||
}
|
||||
|
||||
// Default: text with heading prefix if configured
|
||||
@@ -401,11 +523,15 @@ function renderLoopRecursive(
|
||||
|
||||
const itemOutputs: string[] = [];
|
||||
|
||||
// WP-26: Tracke Item-Index für eindeutige Block-IDs
|
||||
let itemIndex = 0;
|
||||
|
||||
for (const item of items) {
|
||||
if (!item || typeof item !== "object") {
|
||||
continue;
|
||||
}
|
||||
|
||||
itemIndex++;
|
||||
const itemParts: string[] = [];
|
||||
|
||||
// Render each nested step for this item (recursively)
|
||||
@@ -417,8 +543,16 @@ function renderLoopRecursive(
|
||||
const text = String(fieldValue);
|
||||
const captureStep = nestedStep as CaptureTextStep;
|
||||
|
||||
// WP-26: Erstelle temporären Step mit nummerierter Block-ID für Loop-Items
|
||||
const loopStepWithBlockId: CaptureTextStep = {
|
||||
...captureStep,
|
||||
block_id: captureStep.generate_block_id
|
||||
? `${slugify(captureStep.key)}-${itemIndex}`
|
||||
: captureStep.block_id,
|
||||
};
|
||||
|
||||
// WP-26: Verwende erweiterte renderCaptureText Funktion
|
||||
const rendered = renderCaptureText(captureStep, {
|
||||
const rendered = renderCaptureText(loopStepWithBlockId, {
|
||||
collectedData: new Map([[nestedStep.key, fieldValue]]),
|
||||
loopContexts: answers.loopContexts,
|
||||
}, context);
|
||||
@@ -442,8 +576,16 @@ function renderLoopRecursive(
|
||||
itemData.set(headingLevelKey, headingLevel);
|
||||
}
|
||||
|
||||
// WP-26: Erstelle temporären Step mit nummerierter Block-ID für Loop-Items
|
||||
const loopStepWithBlockId: CaptureTextLineStep = {
|
||||
...captureStep,
|
||||
block_id: captureStep.generate_block_id
|
||||
? `${slugify(captureStep.key)}-${itemIndex}`
|
||||
: captureStep.block_id,
|
||||
};
|
||||
|
||||
// WP-26: Verwende erweiterte renderCaptureTextLine Funktion
|
||||
const rendered = renderCaptureTextLine(captureStep, {
|
||||
const rendered = renderCaptureTextLine(loopStepWithBlockId, {
|
||||
collectedData: itemData,
|
||||
loopContexts: answers.loopContexts,
|
||||
}, context);
|
||||
@@ -537,14 +679,15 @@ function renderTemplate(template: string, tokens: { text: string; field: string;
|
||||
|
||||
/**
|
||||
* Kombiniert Heading, Section-Type-Callout, Content und Edges zu einer Section.
|
||||
* Formatierungsregel: Section-Type direkt nach Heading, Edges am Ende.
|
||||
* Formatierungsregel: Section-Type direkt nach Heading, Edges im abstract wrapper am Ende.
|
||||
*/
|
||||
function combineSectionParts(
|
||||
heading: string,
|
||||
sectionTypeCallout: string,
|
||||
content: string,
|
||||
references: string,
|
||||
autoEdges: string
|
||||
autoEdges: string,
|
||||
backwardEdges: string = ""
|
||||
): string {
|
||||
const parts: string[] = [];
|
||||
|
||||
@@ -560,18 +703,97 @@ function combineSectionParts(
|
||||
parts.push(content);
|
||||
}
|
||||
|
||||
// WP-26: Edges am Ende der Sektion (Referenzen + automatische Edges)
|
||||
const edges = [references, autoEdges].filter(e => e.trim()).join("\n");
|
||||
if (edges) {
|
||||
parts.push(edges);
|
||||
// WP-26: Alle Edges im abstract wrapper am Ende der Sektion
|
||||
const allEdges = [references, autoEdges, backwardEdges].filter(e => e.trim());
|
||||
if (allEdges.length > 0) {
|
||||
const abstractWrapper = buildAbstractWrapper(allEdges.join("\n"));
|
||||
if (abstractWrapper) {
|
||||
parts.push(abstractWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
return parts.join("\n\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Erstellt einen abstract wrapper für Edges.
|
||||
* Format: > [!abstract]- 🕸️ Semantic Mapping\n>> [!edge] type\n>> [[link]]
|
||||
*/
|
||||
function buildAbstractWrapper(edgesContent: string): string | null {
|
||||
if (!edgesContent.trim()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Parse edges aus dem Content
|
||||
const edgeLines = edgesContent.split("\n").filter(line => line.trim());
|
||||
const edgeGroups = new Map<string, string[]>();
|
||||
|
||||
let currentEdgeType: string | null = null;
|
||||
for (const line of edgeLines) {
|
||||
// Prüfe auf Edge-Type: > [!edge] type
|
||||
const edgeMatch = line.match(/^>\s*\[!edge\]\s+(.+)$/);
|
||||
if (edgeMatch && edgeMatch[1]) {
|
||||
currentEdgeType = edgeMatch[1].trim();
|
||||
if (!edgeGroups.has(currentEdgeType)) {
|
||||
edgeGroups.set(currentEdgeType, []);
|
||||
}
|
||||
} else {
|
||||
// Prüfe auf Link: > [[#^block-id]]
|
||||
const linkMatch = line.match(/^>\s*(\[\[#\^.+?\]\])$/);
|
||||
if (linkMatch && linkMatch[1] && currentEdgeType) {
|
||||
const links = edgeGroups.get(currentEdgeType) || [];
|
||||
links.push(linkMatch[1]);
|
||||
edgeGroups.set(currentEdgeType, links);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (edgeGroups.size === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Build abstract wrapper
|
||||
const wrapperLines: string[] = [];
|
||||
wrapperLines.push(`> [!abstract]- 🕸️ Semantic Mapping`);
|
||||
|
||||
// Sort edge types alphabetically
|
||||
const sortedEdgeTypes = Array.from(edgeGroups.keys()).sort();
|
||||
|
||||
for (let i = 0; i < sortedEdgeTypes.length; i++) {
|
||||
const edgeType = sortedEdgeTypes[i];
|
||||
if (!edgeType) continue;
|
||||
const links = edgeGroups.get(edgeType) || [];
|
||||
|
||||
if (links.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Add separator between groups (except before first)
|
||||
if (i > 0) {
|
||||
wrapperLines.push(">");
|
||||
}
|
||||
|
||||
// Edge header
|
||||
wrapperLines.push(`>> [!edge] ${edgeType}`);
|
||||
|
||||
// Links (sorted for determinism)
|
||||
const sortedLinks = [...links].sort();
|
||||
for (const link of sortedLinks) {
|
||||
wrapperLines.push(`>> ${link}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Add block-id marker
|
||||
wrapperLines.push(`> ^map-${Date.now()}`);
|
||||
|
||||
return wrapperLines.join("\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Generiert Edge-Callouts für explizite Referenzen.
|
||||
* Format: > [!edge] <edge_type>\n> [[#^block-id]]
|
||||
*
|
||||
* WP-26: Unterstützt auch Basis-Block-IDs für Loop-Items (z.B. "action_heading" wird zu "action_heading-1", "action_heading-2" aufgelöst)
|
||||
*/
|
||||
function renderReferences(
|
||||
references: Array<{ block_id: string; edge_type?: string }>,
|
||||
@@ -585,35 +807,98 @@ function renderReferences(
|
||||
const edgeCallouts: string[] = [];
|
||||
|
||||
for (const ref of references) {
|
||||
// Prüfe, ob Block-ID existiert
|
||||
// WP-26: Auflösung der Block-ID (für Loop-Items mit Basis-Block-ID)
|
||||
let resolvedBlockId = ref.block_id;
|
||||
|
||||
// Prüfe, ob Block-ID direkt existiert
|
||||
if (!context.generatedBlockIds.has(ref.block_id)) {
|
||||
console.warn(`[WP-26] Block-ID "${ref.block_id}" nicht gefunden für Referenz`);
|
||||
continue;
|
||||
// Versuche, Block-ID mit Index aufzulösen (für Loop-Items)
|
||||
// Suche nach Block-IDs, die mit der Basis-Block-ID beginnen
|
||||
let foundBlockId: string | null = null;
|
||||
for (const [blockId] of context.generatedBlockIds.entries()) {
|
||||
// Prüfe, ob Block-ID mit Basis-Block-ID beginnt (z.B. "action_heading-1", "action_heading-2")
|
||||
if (blockId.startsWith(`${ref.block_id}-`)) {
|
||||
// Verwende die neueste gefundene Block-ID (höchster Index)
|
||||
if (!foundBlockId || blockId > foundBlockId) {
|
||||
foundBlockId = blockId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foundBlockId) {
|
||||
resolvedBlockId = foundBlockId;
|
||||
} else {
|
||||
console.warn(`[WP-26] Block-ID "${ref.block_id}" nicht gefunden für Referenz`);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// WP-26: Prüfe auf Selbstreferenz
|
||||
if (ref.block_id === currentSection.blockId) {
|
||||
console.warn(`[WP-26] Selbstreferenz verhindert: Block-ID "${ref.block_id}" zeigt auf sich selbst`);
|
||||
if (resolvedBlockId === currentSection.blockId) {
|
||||
console.warn(`[WP-26] Selbstreferenz verhindert: Block-ID "${resolvedBlockId}" zeigt auf sich selbst`);
|
||||
continue;
|
||||
}
|
||||
|
||||
const edgeType = ref.edge_type || "related_to";
|
||||
edgeCallouts.push(`> [!edge] ${edgeType}`);
|
||||
edgeCallouts.push(`> [[#^${ref.block_id}]]`);
|
||||
edgeCallouts.push(`> [[#^${resolvedBlockId}]]`);
|
||||
}
|
||||
|
||||
return edgeCallouts.join("\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Generiert automatische Edge-Vorschläge zwischen Sections.
|
||||
* Verwendet graph_schema.md für typische Edge-Types und edge_vocabulary.md für inverse Edges.
|
||||
*
|
||||
* Formatierungsregel: Edges werden am Ende der aktuellen Section eingefügt.
|
||||
* Forward-Edge: prevSection -> currentSection (in aktueller Section)
|
||||
* Rückwärts-Edge: currentSection -> prevSection (in aktueller Section, inverser Edge-Type)
|
||||
* Ermittelt den effektiven Section-Type basierend auf Heading-Level.
|
||||
* Wenn eine Section keinen expliziten Type hat, wird der Type der vorherigen Section
|
||||
* auf dem gleichen oder höheren Level verwendet, sonst Note-Type.
|
||||
*/
|
||||
function renderAutomaticEdges(
|
||||
function getEffectiveSectionType(
|
||||
section: SectionInfo,
|
||||
index: number,
|
||||
sectionSequence: SectionInfo[]
|
||||
): string {
|
||||
// Wenn expliziter Section-Type vorhanden, verwende diesen
|
||||
if (section.sectionType) {
|
||||
return section.sectionType;
|
||||
}
|
||||
|
||||
// Extrahiere Heading-Level aus der Überschrift
|
||||
const headingMatch = section.heading.match(/^(#{1,6})\s+/);
|
||||
const currentLevel = headingMatch ? headingMatch[1]?.length || 0 : 0;
|
||||
|
||||
// Suche rückwärts nach der letzten Section mit explizitem Type auf gleichem oder höherem Level
|
||||
for (let i = index - 1; i >= 0; i--) {
|
||||
const prevSection = sectionSequence[i];
|
||||
if (!prevSection) continue;
|
||||
|
||||
const prevHeadingMatch = prevSection.heading.match(/^(#{1,6})\s+/);
|
||||
const prevLevel = prevHeadingMatch ? prevHeadingMatch[1]?.length || 0 : 0;
|
||||
|
||||
// Wenn vorherige Section auf gleichem oder höherem Level einen expliziten Type hat
|
||||
if (prevLevel <= currentLevel && prevSection.sectionType) {
|
||||
return prevSection.sectionType;
|
||||
}
|
||||
|
||||
// Wenn wir auf ein höheres Level stoßen, stoppe die Suche
|
||||
if (prevLevel < currentLevel) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: Note-Type
|
||||
return section.noteType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generiert automatische Forward-Edges zwischen Sections.
|
||||
* Forward-Edge: prevSection -> currentSection (in aktueller Section)
|
||||
* Generiert Edges zu ALLEN vorherigen Sections (nicht nur zur direkt vorherigen).
|
||||
* Verwendet graph_schema.md für typische Edge-Types.
|
||||
*
|
||||
* Spezifikation: Alle Sections haben Edges zu allen anderen Sections.
|
||||
* Edge-Types werden aus graph_schema.md abgeleitet.
|
||||
*/
|
||||
function renderForwardEdges(
|
||||
currentSection: SectionInfo,
|
||||
context: RenderContext
|
||||
): string {
|
||||
@@ -622,43 +907,158 @@ function renderAutomaticEdges(
|
||||
return "";
|
||||
}
|
||||
|
||||
// Nur wenn es vorherige Sections gibt
|
||||
if (context.sectionSequence.length <= 1) {
|
||||
return "";
|
||||
// Finde Index der aktuellen Section in der Sequenz
|
||||
const currentIndex = context.sectionSequence.findIndex(
|
||||
s => s.blockId === currentSection.blockId && s.stepKey === currentSection.stepKey
|
||||
);
|
||||
|
||||
if (currentIndex === -1 || currentIndex === 0) {
|
||||
return ""; // Keine vorherigen Sections
|
||||
}
|
||||
|
||||
// Aktuelle Section ist die letzte in der Sequenz
|
||||
// Wir generieren Edges von allen vorherigen Sections zur aktuellen Section
|
||||
const prevSections = context.sectionSequence.slice(0, -1);
|
||||
// ALLE vorherigen Sections (nicht nur die direkt vorherige)
|
||||
const prevSections = context.sectionSequence.slice(0, currentIndex);
|
||||
|
||||
const edgeCallouts: string[] = [];
|
||||
const { graphSchema, vocabulary } = context.options;
|
||||
const { graphSchema } = context.options;
|
||||
|
||||
for (const prevSection of prevSections) {
|
||||
for (let prevIdx = 0; prevIdx < prevSections.length; prevIdx++) {
|
||||
const prevSection = prevSections[prevIdx];
|
||||
// Nur wenn vorherige Section auch eine Block-ID hat
|
||||
if (!prevSection.blockId) {
|
||||
if (!prevSection || !prevSection.blockId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// WP-26: Prüfe auf Selbstreferenz (sollte nicht vorkommen, aber sicherheitshalber prüfen)
|
||||
// WP-26: Prüfe auf Selbstreferenz
|
||||
if (prevSection.blockId === currentSection.blockId) {
|
||||
console.warn(`[WP-26] Selbstreferenz verhindert: Block-ID "${prevSection.blockId}" zeigt auf sich selbst`);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ermittle effective_types
|
||||
const prevType = prevSection.sectionType || prevSection.noteType;
|
||||
const currentType = currentSection.sectionType || currentSection.noteType;
|
||||
// WP-26: Auflösung der Block-ID für Loop-Items
|
||||
// Prüfe zuerst, ob die Block-ID direkt existiert
|
||||
let resolvedPrevBlockId = prevSection.blockId;
|
||||
if (!context.generatedBlockIds.has(prevSection.blockId)) {
|
||||
// Versuche, Block-ID mit Index aufzulösen (für Loop-Items)
|
||||
// Suche nach Block-IDs, die mit der Basis-Block-ID beginnen
|
||||
let foundBlockId: string | null = null;
|
||||
for (const [blockId] of context.generatedBlockIds.entries()) {
|
||||
if (blockId.startsWith(`${prevSection.blockId}-`)) {
|
||||
// Verwende die neueste gefundene Block-ID (höchster Index)
|
||||
if (!foundBlockId || blockId > foundBlockId) {
|
||||
foundBlockId = blockId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foundBlockId) {
|
||||
resolvedPrevBlockId = foundBlockId;
|
||||
}
|
||||
}
|
||||
|
||||
// Lookup in graph_schema.md: prevType -> currentType
|
||||
// WP-26: Prüfe zuerst, ob ein manuell geänderter Edge-Type vorhanden ist
|
||||
let forwardEdgeType: string | null = null;
|
||||
if (context.options.sectionEdgeTypes) {
|
||||
const fromBlockId = prevSection.blockId;
|
||||
const toBlockId = currentSection.blockId;
|
||||
if (fromBlockId && toBlockId) {
|
||||
const fromMap = context.options.sectionEdgeTypes.get(fromBlockId);
|
||||
if (fromMap) {
|
||||
forwardEdgeType = fromMap.get(toBlockId) || null;
|
||||
if (forwardEdgeType) {
|
||||
console.log(`[WP-26] Verwende manuell geänderten Edge-Type: ${fromBlockId} -> ${toBlockId} = ${forwardEdgeType}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Falls kein manuell geänderter Edge-Type vorhanden, verwende graph_schema
|
||||
if (!forwardEdgeType) {
|
||||
// WP-26: Ermittle effective_types mit Heading-Level-basierter Fallback-Logik
|
||||
const prevType = getEffectiveSectionType(prevSection, prevIdx, context.sectionSequence);
|
||||
const currentType = getEffectiveSectionType(currentSection, currentIndex, context.sectionSequence);
|
||||
|
||||
// Lookup in graph_schema.md: prevType -> currentType
|
||||
if (graphSchema && prevType && currentType) {
|
||||
const hints = getHints(graphSchema, prevType, currentType);
|
||||
if (hints.typical.length > 0) {
|
||||
forwardEdgeType = hints.typical[0] || null;
|
||||
} else {
|
||||
console.debug(`[WP-26] Keine typischen Edges gefunden für ${prevType} -> ${currentType}, verwende Fallback`);
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: related_to für experience -> experience, references für andere
|
||||
if (!forwardEdgeType) {
|
||||
if (prevType === currentType && prevType === "experience") {
|
||||
forwardEdgeType = "related_to";
|
||||
} else {
|
||||
forwardEdgeType = "references";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WP-26: Forward-Edge generieren (prevSection -> currentSection)
|
||||
// Diese Edge wird in der aktuellen Section eingefügt
|
||||
edgeCallouts.push(`> [!edge] ${forwardEdgeType}`);
|
||||
edgeCallouts.push(`> [[#^${resolvedPrevBlockId}]]`);
|
||||
}
|
||||
|
||||
return edgeCallouts.join("\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Generiert eine einzelne Backward-Edge zwischen zwei Sections.
|
||||
* Backward-Edge: currentSection -> prevSection (wird in prevSection eingefügt)
|
||||
*
|
||||
* Wenn Section A -> Section B (Forward-Edge), dann wird Backward-Edge (B -> A) in Section A eingefügt.
|
||||
*/
|
||||
function renderSingleBackwardEdge(
|
||||
currentSection: SectionInfo,
|
||||
prevSection: SectionInfo,
|
||||
currentIndex: number,
|
||||
prevIndex: number,
|
||||
context: RenderContext
|
||||
): string {
|
||||
// Nur wenn beide Sections Block-IDs haben
|
||||
if (!currentSection.blockId || !prevSection.blockId) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// WP-26: Prüfe auf Selbstreferenz
|
||||
if (prevSection.blockId === currentSection.blockId) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const { graphSchema, vocabulary } = context.options;
|
||||
|
||||
// WP-26: Prüfe zuerst, ob ein manuell geänderter Edge-Type vorhanden ist
|
||||
let forwardEdgeType: string | null = null;
|
||||
if (context.options.sectionEdgeTypes) {
|
||||
const fromBlockId = prevSection.blockId;
|
||||
const toBlockId = currentSection.blockId;
|
||||
if (fromBlockId && toBlockId) {
|
||||
const fromMap = context.options.sectionEdgeTypes.get(fromBlockId);
|
||||
if (fromMap) {
|
||||
forwardEdgeType = fromMap.get(toBlockId) || null;
|
||||
if (forwardEdgeType) {
|
||||
console.log(`[WP-26] Verwende manuell geänderten Edge-Type für Backward-Edge: ${fromBlockId} -> ${toBlockId} = ${forwardEdgeType}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Falls kein manuell geänderter Edge-Type vorhanden, verwende graph_schema
|
||||
if (!forwardEdgeType) {
|
||||
// WP-26: Ermittle effective_types mit Heading-Level-basierter Fallback-Logik
|
||||
const prevType = getEffectiveSectionType(prevSection, prevIndex, context.sectionSequence);
|
||||
const currentType = getEffectiveSectionType(currentSection, currentIndex, context.sectionSequence);
|
||||
|
||||
// Lookup in graph_schema.md: prevType -> currentType (Forward-Edge-Type)
|
||||
if (graphSchema && prevType && currentType) {
|
||||
const hints = getHints(graphSchema, prevType, currentType);
|
||||
if (hints.typical.length > 0) {
|
||||
forwardEdgeType = hints.typical[0]; // Erster typischer Edge-Type aus graph_schema
|
||||
} else {
|
||||
// Debug: Log wenn keine typischen Edges gefunden wurden
|
||||
console.debug(`[WP-26] Keine typischen Edges gefunden für ${prevType} -> ${currentType}`);
|
||||
forwardEdgeType = hints.typical[0] || null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -666,32 +1066,136 @@ function renderAutomaticEdges(
|
||||
if (!forwardEdgeType) {
|
||||
forwardEdgeType = "related_to";
|
||||
}
|
||||
|
||||
// WP-26: Automatische Edge-Vorschläge
|
||||
// Wir generieren beide Richtungen:
|
||||
// 1. Forward-Edge: prevSection -> currentSection (mit originalem Edge-Type)
|
||||
// 2. Rückwärts-Edge: currentSection -> prevSection (mit inversem Edge-Type)
|
||||
//
|
||||
// Beide Edges werden in der aktuellen Section eingefügt und zeigen zur prevSection
|
||||
// Der Backlink wird automatisch mitgesetzt
|
||||
|
||||
// Rückwärts-Edge: currentSection -> prevSection (mit inversem Edge-Type)
|
||||
let inverseEdgeType: string | null = null;
|
||||
if (vocabulary) {
|
||||
inverseEdgeType = vocabulary.getInverse(forwardEdgeType);
|
||||
}
|
||||
|
||||
// Generiere Rückwärts-Edge (currentSection -> prevSection)
|
||||
if (inverseEdgeType) {
|
||||
edgeCallouts.push(`> [!edge] ${inverseEdgeType}`);
|
||||
edgeCallouts.push(`> [[#^${prevSection.blockId}]]`);
|
||||
}
|
||||
|
||||
// Generiere Forward-Edge als Backlink (prevSection -> currentSection)
|
||||
// Diese Edge beschreibt die Beziehung von prevSection zu currentSection
|
||||
edgeCallouts.push(`> [!edge] ${forwardEdgeType}`);
|
||||
edgeCallouts.push(`> [[#^${prevSection.blockId}]]`);
|
||||
}
|
||||
|
||||
return edgeCallouts.join("\n");
|
||||
// WP-26: Backward-Edge generieren (currentSection -> prevSection)
|
||||
// Das ist die inverse Edge zu der Forward-Edge (prevSection -> currentSection)
|
||||
let backwardEdgeType: string = forwardEdgeType;
|
||||
if (vocabulary) {
|
||||
const inverse = vocabulary.getInverse(forwardEdgeType);
|
||||
if (inverse) {
|
||||
backwardEdgeType = inverse;
|
||||
}
|
||||
}
|
||||
|
||||
// WP-26: Backward-Edge (currentSection -> prevSection) wird in prevSection eingefügt
|
||||
// Diese Edge zeigt von currentSection zurück zu prevSection
|
||||
return `> [!edge] ${backwardEdgeType}\n> [[#^${currentSection.blockId}]]`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt Edges zu einem bestehenden abstract wrapper hinzu oder erstellt einen neuen.
|
||||
*/
|
||||
function addEdgesToAbstractWrapper(content: string, newEdges: string): string {
|
||||
if (!newEdges.trim()) {
|
||||
return content;
|
||||
}
|
||||
|
||||
// Prüfe, ob bereits ein abstract wrapper vorhanden ist
|
||||
const abstractWrapperMatch = content.match(/(> \[!abstract\][^\n]*\n(?:>>?[^\n]*\n)*> \^map-\d+)/);
|
||||
|
||||
if (abstractWrapperMatch && abstractWrapperMatch[1]) {
|
||||
// Füge neue Edges zum bestehenden wrapper hinzu
|
||||
const existingWrapper = abstractWrapperMatch[1];
|
||||
const updatedWrapper = mergeEdgesIntoWrapper(existingWrapper, newEdges);
|
||||
if (abstractWrapperMatch[0]) {
|
||||
return content.replace(abstractWrapperMatch[0], updatedWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// Erstelle neuen abstract wrapper
|
||||
const abstractWrapper = buildAbstractWrapper(newEdges);
|
||||
if (abstractWrapper) {
|
||||
return content.trimEnd() + "\n\n" + abstractWrapper;
|
||||
}
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Merged neue Edges in einen bestehenden abstract wrapper.
|
||||
*/
|
||||
function mergeEdgesIntoWrapper(existingWrapper: string, newEdges: string): string {
|
||||
// Parse bestehenden wrapper
|
||||
const lines = existingWrapper.split("\n");
|
||||
const wrapperHeader = lines[0] || "> [!abstract]- 🕸️ Semantic Mapping";
|
||||
const mapMarker = lines[lines.length - 1] || `> ^map-${Date.now()}`;
|
||||
|
||||
// Parse bestehende Edges
|
||||
const existingGroups = new Map<string, string[]>();
|
||||
let currentEdgeType: string | null = null;
|
||||
|
||||
for (let i = 1; i < lines.length - 1; i++) {
|
||||
const line = lines[i];
|
||||
if (!line) continue;
|
||||
|
||||
const edgeMatch = line.match(/^>>\s*\[!edge\]\s+(.+)$/);
|
||||
if (edgeMatch && edgeMatch[1]) {
|
||||
currentEdgeType = edgeMatch[1].trim();
|
||||
if (!existingGroups.has(currentEdgeType)) {
|
||||
existingGroups.set(currentEdgeType, []);
|
||||
}
|
||||
} else {
|
||||
const linkMatch = line.match(/^>>\s*(\[\[#\^.+?\]\])$/);
|
||||
if (linkMatch && linkMatch[1] && currentEdgeType) {
|
||||
const links = existingGroups.get(currentEdgeType) || [];
|
||||
links.push(linkMatch[1]);
|
||||
existingGroups.set(currentEdgeType, links);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Parse neue Edges
|
||||
const newEdgeLines = newEdges.split("\n").filter(line => line.trim());
|
||||
for (const line of newEdgeLines) {
|
||||
const edgeMatch = line.match(/^>\s*\[!edge\]\s+(.+)$/);
|
||||
if (edgeMatch && edgeMatch[1]) {
|
||||
currentEdgeType = edgeMatch[1].trim();
|
||||
if (!existingGroups.has(currentEdgeType)) {
|
||||
existingGroups.set(currentEdgeType, []);
|
||||
}
|
||||
} else {
|
||||
const linkMatch = line.match(/^>\s*(\[\[#\^.+?\]\])$/);
|
||||
if (linkMatch && linkMatch[1] && currentEdgeType) {
|
||||
const links = existingGroups.get(currentEdgeType) || [];
|
||||
// Prüfe auf Duplikate
|
||||
if (!links.includes(linkMatch[1])) {
|
||||
links.push(linkMatch[1]);
|
||||
}
|
||||
existingGroups.set(currentEdgeType, links);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Build merged wrapper
|
||||
const wrapperLines: string[] = [];
|
||||
wrapperLines.push(wrapperHeader);
|
||||
|
||||
const sortedEdgeTypes = Array.from(existingGroups.keys()).sort();
|
||||
|
||||
for (let i = 0; i < sortedEdgeTypes.length; i++) {
|
||||
const edgeType = sortedEdgeTypes[i];
|
||||
if (!edgeType) continue;
|
||||
const links = existingGroups.get(edgeType) || [];
|
||||
|
||||
if (links.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i > 0) {
|
||||
wrapperLines.push(">");
|
||||
}
|
||||
|
||||
wrapperLines.push(`>> [!edge] ${edgeType}`);
|
||||
|
||||
const sortedLinks = [...links].sort();
|
||||
for (const link of sortedLinks) {
|
||||
wrapperLines.push(`>> ${link}`);
|
||||
}
|
||||
}
|
||||
|
||||
wrapperLines.push(mapMarker);
|
||||
|
||||
return wrapperLines.join("\n");
|
||||
}
|
||||
@@ -11,6 +11,15 @@ export interface PendingEdgeAssignment {
|
||||
createdAt: number;
|
||||
}
|
||||
|
||||
// WP-26: Section-Info für Block-ID und Section-Type Tracking
|
||||
export interface SectionInfo {
|
||||
stepKey: string;
|
||||
sectionType: string | null;
|
||||
heading: string;
|
||||
blockId: string | null;
|
||||
noteType: string;
|
||||
}
|
||||
|
||||
export interface WizardState {
|
||||
profile: InterviewProfile;
|
||||
currentStepIndex: number;
|
||||
@@ -21,6 +30,9 @@ export interface WizardState {
|
||||
patches: Patch[]; // Collected patches to apply
|
||||
activeLoopPath: string[]; // Stack of loop keys representing current nesting level (e.g. ["items", "item_list"])
|
||||
pendingEdgeAssignments: PendingEdgeAssignment[]; // Inline micro edge assignments collected during wizard
|
||||
// WP-26: Section-Type und Block-ID Tracking
|
||||
generatedBlockIds: Map<string, SectionInfo>;
|
||||
sectionSequence: SectionInfo[];
|
||||
}
|
||||
|
||||
export interface Patch {
|
||||
|
||||
Reference in new issue
Block a user