Bug Description
The analyze command shows that comments (#) and flags (--context) are being parsed as top commands:
π Top 10 Base Commands:
βββββββββββββββββββββββββββββββββββββββββ
git 1411 ( 6.7%) βββ
aws 1288 ( 6.1%) βββ
# 1170 ( 5.6%) ββ <-- Comments!
--context 1144 ( 5.4%) ββ <-- Flags!
touch 1094 ( 5.2%) ββ
Impact
- Model wastes capacity learning comment lines
- Model learns flag patterns without their commands
- Suggestions may include fragments like
--context alone
Root Cause
History parsing splits on whitespace and treats first token as command, but doesn't filter:
- Lines starting with
# (comments)
- Multiline commands where continuation has flags first
- Malformed history entries
Expected Behavior
π Top 10 Base Commands:
βββββββββββββββββββββββββββββββββββββββββ
git 1411 ( 6.7%) βββ
aws 1288 ( 6.1%) βββ
touch 1094 ( 5.2%) ββ
cargo 709 ( 3.4%) β
...
Suggested Fixes
1. Filter comments during training
fn parse_command(line: &str) -> Option<&str> {
let trimmed = line.trim();
if trimmed.is_empty() || trimmed.starts_with('#') {
return None;
}
// ...
}
2. Skip lines starting with flags
fn is_valid_command_start(first_token: &str) -> bool {
!first_token.starts_with('-') &&
!first_token.starts_with('#') &&
!first_token.is_empty()
}
3. Handle multiline commands
ZSH history may contain multiline commands with \ continuations. These should be joined before parsing.
Related
Bug Description
The
analyzecommand shows that comments (#) and flags (--context) are being parsed as top commands:Impact
--contextaloneRoot Cause
History parsing splits on whitespace and treats first token as command, but doesn't filter:
#(comments)Expected Behavior
Suggested Fixes
1. Filter comments during training
2. Skip lines starting with flags
3. Handle multiline commands
ZSH history may contain multiline commands with
\continuations. These should be joined before parsing.Related