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:
jokemanfire 2025-04-02 13:55:37 +08:00 • committed by GitHub
commit c30d8063e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 10 deletions

View file

@ -60,6 +60,14 @@ jobs:
- name: Run clippy
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:
name: Run Tests

View file

@ -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 unextractable_args_indexes = HashSet::new();
for (index, mut fn_arg) in input_fn.sig.inputs.iter_mut().enumerate() {
enum Catched {
enum Caught {
Param(ToolFnParamAttrs),
Aggregated(PatType),
}
let mut catched = None;
let mut caught = None;
match &mut fn_arg {
FnArg::Receiver(_) => {
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",
));
};
catched.replace(Catched::Param(ToolFnParamAttrs {
caught.replace(Caught::Param(ToolFnParamAttrs {
serde_meta: Vec::new(),
schemars_meta: Vec::new(),
ident: arg_ident,
@ -252,7 +252,7 @@ pub(crate) fn tool_fn_item(attr: TokenStream, mut input_fn: ItemFn) -> syn::Resu
}));
}
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) {
@ -268,8 +268,8 @@ pub(crate) fn tool_fn_item(attr: TokenStream, mut input_fn: ItemFn) -> syn::Resu
}
}
}
match catched {
Some(Catched::Param(mut param)) => {
match caught {
Some(Caught::Param(mut param)) => {
param.serde_meta = serde_metas;
param.schemars_meta = schemars_metas;
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);
}
Some(Catched::Aggregated(rust_type)) => {
Some(Caught::Aggregated(rust_type)) => {
tool_macro_attrs.params = ToolParams::Aggregated { rust_type };
unextractable_args_indexes.insert(index);
}

View file

@ -74,9 +74,12 @@ pub async fn output_error(
e: impl std::fmt::Display,
output: &mut BufWriter<tokio::io::Stdout>,
) -> 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(b"\n").await?;
output.flush().await?;
Ok(())
}
@ -84,7 +87,11 @@ pub async fn output_agent(
content: impl std::fmt::Display,
output: &mut BufWriter<tokio::io::Stdout>,
) -> 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(b"\n").await?;
output.flush().await?;
Ok(())
}
@ -93,16 +100,22 @@ pub async fn stream_output_toolcall(
content: impl std::fmt::Display,
output: &mut BufWriter<tokio::io::Stdout>,
) -> 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(b"\n").await?;
output.flush().await?;
Ok(())
}
pub async fn stream_output_agent_start(
output: &mut BufWriter<tokio::io::Stdout>,
) -> 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(())
}
@ -110,5 +123,6 @@ pub async fn stream_output_agent_finished(
output: &mut BufWriter<tokio::io::Stdout>,
) -> std::io::Result<()> {
output.write_all(b"\n").await?;
output.flush().await?;
Ok(())
}