pub const EXIT_DIRECT_COMMANDS: &[&str] = &[
"implement",
"yes",
"go",
"start",
"approve",
"approved",
"implement now",
"start implementing",
"start implementation",
"execute plan",
"execute the plan",
"execute this plan",
"switch to agent mode",
"exit planning workflow",
"exit planning workflow and implement",
];
pub const APPROVAL_WORDS: &[&str] = &["approve", "approved", "lgtm", "accepted", "accept"];
pub const APPROVAL_PHRASES: &[&str] = &[
"approve the plan",
"approve this plan",
"approve the proposed plan",
"looks good",
"ship it",
"accept the plan",
"accept this plan",
];
pub const EXIT_TRIGGER_PHRASES: &[&str] = &[
"start implement",
"start implementation",
"start implementing",
"implement now",
"implement the plan",
"implement this plan",
"begin implement",
"begin implementation",
"begin coding",
"proceed to implement",
"proceed with implementation",
"proceed to coding",
"proceed with coding",
"execute the plan",
"execute this plan",
"let s implement",
"lets implement",
"go ahead and implement",
"go ahead and code",
"ready to implement",
"start coding",
"start building",
"switch to agent mode",
"exit planning workflow",
"exit planning workflow and implement",
];
pub const STAY_PHRASES: &[&str] = &[
"stay in planning workflow",
"keep in planning workflow",
"continue planning",
"keep planning",
"do not implement",
"don t implement",
"not ready to implement",
"don t exit planning workflow",
"do not exit planning workflow",
];
pub const ENTER_PHRASES: &[&str] = &[
"make a plan",
"create a plan",
"write a plan",
"come up with a plan",
"plan this",
"stay in planning workflow",
"keep planning",
"continue planning",
"before you implement make a plan",
"before implementing make a plan",
"outline the implementation plan",
];
pub const IMPLEMENTATION_CUES: &[&str] = &[
"implement this plan",
"implement the plan",
"ready to implement",
"exit planning workflow",
"execute the plan",
"switch out of planning workflow",
"start implementation",
"start implementing",
"start coding",
];
pub const EXECUTION_MODE_ALIASES: &[&str] = &[
"implement",
"continue",
"go",
"start",
"yes",
"approve",
"approved",
"lgtm",
"accepted",
"accept",
"ship it",
"implement now",
"start implementing",
"start implementation",
"execute plan",
"execute the plan",
"execute this plan",
"switch to agent mode",
"exit planning workflow and implement",
];
pub const FLAG_CLEARING_ONLY_ALIASES: &[&str] = &["exit planning workflow"];
pub fn normalize_plan_intent(text: &str) -> String {
text.chars()
.map(|c| {
if c.is_alphanumeric() {
c.to_ascii_lowercase()
} else {
' '
}
})
.collect()
}
pub fn matches_exit_intent(normalized: &str) -> bool {
let trimmed = normalized.trim();
EXIT_DIRECT_COMMANDS.contains(&trimmed)
|| APPROVAL_WORDS
.iter()
.any(|word| normalized.split_whitespace().any(|tok| tok == *word))
|| APPROVAL_PHRASES.iter().any(|phrase| normalized.contains(phrase))
|| EXIT_TRIGGER_PHRASES.iter().any(|phrase| normalized.contains(phrase))
}
pub fn matches_stay_intent(normalized: &str) -> bool {
STAY_PHRASES.iter().any(|phrase| normalized.contains(phrase))
}
pub fn matches_enter_intent(normalized: &str) -> bool {
ENTER_PHRASES.iter().any(|phrase| normalized.contains(phrase))
}
pub fn contains_implementation_cue(normalized: &str) -> bool {
IMPLEMENTATION_CUES.iter().any(|cue| normalized.contains(cue))
}
pub fn is_execution_mode_alias(input: &str) -> bool {
let normalized = input.trim().to_ascii_lowercase();
EXECUTION_MODE_ALIASES
.iter()
.chain(FLAG_CLEARING_ONLY_ALIASES.iter())
.any(|alias| *alias == normalized)
}
pub fn is_implementation_alias(input: &str) -> bool {
let normalized = input.trim().to_ascii_lowercase();
EXECUTION_MODE_ALIASES.iter().any(|alias| *alias == normalized)
}