From e28ac7840f6fb497020585bcc038fa8a00d9cac2 Mon Sep 17 00:00:00 2001 From: "heesk0223@gmail.com" Date: Wed, 24 Jun 2026 08:37:01 +0900 Subject: [PATCH 1/3] refactor(core): Remove unused rapper. Switch from yaml format to json format --- Cargo.lock | 37 +------------ README.md | 2 +- crates/frilvault-core/Cargo.toml | 2 +- crates/frilvault-core/src/app/frilvault.rs | 4 +- crates/frilvault-core/src/constants.rs | 4 +- crates/frilvault-core/src/error/errors.rs | 4 +- .../frilvault-core/src/note/entity/anchor.rs | 34 ++++++++++++ .../src/note/entity/line_anchor.rs | 7 --- crates/frilvault-core/src/note/entity/mod.rs | 10 +--- .../src/note/entity/note_anchor.rs | 11 ---- .../src/note/entity/symbol_anchor.rs | 11 ---- .../src/note/entity/symbol_kind.rs | 12 ---- crates/frilvault-core/src/parser/mod.rs | 6 +- .../frilvault-core/src/parser/note_parser.rs | 14 ----- crates/frilvault-core/src/parser/parser.rs | 15 +++++ .../frilvault-core/src/parser/yaml_parser.rs | 16 ------ .../src/runtime/vault_context.rs | 6 +- crates/frilvault-core/src/storage/mod.rs | 4 +- .../{yaml_repository.rs => repository.rs} | 18 +++--- crates/frilvault-core/src/tests/helper.rs | 8 +-- crates/frilvault-core/src/tests/mod.rs | 4 +- .../src/tests/note_resolver_test.rs | 4 +- .../src/tests/note_service_test.rs | 6 +- .../frilvault-core/src/tests/parser_test.rs | 55 +++++++++++++++++++ ..._repository_test.rs => repository_test.rs} | 4 +- .../src/tests/yaml_parser_test.rs | 53 ------------------ .../src/workspace/path/path_resolver.rs | 4 +- .../repository/workspace_index_repository.rs | 10 ++-- .../repository/workspace_repository.rs | 6 +- docs/ARCHITECTURE.md | 8 +-- docs/CURRENT_STATE.md | 8 +-- docs/ROADMAP.md | 4 +- 32 files changed, 164 insertions(+), 227 deletions(-) create mode 100644 crates/frilvault-core/src/note/entity/anchor.rs delete mode 100644 crates/frilvault-core/src/note/entity/line_anchor.rs delete mode 100644 crates/frilvault-core/src/note/entity/note_anchor.rs delete mode 100644 crates/frilvault-core/src/note/entity/symbol_anchor.rs delete mode 100644 crates/frilvault-core/src/note/entity/symbol_kind.rs delete mode 100644 crates/frilvault-core/src/parser/note_parser.rs create mode 100644 crates/frilvault-core/src/parser/parser.rs delete mode 100644 crates/frilvault-core/src/parser/yaml_parser.rs rename crates/frilvault-core/src/storage/{yaml_repository.rs => repository.rs} (90%) create mode 100644 crates/frilvault-core/src/tests/parser_test.rs rename crates/frilvault-core/src/tests/{yaml_repository_test.rs => repository_test.rs} (84%) delete mode 100644 crates/frilvault-core/src/tests/yaml_parser_test.rs diff --git a/Cargo.lock b/Cargo.lock index 4877a82..f01cdb2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -202,7 +202,7 @@ version = "0.1.0" dependencies = [ "chrono", "serde", - "serde_yml", + "serde_json", "thiserror", "uuid", ] @@ -355,19 +355,6 @@ version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b947ae49db0d222b1dbc6b113ce7248a3fc3a6ca21b696717bfc000ba4484d8" -[[package]] -name = "noyalib" -version = "0.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e493c05128df7a83b9676b709d590e0ebc285c7ed3152bc679668e8c1e506af5" -dependencies = [ - "indexmap", - "memchr", - "rustc-hash", - "serde", - "smallvec", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -429,12 +416,6 @@ version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" -[[package]] -name = "rustc-hash" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe" - [[package]] name = "rustversion" version = "1.0.22" @@ -490,16 +471,6 @@ dependencies = [ "zmij", ] -[[package]] -name = "serde_yml" -version = "0.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909764a65f86829ccdb5eea9ab355843aa02c019a7bfd47465092953565caa05" -dependencies = [ - "noyalib", - "serde", -] - [[package]] name = "shlex" version = "2.0.1" @@ -512,12 +483,6 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" -[[package]] -name = "smallvec" -version = "1.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" - [[package]] name = "strsim" version = "0.11.1" diff --git a/README.md b/README.md index c6d5dfc..ba1e3a3 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ crates/ ├── notes/ ├── cache/ ├── index/ -└── workspace.yml +└── workspace.json ``` Notes are stored separately from source files. FrilVault does not modify the source code it annotates. diff --git a/crates/frilvault-core/Cargo.toml b/crates/frilvault-core/Cargo.toml index 0abc733..197f224 100644 --- a/crates/frilvault-core/Cargo.toml +++ b/crates/frilvault-core/Cargo.toml @@ -15,4 +15,4 @@ serde = { workspace = true, features = ["derive"] } uuid = { workspace = true, features = ["v4", "serde"] } thiserror.workspace = true -serde_yml = "0.0.13" \ No newline at end of file +serde_json= "1.0.150" \ No newline at end of file diff --git a/crates/frilvault-core/src/app/frilvault.rs b/crates/frilvault-core/src/app/frilvault.rs index 91b81eb..e5b06ff 100644 --- a/crates/frilvault-core/src/app/frilvault.rs +++ b/crates/frilvault-core/src/app/frilvault.rs @@ -4,7 +4,7 @@ use crate::{ FrilVaultResult, note::NoteService, runtime::VaultContext, - storage::YamlNoteRepository, + storage::NoteRepository, workspace::{PathResolver, WorkspaceIndexRepository, WorkspaceRepository, WorkspaceService}, }; @@ -28,7 +28,7 @@ impl FrilVault { let index_repository = WorkspaceIndexRepository::new(resolver.clone()); index_repository.create_if_missing()?; - let note_repository = YamlNoteRepository::new(resolver.clone()); + let note_repository = NoteRepository::new(resolver.clone()); let vault_context = VaultContext::new(note_repository, index_repository.clone()); diff --git a/crates/frilvault-core/src/constants.rs b/crates/frilvault-core/src/constants.rs index 3c758b8..ff0202e 100644 --- a/crates/frilvault-core/src/constants.rs +++ b/crates/frilvault-core/src/constants.rs @@ -1,7 +1,7 @@ pub const VAULT_DIR_NAME: &str = ".vault"; -pub const NOTE_FILE_EXTENSION: &str = "yml"; +pub const NOTE_FILE_EXTENSION: &str = "json"; // pub const SCHEMA_VERSION: u32 = 1; pub const NOTES_DIR_NAME: &str = "notes"; pub const CACHE_DIR_NAME: &str = "cache"; pub const INDEX_DIR_NAME: &str = "index"; -pub const WORKSPACE_FILE_NAME: &str = "workspace.yml"; +pub const WORKSPACE_FILE_NAME: &str = "workspace.json"; diff --git a/crates/frilvault-core/src/error/errors.rs b/crates/frilvault-core/src/error/errors.rs index 6440cfd..82b320a 100644 --- a/crates/frilvault-core/src/error/errors.rs +++ b/crates/frilvault-core/src/error/errors.rs @@ -6,8 +6,8 @@ pub enum FrilVaultError { #[error("io error: {0}")] Io(#[from] std::io::Error), - #[error("yaml error: {0}")] - Yaml(#[from] serde_yml::Error), + #[error("json error: {0}")] + JSON(#[from] serde_json::Error), #[error("source path is outside workspace")] SourcePathOutsideWorkspace, diff --git a/crates/frilvault-core/src/note/entity/anchor.rs b/crates/frilvault-core/src/note/entity/anchor.rs new file mode 100644 index 0000000..ac58eb5 --- /dev/null +++ b/crates/frilvault-core/src/note/entity/anchor.rs @@ -0,0 +1,34 @@ +use serde::{Deserialize, Serialize}; + +// TODO: Regex parser +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[serde(tag = "type")] +pub enum NoteAnchor { + Line(LineAnchor), + Symbol(SymbolAnchor), +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +pub struct LineAnchor { + pub line: u32, + pub column: u32, +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +pub struct SymbolAnchor { + pub name: String, + pub kind: SymbolKind, + pub signature: Option, + pub line_hint: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +pub enum SymbolKind { + Function, + Struct, + Enum, + Trait, + Impl, + Method, + Unknown, +} diff --git a/crates/frilvault-core/src/note/entity/line_anchor.rs b/crates/frilvault-core/src/note/entity/line_anchor.rs deleted file mode 100644 index 3074160..0000000 --- a/crates/frilvault-core/src/note/entity/line_anchor.rs +++ /dev/null @@ -1,7 +0,0 @@ -use serde::{Deserialize, Serialize}; - -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] -pub struct LineAnchor { - pub line: u32, - pub column: u32, -} diff --git a/crates/frilvault-core/src/note/entity/mod.rs b/crates/frilvault-core/src/note/entity/mod.rs index ece89bc..364e279 100644 --- a/crates/frilvault-core/src/note/entity/mod.rs +++ b/crates/frilvault-core/src/note/entity/mod.rs @@ -1,13 +1,7 @@ -mod line_anchor; +mod anchor; mod note; -mod note_anchor; mod note_file; -mod symbol_anchor; -mod symbol_kind; -pub use line_anchor::*; +pub use anchor::*; pub use note::*; -pub use note_anchor::*; pub use note_file::*; -pub use symbol_anchor::*; -pub use symbol_kind::*; diff --git a/crates/frilvault-core/src/note/entity/note_anchor.rs b/crates/frilvault-core/src/note/entity/note_anchor.rs deleted file mode 100644 index 3d17587..0000000 --- a/crates/frilvault-core/src/note/entity/note_anchor.rs +++ /dev/null @@ -1,11 +0,0 @@ -use serde::{Deserialize, Serialize}; - -use crate::note::{LineAnchor, SymbolAnchor}; - -// TODO: Regex parser -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] -#[serde(tag = "type")] -pub enum NoteAnchor { - Line(LineAnchor), - Symbol(SymbolAnchor), -} diff --git a/crates/frilvault-core/src/note/entity/symbol_anchor.rs b/crates/frilvault-core/src/note/entity/symbol_anchor.rs deleted file mode 100644 index 824505b..0000000 --- a/crates/frilvault-core/src/note/entity/symbol_anchor.rs +++ /dev/null @@ -1,11 +0,0 @@ -use serde::{Deserialize, Serialize}; - -use crate::note::SymbolKind; - -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] -pub struct SymbolAnchor { - pub name: String, - pub kind: SymbolKind, - pub signature: Option, - pub line_hint: Option, -} diff --git a/crates/frilvault-core/src/note/entity/symbol_kind.rs b/crates/frilvault-core/src/note/entity/symbol_kind.rs deleted file mode 100644 index 4e49ea1..0000000 --- a/crates/frilvault-core/src/note/entity/symbol_kind.rs +++ /dev/null @@ -1,12 +0,0 @@ -use serde::{Deserialize, Serialize}; - -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] -pub enum SymbolKind { - Function, - Struct, - Enum, - Trait, - Impl, - Method, - Unknown, -} diff --git a/crates/frilvault-core/src/parser/mod.rs b/crates/frilvault-core/src/parser/mod.rs index 33dd0a7..5feedaf 100644 --- a/crates/frilvault-core/src/parser/mod.rs +++ b/crates/frilvault-core/src/parser/mod.rs @@ -1,5 +1,3 @@ -mod note_parser; -mod yaml_parser; +mod parser; -pub use note_parser::*; -pub use yaml_parser::*; +pub use parser::*; diff --git a/crates/frilvault-core/src/parser/note_parser.rs b/crates/frilvault-core/src/parser/note_parser.rs deleted file mode 100644 index f37d4a3..0000000 --- a/crates/frilvault-core/src/parser/note_parser.rs +++ /dev/null @@ -1,14 +0,0 @@ -use crate::FrilVaultResult; -use crate::note::NoteFile; - -pub trait NoteParser { - /// Converts a NoteFile into a serialized representation. - /// - /// Implementations may choose YAML, JSON, or any other format. - fn serialize(&self, note_file: &NoteFile) -> FrilVaultResult; - - /// Converts serialized content back into a NoteFile. - /// - /// Returns an error if the content is invalid or unsupported. - fn deserialize(&self, content: &str) -> FrilVaultResult; -} diff --git a/crates/frilvault-core/src/parser/parser.rs b/crates/frilvault-core/src/parser/parser.rs new file mode 100644 index 0000000..5150f52 --- /dev/null +++ b/crates/frilvault-core/src/parser/parser.rs @@ -0,0 +1,15 @@ +use crate::FrilVaultResult; +use crate::note::NoteFile; + +#[derive(Debug, Default, Clone)] +pub struct JsonParser; + +impl JsonParser { + pub fn serialize(&self, note_file: &NoteFile) -> FrilVaultResult { + Ok(serde_json::to_string(note_file)?) + } + + pub fn deserialize(&self, content: &str) -> FrilVaultResult { + Ok(serde_json::from_str(content)?) + } +} diff --git a/crates/frilvault-core/src/parser/yaml_parser.rs b/crates/frilvault-core/src/parser/yaml_parser.rs deleted file mode 100644 index 4d6cdb2..0000000 --- a/crates/frilvault-core/src/parser/yaml_parser.rs +++ /dev/null @@ -1,16 +0,0 @@ -use crate::FrilVaultResult; -use crate::note::NoteFile; -use crate::parser::NoteParser; - -#[derive(Debug, Default, Clone)] -pub struct YamlParser; - -impl NoteParser for YamlParser { - fn serialize(&self, note_file: &NoteFile) -> FrilVaultResult { - Ok(serde_yml::to_string(note_file)?) - } - - fn deserialize(&self, content: &str) -> FrilVaultResult { - Ok(serde_yml::from_str(content)?) - } -} diff --git a/crates/frilvault-core/src/runtime/vault_context.rs b/crates/frilvault-core/src/runtime/vault_context.rs index 204e6a8..8f642a5 100644 --- a/crates/frilvault-core/src/runtime/vault_context.rs +++ b/crates/frilvault-core/src/runtime/vault_context.rs @@ -4,7 +4,7 @@ use crate::{ FrilVaultResult, note::NoteFile, runtime::NoteCache, - storage::{NoteFileRecord, YamlNoteRepository}, + storage::{NoteFileRecord, NoteRepository}, workspace::{WorkspaceIndex, WorkspaceIndexRepository}, }; @@ -20,14 +20,14 @@ use crate::{ /// accessing repositories directly. #[derive(Clone)] pub struct VaultContext { - pub note_repository: YamlNoteRepository, + pub note_repository: NoteRepository, pub workspace_index_repository: WorkspaceIndexRepository, pub note_cache: NoteCache, } impl VaultContext { pub fn new( - note_repository: YamlNoteRepository, + note_repository: NoteRepository, workspace_index_repository: WorkspaceIndexRepository, ) -> Self { Self { diff --git a/crates/frilvault-core/src/storage/mod.rs b/crates/frilvault-core/src/storage/mod.rs index 3faafc1..a42bbcf 100644 --- a/crates/frilvault-core/src/storage/mod.rs +++ b/crates/frilvault-core/src/storage/mod.rs @@ -1,5 +1,5 @@ mod note_file_record; -mod yaml_repository; +mod repository; pub use note_file_record::*; -pub use yaml_repository::*; +pub use repository::*; diff --git a/crates/frilvault-core/src/storage/yaml_repository.rs b/crates/frilvault-core/src/storage/repository.rs similarity index 90% rename from crates/frilvault-core/src/storage/yaml_repository.rs rename to crates/frilvault-core/src/storage/repository.rs index 8844fa1..44a2a38 100644 --- a/crates/frilvault-core/src/storage/yaml_repository.rs +++ b/crates/frilvault-core/src/storage/repository.rs @@ -1,28 +1,28 @@ -//! YAML-backed note repository. +//! JSON-backed note repository. //! -//! Notes are persisted as YAML files +//! Notes are persisted as JSON files //! inside the `.vault/notes` directory. use std::fs; use std::path::{Path, PathBuf}; use crate::note::NoteFile; -use crate::parser::{NoteParser, YamlParser}; +use crate::parser::JsonParser; use crate::storage::NoteFileRecord; use crate::workspace::PathResolver; use crate::{FrilVaultResult, Note}; #[derive(Debug, Clone)] -pub struct YamlNoteRepository { +pub struct NoteRepository { path_resolver: PathResolver, - parser: YamlParser, + parser: JsonParser, } -impl YamlNoteRepository { +impl NoteRepository { pub fn new(path_resolver: PathResolver) -> Self { Self { path_resolver, - parser: YamlParser, + parser: JsonParser, } } @@ -53,9 +53,9 @@ impl YamlNoteRepository { fs::create_dir_all(parent)?; } - let yaml = self.parser.serialize(note_file)?; + let json = self.parser.serialize(note_file)?; - fs::write(note_path, yaml)?; + fs::write(note_path, json)?; Ok(()) } diff --git a/crates/frilvault-core/src/tests/helper.rs b/crates/frilvault-core/src/tests/helper.rs index a745a62..118a4b8 100644 --- a/crates/frilvault-core/src/tests/helper.rs +++ b/crates/frilvault-core/src/tests/helper.rs @@ -6,7 +6,7 @@ use std::{ use crate::{ note::NoteService, runtime::VaultContext, - storage::YamlNoteRepository, + storage::NoteRepository, workspace::{PathResolver, WorkspaceIndexRepository, WorkspaceRepository, WorkspaceService}, }; @@ -43,7 +43,7 @@ pub fn create_test_vault_context(workspace_root: &Path) -> VaultContext { let workspace_repository = WorkspaceRepository::new(resolver.clone()); workspace_repository.create_if_missing().unwrap(); - let note_repository = YamlNoteRepository::new(resolver.clone()); + let note_repository = NoteRepository::new(resolver.clone()); let index_repository = WorkspaceIndexRepository::new(resolver); index_repository.create_if_missing().unwrap(); @@ -63,7 +63,7 @@ pub fn create_test_index_repository(workspace_root: &Path) -> WorkspaceIndexRepo WorkspaceIndexRepository::new(resolver) } -pub fn create_test_yaml_repository(workspace_root: &Path) -> YamlNoteRepository { +pub fn create_test_repository(workspace_root: &Path) -> NoteRepository { let resolver = PathResolver::new(workspace_root); - YamlNoteRepository::new(resolver) + NoteRepository::new(resolver) } diff --git a/crates/frilvault-core/src/tests/mod.rs b/crates/frilvault-core/src/tests/mod.rs index d84d5e6..7ced900 100644 --- a/crates/frilvault-core/src/tests/mod.rs +++ b/crates/frilvault-core/src/tests/mod.rs @@ -10,10 +10,10 @@ mod note_resolver_test; mod note_service_test; #[cfg(test)] -mod yaml_parser_test; +mod parser_test; #[cfg(test)] -mod yaml_repository_test; +mod repository_test; #[cfg(test)] mod workspace_repository_test; diff --git a/crates/frilvault-core/src/tests/note_resolver_test.rs b/crates/frilvault-core/src/tests/note_resolver_test.rs index 17a31fd..f71a68e 100644 --- a/crates/frilvault-core/src/tests/note_resolver_test.rs +++ b/crates/frilvault-core/src/tests/note_resolver_test.rs @@ -8,7 +8,7 @@ fn resolve_note_path_returns_vault_path() { let path = resolver.resolve_note_path("src/main.rs"); - let expected = PathBuf::from("/workspace/.vault/notes/src/main.rs.yml"); + let expected = PathBuf::from("/workspace/.vault/notes/src/main.rs.json"); assert_eq!(path, expected); } @@ -28,7 +28,7 @@ fn source_file_from_note_path_returns_source_path() { let resolver = PathResolver::new("/workspace"); let source_file = resolver - .source_file_from_note_path("/workspace/.vault/notes/src/main.rs.yml") + .source_file_from_note_path("/workspace/.vault/notes/src/main.rs.json") .unwrap(); assert_eq!(source_file, PathBuf::from("src/main.rs")); diff --git a/crates/frilvault-core/src/tests/note_service_test.rs b/crates/frilvault-core/src/tests/note_service_test.rs index 37183bf..b88e1a6 100644 --- a/crates/frilvault-core/src/tests/note_service_test.rs +++ b/crates/frilvault-core/src/tests/note_service_test.rs @@ -7,7 +7,7 @@ use crate::{ use std::fs; #[test] -fn add_line_type_note_creates_yaml_file() { +fn add_line_type_note_creates_json_file() { let workspace = create_test_workspace(); let workspace_root = workspace.root(); let mut service = create_test_note_service(workspace_root); @@ -36,7 +36,7 @@ fn add_line_type_note_creates_yaml_file() { } #[test] -fn add_symbol_type_note_creates_yaml_file() { +fn add_symbol_type_note_creates_json_file() { let workspace = create_test_workspace(); let workspace_root = workspace.root(); let mut service = create_test_note_service(workspace_root); @@ -81,7 +81,7 @@ fn add_symbol_type_note_creates_yaml_file() { } #[test] -fn load_notes_from_existing_yaml() { +fn load_notes_from_existing_json() { let workspace = create_test_workspace(); let workspace_root = workspace.root(); let mut service = create_test_note_service(workspace_root); diff --git a/crates/frilvault-core/src/tests/parser_test.rs b/crates/frilvault-core/src/tests/parser_test.rs new file mode 100644 index 0000000..1ceea7d --- /dev/null +++ b/crates/frilvault-core/src/tests/parser_test.rs @@ -0,0 +1,55 @@ +use crate::{LineAnchor, Note, NoteAnchor, note::NoteFile, parser::JsonParser}; + +use chrono::Utc; +use uuid::Uuid; + +#[test] +fn serialize_note_file() { + let parser = JsonParser; + + let note = Note { + id: Uuid::new_v4(), + anchor: NoteAnchor::Line(LineAnchor { + line: 10, + column: 5, + }), + content: "hello".to_string(), + created_at: Utc::now(), + updated_at: Utc::now(), + }; + + let note_file = NoteFile { notes: vec![note] }; + + let json = parser.serialize(¬e_file).unwrap(); + + assert!(json.contains("hello")); +} + +#[test] +fn deserialize_note_file() { + let parser = JsonParser; + + let json = r#" +{ + "notes": [ + { + "id": "550e8400-e29b-41d4-a716-446655440000", + "anchor": { + "type": "Line", + "line": 10, + "column": 5 + }, + "content": "hello", + "created_at": "2025-01-01T00:00:00Z", + "updated_at": "2025-01-01T00:00:00Z" + } + ] +} +"#; + + let note_file = parser.deserialize(json).unwrap(); + + assert_eq!(note_file.notes.len(), 1); + + assert_eq!(note_file.notes[0].content, "hello"); +} diff --git a/crates/frilvault-core/src/tests/yaml_repository_test.rs b/crates/frilvault-core/src/tests/repository_test.rs similarity index 84% rename from crates/frilvault-core/src/tests/yaml_repository_test.rs rename to crates/frilvault-core/src/tests/repository_test.rs index f7d9cf4..9e26560 100644 --- a/crates/frilvault-core/src/tests/yaml_repository_test.rs +++ b/crates/frilvault-core/src/tests/repository_test.rs @@ -1,4 +1,4 @@ -use super::helper::{create_test_note_service, create_test_workspace, create_test_yaml_repository}; +use super::helper::{create_test_note_service, create_test_repository, create_test_workspace}; use crate::{AddNoteRequest, LineAnchor, NoteAnchor}; #[test] @@ -26,7 +26,7 @@ fn list_all_note_files_returns_all_note_files() { }) .unwrap(); - let repository = create_test_yaml_repository(workspace_root); + let repository = create_test_repository(workspace_root); let note_files = repository.list_all_note_files().unwrap(); diff --git a/crates/frilvault-core/src/tests/yaml_parser_test.rs b/crates/frilvault-core/src/tests/yaml_parser_test.rs deleted file mode 100644 index 054dfcd..0000000 --- a/crates/frilvault-core/src/tests/yaml_parser_test.rs +++ /dev/null @@ -1,53 +0,0 @@ -use crate::{ - LineAnchor, Note, NoteAnchor, - note::NoteFile, - parser::{NoteParser, YamlParser}, -}; - -use chrono::Utc; -use uuid::Uuid; - -#[test] -fn serialize_note_file() { - let parser = YamlParser; - - let note = Note { - id: Uuid::new_v4(), - anchor: NoteAnchor::Line(LineAnchor { - line: 10, - column: 5, - }), - content: "hello".to_string(), - created_at: Utc::now(), - updated_at: Utc::now(), - }; - - let note_file = NoteFile { notes: vec![note] }; - - let yaml = parser.serialize(¬e_file).unwrap(); - - assert!(yaml.contains("hello")); -} - -#[test] -fn deserialize_note_file() { - let parser = YamlParser; - - let yaml = r#" -notes: - - id: "550e8400-e29b-41d4-a716-446655440000" - anchor: - type: Line - line: 10 - column: 5 - content: hello - created_at: 2025-01-01T00:00:00Z - updated_at: 2025-01-01T00:00:00Z -"#; - - let note_file = parser.deserialize(yaml).unwrap(); - - assert_eq!(note_file.notes.len(), 1); - - assert_eq!(note_file.notes[0].content, "hello"); -} diff --git a/crates/frilvault-core/src/workspace/path/path_resolver.rs b/crates/frilvault-core/src/workspace/path/path_resolver.rs index e45a1f1..ee8ef32 100644 --- a/crates/frilvault-core/src/workspace/path/path_resolver.rs +++ b/crates/frilvault-core/src/workspace/path/path_resolver.rs @@ -39,10 +39,10 @@ impl PathResolver { } pub fn workspace_index_path(&self) -> PathBuf { - self.vault_root().join(INDEX_DIR_NAME).join("workspace.yml") + self.vault_root().join(INDEX_DIR_NAME).join("workspace.json") } - // Convert the relative path of the source file to the path '.vault/notes/{source_file}.yml' + // Convert the relative path of the source file to the path '.vault/notes/{source_file}.json' pub fn resolve_note_path(&self, source_file: impl AsRef) -> PathBuf { self.notes_root().join(Self::note_file_name(source_file)) } diff --git a/crates/frilvault-core/src/workspace/repository/workspace_index_repository.rs b/crates/frilvault-core/src/workspace/repository/workspace_index_repository.rs index d25b8c4..7cd85e6 100644 --- a/crates/frilvault-core/src/workspace/repository/workspace_index_repository.rs +++ b/crates/frilvault-core/src/workspace/repository/workspace_index_repository.rs @@ -2,7 +2,7 @@ use std::{fs, path::Path}; use crate::{ FrilVaultResult, RepairSuggestion, - storage::YamlNoteRepository, + storage::NoteRepository, workspace::{FileMove, IndexDiff, IndexedFile, PathResolver, WorkspaceIndex}, }; @@ -29,7 +29,7 @@ impl WorkspaceIndexRepository { let content = fs::read_to_string(path)?; - let index = serde_yml::from_str(&content)?; + let index = serde_json::from_str(&content)?; Ok(index) } @@ -41,9 +41,9 @@ impl WorkspaceIndexRepository { fs::create_dir_all(parent)?; } - let yaml = serde_yml::to_string(index)?; + let json = serde_json::to_string(index)?; - fs::write(path, yaml)?; + fs::write(path, json)?; Ok(()) } @@ -61,7 +61,7 @@ impl WorkspaceIndexRepository { } pub fn rebuild(&self) -> FrilVaultResult { - let note_repository = YamlNoteRepository::new(self.path_resolver.clone()); + let note_repository = NoteRepository::new(self.path_resolver.clone()); let records = note_repository.list_all_note_files()?; diff --git a/crates/frilvault-core/src/workspace/repository/workspace_repository.rs b/crates/frilvault-core/src/workspace/repository/workspace_repository.rs index 641347a..cd9c78f 100644 --- a/crates/frilvault-core/src/workspace/repository/workspace_repository.rs +++ b/crates/frilvault-core/src/workspace/repository/workspace_repository.rs @@ -21,7 +21,7 @@ impl WorkspaceRepository { // let content = fs::read_to_string(path)?; - // let metadata = serde_yml::from_str(&content)?; + // let metadata = serde_json::from_str(&content)?; // Ok(metadata) // } @@ -33,9 +33,9 @@ impl WorkspaceRepository { fs::create_dir_all(parent)?; } - let yaml = serde_yml::to_string(metadata)?; + let json = serde_json::to_string(metadata)?; - fs::write(path, yaml)?; + fs::write(path, json)?; Ok(()) } diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 5ef5426..e22f9f2 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -120,7 +120,7 @@ Responsible for: - line-based anchors - symbol-based anchors - note search -- YAML persistence +- JSON persistence --- @@ -142,7 +142,7 @@ VaultContext is the runtime container of FrilVault. It owns: -- YamlNoteRepository +- NoteRepository - WorkspaceIndexRepository - NoteCache @@ -208,7 +208,7 @@ Important: ├── notes ├── cache ├── index -└── workspace.yml +└── workspace.json ``` --- @@ -257,7 +257,7 @@ Cache (hit/miss) ↓ Repository (fallback) ↓ -Filesystem (YAML) +Filesystem (JSON) ``` --- diff --git a/docs/CURRENT_STATE.md b/docs/CURRENT_STATE.md index c5005e4..b58b0a8 100644 --- a/docs/CURRENT_STATE.md +++ b/docs/CURRENT_STATE.md @@ -37,7 +37,7 @@ The system has moved beyond a simple note storage tool and is evolving into a ** ### Note System - CRUD operations implemented -- YAML-based storage +- JSON-based storage - line anchors implemented - symbol anchors implemented - keyword + symbol search implemented @@ -57,14 +57,14 @@ The system has moved beyond a simple note storage tool and is evolving into a ** ### Storage Layer - `.vault` directory structure implemented -- YAML persistence implemented +- JSON persistence implemented - note file structure stable --- ### Parser Layer -- YAML parser implemented +- JSON parser implemented - note serialization/deserialization stable --- @@ -235,7 +235,7 @@ This is temporary and will be unified later. ├── notes/ ├── cache/ ├── index/ -└── workspace.yml +└── workspace.json ``` --- diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 6477c28..83c9fd2 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -16,7 +16,7 @@ Local note system with structured storage and basic workspace intelligence. ### Note System -- YAML-based note storage +- JSON-based note storage - Note CRUD (create / update / delete / list) - Line-based anchors - Symbol-based anchors @@ -37,7 +37,7 @@ Local note system with structured storage and basic workspace intelligence. ### Storage Layer - `.vault` directory structure -- YAML persistence model +- JSON persistence model - structured note file format --- From 11a43ef4254baa0c84293ad8e1f548430841bd0f Mon Sep 17 00:00:00 2001 From: "heesk0223@gmail.com" Date: Wed, 24 Jun 2026 08:40:22 +0900 Subject: [PATCH 2/3] fix: clippy test error --- .../frilvault-core/src/parser/{parser.rs => json_parser.rs} | 0 crates/frilvault-core/src/parser/mod.rs | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename crates/frilvault-core/src/parser/{parser.rs => json_parser.rs} (100%) diff --git a/crates/frilvault-core/src/parser/parser.rs b/crates/frilvault-core/src/parser/json_parser.rs similarity index 100% rename from crates/frilvault-core/src/parser/parser.rs rename to crates/frilvault-core/src/parser/json_parser.rs diff --git a/crates/frilvault-core/src/parser/mod.rs b/crates/frilvault-core/src/parser/mod.rs index 5feedaf..6f27b7b 100644 --- a/crates/frilvault-core/src/parser/mod.rs +++ b/crates/frilvault-core/src/parser/mod.rs @@ -1,3 +1,3 @@ -mod parser; +mod json_parser; -pub use parser::*; +pub use json_parser::*; From 9df3858d081f3c29a1a4681152bbbb67600961d0 Mon Sep 17 00:00:00 2001 From: "heesk0223@gmail.com" Date: Wed, 24 Jun 2026 08:46:28 +0900 Subject: [PATCH 3/3] fix: cargo fmt --all -- --check error --- crates/frilvault-core/src/note/entity/note_file.rs | 8 ++++++++ crates/frilvault-core/src/runtime/vault_context.rs | 4 ++-- crates/frilvault-core/src/storage/mod.rs | 2 -- crates/frilvault-core/src/storage/note_file_record.rs | 9 --------- crates/frilvault-core/src/storage/repository.rs | 3 +-- .../frilvault-core/src/workspace/path/path_resolver.rs | 4 +++- 6 files changed, 14 insertions(+), 16 deletions(-) delete mode 100644 crates/frilvault-core/src/storage/note_file_record.rs diff --git a/crates/frilvault-core/src/note/entity/note_file.rs b/crates/frilvault-core/src/note/entity/note_file.rs index a840c6a..fe5575b 100644 --- a/crates/frilvault-core/src/note/entity/note_file.rs +++ b/crates/frilvault-core/src/note/entity/note_file.rs @@ -1,7 +1,15 @@ +use std::path::PathBuf; + use serde::{Deserialize, Serialize}; use crate::note::Note; +#[derive(Debug, Clone)] +pub struct NoteFileRecord { + pub source_file: PathBuf, + pub note_file: NoteFile, +} + #[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)] pub struct NoteFile { pub notes: Vec, diff --git a/crates/frilvault-core/src/runtime/vault_context.rs b/crates/frilvault-core/src/runtime/vault_context.rs index 8f642a5..d1d1ace 100644 --- a/crates/frilvault-core/src/runtime/vault_context.rs +++ b/crates/frilvault-core/src/runtime/vault_context.rs @@ -2,9 +2,9 @@ use std::path::{Path, PathBuf}; use crate::{ FrilVaultResult, - note::NoteFile, + note::{NoteFile, NoteFileRecord}, runtime::NoteCache, - storage::{NoteFileRecord, NoteRepository}, + storage::NoteRepository, workspace::{WorkspaceIndex, WorkspaceIndexRepository}, }; diff --git a/crates/frilvault-core/src/storage/mod.rs b/crates/frilvault-core/src/storage/mod.rs index a42bbcf..5b40278 100644 --- a/crates/frilvault-core/src/storage/mod.rs +++ b/crates/frilvault-core/src/storage/mod.rs @@ -1,5 +1,3 @@ -mod note_file_record; mod repository; -pub use note_file_record::*; pub use repository::*; diff --git a/crates/frilvault-core/src/storage/note_file_record.rs b/crates/frilvault-core/src/storage/note_file_record.rs deleted file mode 100644 index eef320a..0000000 --- a/crates/frilvault-core/src/storage/note_file_record.rs +++ /dev/null @@ -1,9 +0,0 @@ -use std::path::PathBuf; - -use crate::note::NoteFile; - -#[derive(Debug, Clone)] -pub struct NoteFileRecord { - pub source_file: PathBuf, - pub note_file: NoteFile, -} diff --git a/crates/frilvault-core/src/storage/repository.rs b/crates/frilvault-core/src/storage/repository.rs index 44a2a38..5b7f8f2 100644 --- a/crates/frilvault-core/src/storage/repository.rs +++ b/crates/frilvault-core/src/storage/repository.rs @@ -6,9 +6,8 @@ use std::fs; use std::path::{Path, PathBuf}; -use crate::note::NoteFile; +use crate::note::{NoteFile, NoteFileRecord}; use crate::parser::JsonParser; -use crate::storage::NoteFileRecord; use crate::workspace::PathResolver; use crate::{FrilVaultResult, Note}; diff --git a/crates/frilvault-core/src/workspace/path/path_resolver.rs b/crates/frilvault-core/src/workspace/path/path_resolver.rs index ee8ef32..d02c98b 100644 --- a/crates/frilvault-core/src/workspace/path/path_resolver.rs +++ b/crates/frilvault-core/src/workspace/path/path_resolver.rs @@ -39,7 +39,9 @@ impl PathResolver { } pub fn workspace_index_path(&self) -> PathBuf { - self.vault_root().join(INDEX_DIR_NAME).join("workspace.json") + self.vault_root() + .join(INDEX_DIR_NAME) + .join("workspace.json") } // Convert the relative path of the source file to the path '.vault/notes/{source_file}.json'