@lamentis/naome 1.3.7 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +2 -2
- package/README.md +5 -0
- package/crates/naome-cli/Cargo.toml +1 -1
- package/crates/naome-core/Cargo.toml +1 -1
- package/crates/naome-core/src/context/select.rs +58 -4
- package/crates/naome-core/src/intent/classifier.rs +56 -81
- package/crates/naome-core/src/intent/envelope.rs +173 -19
- package/crates/naome-core/src/intent/legacy_response.rs +2 -0
- package/crates/naome-core/src/intent/model.rs +6 -0
- package/crates/naome-core/src/intent/resolver.rs +25 -0
- package/crates/naome-core/src/intent/risk.rs +11 -1
- package/crates/naome-core/src/intent.rs +1 -1
- package/crates/naome-core/src/route/context.rs +8 -0
- package/crates/naome-core/tests/context.rs +92 -0
- package/crates/naome-core/tests/intent.rs +98 -18
- package/crates/naome-core/tests/intent_support/mod.rs +39 -1
- package/crates/naome-core/tests/intent_v2.rs +299 -10
- package/crates/naome-core/tests/repo_support/routes.rs +8 -2
- package/crates/naome-core/tests/route_baseline.rs +29 -0
- package/crates/naome-core/tests/route_completion.rs +26 -5
- package/crates/naome-core/tests/route_harness_refresh.rs +7 -1
- package/crates/naome-core/tests/route_user_diff.rs +1 -1
- package/crates/naome-core/tests/task_state_compact.rs +7 -1
- package/native/darwin-arm64/naome +0 -0
- package/native/linux-x64/naome +0 -0
- package/package.json +1 -1
- package/templates/naome-root/.naome/manifest.json +2 -2
- package/templates/naome-root/docs/naome/agent-workflow.md +14 -5
- package/templates/naome-root/docs/naome/architecture.md +9 -0
- package/crates/naome-core/src/intent/patterns.rs +0 -170
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
use super::model::IntentKind;
|
|
2
|
-
|
|
3
|
-
pub(crate) fn normalized(text: &str) -> String {
|
|
4
|
-
text.to_lowercase()
|
|
5
|
-
.chars()
|
|
6
|
-
.map(|ch| if ch.is_alphanumeric() { ch } else { ' ' })
|
|
7
|
-
.collect::<String>()
|
|
8
|
-
.split_whitespace()
|
|
9
|
-
.collect::<Vec<_>>()
|
|
10
|
-
.join(" ")
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
pub(crate) fn lexical_tokens(text: &str) -> Vec<String> {
|
|
14
|
-
text.split_whitespace()
|
|
15
|
-
.map(|token| {
|
|
16
|
-
token
|
|
17
|
-
.trim_matches(|ch: char| !ch.is_alphanumeric() && ch != '_' && ch != '-')
|
|
18
|
-
.to_lowercase()
|
|
19
|
-
})
|
|
20
|
-
.filter(|token| !token.is_empty())
|
|
21
|
-
.collect()
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
pub(crate) fn structured_workflow_intents(text: &str) -> Vec<IntentKind> {
|
|
25
|
-
let tokens = lexical_tokens(text);
|
|
26
|
-
let mut intents = Vec::new();
|
|
27
|
-
|
|
28
|
-
if let Some(intent) = structured_action(&tokens) {
|
|
29
|
-
intents.push(intent);
|
|
30
|
-
}
|
|
31
|
-
if let Some(intent) = legacy_v1_short_action_request(&tokens) {
|
|
32
|
-
intents.push(intent);
|
|
33
|
-
}
|
|
34
|
-
if legacy_v1_no_commit(&tokens) {
|
|
35
|
-
intents.push(IntentKind::NoCommitRequest);
|
|
36
|
-
}
|
|
37
|
-
if has_structured_token(&tokens, &["no_commit", "without_commit"]) {
|
|
38
|
-
intents.push(IntentKind::NoCommitRequest);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
intents.sort_by_key(|kind| kind.as_str());
|
|
42
|
-
intents.dedup();
|
|
43
|
-
intents
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
pub(crate) fn command_workflow_intents(text: &str) -> Vec<IntentKind> {
|
|
47
|
-
let tokens = lexical_tokens(text);
|
|
48
|
-
let mut intents = Vec::new();
|
|
49
|
-
if let Some(intent) = cli_action(&tokens) {
|
|
50
|
-
intents.push(intent);
|
|
51
|
-
}
|
|
52
|
-
intents
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
pub(crate) fn explicit_task_intent(text: &str) -> Option<IntentKind> {
|
|
56
|
-
let tokens = lexical_tokens(text);
|
|
57
|
-
if has_structured_token(&tokens, &["task_revision", "current_task", "active_task"]) {
|
|
58
|
-
return Some(IntentKind::TaskRevision);
|
|
59
|
-
}
|
|
60
|
-
if has_structured_token(&tokens, &["new_task", "create_new_task", "separate_task"]) {
|
|
61
|
-
return Some(IntentKind::NewTask);
|
|
62
|
-
}
|
|
63
|
-
None
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
pub(crate) fn is_generic_work_request(text: &str) -> bool {
|
|
67
|
-
!lexical_tokens(text).is_empty()
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
fn structured_action(tokens: &[String]) -> Option<IntentKind> {
|
|
71
|
-
policy_action(tokens)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
fn policy_action(tokens: &[String]) -> Option<IntentKind> {
|
|
75
|
-
for token in tokens {
|
|
76
|
-
let intent = match token.as_str() {
|
|
77
|
-
"commit_task_baseline" | "commit_user_diff" | "commit_upgrade_baseline" => {
|
|
78
|
-
IntentKind::CommitRequest
|
|
79
|
-
}
|
|
80
|
-
"review_task_diff" | "review_current_task_diff" | "review_unowned_diff" => {
|
|
81
|
-
IntentKind::ReviewRequest
|
|
82
|
-
}
|
|
83
|
-
"repair_harness" | "repair_harness_only" => IntentKind::RepairRequest,
|
|
84
|
-
"cancel_task_changes" | "cancel_current_task" => IntentKind::CancelRequest,
|
|
85
|
-
"continue_current_task" | "task_complete" | "complete_task" => {
|
|
86
|
-
IntentKind::TaskCompletion
|
|
87
|
-
}
|
|
88
|
-
"answer_status_only" => IntentKind::StatusQuestion,
|
|
89
|
-
"clear_or_commit_unowned_diff" => IntentKind::Ambiguous,
|
|
90
|
-
_ => continue,
|
|
91
|
-
};
|
|
92
|
-
return Some(intent);
|
|
93
|
-
}
|
|
94
|
-
None
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
fn cli_action(tokens: &[String]) -> Option<IntentKind> {
|
|
98
|
-
match (
|
|
99
|
-
tokens.first().map(String::as_str),
|
|
100
|
-
tokens.get(1).map(String::as_str),
|
|
101
|
-
) {
|
|
102
|
-
(Some("naome"), Some("commit")) => Some(IntentKind::CommitRequest),
|
|
103
|
-
(Some("naome"), Some("status")) => Some(IntentKind::StatusQuestion),
|
|
104
|
-
(Some("naome"), Some("sync" | "update" | "install")) => Some(IntentKind::RepairRequest),
|
|
105
|
-
(Some("git"), Some("commit")) => Some(IntentKind::CommitRequest),
|
|
106
|
-
_ => None,
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Kept only so pre-v2 route callers keep their existing conservative behavior.
|
|
111
|
-
// A naome-intent-v2 envelope clears these candidates before policy resolution.
|
|
112
|
-
fn legacy_v1_short_action_request(tokens: &[String]) -> Option<IntentKind> {
|
|
113
|
-
let action_index = tokens
|
|
114
|
-
.iter()
|
|
115
|
-
.position(|token| legacy_v1_action_intent(token).is_some())?;
|
|
116
|
-
if action_index > 1 || tokens.len() > 6 {
|
|
117
|
-
return None;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
let intent = legacy_v1_action_intent(&tokens[action_index])?;
|
|
121
|
-
if intent == IntentKind::StatusQuestion || tokens.len() <= 3 {
|
|
122
|
-
return Some(intent);
|
|
123
|
-
}
|
|
124
|
-
if tokens.len() <= 2 || legacy_v1_has_action_scope(tokens) {
|
|
125
|
-
return Some(intent);
|
|
126
|
-
}
|
|
127
|
-
None
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
fn legacy_v1_no_commit(tokens: &[String]) -> bool {
|
|
131
|
-
tokens
|
|
132
|
-
.windows(3)
|
|
133
|
-
.any(|window| window[0] == "do" && window[1] == "not" && window[2] == "commit")
|
|
134
|
-
|| tokens
|
|
135
|
-
.windows(2)
|
|
136
|
-
.any(|window| matches!(window[0].as_str(), "no" | "without") && window[1] == "commit")
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
fn legacy_v1_action_intent(token: &str) -> Option<IntentKind> {
|
|
140
|
-
match token {
|
|
141
|
-
"commit" | "baseline" => Some(IntentKind::CommitRequest),
|
|
142
|
-
"review" => Some(IntentKind::ReviewRequest),
|
|
143
|
-
"repair" | "sync" => Some(IntentKind::RepairRequest),
|
|
144
|
-
"cancel" => Some(IntentKind::CancelRequest),
|
|
145
|
-
"complete" | "completion" => Some(IntentKind::TaskCompletion),
|
|
146
|
-
"status" => Some(IntentKind::StatusQuestion),
|
|
147
|
-
_ => None,
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
fn legacy_v1_has_action_scope(tokens: &[String]) -> bool {
|
|
152
|
-
has_structured_token(
|
|
153
|
-
tokens,
|
|
154
|
-
&[
|
|
155
|
-
"task",
|
|
156
|
-
"diff",
|
|
157
|
-
"harness",
|
|
158
|
-
"baseline",
|
|
159
|
-
"state",
|
|
160
|
-
"current_task",
|
|
161
|
-
"active_task",
|
|
162
|
-
],
|
|
163
|
-
)
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
fn has_structured_token(tokens: &[String], accepted: &[&str]) -> bool {
|
|
167
|
-
tokens
|
|
168
|
-
.iter()
|
|
169
|
-
.any(|token| accepted.iter().any(|accepted| token == accepted))
|
|
170
|
-
}
|