mirror of
https://github.com/ultraworkers/claw-code.git
synced 2026-05-30 11:45:20 +08:00
fix(#701): add detail_entries structured key/value to doctor check JSON; booleans/ints emitted as JSON scalars
This commit is contained in:
parent
9c5f190fcc
commit
47521cf178
@ -2009,6 +2009,37 @@ impl DiagnosticCheck {
|
|||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
// #701: structured key/value pairs parsed from prose detail strings.
|
||||||
|
// Each detail string is `"Key Label value"` separated by 2+ spaces.
|
||||||
|
// Booleans (`true`/`false`) and integers are emitted as JSON scalars.
|
||||||
|
"detail_entries".to_string(),
|
||||||
|
Value::Array(
|
||||||
|
self.details
|
||||||
|
.iter()
|
||||||
|
.map(|s| {
|
||||||
|
// Split on first run of 2+ spaces to separate key from value.
|
||||||
|
let parts: Vec<&str> = s.splitn(2, " ").collect();
|
||||||
|
if parts.len() == 2 {
|
||||||
|
let k = parts[0].trim().to_string();
|
||||||
|
let v_str = parts[1].trim();
|
||||||
|
let v: Value = if v_str == "true" {
|
||||||
|
Value::Bool(true)
|
||||||
|
} else if v_str == "false" {
|
||||||
|
Value::Bool(false)
|
||||||
|
} else if let Ok(n) = v_str.parse::<i64>() {
|
||||||
|
Value::Number(n.into())
|
||||||
|
} else {
|
||||||
|
Value::String(v_str.to_string())
|
||||||
|
};
|
||||||
|
json!({"key": k, "value": v})
|
||||||
|
} else {
|
||||||
|
json!({"key": s.trim(), "value": Value::Null})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
|
),
|
||||||
|
),
|
||||||
]);
|
]);
|
||||||
value.extend(self.data.clone());
|
value.extend(self.data.clone());
|
||||||
Value::Object(value)
|
Value::Object(value)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user