huskies: merge 512_story_migrate_chat_commands_from_filesystem_lookup_to_crdt_db
This commit is contained in:
@@ -10,16 +10,6 @@ use crate::agents::move_story_to_stage;
|
||||
/// Valid stage names accepted by the move command.
|
||||
const VALID_STAGES: &[&str] = &["backlog", "current", "qa", "merge", "done"];
|
||||
|
||||
/// All pipeline stage directories to search when finding a work item by number.
|
||||
const SEARCH_DIRS: &[&str] = &[
|
||||
"1_backlog",
|
||||
"2_current",
|
||||
"3_qa",
|
||||
"4_merge",
|
||||
"5_done",
|
||||
"6_archived",
|
||||
];
|
||||
|
||||
/// Handle the `move` command.
|
||||
///
|
||||
/// Parses `<number> <stage>` from `ctx.args`, locates the work item by its
|
||||
@@ -55,55 +45,20 @@ pub(super) fn handle_move(ctx: &CommandContext) -> Option<String> {
|
||||
));
|
||||
}
|
||||
|
||||
// Find the story file across all pipeline stages by numeric prefix.
|
||||
let mut found_story_id: Option<String> = None;
|
||||
let mut found_name: Option<String> = None;
|
||||
|
||||
'outer: for stage_dir in SEARCH_DIRS {
|
||||
let dir = ctx
|
||||
.project_root
|
||||
.join(".huskies")
|
||||
.join("work")
|
||||
.join(stage_dir);
|
||||
if !dir.exists() {
|
||||
continue;
|
||||
}
|
||||
if let Ok(entries) = std::fs::read_dir(&dir) {
|
||||
for entry in entries.flatten() {
|
||||
let path = entry.path();
|
||||
if path.extension().and_then(|e| e.to_str()) != Some("md") {
|
||||
continue;
|
||||
}
|
||||
if let Some(stem) = path.file_stem().and_then(|s| s.to_str()) {
|
||||
let file_num = stem
|
||||
.split('_')
|
||||
.next()
|
||||
.filter(|s| !s.is_empty() && s.chars().all(|c| c.is_ascii_digit()))
|
||||
.unwrap_or("");
|
||||
if file_num == num_str {
|
||||
found_story_id = Some(stem.to_string());
|
||||
found_name = std::fs::read_to_string(&path)
|
||||
.ok()
|
||||
.and_then(|contents| {
|
||||
crate::io::story_metadata::parse_front_matter(&contents)
|
||||
.ok()
|
||||
.and_then(|m| m.name)
|
||||
});
|
||||
break 'outer;
|
||||
}
|
||||
}
|
||||
// Find the story by numeric prefix: CRDT → content store → filesystem.
|
||||
let (story_id, _stage_dir, _path, content) =
|
||||
match crate::chat::lookup::find_story_by_number(ctx.project_root, num_str) {
|
||||
Some(found) => found,
|
||||
None => {
|
||||
return Some(format!(
|
||||
"No story, bug, or spike with number **{num_str}** found."
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let story_id = match found_story_id {
|
||||
Some(id) => id,
|
||||
None => {
|
||||
return Some(format!(
|
||||
"No story, bug, or spike with number **{num_str}** found."
|
||||
));
|
||||
}
|
||||
};
|
||||
let found_name = content
|
||||
.and_then(|c| crate::io::story_metadata::parse_front_matter(&c).ok())
|
||||
.and_then(|m| m.name);
|
||||
|
||||
let display_name = found_name.as_deref().unwrap_or(&story_id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user