feat(sdk,plugins): API publique d'accès fichiers/workspace + analyse structure (#124,#129)
This commit is contained in:
@ -9,7 +9,7 @@ use std::io;
|
||||
use std::path::Path;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use domain::ports::{DirEntry, FileSystem, FsError, RemotePath};
|
||||
use domain::ports::{DirEntry, FileMetadata, FileSystem, FsError, RemotePath};
|
||||
use tokio::fs;
|
||||
|
||||
/// Filesystem adapter backed by the local OS via `tokio::fs`.
|
||||
@ -54,6 +54,17 @@ impl FileSystem for LocalFileSystem {
|
||||
}
|
||||
}
|
||||
|
||||
async fn metadata(&self, path: &RemotePath) -> Result<FileMetadata, FsError> {
|
||||
let meta = fs::metadata(path.as_str())
|
||||
.await
|
||||
.map_err(|e| map_io(path, &e))?;
|
||||
Ok(FileMetadata {
|
||||
is_file: meta.is_file(),
|
||||
is_dir: meta.is_dir(),
|
||||
len: Some(meta.len()),
|
||||
})
|
||||
}
|
||||
|
||||
async fn remove_file(&self, path: &RemotePath) -> Result<(), FsError> {
|
||||
match fs::remove_file(path.as_str()).await {
|
||||
Ok(()) => Ok(()),
|
||||
|
||||
@ -89,7 +89,7 @@ pub use orchestrator::{
|
||||
pub use pair_attempt_limiter::InMemoryPairAttemptLimiter;
|
||||
pub use permission::{ClaudePermissionProjector, CodexPermissionProjector};
|
||||
pub use plugin::{ExternalMcpPluginSupervisor, FsPluginPackageStore, FsPluginRegistryStore};
|
||||
pub use process::LocalProcessSpawner;
|
||||
pub use process::{LocalEnvironmentReader, LocalProcessSpawner};
|
||||
pub use pty::PortablePtyAdapter;
|
||||
pub use ratelimit::RateLimitParser;
|
||||
pub use remote::{remote_host, LocalHost};
|
||||
|
||||
@ -9,7 +9,9 @@
|
||||
use async_trait::async_trait;
|
||||
use tokio::process::Command;
|
||||
|
||||
use domain::ports::{ExitStatus, Output, ProcessError, ProcessSpawner, SpawnSpec};
|
||||
use domain::ports::{
|
||||
EnvironmentReader, ExitStatus, Output, ProcessError, ProcessSpawner, SpawnSpec,
|
||||
};
|
||||
|
||||
/// Process spawner backed by the local OS via `tokio::process::Command`.
|
||||
#[derive(Debug, Default, Clone, Copy)]
|
||||
@ -23,6 +25,24 @@ impl LocalProcessSpawner {
|
||||
}
|
||||
}
|
||||
|
||||
/// Environment reader backed by the local process environment.
|
||||
#[derive(Debug, Default, Clone, Copy)]
|
||||
pub struct LocalEnvironmentReader;
|
||||
|
||||
impl LocalEnvironmentReader {
|
||||
/// Creates a new [`LocalEnvironmentReader`].
|
||||
#[must_use]
|
||||
pub const fn new() -> Self {
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
||||
impl EnvironmentReader for LocalEnvironmentReader {
|
||||
fn get(&self, name: &str) -> Option<String> {
|
||||
std::env::var(name).ok()
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl ProcessSpawner for LocalProcessSpawner {
|
||||
async fn run(&self, spec: SpawnSpec) -> Result<Output, ProcessError> {
|
||||
|
||||
Reference in New Issue
Block a user