/** MD 资产内部 kind(v9 适配)。 * - "domain" : Content Domain(v7/v9 内容层) * - "blueprint" : Blueprint(v7 配置层 / v9 结构层) * - "profile" : Profile(v9 配置层,新增) * - "term" / "workflow" / "glossary" : Domain type 标签(frontmatter.type,P9 删 stack 死类型后残留的历史枚举值) * - "scene" / "manual" : v6 Struct kind 兼容(v7 资产迁移期残留) * * v9 删除了 "channel"(Channel 留作未来 Connector,本版本不实现)——不再出现在 kind 联合中。 * 如解析到历史资源带 channel 段,frontmatter.kind 可 指 配 "channel"(保留为字符串兜底)。 */ export type AssetKind = "domain" | "blueprint" | "profile" | "term" | "workflow" | "glossary" | "scene" | "manual" | "channel"; export interface Item { /** H3 标题(如 "文章"、"select-topic") */ name: string; /** "- key: value" / "- key: [a, b]" / "- key: { ... }" 字段。 * 值可以是 string / string[] / 嵌套对象(YAML 子集);consumer 用 typeof 收窄。 */ fields: Record; } export interface Section { /** "## Terms" 原文 */ heading: string; /** 段内 markdown(含 H3 子项) */ raw: string; /** H3 子项解析结果 */ items: Item[]; } export interface Asset { kind: AssetKind; /** 文件名去后缀(v7/v8 例:"project-dev.channel" / "pt-blueprint") */ name: string; frontmatter: Record; /** frontmatter 之后的 markdown */ body: string; /** H2 段名(首字母大写)→ 段内容 */ sections: Record; } /** 读 asset 文件并解析 frontmatter + H2 段。 */ export declare function readAsset(path: string): Promise; /** 解析 frontmatter --- ... --- 块(简易:key: value / key: [a, b] / key: { ... }) */ export declare function parseFrontmatter(text: string): { fm: Record; body: string; }; /** 按 `## ` 切 H2 段。H1 `# ` 不在此处理(asset 一般只有 1 个 H1 当标题) */ export declare function splitSections(body: string): Array<{ heading: string; raw: string; }>; /** 把段内 markdown 解析成 Item[]: * - 有 H3 (`### name`) → 每个 H3 是一个 item,下属 `- key: value` 是 fields * - 无 H3,整段就是 list → 顶层 `- key: value` / `- name` 直接作为 items * * 顶层 list 支持两种行形态: * - `- key: value` → { name: "key", fields: { key: value } } * - `- name` → { name: "name", fields: {} }(裸名列表,例 ## Modules 段) */ export declare function parseItems(sectionRaw: string): Item[]; /** 把 unknown 收窄为 string(数组则 join)。无值 → ""。 */ export declare function s(v: unknown): string; /** 把 unknown 收窄为 string[](单值包成 1-数组)。无值 → []。 */ export declare function sArr(v: unknown): string[]; /** 从一个 H2 段里取某个字段的标量值(兼容裸值 / 顶层 list `- key: value` / H3 项 fields.key)。 * 用途:Blueprint 聚合组 H2 下读 inject/mode,Profile 聚合组 H2 下读 ### Domains 追加列表。 */ export declare function extractFieldValue(section: Section | undefined, key: string): string; /** 同 extractBareListUnderH3(section, "Modules") 的别名(Channel 用)。 */ export declare function extractModulesList(section: Section | undefined): string[]; /** 同 extractBareListUnderH3(section, "Domains") 的别名(Blueprint 用)。 */ export declare function extractDomainsList(section: Section | undefined): string[]; /** 从一个 H2 段下取指定 H3 名下的所有裸名列表项(`- name`)。 * Usage: Blueprint `## session-context` → `### Modules` lists Domain Schema Names; * Profile `## session-context` → `### Domains` lists Domain names participating in this aggregation group. * * 行为:扫描 section.raw,找到 `### ` 行后收集紧随其后的 `- name` 行 * (无 `key: value`),遇下一个 H3 或段尾终止。 * * 兼容:若 H3 项的 fields.modules / fields.refs 是数组(旧写法),也支持。 */ export declare function extractBareListUnderH3(section: Section | undefined, h3Name: string): string[];