@lamentis/naome 1.0.0
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 +199 -0
- package/Cargo.toml +11 -0
- package/LICENSE +21 -0
- package/README.md +6 -0
- package/bin/naome-node.js +1424 -0
- package/bin/naome.js +129 -0
- package/crates/naome-cli/Cargo.toml +14 -0
- package/crates/naome-cli/src/main.rs +341 -0
- package/crates/naome-core/Cargo.toml +11 -0
- package/crates/naome-core/src/decision.rs +432 -0
- package/crates/naome-core/src/git.rs +70 -0
- package/crates/naome-core/src/harness_health.rs +557 -0
- package/crates/naome-core/src/install_plan.rs +82 -0
- package/crates/naome-core/src/lib.rs +17 -0
- package/crates/naome-core/src/models.rs +99 -0
- package/crates/naome-core/src/paths.rs +72 -0
- package/crates/naome-core/src/task_state.rs +1859 -0
- package/crates/naome-core/src/verification.rs +217 -0
- package/crates/naome-core/src/verification_contract.rs +406 -0
- package/crates/naome-core/tests/decision.rs +297 -0
- package/crates/naome-core/tests/harness_health.rs +232 -0
- package/crates/naome-core/tests/install_plan.rs +35 -0
- package/crates/naome-core/tests/task_state.rs +588 -0
- package/crates/naome-core/tests/verification.rs +165 -0
- package/crates/naome-core/tests/verification_contract.rs +181 -0
- package/native/darwin-arm64/naome +0 -0
- package/package.json +44 -0
- package/templates/naome-root/.naome/bin/check-harness-health.js +163 -0
- package/templates/naome-root/.naome/bin/check-task-state.js +180 -0
- package/templates/naome-root/.naome/bin/naome.js +306 -0
- package/templates/naome-root/.naome/init-state.json +13 -0
- package/templates/naome-root/.naome/manifest.json +45 -0
- package/templates/naome-root/.naome/package.json +3 -0
- package/templates/naome-root/.naome/task-contract.schema.json +174 -0
- package/templates/naome-root/.naome/task-state.json +8 -0
- package/templates/naome-root/.naome/upgrade-state.json +7 -0
- package/templates/naome-root/.naome/verification.json +45 -0
- package/templates/naome-root/.naomeignore +4 -0
- package/templates/naome-root/AGENTS.md +77 -0
- package/templates/naome-root/docs/naome/agent-workflow.md +82 -0
- package/templates/naome-root/docs/naome/architecture.md +37 -0
- package/templates/naome-root/docs/naome/decisions.md +18 -0
- package/templates/naome-root/docs/naome/execution.md +192 -0
- package/templates/naome-root/docs/naome/first-run.md +135 -0
- package/templates/naome-root/docs/naome/index.md +67 -0
- package/templates/naome-root/docs/naome/repo-profile.md +51 -0
- package/templates/naome-root/docs/naome/security.md +60 -0
- package/templates/naome-root/docs/naome/testing.md +51 -0
- package/templates/naome-root/docs/naome/upgrade.md +20 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
use std::error::Error;
|
|
2
|
+
use std::fmt::{Display, Formatter};
|
|
3
|
+
|
|
4
|
+
use serde::Serialize;
|
|
5
|
+
|
|
6
|
+
#[derive(Debug, Clone, Serialize, PartialEq, Eq)]
|
|
7
|
+
#[serde(rename_all = "camelCase")]
|
|
8
|
+
pub struct Decision {
|
|
9
|
+
pub schema: String,
|
|
10
|
+
pub state: String,
|
|
11
|
+
pub blocked: bool,
|
|
12
|
+
pub summary: String,
|
|
13
|
+
pub allowed_actions: Vec<String>,
|
|
14
|
+
pub next_action: String,
|
|
15
|
+
pub changed_paths: Vec<String>,
|
|
16
|
+
pub required_context: Vec<String>,
|
|
17
|
+
pub task: Option<TaskDecision>,
|
|
18
|
+
pub harness_health: Option<CheckDecision>,
|
|
19
|
+
pub task_admission: Option<CheckDecision>,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
impl Decision {
|
|
23
|
+
pub fn new(
|
|
24
|
+
state: &str,
|
|
25
|
+
blocked: bool,
|
|
26
|
+
summary: &str,
|
|
27
|
+
allowed_actions: Vec<&str>,
|
|
28
|
+
next_action: &str,
|
|
29
|
+
) -> Self {
|
|
30
|
+
Self {
|
|
31
|
+
schema: "naome.decision.v1".to_string(),
|
|
32
|
+
state: state.to_string(),
|
|
33
|
+
blocked,
|
|
34
|
+
summary: summary.to_string(),
|
|
35
|
+
allowed_actions: allowed_actions
|
|
36
|
+
.into_iter()
|
|
37
|
+
.map(ToString::to_string)
|
|
38
|
+
.collect(),
|
|
39
|
+
next_action: next_action.to_string(),
|
|
40
|
+
changed_paths: Vec::new(),
|
|
41
|
+
required_context: Vec::new(),
|
|
42
|
+
task: None,
|
|
43
|
+
harness_health: None,
|
|
44
|
+
task_admission: None,
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
#[derive(Debug, Clone, Serialize, PartialEq, Eq)]
|
|
50
|
+
#[serde(rename_all = "camelCase")]
|
|
51
|
+
pub struct TaskDecision {
|
|
52
|
+
pub id: Option<String>,
|
|
53
|
+
pub status: String,
|
|
54
|
+
pub request: Option<String>,
|
|
55
|
+
pub allowed_paths: Vec<String>,
|
|
56
|
+
pub required_check_ids: Vec<String>,
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
#[derive(Debug, Clone, Serialize, PartialEq, Eq)]
|
|
60
|
+
#[serde(rename_all = "camelCase")]
|
|
61
|
+
pub struct CheckDecision {
|
|
62
|
+
pub command: String,
|
|
63
|
+
pub exit_code: Option<i32>,
|
|
64
|
+
pub ok: bool,
|
|
65
|
+
pub output: String,
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
#[derive(Debug)]
|
|
69
|
+
pub struct NaomeError {
|
|
70
|
+
message: String,
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
impl NaomeError {
|
|
74
|
+
pub fn new(message: impl Into<String>) -> Self {
|
|
75
|
+
Self {
|
|
76
|
+
message: message.into(),
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
impl Display for NaomeError {
|
|
82
|
+
fn fmt(&self, formatter: &mut Formatter<'_>) -> std::fmt::Result {
|
|
83
|
+
write!(formatter, "{}", self.message)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
impl Error for NaomeError {}
|
|
88
|
+
|
|
89
|
+
impl From<std::io::Error> for NaomeError {
|
|
90
|
+
fn from(error: std::io::Error) -> Self {
|
|
91
|
+
Self::new(error.to_string())
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
impl From<serde_json::Error> for NaomeError {
|
|
96
|
+
fn from(error: serde_json::Error) -> Self {
|
|
97
|
+
Self::new(error.to_string())
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
pub fn matches_any(path: &str, patterns: &[String]) -> bool {
|
|
2
|
+
patterns
|
|
3
|
+
.iter()
|
|
4
|
+
.any(|pattern| matches_pattern(path, pattern))
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
fn matches_pattern(path: &str, pattern: &str) -> bool {
|
|
8
|
+
let normalized_path = path.replace('\\', "/");
|
|
9
|
+
let normalized_pattern = pattern.replace('\\', "/");
|
|
10
|
+
|
|
11
|
+
if normalized_pattern == normalized_path {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if let Some(prefix) = normalized_pattern.strip_suffix("/**") {
|
|
16
|
+
return normalized_path == prefix || normalized_path.starts_with(&format!("{prefix}/"));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if !normalized_pattern.contains('*') {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
wildcard_match(normalized_path.as_bytes(), normalized_pattern.as_bytes())
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
fn wildcard_match(value: &[u8], pattern: &[u8]) -> bool {
|
|
27
|
+
let (mut value_index, mut pattern_index) = (0, 0);
|
|
28
|
+
let mut star_index = None;
|
|
29
|
+
let mut match_index = 0;
|
|
30
|
+
|
|
31
|
+
while value_index < value.len() {
|
|
32
|
+
if pattern_index < pattern.len() && pattern[pattern_index] == value[value_index] {
|
|
33
|
+
value_index += 1;
|
|
34
|
+
pattern_index += 1;
|
|
35
|
+
} else if pattern_index < pattern.len() && pattern[pattern_index] == b'*' {
|
|
36
|
+
star_index = Some(pattern_index);
|
|
37
|
+
match_index = value_index;
|
|
38
|
+
pattern_index += 1;
|
|
39
|
+
} else if let Some(star) = star_index {
|
|
40
|
+
pattern_index = star + 1;
|
|
41
|
+
match_index += 1;
|
|
42
|
+
value_index = match_index;
|
|
43
|
+
} else {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
while pattern_index < pattern.len() && pattern[pattern_index] == b'*' {
|
|
49
|
+
pattern_index += 1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
pattern_index == pattern.len()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
#[cfg(test)]
|
|
56
|
+
mod tests {
|
|
57
|
+
use super::matches_any;
|
|
58
|
+
|
|
59
|
+
#[test]
|
|
60
|
+
fn supports_exact_prefix_and_wildcard_patterns() {
|
|
61
|
+
let patterns = vec![
|
|
62
|
+
"README.md".to_string(),
|
|
63
|
+
"docs/naome/**".to_string(),
|
|
64
|
+
"scripts/*.js".to_string(),
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
assert!(matches_any("README.md", &patterns));
|
|
68
|
+
assert!(matches_any("docs/naome/testing.md", &patterns));
|
|
69
|
+
assert!(matches_any("scripts/check-task-state.js", &patterns));
|
|
70
|
+
assert!(!matches_any("src/main.rs", &patterns));
|
|
71
|
+
}
|
|
72
|
+
}
|