Skip to content

Commit f5ff55f

Browse files
committed
minor tweaks
1 parent cc305f3 commit f5ff55f

File tree

22 files changed

+91
-136
lines changed

22 files changed

+91
-136
lines changed

crates/chat-cli/src/cli/chat/command.rs

Lines changed: 28 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,70 +1149,38 @@ impl Command {
11491149
.await
11501150
}
11511151

1152+
/// Returns a vector of all available commands for dynamic enumeration
1153+
pub fn all_commands() -> Vec<(&'static str, &'static dyn CommandHandler)> {
1154+
vec![
1155+
("help", &HELP_HANDLER as &dyn CommandHandler),
1156+
("quit", &QUIT_HANDLER as &dyn CommandHandler),
1157+
("clear", &CLEAR_HANDLER as &dyn CommandHandler),
1158+
("context", &CONTEXT_HANDLER as &dyn CommandHandler),
1159+
("profile", &PROFILE_HANDLER as &dyn CommandHandler),
1160+
("tools", &TOOLS_HANDLER as &dyn CommandHandler),
1161+
("compact", &COMPACT_HANDLER as &dyn CommandHandler),
1162+
("usage", &USAGE_HANDLER as &dyn CommandHandler),
1163+
("editor", &EDITOR_HANDLER as &dyn CommandHandler),
1164+
("issue", &ISSUE_HANDLER as &dyn CommandHandler),
1165+
]
1166+
}
1167+
11521168
/// Generate descriptions for all commands for LLM tool descriptions
1169+
///
1170+
/// This method dynamically iterates through all available commands and collects
1171+
/// their descriptions for use in LLM integration. This ensures that all commands
1172+
/// are properly described and no commands are missed when new ones are added.
11531173
pub fn generate_llm_descriptions() -> std::collections::HashMap<String, CommandDescription> {
11541174
let mut descriptions = std::collections::HashMap::new();
11551175

1156-
// Add descriptions for all implemented commands
1157-
descriptions.insert("help".to_string(), CommandDescription {
1158-
short_description: HELP_HANDLER.description().to_string(),
1159-
full_description: HELP_HANDLER.llm_description(),
1160-
usage: HELP_HANDLER.usage().to_string(),
1161-
});
1162-
1163-
descriptions.insert("quit".to_string(), CommandDescription {
1164-
short_description: QUIT_HANDLER.description().to_string(),
1165-
full_description: QUIT_HANDLER.llm_description(),
1166-
usage: QUIT_HANDLER.usage().to_string(),
1167-
});
1168-
1169-
descriptions.insert("clear".to_string(), CommandDescription {
1170-
short_description: CLEAR_HANDLER.description().to_string(),
1171-
full_description: CLEAR_HANDLER.llm_description(),
1172-
usage: CLEAR_HANDLER.usage().to_string(),
1173-
});
1174-
1175-
descriptions.insert("context".to_string(), CommandDescription {
1176-
short_description: CONTEXT_HANDLER.description().to_string(),
1177-
full_description: CONTEXT_HANDLER.llm_description(),
1178-
usage: CONTEXT_HANDLER.usage().to_string(),
1179-
});
1180-
1181-
descriptions.insert("profile".to_string(), CommandDescription {
1182-
short_description: PROFILE_HANDLER.description().to_string(),
1183-
full_description: PROFILE_HANDLER.llm_description(),
1184-
usage: PROFILE_HANDLER.usage().to_string(),
1185-
});
1186-
1187-
descriptions.insert("tools".to_string(), CommandDescription {
1188-
short_description: TOOLS_HANDLER.description().to_string(),
1189-
full_description: TOOLS_HANDLER.llm_description(),
1190-
usage: TOOLS_HANDLER.usage().to_string(),
1191-
});
1192-
1193-
descriptions.insert("compact".to_string(), CommandDescription {
1194-
short_description: COMPACT_HANDLER.description().to_string(),
1195-
full_description: COMPACT_HANDLER.llm_description(),
1196-
usage: COMPACT_HANDLER.usage().to_string(),
1197-
});
1198-
1199-
descriptions.insert("usage".to_string(), CommandDescription {
1200-
short_description: USAGE_HANDLER.description().to_string(),
1201-
full_description: USAGE_HANDLER.llm_description(),
1202-
usage: USAGE_HANDLER.usage().to_string(),
1203-
});
1204-
1205-
descriptions.insert("editor".to_string(), CommandDescription {
1206-
short_description: EDITOR_HANDLER.description().to_string(),
1207-
full_description: EDITOR_HANDLER.llm_description(),
1208-
usage: EDITOR_HANDLER.usage().to_string(),
1209-
});
1210-
1211-
descriptions.insert("issue".to_string(), CommandDescription {
1212-
short_description: ISSUE_HANDLER.description().to_string(),
1213-
full_description: ISSUE_HANDLER.llm_description(),
1214-
usage: ISSUE_HANDLER.usage().to_string(),
1215-
});
1176+
// Dynamically iterate through all commands
1177+
for (name, handler) in Self::all_commands() {
1178+
descriptions.insert(name.to_string(), CommandDescription {
1179+
short_description: handler.description().to_string(),
1180+
full_description: handler.llm_description(),
1181+
usage: handler.usage().to_string(),
1182+
});
1183+
}
12161184

12171185
descriptions
12181186
}

