pub struct WikiGenerator<'a, P: LlmProvider> { /* private fields */ }Expand description
Wiki 页面生成器
通过 LLM 为每个模块生成叙述性的 Wiki 页面, 供人类开发者阅读和理解代码。
Implementations§
Source§impl<'a, P: LlmProvider> WikiGenerator<'a, P>
impl<'a, P: LlmProvider> WikiGenerator<'a, P>
Sourcepub fn new(provider: &'a P, max_concurrent: usize) -> Self
pub fn new(provider: &'a P, max_concurrent: usize) -> Self
使用指定的 LLM Provider 创建 WikiGenerator
max_concurrent 控制 describe_modules 的并行上限(0 表示不限制)。
Sourcepub fn llm_call_count(&self) -> usize
pub fn llm_call_count(&self) -> usize
返回已完成的 LLM 调用次数
Sourcepub fn failed_modules(&self) -> Vec<String>
pub fn failed_modules(&self) -> Vec<String>
返回生成失败的模块名列表(演进计划 T3.2:失败隔离的可见性出口)
Sourcepub async fn generate_wiki_page(
&self,
chunk: &Chunk,
card_summary: &str,
config: &WikiConfig,
root: &ProjectRoot,
entity_ranges: Option<&EntityRanges>,
) -> Result<WikiDocument>
pub async fn generate_wiki_page( &self, chunk: &Chunk, card_summary: &str, config: &WikiConfig, root: &ProjectRoot, entity_ranges: Option<&EntityRanges>, ) -> Result<WikiDocument>
生成模块 Wiki 页面
chunk— 模块的代码数据块card_summary— 之前生成的 Knowledge Card 摘要,作为上下文参考config— Wiki 配置(用于获取语言设置等)
P0-1 引用契约:生成后校验源码引用(文件存在 + 行号有效),
引用无效时重试(最多 CITATION_RETRY_MAX 次,用户决策“总是重试“)。
重试注入错误反馈(无效引用清单),最后一次仍失败时返回错误——
由调用方失败隔离(record_failure)记录,不产出无引用的页面。
G2 Mermaid 契约:正文中的 Mermaid 代码块同样校验(merman 权威解析),
坏块错误消息注入重试反馈;重试耗尽后降级而非失败——坏块替换为
text fence + 标记注释(OpenWiki degrade-and-repair),页面照常产出。
Sourcepub async fn generate_architecture(
&self,
output: &GenerationOutput,
graph: &KnowledgeGraph,
config: &WikiConfig,
root: &ProjectRoot,
) -> Result<WikiDocument>
pub async fn generate_architecture( &self, output: &GenerationOutput, graph: &KnowledgeGraph, config: &WikiConfig, root: &ProjectRoot, ) -> Result<WikiDocument>
生成架构概览页面
基于所有模块的生成输出和知识图谱,生成项目级的架构概览文档。 生成前先为每个模块生成一行职责描述(describe_modules), 填充到模块快照的 description 字段——架构 prompt 依此输出模块职责, 取代原本恒为 None 的空描述(此前的 overview 只有模块名+节点数+边计数, 无法表达“模块负责什么“)。
Sourcepub async fn generate_overview(
&self,
output: &GenerationOutput,
graph: &KnowledgeGraph,
config: &WikiConfig,
root: &ProjectRoot,
) -> Result<WikiDocument>
pub async fn generate_overview( &self, output: &GenerationOutput, graph: &KnowledgeGraph, config: &WikiConfig, root: &ProjectRoot, ) -> Result<WikiDocument>
生成项目概览页面
与 generate_architecture 同签名同风格:基于完整 KnowledgeGraph 的 模块列表与模块间依赖摘要,生成全仓库概览(技术栈/目录结构/核心模块)。
Auto Trait Implementations§
impl<'a, P> !Freeze for WikiGenerator<'a, P>
impl<'a, P> RefUnwindSafe for WikiGenerator<'a, P>where
P: RefUnwindSafe,
impl<'a, P> Send for WikiGenerator<'a, P>
impl<'a, P> Sync for WikiGenerator<'a, P>
impl<'a, P> Unpin for WikiGenerator<'a, P>
impl<'a, P> UnsafeUnpin for WikiGenerator<'a, P>
impl<'a, P> UnwindSafe for WikiGenerator<'a, P>where
P: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more