Skip to content

Commit 877048d

Browse files
wesbillmanBrainnpub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7
authored
fix: persona is source of truth at spawn + thread-depth conventions (#930)
Signed-off-by: Wes <[email protected]> Signed-off-by: npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Brain <21994759fc7a6fa6b965551d35cfd7897d262f2495467f2d78694ddcfa6a5c7e@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@sprout-oss.stage.blox.sqprod.co>
1 parent 73cd8d0 commit 877048d

6 files changed

Lines changed: 461 additions & 270 deletions

File tree

‎crates/sprout-acp/src/base_prompt.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ Run `sprout --help` or `sprout <group> --help` for full usage.
2727
- Respond promptly to @mentions.
2828
- Be direct. State what you did, what you found, or what you need. No preamble.
2929
- Message content supports GitHub-flavored Markdown. Use fenced code blocks with a language tag (` ```python `, ` ```typescript `, etc.) for syntax-highlighted rendering on desktop and mobile. Omitting the language tag renders monochrome.
30-
- When responding in-thread, use `sprout messages send --reply-to <thread-root-event-id>` to keep replies scoped to the thread. Post new top-level messages for new topics.
30+
- Reply to the thread root (`sprout messages send --reply-to <thread-root-event-id>`), not the latest message — flat threads stay readable; reply chains bury context 3+ levels deep. One thread = one unit of work: ask sub-questions inline. A real tangent starts a new top-level message.
31+
- Work in the thread, report milestones at the root. The thread is the messy middle — progress, dead ends, clarifying questions, and routine updates. Use a top-level post for channel-visible milestones: picked up, blocked + need input, change ready / PR up, done, or anything teammates skimming only root-level messages must act on. Thread notifications are easy to miss; a top-level post ensures the requester sees the outcome.
32+
- New topic → new top-level message. Don't graft an unrelated task onto an existing thread.
3133
- When you are mentioned in multiple threads, prioritize the most recent one chronologically. If someone steers or redirects you in a newer thread while you are working from an older dispatch, reply in the newer thread to acknowledge — do not bury your response in the original thread where it may go unseen.
32-
- When you complete a task (e.g., PR created, implementation finished, research delivered), post a top-level channel message with the result — do not only reply in-thread. Thread notifications are easy to miss; a broadcast message ensures the requester sees the outcome promptly.
3334
- No push notifications — poll with `sprout messages get --channel <UUID> --since <ts>`. When `since` is set without `before`, results are oldest-first (chronological).
3435

3536
## Startup Recovery

‎desktop/scripts/check-file-sizes.mjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const overrides = new Map([
3333
["src-tauri/src/commands/agents.rs", 1287],
3434
["src-tauri/src/managed_agents/nest.rs", 1420],
3535
["src-tauri/src/managed_agents/runtime.rs", 1465],
36+
["src-tauri/src/managed_agents/personas.rs", 1080],
3637
["src-tauri/src/managed_agents/persona_card.rs", 1050],
3738
["src-tauri/src/huddle/tts.rs", 1364],
3839
["src/shared/api/tauri.ts", 1196],

‎desktop/src-tauri/src/lib.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,10 @@ pub fn run() {
524524
migration::reconcile_provider_mcp_commands(&app_handle);
525525
migration::migrate_persona_provider_to_runtime(&app_handle);
526526

527+
if let Err(e) = managed_agents::sync_pack_personas(&app_handle) {
528+
eprintln!("sprout-desktop: sync-pack-personas: {e}");
529+
}
530+
527531
// Resolve persisted identity key (env var → file → generate+save).
528532
// This is fatal — the app should not start with an ephemeral identity
529533
// that will be lost on restart, as that silently breaks channel

‎desktop/src-tauri/src/managed_agents/personas.rs‎

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,95 @@ pub struct PackSummary {
952952
pub path: PathBuf,
953953
}
954954

955+
/// Re-read pack directories and update persona records whose source content
956+
/// has changed. Runs on launch so pack edits on disk propagate without
957+
/// manual intervention.
958+
pub fn sync_pack_personas(app: &AppHandle) -> Result<(), String> {
959+
let mut records = load_personas(app)?;
960+
let packs = packs_dir(app)?;
961+
962+
if !packs.exists() {
963+
return Ok(());
964+
}
965+
966+
let mut changed = false;
967+
968+
for record in records.iter_mut() {
969+
let pack_id = match &record.source_pack {
970+
Some(id) => id.clone(),
971+
None => continue,
972+
};
973+
let slug = match &record.source_pack_persona_slug {
974+
Some(s) => s.clone(),
975+
None => continue,
976+
};
977+
978+
// Find the pack directory whose resolved ID matches
979+
let pack_dir_entries =
980+
fs::read_dir(&packs).map_err(|e| format!("failed to read packs dir: {e}"))?;
981+
982+
let mut found = false;
983+
for entry in pack_dir_entries {
984+
let entry = entry.map_err(|e| format!("dir entry error: {e}"))?;
985+
let dir = entry.path();
986+
if !dir.is_dir() {
987+
continue;
988+
}
989+
let resolved = match sprout_persona::resolve::resolve_pack(&dir) {
990+
Ok(r) => r,
991+
Err(_) => continue,
992+
};
993+
if resolved.id != pack_id {
994+
continue;
995+
}
996+
997+
// Found the matching pack — find the persona by slug
998+
if let Some(persona) = resolved.personas.iter().find(|p| p.name == slug) {
999+
let mut record_changed = false;
1000+
1001+
if record.system_prompt != persona.system_prompt {
1002+
record.system_prompt = persona.system_prompt.clone();
1003+
record_changed = true;
1004+
}
1005+
if record.model != persona.model {
1006+
record.model = persona.model.clone();
1007+
record_changed = true;
1008+
}
1009+
if record.avatar_url != persona.avatar {
1010+
record.avatar_url = persona.avatar.clone();
1011+
record_changed = true;
1012+
}
1013+
if record.display_name != persona.display_name {
1014+
record.display_name = persona.display_name.clone();
1015+
record_changed = true;
1016+
}
1017+
1018+
if record_changed {
1019+
record.updated_at = now_iso();
1020+
changed = true;
1021+
eprintln!(
1022+
"sprout-desktop: sync-pack-personas: updated {:?} from pack {:?}",
1023+
record.display_name, pack_id
1024+
);
1025+
}
1026+
}
1027+
found = true;
1028+
break;
1029+
}
1030+
1031+
if !found {
1032+
// Pack directory no longer exists or doesn't resolve — skip silently
1033+
continue;
1034+
}
1035+
}
1036+
1037+
if changed {
1038+
save_personas(app, &records)?;
1039+
}
1040+
1041+
Ok(())
1042+
}
1043+
9551044
pub fn load_personas(app: &AppHandle) -> Result<Vec<PersonaRecord>, String> {
9561045
let path = personas_store_path(app)?;
9571046
let now = now_iso();

0 commit comments

Comments
 (0)