Skills: manage and import your own, switch on per chat, search instead of listing
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e150de3c93
commit
a84a3acaa0
20 files changed
+943
-26
No files matched your search
+18
-2
@@ -72,6 +72,10 @@ pub fn router(app: AppState) -> Router {
|
||||
.route("/agents/tools", get(agent_tools))
|
||||
.route("/agents/{name}", delete(delete_agent))
|
||||
.route("/commands", get(commands))
|
||||
.route("/skills", get(crate::skills_api::list))
|
||||
.route("/skills/github/scan", post(crate::skills_api::scan))
|
||||
.route("/skills/github/import", post(crate::skills_api::import))
|
||||
.route("/skills/{name}", get(crate::skills_api::get).put(crate::skills_api::put).delete(crate::skills_api::delete))
|
||||
.route("/transcribe", post(transcribe))
|
||||
.route("/sessions", get(list_sessions).post(create_session))
|
||||
.route("/sessions/search", get(search_sessions))
|
||||
@@ -532,7 +536,7 @@ async fn commands(Extension(user): Extension<User>, State(app): State<AppState>,
|
||||
let (root, cwd) = scope(&app, &user, q.cwd);
|
||||
Json(json!({
|
||||
"commands": prompts::commands(&app, &root, &cwd),
|
||||
"skills": prompts::skills(&app, &root, &cwd),
|
||||
"skills": prompts::skills(&app, &root, &cwd, Some(&user.id)),
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -676,6 +680,7 @@ async fn create_session(Extension(user): Extension<User>, State(app): State<AppS
|
||||
summary: String::new(),
|
||||
color: dstr("color").filter(|c| codecraft_core::types::SESSION_COLORS.contains(&c.as_str())),
|
||||
icon: dstr("icon").filter(|c| codecraft_core::types::SESSION_ICONS.contains(&c.as_str())),
|
||||
skills: Vec::new(),
|
||||
};
|
||||
let s = app.save_session(s)?;
|
||||
Ok(Json(json!(s)))
|
||||
@@ -973,6 +978,8 @@ struct UpdateSession {
|
||||
color: Option<String>,
|
||||
/// Icon ("" removes it).
|
||||
icon: Option<String>,
|
||||
/// Skills switched on for this chat (names).
|
||||
skills: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
async fn update_session(Extension(user): Extension<User>, State(app): State<AppState>, Path(id): Path<String>, Json(body): Json<UpdateSession>) -> ApiResult {
|
||||
@@ -1036,6 +1043,15 @@ async fn update_session(Extension(user): Extension<User>, State(app): State<AppS
|
||||
if let Some(i) = body.icon {
|
||||
s.icon = (!i.is_empty()).then_some(i);
|
||||
}
|
||||
if let Some(list) = body.skills {
|
||||
let mut seen = Vec::new();
|
||||
for n in list.into_iter().map(|n| n.trim().to_string()).filter(|n| !n.is_empty() && n.len() <= 64) {
|
||||
if !seen.contains(&n) && seen.len() < 20 {
|
||||
seen.push(n);
|
||||
}
|
||||
}
|
||||
s.skills = seen;
|
||||
}
|
||||
})?;
|
||||
Ok(Json(json!(s)))
|
||||
}
|
||||
@@ -2436,7 +2452,7 @@ async fn job_assistant(Extension(user): Extension<User>, State(app): State<AppSt
|
||||
telegram_quiet: true,
|
||||
summary: String::new(),
|
||||
color: None,
|
||||
icon: None,
|
||||
icon: None, skills: Vec::new(),
|
||||
};
|
||||
let s = app.save_session(s)?;
|
||||
st.assistant_session = Some(s.id.clone());
|
||||
|
||||
Reference in new issue
Block a user