artifactize_core/
config.rs1use std::{
4 collections::{BTreeMap, BTreeSet},
5 path::{Path, PathBuf},
6};
7
8use thiserror::Error;
9
10mod authored_target;
11mod backend;
12mod declaration;
13mod definition;
14mod discovery;
15pub mod edit;
16mod eval;
17mod identities;
18mod legacy;
19mod location;
20pub mod migrate;
21mod mutex;
22mod plain;
23pub mod plugins;
24mod profile;
25mod schemas;
26mod settings;
27mod site;
28mod stored;
29mod tools;
30pub(crate) mod validation;
31mod workspace;
32
33pub use crate::types::{ArtifactName, EvalId};
34pub use artifactize_tools::scope::{ArtifactKind, Target, Uri};
35pub use backend::{Backend, Provider};
36pub use declaration::{ArtifactDeclaration, Fingerprint, Views, parse_declaration};
37pub use discovery::read_workspace_config;
38pub(crate) use discovery::read_workspace_declarations;
39use discovery::{logical_join, read_regular_text};
40pub use eval::{EvalDeclaration, EvalPayload, LocalEvalId, Priority};
41pub use identities::{
42 ArtifactType, ChildPrefix, EndpointId, ExecutionPinName, HubEpoch, LogicalPath, ModelId,
43 ProfileAliasName, ProfileVariantName, ReferenceName, ToolName, ToolOperationName,
44};
45pub use mutex::MutexTag;
46pub use profile::{Profile, ProfileKind, Reasoning};
47pub use settings::{SETTINGS_FILE, Settings, parse_settings};
48pub use site::{ScopeReadError, Site, read_sites};
49pub(crate) use site::{read_artifact_scope, read_eval_scope};
50pub use stored::{Field, StoredPayload, StoredProfile};
51pub use tools::{
52 AgentTool, Builtin, BuiltinTool, CommandTool, HumanBuiltinTool, HumanCommandTool, HumanTool,
53 HumanToolKind, HumanViewerTool, SessionCommand, ToolProtocol, ToolSession,
54};
55pub use validation::MAX_TIMEOUT_MS;
56pub(crate) use validation::{artifact_name, identifier};
57pub use workspace::{Artifact, Eval, RepoConfig, ReviewRequirement};
58
59pub const CONFIG_FORMAT_VERSION: u32 = 1;
61pub const CONFIG_FILE: &str = "index.artf";
62pub const IGNORE_FILE: &str = ".artfignore";
64const MAX_DECLARED_ITEMS: usize = 64;
66
67#[derive(Debug, Error)]
68#[error("{}: {message}", crate::platform::path_text(.path))]
69pub struct ConfigError {
70 pub path: PathBuf,
71 pub message: String,
72 declaration: Option<(Vec<String>, String)>,
73}
74
75impl ConfigError {
76 pub(crate) fn new(path: impl Into<PathBuf>, message: impl ToString) -> Self {
77 Self {
78 path: path.into(),
79 message: message.to_string(),
80 declaration: None,
81 }
82 }
83
84 pub(crate) fn declaration(
86 path: impl Into<PathBuf>,
87 keys: &[&str],
88 message: impl ToString,
89 ) -> Self {
90 let path = path.into();
91 let message = message.to_string();
92 let declaration = Some((
93 keys.iter().map(|key| (*key).to_owned()).collect(),
94 message.clone(),
95 ));
96 let message = read_regular_text(&path).map_or(message.clone(), |source| {
97 location::error_at(&source, keys, &message)
98 });
99 Self {
100 path,
101 message,
102 declaration,
103 }
104 }
105}
106
107#[cfg(test)]
108mod tests;