Enhance interview configuration and rendering for WP-26 integration
Node.js build / build (20.x) (push) Waiting to run
Node.js build / build (22.x) (push) Waiting to run

- Expanded the interview configuration YAML to include new profiles for experience and insight, with detailed steps for capturing user input.
- Updated the parsing logic to support new input types, including select options, enhancing user interaction during interviews.
- Improved the rendering logic to ensure correct handling of section edges and types, aligning with the updated configuration structure.
- Enhanced tests to validate the new configurations and rendering behavior, ensuring robustness in the interview process.
This commit is contained in:
Lars committed 2026-01-30 18:27:38 +01:00
1 parent 8186ca5ce0
commit 054cfcf82d
7 files changed
+783 -266

No files matched your search

+27 -1
View File
@@ -284,7 +284,33 @@ function parseStep(raw: Record<string, unknown>): InterviewStep | null {
if (typeof raw.prompt === "string" && raw.prompt.trim()) {
step.prompt = raw.prompt.trim();
}
// Parse input (kind: select | number | text_line, options for select)
if (raw.input && typeof raw.input === "object") {
const input = raw.input as Record<string, unknown>;
const inputKind =
typeof input.kind === "string" && input.kind.trim()
? (input.kind.trim() as "text_line" | "number" | "select")
: "text_line";
step.input = { kind: inputKind };
if (inputKind === "select" && Array.isArray(input.options)) {
step.input.options = [];
for (const opt of input.options) {
if (opt && typeof opt === "object") {
const o = opt as Record<string, unknown>;
const label = typeof o.label === "string" ? o.label.trim() : "";
const value = typeof o.value === "number" ? o.value : typeof o.value === "string" ? o.value : "";
if (label !== "" || value !== "") {
step.input!.options!.push({ label: label || String(value), value });
}
}
}
}
if (typeof input.min === "number") step.input.min = input.min;
if (typeof input.max === "number") step.input.max = input.max;
if (typeof input.step === "number") step.input.step = input.step;
}
// Parse output.template
if (raw.output && typeof raw.output === "object") {
const output = raw.output as Record<string, unknown>;
+3 -3
View File
@@ -285,9 +285,9 @@ 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[\s\S]*?Einsicht-Text\n\n(> \[!edge\][\s\S]*)/)?.[1];
// Prüfe, dass Edges am Ende der Einsicht-Sektion stehen (nach dem Text; Abstract-Wrapper nutzt >>)
const insightSection = result.match(/## Einsicht[\s\S]*?Einsicht-Text\n\n([\s\S]*?\[!edge\][\s\S]*)/)?.[1];
expect(insightSection).toBeDefined();
expect(insightSection).toMatch(/> \[!edge\]/);
expect(insightSection).toMatch(/>+ \[!edge\]/);
});
});
+21 -36
View File
@@ -36,28 +36,13 @@ export function renderProfileToMarkdown(
answers: RenderAnswers,
options?: RenderOptions
): 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] : [];
// WP-26: Section-Sequenz und Block-IDs ausschließlich während des Render-Durchlaufs aufbauen.
// Kein Vorfüllen aus answers.sectionSequence, damit nur Sektionen mit tatsächlichem Inhalt
// (die gerendert werden) in der Sequenz landen – keine Kanten zu nicht existierenden Sektionen.
const sectionSequence: SectionInfo[] = [];
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) {
if (sectionInfo.blockId) {
generatedBlockIds.set(sectionInfo.blockId, sectionInfo);
}
}
}
console.log(`[WP-26] renderProfileToMarkdown: sectionSequence wird beim Rendern aufgebaut (kein Vorfüllen).`);
const context: RenderContext = {
profile,
@@ -998,9 +983,18 @@ function renderForwardEdges(
}
}
// WP-26: Forward-Edge generieren (prevSection -> currentSection)
// Diese Edge wird in der aktuellen Section eingefügt
edgeCallouts.push(`> [!edge] ${forwardEdgeType}`);
// WP-26: In der aktuellen Section steht ein Link ZU prev → reale Kante ist current -> prev.
// sectionEdgeTypes liefert den Type für prev -> current; hier brauchen wir die Inverse (current -> prev).
const { vocabulary } = context.options;
let edgeTypeForCallout = forwardEdgeType;
if (vocabulary) {
const canonical = vocabulary.getCanonical(forwardEdgeType);
const inverse = canonical ? vocabulary.getInverse(canonical) : null;
if (inverse) {
edgeTypeForCallout = inverse;
}
}
edgeCallouts.push(`> [!edge] ${edgeTypeForCallout}`);
edgeCallouts.push(`> [[#^${resolvedPrevBlockId}]]`);
}
@@ -1068,19 +1062,10 @@ function renderSingleBackwardEdge(
}
}
// 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}]]`;
// WP-26: Backward-Edge wird in prevSection eingefügt: Link von prev zu current → reale Kante ist prev -> current.
// sectionEdgeTypes liefert genau den Type für prev -> current; also forwardEdgeType unverändert verwenden.
// (Keine Inverse: Die Kante im Text ist prev -> current, nicht current -> prev.)
return `> [!edge] ${forwardEdgeType}\n> [[#^${currentSection.blockId}]]`;
}
/**
+8
View File
@@ -64,6 +64,14 @@ export interface CaptureFrontmatterStep {
field: string;
required?: boolean;
prompt?: string; // Optional prompt text
/** Input UI: "text_line" (default) or "select" with options */
input?: {
kind: "text_line" | "number" | "select";
options?: Array<{ label: string; value: string | number }>;
min?: number;
max?: number;
step?: number;
};
output?: {
template?: string; // Template with tokens: {text}, {field}, {value}
};