summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--makima/src/bin/makima.rs44
-rw-r--r--makima/src/daemon/api/directive.rs80
-rw-r--r--makima/src/daemon/cli/directive.rs48
-rw-r--r--makima/src/daemon/cli/mod.rs18
4 files changed, 190 insertions, 0 deletions
diff --git a/makima/src/bin/makima.rs b/makima/src/bin/makima.rs
index a0889d0..e881cf1 100644
--- a/makima/src/bin/makima.rs
+++ b/makima/src/bin/makima.rs
@@ -818,6 +818,50 @@ async fn run_directive(
.await?;
println!("{}", serde_json::to_string(&result.0)?);
}
+ DirectiveCommand::MemorySet(args) => {
+ let client = ApiClient::new(args.common.api_url, args.common.api_key)?;
+ let result = client
+ .directive_memory_set(args.common.directive_id, &args.key, &args.value)
+ .await?;
+ println!("{}", serde_json::to_string(&result.0)?);
+ }
+ DirectiveCommand::MemoryGet(args) => {
+ let client = ApiClient::new(args.common.api_url, args.common.api_key)?;
+ let result = client
+ .directive_memory_get(args.common.directive_id, &args.key)
+ .await?;
+ println!("{}", serde_json::to_string(&result.0)?);
+ }
+ DirectiveCommand::MemoryList(args) => {
+ let client = ApiClient::new(args.api_url, args.api_key)?;
+ let result = client
+ .directive_memory_list(args.directive_id)
+ .await?;
+ println!("{}", serde_json::to_string(&result.0)?);
+ }
+ DirectiveCommand::MemoryDelete(args) => {
+ let client = ApiClient::new(args.common.api_url, args.common.api_key)?;
+ client
+ .directive_memory_delete(args.common.directive_id, &args.key)
+ .await?;
+ println!(r#"{{"success": true}}"#);
+ }
+ DirectiveCommand::MemoryClear(args) => {
+ let client = ApiClient::new(args.api_url, args.api_key)?;
+ client
+ .directive_memory_clear(args.directive_id)
+ .await?;
+ println!(r#"{{"success": true}}"#);
+ }
+ DirectiveCommand::MemoryBatchSet(args) => {
+ let client = ApiClient::new(args.common.api_url, args.common.api_key)?;
+ let entries: serde_json::Value = serde_json::from_str(&args.json)
+ .map_err(|e| format!("Invalid JSON: {}", e))?;
+ let result = client
+ .directive_memory_batch_set(args.common.directive_id, entries)
+ .await?;
+ println!("{}", serde_json::to_string(&result.0)?);
+ }
}
Ok(())
diff --git a/makima/src/daemon/api/directive.rs b/makima/src/daemon/api/directive.rs
index cd21692..edf6364 100644
--- a/makima/src/daemon/api/directive.rs
+++ b/makima/src/daemon/api/directive.rs
@@ -30,6 +30,12 @@ pub struct UpdateStepDepsRequest {
pub depends_on: Vec<Uuid>,
}
+#[derive(Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct MemorySetRequest {
+ pub value: String,
+}
+
impl ApiClient {
/// List all directives.
pub async fn list_directives(&self) -> Result<JsonValue, ApiError> {
@@ -134,4 +140,78 @@ impl ApiClient {
let req = UpdateGoalRequest { goal: goal.to_string() };
self.put(&format!("/api/v1/directives/{}/goal", directive_id), &req).await
}
+
+ /// Set a memory key-value pair for a directive.
+ pub async fn directive_memory_set(
+ &self,
+ directive_id: Uuid,
+ key: &str,
+ value: &str,
+ ) -> Result<JsonValue, ApiError> {
+ let req = MemorySetRequest {
+ value: value.to_string(),
+ };
+ self.put(
+ &format!("/api/v1/directives/{}/memory/{}", directive_id, key),
+ &req,
+ )
+ .await
+ }
+
+ /// Get a memory value by key for a directive.
+ pub async fn directive_memory_get(
+ &self,
+ directive_id: Uuid,
+ key: &str,
+ ) -> Result<JsonValue, ApiError> {
+ self.get(&format!(
+ "/api/v1/directives/{}/memory/{}",
+ directive_id, key
+ ))
+ .await
+ }
+
+ /// List all memory key-value pairs for a directive.
+ pub async fn directive_memory_list(
+ &self,
+ directive_id: Uuid,
+ ) -> Result<JsonValue, ApiError> {
+ self.get(&format!("/api/v1/directives/{}/memory", directive_id))
+ .await
+ }
+
+ /// Delete a memory key for a directive.
+ pub async fn directive_memory_delete(
+ &self,
+ directive_id: Uuid,
+ key: &str,
+ ) -> Result<(), ApiError> {
+ self.delete(&format!(
+ "/api/v1/directives/{}/memory/{}",
+ directive_id, key
+ ))
+ .await
+ }
+
+ /// Clear all memory for a directive.
+ pub async fn directive_memory_clear(
+ &self,
+ directive_id: Uuid,
+ ) -> Result<(), ApiError> {
+ self.delete(&format!("/api/v1/directives/{}/memory", directive_id))
+ .await
+ }
+
+ /// Batch set multiple memory key-value pairs for a directive.
+ pub async fn directive_memory_batch_set(
+ &self,
+ directive_id: Uuid,
+ entries: serde_json::Value,
+ ) -> Result<JsonValue, ApiError> {
+ self.post(
+ &format!("/api/v1/directives/{}/memory/batch", directive_id),
+ &entries,
+ )
+ .await
+ }
}
diff --git a/makima/src/daemon/cli/directive.rs b/makima/src/daemon/cli/directive.rs
index cd94a56..135e09c 100644
--- a/makima/src/daemon/cli/directive.rs
+++ b/makima/src/daemon/cli/directive.rs
@@ -110,3 +110,51 @@ pub struct BatchAddStepsArgs {
#[arg(long)]
pub json: String,
}
+
+/// Arguments for memory-set command.
+#[derive(Args, Debug)]
+pub struct MemorySetArgs {
+ #[command(flatten)]
+ pub common: DirectiveArgs,
+
+ /// Memory key
+ pub key: String,
+
+ /// Memory value
+ pub value: String,
+}
+
+/// Arguments for memory-get command.
+#[derive(Args, Debug)]
+pub struct MemoryGetArgs {
+ #[command(flatten)]
+ pub common: DirectiveArgs,
+
+ /// Memory key
+ pub key: String,
+}
+
+/// Arguments for memory-list command (uses DirectiveArgs directly).
+
+/// Arguments for memory-delete command.
+#[derive(Args, Debug)]
+pub struct MemoryDeleteArgs {
+ #[command(flatten)]
+ pub common: DirectiveArgs,
+
+ /// Memory key to delete
+ pub key: String,
+}
+
+/// Arguments for memory-clear command (uses DirectiveArgs directly).
+
+/// Arguments for memory-batch-set command.
+#[derive(Args, Debug)]
+pub struct MemoryBatchSetArgs {
+ #[command(flatten)]
+ pub common: DirectiveArgs,
+
+ /// JSON object of key-value pairs: {"key1":"value1","key2":"value2"}
+ #[arg(long)]
+ pub json: String,
+}
diff --git a/makima/src/daemon/cli/mod.rs b/makima/src/daemon/cli/mod.rs
index 98923d9..1e9f31a 100644
--- a/makima/src/daemon/cli/mod.rs
+++ b/makima/src/daemon/cli/mod.rs
@@ -246,6 +246,24 @@ pub enum DirectiveCommand {
/// Batch add multiple steps from JSON
BatchAddSteps(directive::BatchAddStepsArgs),
+
+ /// Set a memory key-value pair for the directive
+ MemorySet(directive::MemorySetArgs),
+
+ /// Get a memory value by key
+ MemoryGet(directive::MemoryGetArgs),
+
+ /// List all memory key-value pairs
+ MemoryList(DirectiveArgs),
+
+ /// Delete a memory key
+ MemoryDelete(directive::MemoryDeleteArgs),
+
+ /// Clear all memory for the directive
+ MemoryClear(DirectiveArgs),
+
+ /// Batch set multiple memory key-value pairs from JSON
+ MemoryBatchSet(directive::MemoryBatchSetArgs),
}
impl Cli {