MCPcopy Create free account
hub / github.com/AI45Lab/Code / ls

Method ls

sdk/python/src/lib.rs:2074–2090  ·  view source on GitHub ↗
(&self, py: Python<'_>, path: Option<String>)

Source from the content-addressed store, hash-verified

2072 /// List a directory in the workspace.
2073 #[pyo3(signature = (path=None))]
2074 fn ls(&self, py: Python<'_>, path: Option<String>) -> PyResult<PyToolResult> {
2075 let session = self.inner.clone();
2076 let result = py
2077 .allow_threads(move || get_runtime().block_on(session.ls(path.as_deref())))
2078 .map_err(|e| PyRuntimeError::new_err(format!("{e}")))?;
2079
2080 Ok(PyToolResult {
2081 name: result.name,
2082 output: result.output,
2083 exit_code: result.exit_code,
2084 metadata_json: result.metadata.as_ref().map(serde_json::Value::to_string),
2085 error_kind_json: result
2086 .error_kind
2087 .as_ref()
2088 .and_then(|k| serde_json::to_string(k).ok()),
2089 })
2090 }
2091
2092 /// Edit a file by replacing text in the workspace.
2093 #[pyo3(signature = (path, old_string, new_string, replace_all=false))]

Callers 1

Calls 3

block_onMethod · 0.80
get_runtimeFunction · 0.70
cloneMethod · 0.45

Tested by

no test coverage detected