From 5fd927403953c52b1c5d072ac8f70b7c9f3ceade Mon Sep 17 00:00:00 2001 From: ssdfasd <2156608475@qq.com> Date: Wed, 18 Mar 2026 14:49:49 +0800 Subject: [PATCH] fix: use indent check to avoid parsing params as modules/subsystems --- src/data/blueprintParser.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/data/blueprintParser.ts b/src/data/blueprintParser.ts index 04110c8..6feca45 100644 --- a/src/data/blueprintParser.ts +++ b/src/data/blueprintParser.ts @@ -52,15 +52,17 @@ function parseSubsystems(yaml: string): Subsystem[] { let current: Partial = {}; let currentField: string | null = null; + let inSubsystem = false; for (const line of lines) { const trimmed = line.trim(); + const indent = line.search(/\S/); if (trimmed.startsWith('subsystems:')) { continue; } - if (trimmed.startsWith('- name:')) { + if (trimmed.startsWith('- name:') && indent <= 2) { if (current.name) { subsystems.push({ id: current.name, @@ -77,11 +79,12 @@ function parseSubsystems(yaml: string): Subsystem[] { provides: [], depends_on: [] }; + inSubsystem = true; currentField = null; continue; } - if (!current.name) continue; + if (!inSubsystem || !current.name) continue; if (trimmed.startsWith('responsibilities:')) { currentField = 'responsibilities'; @@ -164,15 +167,17 @@ function parseModules(yaml: string): Module[] { let currentApi: Module['public_api'][0] | null = null; let inPublicApi = false; let inParams = false; + let inModule = false; for (const line of lines) { const trimmed = line.trim(); + const indent = line.search(/\S/); if (trimmed.startsWith('modules:')) { continue; } - if (trimmed.startsWith('- name:')) { + if (trimmed.startsWith('- name:') && indent <= 2) { if (current.name && current.parent_subsystem) { modules.push({ id: current.name, @@ -188,13 +193,14 @@ function parseModules(yaml: string): Module[] { responsibility: '', public_api: [] }; + inModule = true; inPublicApi = false; inParams = false; currentApi = null; continue; } - if (!current.name) continue; + if (!inModule || !current.name) continue; if (trimmed.startsWith('parent_subsystem:')) { current.parent_subsystem = trimmed.replace('parent_subsystem:', '').trim();