-
Notifications
You must be signed in to change notification settings - Fork 1
refactor(core): Remove unused wrapper. Switch from yaml format to json #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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"; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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<String>, | ||
| pub line_hint: Option<u32>, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] | ||
| pub enum SymbolKind { | ||
| Function, | ||
| Struct, | ||
| Enum, | ||
| Trait, | ||
| Impl, | ||
| Method, | ||
| Unknown, | ||
| } |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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::*; |
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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<String> { | ||
| Ok(serde_json::to_string(note_file)?) | ||
| } | ||
|
|
||
| pub fn deserialize(&self, content: &str) -> FrilVaultResult<NoteFile> { | ||
| Ok(serde_json::from_str(content)?) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| mod note_parser; | ||
| mod yaml_parser; | ||
| mod json_parser; | ||
|
|
||
| pub use note_parser::*; | ||
| pub use yaml_parser::*; | ||
| pub use json_parser::*; |
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| mod note_file_record; | ||
| mod yaml_repository; | ||
| mod repository; | ||
|
|
||
| pub use note_file_record::*; | ||
| pub use yaml_repository::*; | ||
| pub use repository::*; |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,27 @@ | ||
| //! 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::storage::NoteFileRecord; | ||
| use crate::note::{NoteFile, NoteFileRecord}; | ||
| use crate::parser::JsonParser; | ||
| 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 +52,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)?; | ||
|
Comment on lines
+56
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift Add a legacy-note migration/fallback path before fully switching writes to JSON. On Line 56 and Line 58, writes are JSON-only. Combined with JSON path resolution/loading, existing 🤖 Prompt for AI Agents |
||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Add a backward-compatible read path for legacy YAML vault data.
Changing both constants to JSON-only makes existing
*.ymlnotes andworkspace.ymlundiscoverable unless migration/fallback is guaranteed. That is a persisted storage contract break for existing vaults.Minimal compatibility bridge
Then load-path logic should: try JSON first, fallback to legacy YAML once, then rewrite JSON.
Also applies to: 7-7
🤖 Prompt for AI Agents