crates/chat-cli/src/cli/chat/commands/context/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ To see the full content of context files, use "/context show --expand"."#
215215
Ok(ChatState::PromptUser {
216216
tool_uses,
217217
pending_tool_index,
218-
skip_printing_tools: false,
218+
skip_printing_tools: true,
219219
})
220220
},
221221
// For other subcommands, delegate to the appropriate handler

crates/chat-cli/src/cli/chat/commands/editor.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ Examples:
167167
return Ok(ChatState::PromptUser {
168168
tool_uses,
169169
pending_tool_index,
170-
skip_printing_tools: false,
170+
skip_printing_tools: true,
171171
});
172172
},
173173
};
@@ -185,7 +185,7 @@ Examples:
185185
return Ok(ChatState::PromptUser {
186186
tool_uses,
187187
pending_tool_index,
188-
skip_printing_tools: false,
188+
skip_printing_tools: true,
189189
});
190190
}
191191
// Flush to ensure content is written before editor opens
@@ -232,7 +232,7 @@ Examples:
232232
return Ok(ChatState::PromptUser {
233233
tool_uses,
234234
pending_tool_index,
235-
skip_printing_tools: false,
235+
skip_printing_tools: true,
236236
});
237237
}
238238

@@ -276,7 +276,7 @@ Examples:
276276
Ok(ChatState::PromptUser {
277277
tool_uses,
278278
pending_tool_index,
279-
skip_printing_tools: false,
279+
skip_printing_tools: true,
280280
})
281281
} else {
282282
Err(ChatError::Custom(

crates/chat-cli/src/cli/chat/commands/execute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ This command allows you to run any shell command without leaving the chat interf
7777
Ok(ChatState::PromptUser {
7878
tool_uses,
7979
pending_tool_index,
80-
skip_printing_tools: false,
80+
skip_printing_tools: true,
8181
})
8282
} else {
8383
Err(ChatError::Custom(

crates/chat-cli/src/cli/chat/commands/profile/create.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl CommandHandler for CreateProfileCommand {
128128
Ok(ChatState::PromptUser {
129129
tool_uses,
130130
pending_tool_index,
131-
skip_printing_tools: false,
131+
skip_printing_tools: true,
132132
})
133133
})
134134
}

crates/chat-cli/src/cli/chat/commands/profile/delete.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl CommandHandler for DeleteProfileCommand {
108108
Ok(ChatState::PromptUser {
109109
tool_uses,
110110
pending_tool_index,
111-
skip_printing_tools: false,
111+
skip_printing_tools: true,
112112
})
113113
})
114114
}

crates/chat-cli/src/cli/chat/commands/profile/handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ To get the current profiles, use the command "/profile list" which will display
293293
Ok(ChatState::PromptUser {
294294
tool_uses,
295295
pending_tool_index,
296-
skip_printing_tools: false,
296+
skip_printing_tools: true,
297297
})
298298
})
299299
}

crates/chat-cli/src/cli/chat/commands/profile/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl CommandHandler for ListProfileCommand {
138138
Ok(ChatState::PromptUser {
139139
tool_uses,
140140
pending_tool_index,
141-
skip_printing_tools: false,
141+
skip_printing_tools: true,
142142
})
143143
} else {
144144
Err(ChatError::Custom(

crates/chat-cli/src/cli/chat/commands/profile/rename.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl CommandHandler for RenameProfileCommand {
125125
Ok(ChatState::PromptUser {
126126
tool_uses,
127127
pending_tool_index,
128-
skip_printing_tools: false,
128+
skip_printing_tools: true,
129129
})
130130
})
131131
}

crates/chat-cli/src/cli/chat/commands/profile/set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl CommandHandler for SetProfileCommand {
108108
Ok(ChatState::PromptUser {
109109
tool_uses,
110110
pending_tool_index,
111-
skip_printing_tools: false,
111+
skip_printing_tools: true,
112112
})
113113
})
114114
}

0 commit comments

Comments
 (0)