fix: fix some ui displays and features miss implemented

This commit is contained in:
2026-06-06 16:15:19 +02:00
parent 9736c42424
commit 2332b7f815
22 changed files with 1599 additions and 14 deletions

View File

@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize};
use crate::error::DomainError;
use crate::ids::{AgentId, ProfileId, TemplateId};
use crate::skill::SkillRef;
use crate::template::TemplateVersion;
/// Origin of an agent: created from scratch, or derived from a template.
@ -65,6 +66,10 @@ pub struct Agent {
pub origin: AgentOrigin,
/// Whether the agent tracks its template (only valid for template origins).
pub synchronized: bool,
/// Skills assigned to this agent, injected into its convention file at
/// activation (ARCHITECTURE §14.2). Empty by default.
#[serde(default)]
pub skills: Vec<SkillRef>,
}
impl Agent {
@ -98,8 +103,37 @@ impl Agent {
profile_id,
origin,
synchronized,
skills: Vec::new(),
})
}
/// Returns a copy of this agent carrying the given assigned skills,
/// deduplicated by `skill_id` (keeping first occurrence).
#[must_use]
pub fn with_skills(mut self, skills: Vec<SkillRef>) -> Self {
self.skills = Vec::new();
for skill in skills {
self.assign_skill(skill);
}
self
}
/// Assigns a skill to this agent. Idempotent: re-assigning the same
/// `skill_id` is a no-op (returns `false`); a new assignment returns `true`.
pub fn assign_skill(&mut self, skill: SkillRef) -> bool {
if self.skills.iter().any(|s| s.skill_id == skill.skill_id) {
return false;
}
self.skills.push(skill);
true
}
/// Removes a skill assignment by id. Returns `true` if a skill was removed.
pub fn unassign_skill(&mut self, skill_id: crate::ids::SkillId) -> bool {
let before = self.skills.len();
self.skills.retain(|s| s.skill_id != skill_id);
self.skills.len() != before
}
}
/// One entry in the project agent manifest (`.ideai/agents.json`).
@ -135,6 +169,10 @@ pub struct ManifestEntry {
/// Template version recorded at the last sync.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub synced_template_version: Option<TemplateVersion>,
/// Skills assigned to this agent (ARCHITECTURE §14.2). Defaults to empty for
/// backward-compatible deserialisation of pre-L12 manifests.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub skills: Vec<SkillRef>,
}
impl ManifestEntry {
@ -172,6 +210,7 @@ impl ManifestEntry {
template_id,
synchronized,
synced_template_version,
skills: Vec::new(),
})
}
@ -196,6 +235,7 @@ impl ManifestEntry {
template_id,
synchronized: agent.synchronized,
synced_template_version,
skills: agent.skills.clone(),
}
}
@ -213,14 +253,15 @@ impl ManifestEntry {
},
_ => AgentOrigin::Scratch,
};
Agent::new(
Ok(Agent::new(
self.agent_id,
self.name.clone(),
self.md_path.clone(),
self.profile_id,
origin,
self.synchronized,
)
)?
.with_skills(self.skills.clone()))
}
}