diff --git a/Cargo.lock b/Cargo.lock index 5b785ce28..03f0c588b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -720,7 +720,7 @@ checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" [[package]] name = "codegraph" -version = "2.1.5" +version = "2.1.6" dependencies = [ "anyhow", "camino", @@ -743,7 +743,7 @@ dependencies = [ [[package]] name = "codegraph-api" -version = "2.1.5" +version = "2.1.6" dependencies = [ "anyhow", "camino", @@ -760,7 +760,7 @@ dependencies = [ [[package]] name = "codegraph-bench" -version = "2.1.5" +version = "2.1.6" dependencies = [ "anyhow", "camino", @@ -778,7 +778,7 @@ dependencies = [ [[package]] name = "codegraph-binary" -version = "2.1.5" +version = "2.1.6" dependencies = [ "camino", "codegraph-core", @@ -795,7 +795,7 @@ dependencies = [ [[package]] name = "codegraph-context" -version = "2.1.5" +version = "2.1.6" dependencies = [ "codegraph-core", "codegraph-graph", @@ -807,7 +807,7 @@ dependencies = [ [[package]] name = "codegraph-core" -version = "2.1.5" +version = "2.1.6" dependencies = [ "async-graphql", "camino", @@ -818,7 +818,7 @@ dependencies = [ [[package]] name = "codegraph-docs" -version = "2.1.5" +version = "2.1.6" dependencies = [ "anyhow", "codegraph-core", @@ -835,7 +835,7 @@ dependencies = [ [[package]] name = "codegraph-extract" -version = "2.1.5" +version = "2.1.6" dependencies = [ "camino", "codegraph-binary", @@ -874,7 +874,7 @@ dependencies = [ [[package]] name = "codegraph-graph" -version = "2.1.5" +version = "2.1.6" dependencies = [ "async-trait", "bincode", @@ -904,7 +904,7 @@ dependencies = [ [[package]] name = "codegraph-graphql" -version = "2.1.5" +version = "2.1.6" dependencies = [ "anyhow", "async-graphql", @@ -927,7 +927,7 @@ dependencies = [ [[package]] name = "codegraph-installer" -version = "2.1.5" +version = "2.1.6" dependencies = [ "anyhow", "camino", @@ -943,7 +943,7 @@ dependencies = [ [[package]] name = "codegraph-mcp" -version = "2.1.5" +version = "2.1.6" dependencies = [ "anyhow", "axum", @@ -966,7 +966,7 @@ dependencies = [ [[package]] name = "codegraph-sboxes" -version = "2.1.5" +version = "2.1.6" dependencies = [ "camino", "codegraph-core", diff --git a/Cargo.toml b/Cargo.toml index 62cde133f..d2af0bb00 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ members = [ ] [workspace.package] -version = "2.1.5" +version = "2.1.6" edition = "2021" rust-version = "1.80" license = "MIT" diff --git a/crates/codegraph-docs/src/parsers/mod.rs b/crates/codegraph-docs/src/parsers/mod.rs index 2a1a2e8c4..ce9207c52 100644 --- a/crates/codegraph-docs/src/parsers/mod.rs +++ b/crates/codegraph-docs/src/parsers/mod.rs @@ -1,5 +1,6 @@ use crate::ir::{ByteSpan, Document, Kind, Node, Scalar}; use anyhow::Result; +use serde::Deserialize; use std::collections::HashMap; /// Generic document parser: turns a raw source file into the normalized @@ -137,14 +138,25 @@ impl DocParser for YamlParser { } fn parse(&self, path: &str, source: &str, id: u64) -> Result { - let value: serde_yaml::Value = serde_yaml::from_str(source)?; - let root = convert_yaml_value( - &value, - ByteSpan { - start: 0, - end: source.len() as u64, - }, - ); + // File YAML được phép chứa nhiều document (`---`), vd k8s manifest. + let mut values: Vec = Vec::new(); + for doc in serde_yaml::Deserializer::from_str(source) { + values.push(serde_yaml::Value::deserialize(doc)?); + } + let span = ByteSpan { + start: 0, + end: source.len() as u64, + }; + let root = match values.len() { + 0 => RecursiveNode::Null(span), + 1 => convert_yaml_value(&values[0], span), + _ => RecursiveNode::Array( + values + .iter() + .map(|v| (convert_yaml_value(v, ByteSpan { start: 0, end: 0 }), span)) + .collect(), + ), + }; Ok(build_document( path.to_string(), self.format().to_string(), @@ -739,6 +751,21 @@ service: assert_eq!(doc.nodes.len(), 4); // root, service, name, replicas } + #[test] + fn yaml_parser_multi_document() { + let src = "---\nkind: Service\nname: api\n---\nkind: Deployment\nname: web\n"; + let doc = YamlParser.parse("/tmp/multi.yaml", src, 1).unwrap(); + // root (Array của 2 doc) + 2 doc + 4 trường con + assert_eq!(doc.nodes.len(), 7); + assert_eq!( + doc.nodes + .iter() + .filter(|n| n.key == Some("kind".into())) + .count(), + 2 + ); + } + #[test] fn nginx_parser_nested_blocks_and_directives() { let src = r#" diff --git a/packaging/aur/codegraph-rs-bin/PKGBUILD b/packaging/aur/codegraph-rs-bin/PKGBUILD index d392cf789..8818dc784 100644 --- a/packaging/aur/codegraph-rs-bin/PKGBUILD +++ b/packaging/aur/codegraph-rs-bin/PKGBUILD @@ -1,6 +1,6 @@ # Maintainer: Hung Pham pkgname=codegraph-rs-bin -pkgver=2.1.5 +pkgver=2.1.6 pkgrel=1 pkgdesc="Local-first code intelligence: tree-sitter knowledge graph + MCP server (prebuilt binary)" arch=('x86_64' 'aarch64') diff --git a/packaging/choco/codegraph.nuspec b/packaging/choco/codegraph.nuspec index b3880373d..83db65d4c 100644 --- a/packaging/choco/codegraph.nuspec +++ b/packaging/choco/codegraph.nuspec @@ -2,7 +2,7 @@ codegraph - 2.1.5 + 2.1.6 codegraph Hung Pham https://github.com/hungpham10/codegraph-rs diff --git a/packaging/winget/codegraph.yaml b/packaging/winget/codegraph.yaml index da9cb4b85..4213d0936 100644 --- a/packaging/winget/codegraph.yaml +++ b/packaging/winget/codegraph.yaml @@ -6,7 +6,7 @@ # release time (or automate it in the release pipeline before submitting to # microsoft/winget-pkgs). PackageIdentifier: hungpham10.codegraph -PackageVersion: 2.1.5 +PackageVersion: 2.1.6 PackageName: codegraph Publisher: Hung Pham PublisherUrl: https://github.com/hungpham10/codegraph-rs @@ -18,7 +18,7 @@ PackageUrl: https://github.com/hungpham10/codegraph-rs InstallerType: zip Installers: - Architecture: x64 - InstallerUrl: https://github.com/hungpham10/codegraph-rs/releases/download/v2.1.5/codegraph-x86_64-pc-windows-msvc.zip + InstallerUrl: https://github.com/hungpham10/codegraph-rs/releases/download/v2.1.6/codegraph-x86_64-pc-windows-msvc.zip InstallerSha256: 0000000000000000000000000000000000000000000000000000000000000000 InstallerType: zip ManifestType: singleton diff --git a/scripts/install.ps1 b/scripts/install.ps1 index b374c965c..3b22da196 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -5,11 +5,11 @@ # # Usage (pin a version / download the script first): # irm https://raw.githubusercontent.com/hungpham10/codegraph-rs/main/scripts/install.ps1 -OutFile install.ps1 -# .\install.ps1 -Version 2.1.5 +# .\install.ps1 -Version 2.1.6 [CmdletBinding()] param( - # Pin a specific version, e.g. "2.1.5". Empty = latest release. + # Pin a specific version, e.g. "2.1.6". Empty = latest release. [string]$Version )