ci: add spell check (#82)
for code greater use spell check Signed-off-by: jokemanfire <hu.dingyang@zte.com.cn>
This commit is contained in:
parent
d5c4bf09c2
commit
c30d8063e3
3 changed files with 32 additions and 10 deletions
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
|
|
@ -60,6 +60,14 @@ jobs:
|
||||||
|
|
||||||
- name: Run clippy
|
- name: Run clippy
|
||||||
run: cargo clippy --all-targets --all-features -- -D warnings
|
run: cargo clippy --all-targets --all-features -- -D warnings
|
||||||
|
|
||||||
|
spelling:
|
||||||
|
name: spell check with typos
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Spell Check Repo
|
||||||
|
uses: crate-ci/typos@master
|
||||||
|
|
||||||
test:
|
test:
|
||||||
name: Run Tests
|
name: Run Tests
|
||||||
|
|
|
||||||
|
|
@ -213,11 +213,11 @@ pub(crate) fn tool_fn_item(attr: TokenStream, mut input_fn: ItemFn) -> syn::Resu
|
||||||
// let mut fommated_fn_args: Punctuated<FnArg, Comma> = Punctuated::new();
|
// let mut fommated_fn_args: Punctuated<FnArg, Comma> = Punctuated::new();
|
||||||
let mut unextractable_args_indexes = HashSet::new();
|
let mut unextractable_args_indexes = HashSet::new();
|
||||||
for (index, mut fn_arg) in input_fn.sig.inputs.iter_mut().enumerate() {
|
for (index, mut fn_arg) in input_fn.sig.inputs.iter_mut().enumerate() {
|
||||||
enum Catched {
|
enum Caught {
|
||||||
Param(ToolFnParamAttrs),
|
Param(ToolFnParamAttrs),
|
||||||
Aggregated(PatType),
|
Aggregated(PatType),
|
||||||
}
|
}
|
||||||
let mut catched = None;
|
let mut caught = None;
|
||||||
match &mut fn_arg {
|
match &mut fn_arg {
|
||||||
FnArg::Receiver(_) => {
|
FnArg::Receiver(_) => {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -244,7 +244,7 @@ pub(crate) fn tool_fn_item(attr: TokenStream, mut input_fn: ItemFn) -> syn::Resu
|
||||||
"input param must have an ident as name",
|
"input param must have an ident as name",
|
||||||
));
|
));
|
||||||
};
|
};
|
||||||
catched.replace(Catched::Param(ToolFnParamAttrs {
|
caught.replace(Caught::Param(ToolFnParamAttrs {
|
||||||
serde_meta: Vec::new(),
|
serde_meta: Vec::new(),
|
||||||
schemars_meta: Vec::new(),
|
schemars_meta: Vec::new(),
|
||||||
ident: arg_ident,
|
ident: arg_ident,
|
||||||
|
|
@ -252,7 +252,7 @@ pub(crate) fn tool_fn_item(attr: TokenStream, mut input_fn: ItemFn) -> syn::Resu
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
ParamMarker::Aggregated => {
|
ParamMarker::Aggregated => {
|
||||||
catched.replace(Catched::Aggregated(pat_type.clone()));
|
caught.replace(Caught::Aggregated(pat_type.clone()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if meta_list.path.is_ident(SERDE_IDENT) {
|
} else if meta_list.path.is_ident(SERDE_IDENT) {
|
||||||
|
|
@ -268,8 +268,8 @@ pub(crate) fn tool_fn_item(attr: TokenStream, mut input_fn: ItemFn) -> syn::Resu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
match catched {
|
match caught {
|
||||||
Some(Catched::Param(mut param)) => {
|
Some(Caught::Param(mut param)) => {
|
||||||
param.serde_meta = serde_metas;
|
param.serde_meta = serde_metas;
|
||||||
param.schemars_meta = schemars_metas;
|
param.schemars_meta = schemars_metas;
|
||||||
match &mut tool_macro_attrs.params {
|
match &mut tool_macro_attrs.params {
|
||||||
|
|
@ -282,7 +282,7 @@ pub(crate) fn tool_fn_item(attr: TokenStream, mut input_fn: ItemFn) -> syn::Resu
|
||||||
}
|
}
|
||||||
unextractable_args_indexes.insert(index);
|
unextractable_args_indexes.insert(index);
|
||||||
}
|
}
|
||||||
Some(Catched::Aggregated(rust_type)) => {
|
Some(Caught::Aggregated(rust_type)) => {
|
||||||
tool_macro_attrs.params = ToolParams::Aggregated { rust_type };
|
tool_macro_attrs.params = ToolParams::Aggregated { rust_type };
|
||||||
unextractable_args_indexes.insert(index);
|
unextractable_args_indexes.insert(index);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,9 +74,12 @@ pub async fn output_error(
|
||||||
e: impl std::fmt::Display,
|
e: impl std::fmt::Display,
|
||||||
output: &mut BufWriter<tokio::io::Stdout>,
|
output: &mut BufWriter<tokio::io::Stdout>,
|
||||||
) -> std::io::Result<()> {
|
) -> std::io::Result<()> {
|
||||||
output.write_all(b"\x1b[31mERROR: \x1b[0m").await?;
|
output
|
||||||
|
.write_all(b"\x1b[1;31m\xE2\x9D\x8C ERROR: \x1b[0m")
|
||||||
|
.await?;
|
||||||
output.write_all(e.to_string().as_bytes()).await?;
|
output.write_all(e.to_string().as_bytes()).await?;
|
||||||
output.write_all(b"\n").await?;
|
output.write_all(b"\n").await?;
|
||||||
|
output.flush().await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,7 +87,11 @@ pub async fn output_agent(
|
||||||
content: impl std::fmt::Display,
|
content: impl std::fmt::Display,
|
||||||
output: &mut BufWriter<tokio::io::Stdout>,
|
output: &mut BufWriter<tokio::io::Stdout>,
|
||||||
) -> std::io::Result<()> {
|
) -> std::io::Result<()> {
|
||||||
|
output
|
||||||
|
.write_all(b"\x1b[1;34m\xF0\x9F\xA4\x96 Agent: \x1b[0m")
|
||||||
|
.await?;
|
||||||
output.write_all(content.to_string().as_bytes()).await?;
|
output.write_all(content.to_string().as_bytes()).await?;
|
||||||
|
output.write_all(b"\n").await?;
|
||||||
output.flush().await?;
|
output.flush().await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -93,16 +100,22 @@ pub async fn stream_output_toolcall(
|
||||||
content: impl std::fmt::Display,
|
content: impl std::fmt::Display,
|
||||||
output: &mut BufWriter<tokio::io::Stdout>,
|
output: &mut BufWriter<tokio::io::Stdout>,
|
||||||
) -> std::io::Result<()> {
|
) -> std::io::Result<()> {
|
||||||
output.write_all(b"\x1b[33mtool>\x1b[0m ").await?;
|
output
|
||||||
|
.write_all(b"\x1b[1;33m\xF0\x9F\x9B\xA0 Tool Call: \x1b[0m")
|
||||||
|
.await?;
|
||||||
output.write_all(content.to_string().as_bytes()).await?;
|
output.write_all(content.to_string().as_bytes()).await?;
|
||||||
output.write_all(b"\n").await?;
|
output.write_all(b"\n").await?;
|
||||||
|
output.flush().await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn stream_output_agent_start(
|
pub async fn stream_output_agent_start(
|
||||||
output: &mut BufWriter<tokio::io::Stdout>,
|
output: &mut BufWriter<tokio::io::Stdout>,
|
||||||
) -> std::io::Result<()> {
|
) -> std::io::Result<()> {
|
||||||
output.write_all(b"\x1b[34magent>\x1b[0m ").await?;
|
output
|
||||||
|
.write_all(b"\x1b[1;34m\xF0\x9F\xA4\x96 Agent: \x1b[0m")
|
||||||
|
.await?;
|
||||||
|
output.flush().await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,5 +123,6 @@ pub async fn stream_output_agent_finished(
|
||||||
output: &mut BufWriter<tokio::io::Stdout>,
|
output: &mut BufWriter<tokio::io::Stdout>,
|
||||||
) -> std::io::Result<()> {
|
) -> std::io::Result<()> {
|
||||||
output.write_all(b"\n").await?;
|
output.write_all(b"\n").await?;
|
||||||
|
output.flush().await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue