feat(plugins): paramètres projet plugins + attribution skills/tools aux agents — #282 (manifeste accepte contributes.skills IdeA-native multi-harness; store .ideai/project-plugins.json v1: enable plugin par projet + assignments skills/tools par agent; refs + use cases settings/assign/unassign; resolver skills pour idea_skill_read et injection catalogue lancement agent; permissions MCP dynamiques projetées par harness Claude Code/Codex/OpenCode; tombstones uninstall, hot reload recalcule catalogue et marque assignments cassés; frontend: Settings projet Plugins, détail capabilities, attribution agent, catalogue permissions; bump pointeur IdeaSDK 6eb8db3; QA verte: cargo test -p application, project_plugin_settings 3/3, dto_plugins 2/2, structured_launch_d3 26/26, catalogue mcp 7/7, frontend 5 tests ProjectPluginSettings/plugin, npm build frontend)
This commit is contained in:
@ -110,6 +110,7 @@ pub use sandbox::{default_enforcer, NoopSandbox};
|
||||
pub use scheduler::TokioScheduler;
|
||||
pub use session::{ClaudeSdkSession, CodexExecSession, FakeCli, StructuredSessionFactory};
|
||||
pub use sprints::FsSprintStore;
|
||||
pub use store::FsProjectPluginSettingsStore;
|
||||
#[cfg(feature = "vector-onnx")]
|
||||
pub use store::OnnxEmbedder;
|
||||
#[cfg(feature = "vector-http")]
|
||||
|
||||
@ -155,6 +155,21 @@ impl PluginPackageStore for FsPluginPackageStore {
|
||||
Ok(PluginManifestBytes { bytes })
|
||||
}
|
||||
|
||||
async fn read_installed_file(
|
||||
&self,
|
||||
plugin_id: &PluginId,
|
||||
path: &RelativePath,
|
||||
) -> Result<Vec<u8>, PluginStoreError> {
|
||||
let resolved = self.resolve_asset_path(plugin_id, path)?;
|
||||
fs::read(resolved).map_err(|e| {
|
||||
if e.kind() == io::ErrorKind::NotFound {
|
||||
PluginStoreError::NotFound
|
||||
} else {
|
||||
PluginStoreError::Io(e.to_string())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async fn install_from_archive(
|
||||
&self,
|
||||
archive: &LocalPath,
|
||||
|
||||
@ -14,6 +14,7 @@ mod memory;
|
||||
mod permission;
|
||||
mod profile;
|
||||
mod project;
|
||||
mod project_plugin;
|
||||
mod secrets;
|
||||
mod skill;
|
||||
mod system_permission;
|
||||
@ -39,6 +40,7 @@ pub use memory::{index_token_size, FsMemoryStore, NaiveMemoryRecall};
|
||||
pub use permission::FsPermissionStore;
|
||||
pub use profile::{FsEmbedderProfileStore, FsProfileStore};
|
||||
pub use project::FsProjectStore;
|
||||
pub use project_plugin::FsProjectPluginSettingsStore;
|
||||
pub use secrets::FsSecretStore;
|
||||
pub use skill::FsSkillStore;
|
||||
pub use system_permission::FsSystemPermissionStore;
|
||||
|
||||
76
crates/infrastructure/src/store/project_plugin.rs
Normal file
76
crates/infrastructure/src/store/project_plugin.rs
Normal file
@ -0,0 +1,76 @@
|
||||
//! Project-scoped plugin activation and assignment persistence.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use domain::{
|
||||
FileSystem, FsError, ProjectPath, ProjectPluginSettings, ProjectPluginSettingsStore,
|
||||
RemotePath, StoreError,
|
||||
};
|
||||
|
||||
const SETTINGS_FILE: &str = ".ideai/project-plugins.json";
|
||||
|
||||
/// File-backed settings store using the project's location-neutral filesystem.
|
||||
#[derive(Clone)]
|
||||
pub struct FsProjectPluginSettingsStore {
|
||||
fs: Arc<dyn FileSystem>,
|
||||
}
|
||||
|
||||
impl FsProjectPluginSettingsStore {
|
||||
/// Builds the adapter.
|
||||
#[must_use]
|
||||
pub fn new(fs: Arc<dyn FileSystem>) -> Self {
|
||||
Self { fs }
|
||||
}
|
||||
|
||||
fn path(project_root: &ProjectPath) -> RemotePath {
|
||||
RemotePath::new(format!(
|
||||
"{}/{}",
|
||||
project_root.as_str().trim_end_matches(['/', '\\']),
|
||||
SETTINGS_FILE
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl ProjectPluginSettingsStore for FsProjectPluginSettingsStore {
|
||||
async fn load(&self, project_root: &ProjectPath) -> Result<ProjectPluginSettings, StoreError> {
|
||||
match self.fs.read(&Self::path(project_root)).await {
|
||||
Ok(bytes) => {
|
||||
let settings: ProjectPluginSettings = serde_json::from_slice(&bytes)
|
||||
.map_err(|e| StoreError::Serialization(e.to_string()))?;
|
||||
if settings.version != 1 {
|
||||
return Err(StoreError::Invalid(format!(
|
||||
"unsupported project plugin settings version {}",
|
||||
settings.version
|
||||
)));
|
||||
}
|
||||
Ok(settings)
|
||||
}
|
||||
Err(FsError::NotFound(_)) => Ok(ProjectPluginSettings::default()),
|
||||
Err(e) => Err(StoreError::Io(e.to_string())),
|
||||
}
|
||||
}
|
||||
|
||||
async fn save(
|
||||
&self,
|
||||
project_root: &ProjectPath,
|
||||
settings: &ProjectPluginSettings,
|
||||
) -> Result<(), StoreError> {
|
||||
let dir = RemotePath::new(format!(
|
||||
"{}/.ideai",
|
||||
project_root.as_str().trim_end_matches(['/', '\\'])
|
||||
));
|
||||
self.fs
|
||||
.create_dir_all(&dir)
|
||||
.await
|
||||
.map_err(|e| StoreError::Io(e.to_string()))?;
|
||||
let mut bytes = serde_json::to_vec_pretty(settings)
|
||||
.map_err(|e| StoreError::Serialization(e.to_string()))?;
|
||||
bytes.push(b'\n');
|
||||
self.fs
|
||||
.write(&Self::path(project_root), &bytes)
|
||||
.await
|
||||
.map_err(|e| StoreError::Io(e.to_string()))
|
||||
}
|
||||
}
|
||||
84
crates/infrastructure/tests/project_plugin_settings.rs
Normal file
84
crates/infrastructure/tests/project_plugin_settings.rs
Normal file
@ -0,0 +1,84 @@
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use domain::{
|
||||
AgentId, AgentPluginAssignments, FileSystem, PluginId, PluginSkillId, PluginSkillRef,
|
||||
ProjectPath, ProjectPluginActivation, ProjectPluginSettings, ProjectPluginSettingsStore,
|
||||
};
|
||||
use infrastructure::{FsProjectPluginSettingsStore, LocalFileSystem};
|
||||
use uuid::Uuid;
|
||||
|
||||
struct TempDir(PathBuf);
|
||||
|
||||
impl TempDir {
|
||||
fn new() -> Self {
|
||||
let path = std::env::temp_dir().join(format!("idea-project-plugins-{}", Uuid::new_v4()));
|
||||
std::fs::create_dir_all(&path).unwrap();
|
||||
Self(path)
|
||||
}
|
||||
|
||||
fn root(&self) -> ProjectPath {
|
||||
ProjectPath::new(self.0.to_string_lossy().into_owned()).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for TempDir {
|
||||
fn drop(&mut self) {
|
||||
let _ = std::fs::remove_dir_all(&self.0);
|
||||
}
|
||||
}
|
||||
|
||||
fn store() -> FsProjectPluginSettingsStore {
|
||||
let fs: Arc<dyn FileSystem> = Arc::new(LocalFileSystem::new());
|
||||
FsProjectPluginSettingsStore::new(fs)
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn missing_document_returns_version_one_defaults() {
|
||||
let tmp = TempDir::new();
|
||||
let settings = store().load(&tmp.root()).await.unwrap();
|
||||
assert_eq!(settings, ProjectPluginSettings::default());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn settings_round_trip_under_project_ideai_directory() {
|
||||
let tmp = TempDir::new();
|
||||
let plugin_id = PluginId::new("dev.acme.tools").unwrap();
|
||||
let agent_id = AgentId::from_uuid(Uuid::from_u128(42));
|
||||
let settings = ProjectPluginSettings {
|
||||
version: 1,
|
||||
plugins: vec![ProjectPluginActivation {
|
||||
plugin_id: plugin_id.clone(),
|
||||
enabled: true,
|
||||
}],
|
||||
agents: vec![AgentPluginAssignments {
|
||||
agent_id,
|
||||
skills: vec![PluginSkillRef {
|
||||
plugin_id,
|
||||
skill_id: PluginSkillId::new("build-debug").unwrap(),
|
||||
}],
|
||||
tools: Vec::new(),
|
||||
}],
|
||||
};
|
||||
|
||||
store().save(&tmp.root(), &settings).await.unwrap();
|
||||
|
||||
assert_eq!(store().load(&tmp.root()).await.unwrap(), settings);
|
||||
assert!(tmp.0.join(".ideai/project-plugins.json").is_file());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn unsupported_document_version_is_rejected() {
|
||||
let tmp = TempDir::new();
|
||||
std::fs::create_dir_all(tmp.0.join(".ideai")).unwrap();
|
||||
std::fs::write(
|
||||
tmp.0.join(".ideai/project-plugins.json"),
|
||||
br#"{"version":2,"plugins":[],"agents":[]}"#,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let error = store().load(&tmp.root()).await.unwrap_err();
|
||||
assert!(error
|
||||
.to_string()
|
||||
.contains("unsupported project plugin settings version 2"));
|
||||
}
|
||||
Reference in New Issue
Block a user