fix: fix some displays and features
This commit is contained in:
@ -26,12 +26,13 @@ use domain::markdown::MarkdownDoc;
|
||||
use domain::ports::{
|
||||
AgentContextStore, AgentRuntime, ContextInjectionPlan, DirEntry, EventBus, EventStream,
|
||||
ExitStatus, FileSystem, FsError, IdGenerator, OutputStream, PreparedContext, ProfileStore,
|
||||
PtyError, PtyHandle, PtyPort, RemotePath, RuntimeError, SpawnSpec, StoreError,
|
||||
PtyError, PtyHandle, PtyPort, RemotePath, RuntimeError, SkillStore, SpawnSpec, StoreError,
|
||||
};
|
||||
use domain::profile::{AgentProfile, ContextInjection};
|
||||
use domain::project::{Project, ProjectPath};
|
||||
use domain::remote::RemoteRef;
|
||||
use domain::{PtySize, SessionId};
|
||||
use domain::skill::{Skill, SkillScope};
|
||||
use domain::{PtySize, SessionId, SkillId, SkillRef};
|
||||
use uuid::Uuid;
|
||||
|
||||
use application::{
|
||||
@ -177,6 +178,49 @@ impl ProfileStore for FakeProfiles {
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// FakeSkills (SkillStore) — an in-memory store seeded with a few skills
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
struct FakeSkills(Arc<Vec<Skill>>);
|
||||
|
||||
impl FakeSkills {
|
||||
fn with(skills: Vec<Skill>) -> Self {
|
||||
Self(Arc::new(skills))
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl SkillStore for FakeSkills {
|
||||
async fn list(&self, scope: SkillScope, _root: &ProjectPath) -> Result<Vec<Skill>, StoreError> {
|
||||
Ok(self.0.iter().filter(|s| s.scope == scope).cloned().collect())
|
||||
}
|
||||
async fn get(
|
||||
&self,
|
||||
scope: SkillScope,
|
||||
_root: &ProjectPath,
|
||||
id: SkillId,
|
||||
) -> Result<Skill, StoreError> {
|
||||
self.0
|
||||
.iter()
|
||||
.find(|s| s.scope == scope && s.id == id)
|
||||
.cloned()
|
||||
.ok_or(StoreError::NotFound)
|
||||
}
|
||||
async fn save(&self, _skill: &Skill, _root: &ProjectPath) -> Result<(), StoreError> {
|
||||
Ok(())
|
||||
}
|
||||
async fn delete(
|
||||
&self,
|
||||
_scope: SkillScope,
|
||||
_root: &ProjectPath,
|
||||
_id: SkillId,
|
||||
) -> Result<(), StoreError> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// FakeRuntime (AgentRuntime) — records prepare + returns a configured plan
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -577,6 +621,7 @@ fn launch_fixture(injection: ContextInjection, plan: Option<ContextInjectionPlan
|
||||
Arc::new(runtime),
|
||||
Arc::new(fs.clone()),
|
||||
Arc::new(pty.clone()),
|
||||
Arc::new(FakeSkills::default()),
|
||||
Arc::clone(&sessions),
|
||||
Arc::new(bus.clone()),
|
||||
);
|
||||
@ -695,6 +740,7 @@ async fn two_agents_same_root_get_distinct_run_dirs_no_collision() {
|
||||
Arc::new(FakeRuntime::new(Arc::clone(&tr), plan)),
|
||||
Arc::new(fs.clone()),
|
||||
Arc::new(pty.clone()),
|
||||
Arc::new(FakeSkills::default()),
|
||||
Arc::clone(&sessions),
|
||||
Arc::new(SpyBus::default()),
|
||||
);
|
||||
@ -730,6 +776,98 @@ async fn two_agents_same_root_get_distinct_run_dirs_no_collision() {
|
||||
assert!(String::from_utf8(writes[1].1.clone()).unwrap().contains("# bravo"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn launch_conventionfile_injects_assigned_skills_in_order() {
|
||||
// An agent with two assigned global skills; the generated convention file must
|
||||
// carry both skill bodies, after the persona, in assignment order (§14.2).
|
||||
let skill_id = |n: u128| SkillId::from_uuid(Uuid::from_u128(n));
|
||||
let skill = |n: u128, name: &str, body: &str| {
|
||||
Skill::new(skill_id(n), name, MarkdownDoc::new(body), SkillScope::Global).unwrap()
|
||||
};
|
||||
|
||||
let mut agent = scratch_agent(aid(1), "Backend", "agents/backend.md", pid(9));
|
||||
agent.assign_skill(SkillRef::new(skill_id(1), SkillScope::Global));
|
||||
agent.assign_skill(SkillRef::new(skill_id(2), SkillScope::Global));
|
||||
|
||||
let contexts = FakeContexts::with_agent(&agent, "# persona");
|
||||
let profiles = FakeProfiles::new(vec![profile(
|
||||
pid(9),
|
||||
ContextInjection::convention_file("CLAUDE.md").unwrap(),
|
||||
)]);
|
||||
let tr = trace();
|
||||
let fs = FakeFs::new(Arc::clone(&tr));
|
||||
let pty = FakePty::new(Arc::clone(&tr), sid(777));
|
||||
let skills = FakeSkills::with(vec![
|
||||
skill(1, "refactor", "REFAC_BODY"),
|
||||
skill(2, "review", "REVIEW_BODY"),
|
||||
]);
|
||||
let launch = LaunchAgent::new(
|
||||
Arc::new(contexts),
|
||||
Arc::new(profiles),
|
||||
Arc::new(FakeRuntime::new(
|
||||
Arc::clone(&tr),
|
||||
Some(ContextInjectionPlan::File {
|
||||
target: "CLAUDE.md".to_owned(),
|
||||
}),
|
||||
)),
|
||||
Arc::new(fs.clone()),
|
||||
Arc::new(pty.clone()),
|
||||
Arc::new(skills),
|
||||
Arc::new(TerminalSessions::new()),
|
||||
Arc::new(SpyBus::default()),
|
||||
);
|
||||
|
||||
launch.execute(launch_input(agent.id)).await.unwrap();
|
||||
|
||||
let writes = fs.writes();
|
||||
assert_eq!(writes.len(), 1);
|
||||
let doc = String::from_utf8(writes[0].1.clone()).unwrap();
|
||||
assert!(doc.contains("# persona"), "persona present: {doc}");
|
||||
assert!(doc.contains("REFAC_BODY"), "first skill body present");
|
||||
assert!(doc.contains("REVIEW_BODY"), "second skill body present");
|
||||
// Deterministic order: persona before skills, skill 1 before skill 2.
|
||||
let persona_at = doc.find("# persona").unwrap();
|
||||
let refac_at = doc.find("REFAC_BODY").unwrap();
|
||||
let review_at = doc.find("REVIEW_BODY").unwrap();
|
||||
assert!(persona_at < refac_at && refac_at < review_at, "ordering: {doc}");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn launch_skips_dangling_skill_ref_without_failing() {
|
||||
// The agent references a skill that no longer exists in the store: launch must
|
||||
// still succeed and simply omit it (no Skills section for a sole dangling ref).
|
||||
let mut agent = scratch_agent(aid(1), "Backend", "agents/backend.md", pid(9));
|
||||
agent.assign_skill(SkillRef::new(SkillId::from_uuid(Uuid::from_u128(99)), SkillScope::Global));
|
||||
|
||||
let contexts = FakeContexts::with_agent(&agent, "# persona");
|
||||
let profiles = FakeProfiles::new(vec![profile(
|
||||
pid(9),
|
||||
ContextInjection::convention_file("CLAUDE.md").unwrap(),
|
||||
)]);
|
||||
let tr = trace();
|
||||
let fs = FakeFs::new(Arc::clone(&tr));
|
||||
let pty = FakePty::new(Arc::clone(&tr), sid(777));
|
||||
let launch = LaunchAgent::new(
|
||||
Arc::new(contexts),
|
||||
Arc::new(profiles),
|
||||
Arc::new(FakeRuntime::new(
|
||||
Arc::clone(&tr),
|
||||
Some(ContextInjectionPlan::File {
|
||||
target: "CLAUDE.md".to_owned(),
|
||||
}),
|
||||
)),
|
||||
Arc::new(fs.clone()),
|
||||
Arc::new(pty.clone()),
|
||||
Arc::new(FakeSkills::default()), // empty store ⇒ the ref is dangling
|
||||
Arc::new(TerminalSessions::new()),
|
||||
Arc::new(SpyBus::default()),
|
||||
);
|
||||
|
||||
launch.execute(launch_input(agent.id)).await.expect("launch must succeed");
|
||||
let doc = String::from_utf8(fs.writes()[0].1.clone()).unwrap();
|
||||
assert!(!doc.contains("# Skills"), "no Skills section for a dangling ref: {doc}");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn launch_stdin_strategy_pipes_context_after_spawn() {
|
||||
let (launch, agent, fs, pty, _bus, _sessions, tr) =
|
||||
@ -771,6 +909,7 @@ async fn launch_unknown_profile_is_not_found() {
|
||||
Arc::new(FakeRuntime::new(Arc::clone(&tr), Some(ContextInjectionPlan::Stdin))),
|
||||
Arc::new(FakeFs::new(Arc::clone(&tr))),
|
||||
Arc::new(pty.clone()),
|
||||
Arc::new(FakeSkills::default()),
|
||||
Arc::new(TerminalSessions::new()),
|
||||
Arc::new(SpyBus::default()),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user