assay_core/agentic/
mod.rs1use serde::{Deserialize, Serialize};
9use serde_json::Value as JsonValue;
10use std::path::PathBuf;
11
12use crate::errors::diagnostic::Diagnostic;
13
14mod builder;
15mod policy_helpers;
16
17#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
18#[serde(rename_all = "lowercase")]
19pub enum RiskLevel {
20 Low,
21 Medium,
22 High,
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
26pub struct SuggestedAction {
27 pub id: String,
28 pub title: String,
29 pub risk: RiskLevel,
30 pub command: Vec<String>,
31}
32
33#[derive(Debug, Clone, Serialize, Deserialize)]
34pub struct SuggestedPatch {
35 pub id: String,
36 pub title: String,
37 pub risk: RiskLevel,
38 pub file: String, pub ops: Vec<JsonPatchOp>,
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
43#[serde(tag = "op", rename_all = "lowercase")]
44pub enum JsonPatchOp {
45 Add { path: String, value: JsonValue },
46 Remove { path: String },
47 Replace { path: String, value: JsonValue },
48 Move { from: String, path: String },
49}
50
51pub struct AgenticCtx {
56 pub policy_path: Option<PathBuf>,
59
60 pub config_path: Option<PathBuf>,
63}
64
65pub fn build_suggestions(
73 diags: &[Diagnostic],
74 ctx: &AgenticCtx,
75) -> (Vec<SuggestedAction>, Vec<SuggestedPatch>) {
76 builder::build_suggestions_impl(diags, ctx)
77}
78
79#[cfg(test)]
80mod tests;