fix: fix some displays and features
This commit is contained in:
@ -14,6 +14,8 @@ use application::{
|
||||
GitStatusInput, LaunchAgentInput, ListAgentsInput, ListLayoutsInput, LoadLayoutInput,
|
||||
MutateLayoutInput, OpenProjectInput, ReadAgentContextInput, RenameLayoutInput,
|
||||
SetActiveLayoutInput, SyncAgentWithTemplateInput, UpdateAgentContextInput,
|
||||
AssignSkillToAgentInput, CreateSkillInput, DeleteSkillInput, ListSkillsInput,
|
||||
UnassignSkillFromAgentInput, UpdateSkillInput,
|
||||
};
|
||||
use domain::ports::PtyHandle;
|
||||
|
||||
@ -31,8 +33,10 @@ use crate::dto::{
|
||||
ReattachResultDto, RenameLayoutRequestDto, ResizeTerminalRequestDto, SaveProfileRequestDto,
|
||||
SetActiveLayoutRequestDto, SyncAgentWithTemplateRequestDto, SyncResultDto, TemplateDto,
|
||||
TemplateListDto, TerminalClosedDto, TerminalSessionDto, UpdateAgentContextRequestDto,
|
||||
UpdateTemplateRequestDto, WriteTerminalRequestDto,
|
||||
UpdateTemplateRequestDto, WriteTerminalRequestDto, parse_skill_id, AssignSkillRequestDto,
|
||||
CreateSkillRequestDto, SkillDto, SkillListDto, UnassignSkillRequestDto, UpdateSkillRequestDto,
|
||||
};
|
||||
use domain::{SkillRef, SkillScope};
|
||||
use crate::pty::{PtyBridge, PtyChunk};
|
||||
use crate::state::AppState;
|
||||
|
||||
@ -1182,3 +1186,157 @@ pub async fn move_tab_to_new_window(
|
||||
|
||||
Ok(MoveTabResultDto::from(out))
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Skills (L12)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// `create_skill` — create a skill in its scope's store.
|
||||
///
|
||||
/// # Errors
|
||||
/// Returns an [`ErrorDto`] (`INVALID` for an empty name/content or malformed
|
||||
/// project id, `NOT_FOUND` if the project is unknown, `STORE` on failure).
|
||||
#[tauri::command]
|
||||
pub async fn create_skill(
|
||||
request: CreateSkillRequestDto,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<SkillDto, ErrorDto> {
|
||||
let project = resolve_project(&request.project_id, &state).await?;
|
||||
state
|
||||
.create_skill
|
||||
.execute(CreateSkillInput {
|
||||
name: request.name,
|
||||
content: request.content,
|
||||
scope: request.scope,
|
||||
project_root: project.root,
|
||||
})
|
||||
.await
|
||||
.map(SkillDto::from)
|
||||
.map_err(ErrorDto::from)
|
||||
}
|
||||
|
||||
/// `update_skill` — replace a skill's Markdown content.
|
||||
///
|
||||
/// # Errors
|
||||
/// Returns an [`ErrorDto`] (`INVALID` for malformed ids or empty content,
|
||||
/// `NOT_FOUND` if the project or skill is unknown, `STORE` on failure).
|
||||
#[tauri::command]
|
||||
pub async fn update_skill(
|
||||
request: UpdateSkillRequestDto,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<SkillDto, ErrorDto> {
|
||||
let project = resolve_project(&request.project_id, &state).await?;
|
||||
let skill_id = parse_skill_id(&request.skill_id)?;
|
||||
state
|
||||
.update_skill
|
||||
.execute(UpdateSkillInput {
|
||||
scope: request.scope,
|
||||
skill_id,
|
||||
content: request.content,
|
||||
project_root: project.root,
|
||||
})
|
||||
.await
|
||||
.map(SkillDto::from)
|
||||
.map_err(ErrorDto::from)
|
||||
}
|
||||
|
||||
/// `list_skills` — list the skills in one scope.
|
||||
///
|
||||
/// # Errors
|
||||
/// Returns an [`ErrorDto`] (`INVALID` for a malformed id, `NOT_FOUND` if the
|
||||
/// project is unknown, `STORE` on failure).
|
||||
#[tauri::command]
|
||||
pub async fn list_skills(
|
||||
project_id: String,
|
||||
scope: SkillScope,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<SkillListDto, ErrorDto> {
|
||||
let project = resolve_project(&project_id, &state).await?;
|
||||
state
|
||||
.list_skills
|
||||
.execute(ListSkillsInput {
|
||||
scope,
|
||||
project_root: project.root,
|
||||
})
|
||||
.await
|
||||
.map(SkillListDto::from)
|
||||
.map_err(ErrorDto::from)
|
||||
}
|
||||
|
||||
/// `delete_skill` — remove a skill from its scope's store.
|
||||
///
|
||||
/// Agents that referenced it keep their `SkillRef`; injection simply skips the
|
||||
/// now-absent skill.
|
||||
///
|
||||
/// # Errors
|
||||
/// Returns an [`ErrorDto`] (`INVALID` for malformed ids, `NOT_FOUND` if the
|
||||
/// project or skill is unknown, `STORE` on failure).
|
||||
#[tauri::command]
|
||||
pub async fn delete_skill(
|
||||
project_id: String,
|
||||
scope: SkillScope,
|
||||
skill_id: String,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<(), ErrorDto> {
|
||||
let project = resolve_project(&project_id, &state).await?;
|
||||
let id = parse_skill_id(&skill_id)?;
|
||||
state
|
||||
.delete_skill
|
||||
.execute(DeleteSkillInput {
|
||||
scope,
|
||||
skill_id: id,
|
||||
project_root: project.root,
|
||||
})
|
||||
.await
|
||||
.map_err(ErrorDto::from)
|
||||
}
|
||||
|
||||
/// `assign_skill_to_agent` — record a `SkillRef` in the agent's manifest entry.
|
||||
/// Idempotent.
|
||||
///
|
||||
/// # Errors
|
||||
/// Returns an [`ErrorDto`] (`INVALID` for malformed ids, `NOT_FOUND` if the
|
||||
/// project or agent is unknown, `STORE` on failure).
|
||||
#[tauri::command]
|
||||
pub async fn assign_skill_to_agent(
|
||||
request: AssignSkillRequestDto,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<(), ErrorDto> {
|
||||
let project = resolve_project(&request.project_id, &state).await?;
|
||||
let agent_id = parse_agent_id(&request.agent_id)?;
|
||||
let skill_id = parse_skill_id(&request.skill_id)?;
|
||||
state
|
||||
.assign_skill
|
||||
.execute(AssignSkillToAgentInput {
|
||||
project,
|
||||
agent_id,
|
||||
skill: SkillRef::new(skill_id, request.scope),
|
||||
})
|
||||
.await
|
||||
.map_err(ErrorDto::from)
|
||||
}
|
||||
|
||||
/// `unassign_skill_from_agent` — drop a skill assignment from an agent.
|
||||
/// Idempotent.
|
||||
///
|
||||
/// # Errors
|
||||
/// Returns an [`ErrorDto`] (`INVALID` for malformed ids, `NOT_FOUND` if the
|
||||
/// project or agent is unknown, `STORE` on failure).
|
||||
#[tauri::command]
|
||||
pub async fn unassign_skill_from_agent(
|
||||
request: UnassignSkillRequestDto,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<(), ErrorDto> {
|
||||
let project = resolve_project(&request.project_id, &state).await?;
|
||||
let agent_id = parse_agent_id(&request.agent_id)?;
|
||||
let skill_id = parse_skill_id(&request.skill_id)?;
|
||||
state
|
||||
.unassign_skill
|
||||
.execute(UnassignSkillFromAgentInput {
|
||||
project,
|
||||
agent_id,
|
||||
skill_id,
|
||||
})
|
||||
.await
|
||||
.map_err(ErrorDto::from)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user