Skip to content

Commit da14a80

Browse files
committed
Add RouterBoundary support and timestamp option for editors
- Introduce RouterBoundary and RouterParam types to boundary analysis - Update BoundaryEditor to generate router documentation - Add should_include_timestamp to editor agents for prompt control - Update prompt builder and StepForwardAgent to support timestamp inclusion - Bump version to 1.1.5
1 parent d6bf6f8 commit da14a80

10 files changed

Lines changed: 157 additions & 49 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "deepwiki-rs"
3-
version = "1.1.1"
3+
version = "1.1.5"
44
edition = "2024"
55

66
description = "deepwiki-rs(also known as Litho) is a high-performance automatic generation engine for C4 architecture documentation, developed using Rust. It can intelligently analyze project structures, identify core components, parse dependency relationships, and leverage large language models (LLMs) to automatically generate professional architecture documentation."

src/generator/compose/agents/architecture_editor.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ impl StepForwardAgent for ArchitectureEditor {
1919
MemoryScope::DOCUMENTATION.to_string()
2020
}
2121

22+
fn should_include_timestamp(&self) -> bool {
23+
true
24+
}
25+
2226
fn data_config(&self) -> AgentDataConfig {
2327
AgentDataConfig {
2428
required_sources: vec![

src/generator/compose/agents/boundary_editor.rs

Lines changed: 93 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
use anyhow::Result;
2-
use async_trait::async_trait;
31
use crate::generator::compose::memory::MemoryScope;
42
use crate::generator::compose::types::AgentType;
53
use crate::generator::context::GeneratorContext;
64
use crate::generator::research::memory::MemoryRetriever;
7-
use crate::generator::research::types::{AgentType as ResearchAgentType, BoundaryAnalysisReport, CLIBoundary, APIBoundary, IntegrationSuggestion};
5+
use crate::generator::research::types::{
6+
APIBoundary, AgentType as ResearchAgentType, BoundaryAnalysisReport, CLIBoundary,
7+
IntegrationSuggestion, RouterBoundary,
8+
};
89
use crate::generator::step_forward_agent::{
910
AgentDataConfig, DataSource, PromptTemplate, StepForwardAgent,
1011
};
12+
use anyhow::Result;
13+
use async_trait::async_trait;
1114

1215
/// 边界接口文档编辑器 - 将边界分析结果编排为标准化文档
1316
#[derive(Default)]
@@ -25,6 +28,10 @@ impl StepForwardAgent for BoundaryEditor {
2528
MemoryScope::DOCUMENTATION.to_string()
2629
}
2730

31+
fn should_include_timestamp(&self) -> bool {
32+
true
33+
}
34+
2835
fn data_config(&self) -> AgentDataConfig {
2936
AgentDataConfig {
3037
required_sources: vec![],
@@ -98,26 +105,38 @@ impl BoundaryEditor {
98105
fn generate_boundary_documentation(&self, report: &BoundaryAnalysisReport) -> String {
99106
let mut content = String::new();
100107
content.push_str("# 系统边界接口文档\n\n");
101-
content.push_str("本文档描述了系统的外部调用接口,包括CLI命令、API端点、配置参数等边界机制。\n\n");
102-
108+
content.push_str(
109+
"本文档描述了系统的外部调用接口,包括CLI命令、API端点、配置参数等边界机制。\n\n",
110+
);
111+
103112
// 生成CLI接口文档
104113
if !report.cli_boundaries.is_empty() {
105114
content.push_str(&self.generate_cli_documentation(&report.cli_boundaries));
106115
}
107-
116+
108117
// 生成API接口文档
109118
if !report.api_boundaries.is_empty() {
110119
content.push_str(&self.generate_api_documentation(&report.api_boundaries));
111120
}
112-
121+
122+
// 生成Router路由文档
123+
if !report.router_boundaries.is_empty() {
124+
content.push_str(&self.generate_router_documentation(&report.router_boundaries));
125+
}
126+
113127
// 生成集成建议
114128
if !report.integration_suggestions.is_empty() {
115-
content.push_str(&self.generate_integration_documentation(&report.integration_suggestions));
129+
content.push_str(
130+
&self.generate_integration_documentation(&report.integration_suggestions),
131+
);
116132
}
117133

118134
// 添加分析置信度
119-
content.push_str(&format!("\n---\n\n**分析置信度**: {:.1}/10\n", report.confidence_score));
120-
135+
content.push_str(&format!(
136+
"\n---\n\n**分析置信度**: {:.1}/10\n",
137+
report.confidence_score
138+
));
139+
121140
content
122141
}
123142

@@ -128,102 +147,143 @@ impl BoundaryEditor {
128147

129148
let mut content = String::new();
130149
content.push_str("## 命令行接口 (CLI)\n\n");
131-
150+
132151
for cli in cli_boundaries {
133152
content.push_str(&format!("### {}\n\n", cli.command));
134153
content.push_str(&format!("**描述**: {}\n\n", cli.description));
135154
content.push_str(&format!("**源文件**: `{}`\n\n", cli.source_location));
136-
155+
137156
if !cli.arguments.is_empty() {
138157
content.push_str("**参数**:\n\n");
139158
for arg in &cli.arguments {
140159
let required_text = if arg.required { "必需" } else { "可选" };
141-
let default_text = arg.default_value.as_ref()
160+
let default_text = arg
161+
.default_value
162+
.as_ref()
142163
.map(|v| format!(" (默认: `{}`)", v))
143164
.unwrap_or_default();
144165
content.push_str(&format!(
145-
"- `{}` ({}): {} - {}{}\n",
166+
"- `{}` ({}): {} - {}{}\n",
146167
arg.name, arg.value_type, required_text, arg.description, default_text
147168
));
148169
}
149170
content.push_str("\n");
150171
}
151-
172+
152173
if !cli.options.is_empty() {
153174
content.push_str("**选项**:\n\n");
154175
for option in &cli.options {
155-
let short_text = option.short_name.as_ref()
176+
let short_text = option
177+
.short_name
178+
.as_ref()
156179
.map(|s| format!(", {}", s))
157180
.unwrap_or_default();
158181
let required_text = if option.required { "必需" } else { "可选" };
159-
let default_text = option.default_value.as_ref()
182+
let default_text = option
183+
.default_value
184+
.as_ref()
160185
.map(|v| format!(" (默认: `{}`)", v))
161186
.unwrap_or_default();
162187
content.push_str(&format!(
163-
"- `{}{}`({}): {} - {}{}\n",
164-
option.name, short_text, option.value_type, required_text, option.description, default_text
188+
"- `{}{}`({}): {} - {}{}\n",
189+
option.name,
190+
short_text,
191+
option.value_type,
192+
required_text,
193+
option.description,
194+
default_text
165195
));
166196
}
167197
content.push_str("\n");
168198
}
169-
199+
170200
if !cli.examples.is_empty() {
171201
content.push_str("**使用示例**:\n\n");
172202
for example in &cli.examples {
173203
content.push_str(&format!("```bash\n{}\n```\n\n", example));
174204
}
175205
}
176206
}
177-
207+
178208
content
179209
}
180-
210+
181211
fn generate_api_documentation(&self, api_boundaries: &[APIBoundary]) -> String {
182212
if api_boundaries.len() == 0 {
183213
return String::new();
184214
}
185215

186216
let mut content = String::new();
187217
content.push_str("## API接口\n\n");
188-
218+
189219
for api in api_boundaries {
190220
content.push_str(&format!("### {} {}\n\n", api.method, api.endpoint));
191221
content.push_str(&format!("**描述**: {}\n\n", api.description));
192222
content.push_str(&format!("**源文件**: `{}`\n\n", api.source_location));
193-
223+
194224
if let Some(request_format) = &api.request_format {
195225
content.push_str(&format!("**请求格式**: {}\n\n", request_format));
196226
}
197-
227+
198228
if let Some(response_format) = &api.response_format {
199229
content.push_str(&format!("**响应格式**: {}\n\n", response_format));
200230
}
201-
231+
202232
if let Some(auth) = &api.authentication {
203233
content.push_str(&format!("**认证方式**: {}\n\n", auth));
204234
}
205235
}
206-
236+
237+
content
238+
}
239+
240+
fn generate_router_documentation(&self, router_boundaries: &[RouterBoundary]) -> String {
241+
if router_boundaries.len() == 0 {
242+
return String::new();
243+
}
244+
245+
let mut content = String::new();
246+
content.push_str("## Router路由\n\n");
247+
248+
for router in router_boundaries {
249+
content.push_str(&format!("### {}\n\n", router.path));
250+
content.push_str(&format!("**描述**: {}\n\n", router.description));
251+
content.push_str(&format!("**源文件**: `{}`\n\n", router.source_location));
252+
253+
if !router.params.is_empty() {
254+
content.push_str("**参数**:\n\n");
255+
for param in &router.params {
256+
content.push_str(&format!(
257+
"- `{}` ({}): {}\n",
258+
param.key, param.value_type, param.description
259+
));
260+
}
261+
}
262+
}
263+
207264
content
208265
}
209266

210-
fn generate_integration_documentation(&self, integration_suggestions: &[IntegrationSuggestion]) -> String {
267+
fn generate_integration_documentation(
268+
&self,
269+
integration_suggestions: &[IntegrationSuggestion],
270+
) -> String {
211271
if integration_suggestions.len() == 0 {
212272
return String::new();
213273
}
214274

215275
let mut content = String::new();
216276
content.push_str("## 集成建议\n\n");
217-
277+
218278
for suggestion in integration_suggestions {
219279
content.push_str(&format!("### {}\n\n", suggestion.integration_type));
220280
content.push_str(&format!("{}\n\n", suggestion.description));
221-
281+
222282
if !suggestion.example_code.is_empty() {
223283
content.push_str("**示例代码**:\n\n");
224284
content.push_str(&format!("```\n{}\n```\n\n", suggestion.example_code));
225285
}
226-
286+
227287
if !suggestion.best_practices.is_empty() {
228288
content.push_str("**最佳实践**:\n\n");
229289
for practice in &suggestion.best_practices {
@@ -232,7 +292,7 @@ impl BoundaryEditor {
232292
content.push_str("\n");
233293
}
234294
}
235-
295+
236296
content
237297
}
238-
}
298+
}

src/generator/compose/agents/key_modules_insight_editor.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ impl StepForwardAgent for KeyModuleInsightEditor {
8989
MemoryScope::DOCUMENTATION.to_string()
9090
}
9191

92+
fn should_include_timestamp(&self) -> bool {
93+
true
94+
}
95+
9296
fn data_config(&self) -> AgentDataConfig {
9397
AgentDataConfig {
9498
required_sources: vec![

src/generator/compose/agents/overview_editor.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ impl StepForwardAgent for OverviewEditor {
1919
MemoryScope::DOCUMENTATION.to_string()
2020
}
2121

22+
fn should_include_timestamp(&self) -> bool {
23+
true
24+
}
25+
2226
fn data_config(&self) -> AgentDataConfig {
2327
AgentDataConfig {
2428
required_sources: vec![

src/generator/compose/agents/workflow_editor.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ impl StepForwardAgent for WorkflowEditor {
1919
MemoryScope::DOCUMENTATION.to_string()
2020
}
2121

22+
fn should_include_timestamp(&self) -> bool {
23+
true
24+
}
25+
2226
fn data_config(&self) -> AgentDataConfig {
2327
AgentDataConfig {
2428
required_sources: vec![

src/generator/research/agents/boundary_analyzer.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,8 @@ impl StepForwardAgent for BoundaryAnalyzer {
4545
你的任务是基于提供的边界相关代码,识别并分析:
4646
1. CLI命令行接口 - 命令、参数、选项、使用示例
4747
2. API接口 - HTTP端点、请求/响应格式、认证方式
48-
3. 配置接口 - 配置参数、数据类型、配置来源
49-
4. 库接口 - 公共函数、接口签名、可见性
50-
5. 安全边界考虑 - 潜在风险和缓解策略
51-
6. 集成建议 - 最佳实践和示例代码
48+
3. Router路由 - 页面的Router路由、URL路径、路由参数
49+
4. 集成建议 - 最佳实践和示例代码
5250
5351
重点关注:
5452
- 从Entry、Api、Controller、Router类型的代码中提取边界信息
@@ -108,8 +106,9 @@ impl StepForwardAgent for BoundaryAnalyzer {
108106
_context: &GeneratorContext,
109107
) -> Result<()> {
110108
println!("✅ 边界接口分析完成:");
111-
println!(" - CLI接口: {} 个", result.cli_boundaries.len());
109+
println!(" - CLI命令: {} 个", result.cli_boundaries.len());
112110
println!(" - API接口: {} 个", result.api_boundaries.len());
111+
println!(" - Router路由: {} 个", result.router_boundaries.len());
113112
println!(" - 集成建议: {} 项", result.integration_suggestions.len());
114113
println!(" - 置信度: {:.1}/10", result.confidence_score);
115114

src/generator/research/types.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ pub struct BoundaryAnalysisReport {
217217
pub cli_boundaries: Vec<CLIBoundary>,
218218
/// 供外部调用的网络API边界接口(包括HTTP、RPC等协议)
219219
pub api_boundaries: Vec<APIBoundary>,
220+
/// 页面路由
221+
pub router_boundaries: Vec<RouterBoundary>,
220222
/// 集成建议
221223
pub integration_suggestions: Vec<IntegrationSuggestion>,
222224
/// 分析置信度 (1-10分)
@@ -263,6 +265,21 @@ pub struct APIBoundary {
263265
pub source_location: String,
264266
}
265267

268+
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
269+
pub struct RouterBoundary {
270+
pub path: String,
271+
pub description: String,
272+
pub source_location: String,
273+
pub params: Vec<RouterParam>,
274+
}
275+
276+
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
277+
pub struct RouterParam {
278+
pub key: String,
279+
pub value_type: String,
280+
pub description: String,
281+
}
282+
266283
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
267284
pub struct IntegrationSuggestion {
268285
pub integration_type: String,
@@ -278,6 +295,7 @@ impl Default for BoundaryAnalysisReport {
278295
api_boundaries: Vec::new(),
279296
integration_suggestions: Vec::new(),
280297
confidence_score: 0.0,
298+
router_boundaries: Vec::new(),
281299
}
282300
}
283301
}

0 commit comments

Comments
 (0)