Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ edition = "2024"
license = "BSL-1.0"

[workspace.dependencies]
# The Plugin SDK at contract 0.8, pinned to a commit. A Host loads this
# The Plugin SDK at contract 0.9, pinned to a commit. A Host loads this
# Plugin only when its Harness speaks the same contract version.
runvil-plugin-sdk = { version = "0.8.0", git = "https://github.com/cppalliance/runvil-plugin-api", rev = "f2d42cc41b0f28f81ac73193f21c2eacfafc11d9" }
runvil-plugin-sdk = { version = "0.9.0", git = "https://github.com/cppalliance/runvil-plugin-api", rev = "4c10a7d4d26c11e6a3055c6f6c4b5657f1bf2faa" }
# The shell: a bash interpreter that runs in process, with every command
# built in. Its default features are off, which leaves out its own tool
# layer and the time zone database, and no feature that reaches the
Expand Down
4 changes: 2 additions & 2 deletions crates/plugin-bashkit/src/pack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ impl Pack for BashPack {
definition.description.clone(),
definition.parameters.clone(),
)
.wire_name(definition.wire_name.clone())
.with_wire_name(definition.wire_name.clone())
// A script may change the run's files. With the flag, the
// Host runs the calls of the tool that one reply asks for one
// after another, in the order the reply lists them.
.changes_files(),
.with_changes_files(true),
]
}

Expand Down
33 changes: 8 additions & 25 deletions crates/plugin-bashkit/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,14 @@ use serde_json::Value;
use crate::shell::{OUTPUT_CAP, TIMEOUT_MS};

/// The tool's definition, as the Pack hands it to the Host.
#[derive(Debug)]
#[derive(Debug, Deserialize)]
pub(crate) struct Definition {
/// The name the model calls the tool by.
pub(crate) wire_name: String,
/// The description the model reads.
pub(crate) description: String,
/// The JSON text of the JSON-Schema `object` the tool's arguments
/// must match.
pub(crate) parameters: String,
}

/// The tool's file, as the file itself holds it.
#[derive(Debug, Deserialize)]
struct File {
/// The name the model calls the tool by.
wire_name: String,
/// The description the model reads.
description: String,
/// The JSON-Schema `object` the tool's arguments must match.
parameters: Value,
pub(crate) parameters: Value,
}

/// The source of the tool's file.
Expand All @@ -44,12 +32,7 @@ const SOURCE: &str = include_str!("../schemas/shell.json");
/// Returns why the file does not parse. The file is embedded, so this can
/// only happen after an edit.
pub(crate) fn load() -> Result<Definition, serde_json::Error> {
let file: File = serde_json::from_str(&fill(SOURCE))?;
Ok(Definition {
wire_name: file.wire_name,
description: file.description,
parameters: file.parameters.to_string(),
})
serde_json::from_str(&fill(SOURCE))
}

/// `source` with its `{...}` placeholders filled from the constants the
Expand All @@ -63,7 +46,7 @@ fn fill(source: &str) -> String {

#[cfg(test)]
mod tests {
use serde_json::{Value, json};
use serde_json::json;

use super::{SOURCE, load};

Expand All @@ -82,13 +65,14 @@ mod tests {
fn every_placeholder_is_filled_from_the_constant_the_code_enforces() {
assert!(SOURCE.contains("{output_cap}") && SOURCE.contains("{timeout_ms}"));
let definition = load().expect("the embedded definition parses");
let parameters = definition.parameters.to_string();
assert!(
definition
.description
.contains("Output past 20000 characters")
);
assert!(definition.parameters.contains("Defaults to 30000ms"));
for text in [&definition.description, &definition.parameters] {
assert!(parameters.contains("Defaults to 30000ms"));
for text in [&definition.description, &parameters] {
assert!(
!text.contains("{output_cap}") && !text.contains("{timeout_ms}"),
"a placeholder is left in {text}"
Expand All @@ -99,8 +83,7 @@ mod tests {
#[test]
fn the_schema_declares_the_four_parameters_and_requires_the_command() {
let definition = load().expect("the embedded definition parses");
let schema: Value =
serde_json::from_str(&definition.parameters).expect("the schema is JSON");
let schema = &definition.parameters;
assert_eq!(schema["type"], "object");
assert_eq!(schema["required"], json!(["command"]));
let mut names: Vec<&str> = schema["properties"]
Expand Down
Loading
Loading