Add usable table/map stdlib with put, and show run bindings in view.

Authors can update nested collections via table.put/表.改 instead of json.set chains; view’s right rail adds collapsible Variables from the entry env.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-08-12 11:49:48 +08:00
1 parent 91d51f3f0a
commit 25b7be6739
26 files changed
+1577 -123

No files matched your search

+2 -26
View File
@@ -125,35 +125,11 @@ fn skill_search_roots(ctx: &HostContext) -> Vec<PathBuf> {
}
pub fn map_set(map: &Value, key: &Value, value: &Value) -> Result<Value, String> {
let k = match key {
Value::Text(s) => s.clone(),
_ => return Err("map_set key must be text".into()),
};
match map {
Value::Map(entries) => {
let mut out = entries.clone();
if let Some((_, slot)) = out.iter_mut().find(|(kk, _)| *kk == k) {
*slot = value.clone();
} else {
out.push((k, value.clone()));
}
Ok(Value::Map(out))
}
Value::None => Ok(Value::Map(vec![(k, value.clone())])),
_ => Err("map_set needs map".into()),
}
crate::host::collection::map_set(map, key, value)
}
pub fn list_append(list: &Value, item: &Value) -> Result<Value, String> {
match list {
Value::List(xs) => {
let mut out = xs.clone();
out.push(item.clone());
Ok(Value::List(out))
}
Value::None => Ok(Value::List(vec![item.clone()])),
_ => Err("list_append needs list".into()),
}
crate::host::collection::list_append(list, item)
}
#[cfg(test)]