zarz 0.3.1-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +2815 -0
- package/Cargo.toml +30 -0
- package/QUICKSTART.md +326 -0
- package/README.md +72 -0
- package/bin/zarz.js +80 -0
- package/package.json +53 -0
- package/scripts/postinstall.js +91 -0
- package/src/cli.rs +201 -0
- package/src/config.rs +249 -0
- package/src/conversation_store.rs +183 -0
- package/src/executor.rs +164 -0
- package/src/fs_ops.rs +117 -0
- package/src/intelligence/context.rs +143 -0
- package/src/intelligence/mod.rs +60 -0
- package/src/intelligence/rust_parser.rs +141 -0
- package/src/intelligence/symbol_search.rs +97 -0
- package/src/main.rs +867 -0
- package/src/mcp/client.rs +316 -0
- package/src/mcp/config.rs +133 -0
- package/src/mcp/manager.rs +186 -0
- package/src/mcp/mod.rs +12 -0
- package/src/mcp/types.rs +170 -0
- package/src/providers/anthropic.rs +214 -0
- package/src/providers/glm.rs +209 -0
- package/src/providers/mod.rs +90 -0
- package/src/providers/openai.rs +197 -0
- package/src/repl.rs +1910 -0
- package/src/session.rs +173 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
use super::{RustParser, Symbol};
|
|
2
|
+
use anyhow::Result;
|
|
3
|
+
use std::path::Path;
|
|
4
|
+
use walkdir::WalkDir;
|
|
5
|
+
|
|
6
|
+
pub struct SymbolSearcher;
|
|
7
|
+
|
|
8
|
+
impl SymbolSearcher {
|
|
9
|
+
pub fn search(root: &Path, name: &str) -> Result<Vec<Symbol>> {
|
|
10
|
+
let mut results = Vec::new();
|
|
11
|
+
|
|
12
|
+
for entry in WalkDir::new(root)
|
|
13
|
+
.follow_links(false)
|
|
14
|
+
.into_iter()
|
|
15
|
+
.filter_map(|e| e.ok())
|
|
16
|
+
{
|
|
17
|
+
if entry.file_type().is_file() {
|
|
18
|
+
let path = entry.path();
|
|
19
|
+
|
|
20
|
+
if let Some(ext) = path.extension() {
|
|
21
|
+
if ext == "rs" {
|
|
22
|
+
if let Ok(symbols) = RustParser::parse_file(path) {
|
|
23
|
+
for symbol in symbols {
|
|
24
|
+
if symbol.name.contains(name) {
|
|
25
|
+
results.push(symbol);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
Ok(results)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
#[allow(dead_code)]
|
|
38
|
+
pub fn search_exact(root: &Path, name: &str) -> Result<Vec<Symbol>> {
|
|
39
|
+
let mut results = Vec::new();
|
|
40
|
+
|
|
41
|
+
for entry in WalkDir::new(root)
|
|
42
|
+
.follow_links(false)
|
|
43
|
+
.into_iter()
|
|
44
|
+
.filter_map(|e| e.ok())
|
|
45
|
+
{
|
|
46
|
+
if entry.file_type().is_file() {
|
|
47
|
+
let path = entry.path();
|
|
48
|
+
|
|
49
|
+
if let Some(ext) = path.extension() {
|
|
50
|
+
if ext == "rs" {
|
|
51
|
+
if let Ok(symbols) = RustParser::parse_file(path) {
|
|
52
|
+
for symbol in symbols {
|
|
53
|
+
if symbol.name == name {
|
|
54
|
+
results.push(symbol);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
Ok(results)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
#[allow(dead_code)]
|
|
67
|
+
pub fn find_references(root: &Path, symbol_name: &str) -> Result<Vec<(String, usize)>> {
|
|
68
|
+
let mut references = Vec::new();
|
|
69
|
+
|
|
70
|
+
for entry in WalkDir::new(root)
|
|
71
|
+
.follow_links(false)
|
|
72
|
+
.into_iter()
|
|
73
|
+
.filter_map(|e| e.ok())
|
|
74
|
+
{
|
|
75
|
+
if entry.file_type().is_file() {
|
|
76
|
+
let path = entry.path();
|
|
77
|
+
|
|
78
|
+
if let Some(ext) = path.extension() {
|
|
79
|
+
if ext == "rs" {
|
|
80
|
+
if let Ok(content) = std::fs::read_to_string(path) {
|
|
81
|
+
for (line_num, line) in content.lines().enumerate() {
|
|
82
|
+
if line.contains(symbol_name) {
|
|
83
|
+
references.push((
|
|
84
|
+
format!("{}:{}", path.display(), line_num + 1),
|
|
85
|
+
line_num + 1,
|
|
86
|
+
));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
Ok(references)
|
|
96
|
+
}
|
|
97
|
+
}
|