Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/grite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ authors.workspace = true
name = "grite"
path = "src/main.rs"

[features]
default = ["context"]
context = ["libgrite-core/context", "libgrite-cli/context", "libgrite-git/context"]

[dependencies]
libgrite-core = { path = "../libgrite-core", version = "0.5.1" }
libgrite-git = { path = "../libgrite-git", version = "0.5.1" }
Expand Down
2 changes: 2 additions & 0 deletions crates/grite/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ pub enum Command {
},

/// Context store management (file/symbol indexing)
#[cfg(feature = "context")]
Context {
#[command(subcommand)]
cmd: ContextCommand,
Expand Down Expand Up @@ -541,6 +542,7 @@ pub enum DepCommand {
},
}

#[cfg(feature = "context")]
#[derive(Clone, Subcommand)]
pub enum ContextCommand {
/// Index files in the repository
Expand Down
1 change: 1 addition & 0 deletions crates/grite/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod actor;
#[cfg(feature = "context")]
pub mod context;
pub mod daemon;
pub mod db;
Expand Down
1 change: 1 addition & 0 deletions crates/grite/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ fn run_command(cli: &Cli) -> Result<(), GriteError> {
Command::Daemon { cmd } => commands::daemon::run(cli, cmd.clone()),
Command::Lock { cmd } => commands::lock::run(cli, cmd.clone()),
Command::Doctor { fix } => commands::doctor::run(cli, *fix),
#[cfg(feature = "context")]
Command::Context { cmd } => commands::context::run(cli, cmd.clone()),
Command::InstallSkill { global, force } => {
commands::install_skill::run(cli, *global, *force)
Expand Down
4 changes: 3 additions & 1 deletion crates/grite/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ pub fn should_route_through_daemon(cmd: &crate::cli::Command) -> bool {
Command::Doctor { .. } => false,

// Context commands are local-only (need filesystem access)
#[cfg(feature = "context")]
Command::Context { .. } => false,

// Install-skill is local-only
Expand Down Expand Up @@ -150,8 +151,9 @@ pub fn cli_to_ipc_command(cmd: &crate::cli::Command) -> Option<IpcCommand> {
| Command::Daemon { .. }
| Command::Lock { .. }
| Command::Doctor { .. }
| Command::Context { .. }
| Command::InstallSkill { .. } => None,
#[cfg(feature = "context")]
Command::Context { .. } => None,
}
}

Expand Down
3 changes: 2 additions & 1 deletion crates/libgrite-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ readme = "README.md"
authors.workspace = true

[features]
default = []
default = ["context"]
async = ["dep:tokio"]
context = ["libgrite-core/context"]

[dependencies]
libgrite-core = { path = "../libgrite-core", version = "0.5.1" }
Expand Down
1 change: 1 addition & 0 deletions crates/libgrite-cli/src/async_wrappers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ pub async fn rebuild_async(
}

/// Async: index context.
#[cfg(feature = "context")]
pub async fn context_index_async(
ctx: &GriteContext,
opts: ContextIndexOptions,
Expand Down
1 change: 1 addition & 0 deletions crates/libgrite-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

pub mod actor;
pub mod context;
#[cfg(feature = "context")]
pub mod context_cmd;
pub mod daemon;
pub mod db;
Expand Down
10 changes: 10 additions & 0 deletions crates/libgrite-cli/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ pub struct DoctorCheckResult {
}

/// Options for context index.
#[cfg(feature = "context")]
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ContextIndexOptions {
pub paths: Vec<String>,
Expand All @@ -509,56 +510,65 @@ pub struct ContextIndexOptions {
}

/// Result of context index.
#[cfg(feature = "context")]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ContextIndexResult {
pub indexed_files: usize,
pub indexed_symbols: usize,
}

/// Options for context query.
#[cfg(feature = "context")]
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ContextQueryOptions {
pub query: String,
}

/// Result of context query.
#[cfg(feature = "context")]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ContextQueryResult {
pub symbols: Vec<libgrite_core::SymbolInfo>,
}

/// Options for context show.
#[cfg(feature = "context")]
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ContextShowOptions {
pub path: String,
}

/// Result of context show.
#[cfg(feature = "context")]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ContextShowResult {
pub file: libgrite_core::FileContext,
}

/// Options for context project.
#[cfg(feature = "context")]
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ContextProjectOptions {
pub key: Option<String>,
}

/// Result of context project.
#[cfg(feature = "context")]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ContextProjectResult {
pub entries: Vec<libgrite_core::ProjectContextEntry>,
}

/// Options for context set.
#[cfg(feature = "context")]
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ContextSetOptions {
pub key: String,
pub value: String,
}

/// Result of context set.
#[cfg(feature = "context")]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ContextSetResult {
pub key: String,
Expand Down
44 changes: 31 additions & 13 deletions crates/libgrite-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,24 @@ description = "Core library for grite: event types, CRDT projections, hashing, a
readme = "README.md"
authors.workspace = true

[features]
default = ["context"]
context = [
"dep:tree-sitter",
"dep:tree-sitter-language",
"dep:streaming-iterator",
"dep:tree-sitter-rust",
"dep:tree-sitter-python",
"dep:tree-sitter-typescript",
"dep:tree-sitter-javascript",
"dep:tree-sitter-go",
"dep:tree-sitter-java",
"dep:tree-sitter-c",
"dep:tree-sitter-cpp",
"dep:tree-sitter-ruby",
"dep:tree-sitter-elixir",
]

[dependencies]
blake2 = { workspace = true }
ciborium = { workspace = true }
Expand All @@ -29,19 +47,19 @@ sha2 = { workspace = true }
ed25519-dalek = { workspace = true }
fs2 = { workspace = true }
regex = { workspace = true }
tree-sitter = { workspace = true }
tree-sitter-language = { workspace = true }
streaming-iterator = { workspace = true }
tree-sitter-rust = { workspace = true }
tree-sitter-python = { workspace = true }
tree-sitter-typescript = { workspace = true }
tree-sitter-javascript = { workspace = true }
tree-sitter-go = { workspace = true }
tree-sitter-java = { workspace = true }
tree-sitter-c = { workspace = true }
tree-sitter-cpp = { workspace = true }
tree-sitter-ruby = { workspace = true }
tree-sitter-elixir = { workspace = true }
tree-sitter = { workspace = true, optional = true }
tree-sitter-language = { workspace = true, optional = true }
streaming-iterator = { workspace = true, optional = true }
tree-sitter-rust = { workspace = true, optional = true }
tree-sitter-python = { workspace = true, optional = true }
tree-sitter-typescript = { workspace = true, optional = true }
tree-sitter-javascript = { workspace = true, optional = true }
tree-sitter-go = { workspace = true, optional = true }
tree-sitter-java = { workspace = true, optional = true }
tree-sitter-c = { workspace = true, optional = true }
tree-sitter-cpp = { workspace = true, optional = true }
tree-sitter-ruby = { workspace = true, optional = true }
tree-sitter-elixir = { workspace = true, optional = true }

[dev-dependencies]
tempfile = "3.10"
2 changes: 2 additions & 0 deletions crates/libgrite-core/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ fn event_kind_to_json(kind: &EventKind) -> serde_json::Value {
}
})
}
#[cfg(feature = "context")]
EventKind::ContextUpdated {
path,
language,
Expand All @@ -191,6 +192,7 @@ fn event_kind_to_json(kind: &EventKind) -> serde_json::Value {
}
})
}
#[cfg(feature = "context")]
EventKind::ProjectContextUpdated { key, value } => {
serde_json::json!({
"ProjectContextUpdated": {
Expand Down
4 changes: 4 additions & 0 deletions crates/libgrite-core/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ pub fn kind_to_tag_and_payload(kind: &EventKind) -> (u32, ciborium::Value) {
Value::Text(dep_type.as_str().to_string()),
]),
),
#[cfg(feature = "context")]
EventKind::ContextUpdated {
path,
language,
Expand Down Expand Up @@ -161,6 +162,7 @@ pub fn kind_to_tag_and_payload(kind: &EventKind) -> (u32, ciborium::Value) {
]),
)
}
#[cfg(feature = "context")]
EventKind::ProjectContextUpdated { key, value } => (
14,
Value::Array(vec![Value::Text(key.clone()), Value::Text(value.clone())]),
Expand Down Expand Up @@ -497,6 +499,7 @@ mod tests {
assert_ne!(id1, id_add);
}

#[cfg(feature = "context")]
#[test]
fn test_vector_13_context_updated() {
use crate::types::event::SymbolInfo;
Expand Down Expand Up @@ -553,6 +556,7 @@ mod tests {
assert_eq!(id1, id3, "Symbol order should not affect hash");
}

#[cfg(feature = "context")]
#[test]
fn test_vector_14_project_context_updated() {
let issue_id: IssueId = hex_to_id("000102030405060708090a0b0c0d0e0f").unwrap();
Expand Down
6 changes: 5 additions & 1 deletion crates/libgrite-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
//! - **Append-only** for comments, links, attachments

pub mod config;
#[cfg(feature = "context")]
pub mod context;
pub mod error;
pub mod export;
Expand All @@ -47,8 +48,11 @@ pub use lock::{resource_hash, Lock, LockCheckResult, LockPolicy, LockStatus, DEF
pub use signing::{verify_signature, SigningError, SigningKeyPair, VerificationPolicy};
pub use store::{DbStats, GriteStore, IssueFilter, LockedStore, RebuildStats};
pub use types::actor::ActorConfig;
#[cfg(feature = "context")]
pub use types::context::{FileContext, ProjectContext, ProjectContextEntry};
pub use types::event::{DependencyType, Event, EventKind, IssueState, SymbolInfo};
#[cfg(feature = "context")]
pub use types::event::SymbolInfo;
pub use types::event::{DependencyType, Event, EventKind, IssueState};
pub use types::ids::{generate_actor_id, generate_issue_id, hex_to_id, id_to_hex};
pub use types::issue::{IssueProjection, IssueSummary, Version};
pub use types::{ActorId, EventId, IssueId};
1 change: 1 addition & 0 deletions crates/libgrite-core/src/projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ impl IssueProjection {
});
}

#[cfg(feature = "context")]
EventKind::ContextUpdated { .. } | EventKind::ProjectContextUpdated { .. } => {
// Context events are handled by the context store, not issue projections
return Ok(());
Expand Down
Loading