pub struct Agent {
pub spec: AgentSpec,
/* private fields */
}Fields§
§spec: AgentSpecImplementations§
Source§impl Agent
impl Agent
pub fn new(spec: AgentSpec) -> Self
pub fn name(&self) -> &str
Sourcepub fn program(&self) -> &str
pub fn program(&self) -> &str
The program the template names, before any resolution. What somebody has to install when spar reports it missing.
Sourcepub fn env_key(&self) -> String
pub fn env_key(&self) -> String
The environment variable that points this agent’s binary somewhere else.
Sourcepub fn resolve_bin(&self) -> Result<&Path>
pub fn resolve_bin(&self) -> Result<&Path>
SPAR_<NAME>_BIN first, then the template’s own program name on PATH or
as an absolute path, then the preset’s search paths. Never guess
silently: a miss reports every location tried, because a tool that
quietly runs the wrong binary is worse than one that fails.
Sourcepub fn render(&self, values: &Placeholders) -> Result<Vec<String>>
pub fn render(&self, values: &Placeholders) -> Result<Vec<String>>
Substitute placeholders. A group whose placeholder is unset is dropped
whole, so omitting model drops --model with it rather than passing
an empty string that the CLI would reject or, worse, accept.
Sourcepub fn supports_schema(&self) -> bool
pub fn supports_schema(&self) -> bool
True when the template has somewhere to put a schema, meaning the CLI can do structured output natively rather than being asked in the prompt.
Either form counts: a path for a CLI that reads the schema from disk, or the schema itself for one that takes it as an argument.
pub fn extract(&self, stdout: &str) -> Result<String>
pub fn ask( &self, prompt: &str, cwd: &Path, effort: Option<&str>, ) -> Result<String>
Sourcepub fn ask_json<T: DeserializeOwned>(
&self,
prompt: &str,
schema: &Value,
cwd: &Path,
effort: Option<&str>,
) -> Result<T>
pub fn ask_json<T: DeserializeOwned>( &self, prompt: &str, schema: &Value, cwd: &Path, effort: Option<&str>, ) -> Result<T>
Structured output through the CLI’s own mechanism when the template exposes one, otherwise by asking for JSON in the prompt and parsing it back out.
Sourcepub fn review<T: DeserializeOwned>(
&self,
base: &str,
prompt: &str,
schema: &Value,
cwd: &Path,
effort: Option<&str>,
) -> Result<T>
pub fn review<T: DeserializeOwned>( &self, base: &str, prompt: &str, schema: &Value, cwd: &Path, effort: Option<&str>, ) -> Result<T>
Review the branch against base.
Deliberately generic. codex exec review was tried and rejected: it
refuses a custom prompt alongside --base and returns prose regardless
of --output-schema, so it cannot yield a machine checkable verdict.
Running inside the worktree is what makes an agent repo aware, not a
subcommand.