Skip to content
Draft
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
75 changes: 75 additions & 0 deletions crates/pidgin-napi/schema/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,81 @@
"name": "substituteArgs"
}
}
},
{
"name": "getConfigValueEnvVarName",
"doc": "`getConfigValueEnvVarName` (resolve-config-value.ts): the single env var a\nvalue references, or `null` (pi's `undefined`).",
"shape": "unary",
"infallible": true,
"readonly": true,
"params": [
{
"name": "config",
"type": "string"
}
],
"returns": {
"nullable": "string"
},
"bindings": {
"node": {
"name": "getConfigValueEnvVarName"
}
}
},
{
"name": "getConfigValueEnvVarNames",
"doc": "`getConfigValueEnvVarNames` (resolve-config-value.ts): all distinct env var\nnames a value references, in first-seen order.",
"shape": "unary",
"infallible": true,
"readonly": true,
"params": [
{
"name": "config",
"type": "string"
}
],
"returns": {
"list": "string"
},
"bindings": {
"node": {
"name": "getConfigValueEnvVarNames"
}
}
},
{
"name": "isCommandConfigValue",
"doc": "`isCommandConfigValue` (resolve-config-value.ts): whether a value is a\n`!`-prefixed shell command.",
"shape": "unary",
"infallible": true,
"readonly": true,
"params": [
{
"name": "config",
"type": "string"
}
],
"returns": "boolean",
"bindings": {
"node": {
"name": "isCommandConfigValue"
}
}
},
{
"name": "clearConfigValueCache",
"doc": "`clearConfigValueCache` (resolve-config-value.ts): clear the process-lifetime\n`!command` result cache.",
"shape": "unary",
"infallible": true,
"readonly": false,
"params": [],
"returns": "void",
"bindings": {
"node": {
"name": "clearConfigValueCache"
}
}
}
]
},
Expand Down
16 changes: 16 additions & 0 deletions crates/pidgin-napi/src/core_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,22 @@ impl crate::generated::PidginCore for PidginImpl {
let refs: Vec<&str> = args.iter().map(String::as_str).collect();
pidgin_agent::harness::prompt_templates::substitute_args(&content, &refs)
}

fn get_config_value_env_var_name(config: String) -> Option<String> {
pidgin_coding::core::resolve_config_value::get_config_value_env_var_name(&config)
}

fn get_config_value_env_var_names(config: String) -> Vec<String> {
pidgin_coding::core::resolve_config_value::get_config_value_env_var_names(&config)
}

fn is_command_config_value(config: String) -> bool {
pidgin_coding::core::resolve_config_value::is_command_config_value(&config)
}

fn clear_config_value_cache() {
pidgin_coding::core::resolve_config_value::clear_config_value_cache();
}
}

// --- coding-agent session-cwd seam (core/session-cwd.ts) --------------------
Expand Down
32 changes: 32 additions & 0 deletions crates/pidgin-napi/src/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ pub trait PidginCore: Sized + Send + Sync + 'static {
fn format_missing_session_cwd_prompt(issue: SessionCwdIssueJs) -> String;
fn parse_command_args(args_string: String) -> Vec<String>;
fn substitute_args(content: String, args: Vec<String>) -> String;
fn get_config_value_env_var_name(config: String) -> Option<String>;
fn get_config_value_env_var_names(config: String) -> Vec<String>;
fn is_command_config_value(config: String) -> bool;
fn clear_config_value_cache() -> ();
}

/// The `KeybindingsManagerCore` contract — implement over the engine in `crate::core_impl`.
Expand Down Expand Up @@ -338,6 +342,34 @@ pub fn substitute_args(content: String, args: Vec<String>) -> String {
<crate::core_impl::PidginImpl as PidginCore>::substitute_args(content, args)
}

/// `getConfigValueEnvVarName` (resolve-config-value.ts): the single env var a
/// value references, or `null` (pi's `undefined`).
#[napi(js_name = "getConfigValueEnvVarName")]
pub fn get_config_value_env_var_name(config: String) -> Option<String> {
<crate::core_impl::PidginImpl as PidginCore>::get_config_value_env_var_name(config)
}

/// `getConfigValueEnvVarNames` (resolve-config-value.ts): all distinct env var
/// names a value references, in first-seen order.
#[napi(js_name = "getConfigValueEnvVarNames")]
pub fn get_config_value_env_var_names(config: String) -> Vec<String> {
<crate::core_impl::PidginImpl as PidginCore>::get_config_value_env_var_names(config)
}

/// `isCommandConfigValue` (resolve-config-value.ts): whether a value is a
/// `!`-prefixed shell command.
#[napi(js_name = "isCommandConfigValue")]
pub fn is_command_config_value(config: String) -> bool {
<crate::core_impl::PidginImpl as PidginCore>::is_command_config_value(config)
}

/// `clearConfigValueCache` (resolve-config-value.ts): clear the process-lifetime
/// `!command` result cache.
#[napi(js_name = "clearConfigValueCache")]
pub fn clear_config_value_cache() -> () {
<crate::core_impl::PidginImpl as PidginCore>::clear_config_value_cache()
}

/// The Rust-backed keybindings core, exposed to JavaScript as
/// `KeybindingsManagerCore`.
#[napi]
Expand Down
28 changes: 0 additions & 28 deletions crates/pidgin-napi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,20 +638,6 @@ pub fn resolve_config_value_or_throw(
.map_err(|e| napi::Error::from_reason(e.to_string()))
}

/// `getConfigValueEnvVarName` (resolve-config-value.ts): the single env var a
/// value references, or `null` (pi's `undefined`).
#[napi(js_name = "getConfigValueEnvVarName")]
pub fn get_config_value_env_var_name(config: String) -> Option<String> {
pidgin_coding::core::resolve_config_value::get_config_value_env_var_name(&config)
}

/// `getConfigValueEnvVarNames` (resolve-config-value.ts): all distinct env var
/// names a value references, in first-seen order.
#[napi(js_name = "getConfigValueEnvVarNames")]
pub fn get_config_value_env_var_names(config: String) -> Vec<String> {
pidgin_coding::core::resolve_config_value::get_config_value_env_var_names(&config)
}

/// `getMissingConfigValueEnvVarNames` (resolve-config-value.ts): referenced env
/// var names that do not currently resolve.
#[napi(js_name = "getMissingConfigValueEnvVarNames")]
Expand All @@ -668,13 +654,6 @@ pub fn get_missing_config_value_env_var_names(
)
}

/// `isCommandConfigValue` (resolve-config-value.ts): whether a value is a
/// `!`-prefixed shell command.
#[napi(js_name = "isCommandConfigValue")]
pub fn is_command_config_value(config: String) -> bool {
pidgin_coding::core::resolve_config_value::is_command_config_value(&config)
}

/// `isConfigValueConfigured` (resolve-config-value.ts): whether every env var a
/// value references is set.
#[napi(js_name = "isConfigValueConfigured")]
Expand Down Expand Up @@ -733,13 +712,6 @@ pub fn resolve_headers_or_throw(
headers_json(resolved)
}

/// `clearConfigValueCache` (resolve-config-value.ts): clear the process-lifetime
/// `!command` result cache.
#[napi(js_name = "clearConfigValueCache")]
pub fn clear_config_value_cache() {
pidgin_coding::core::resolve_config_value::clear_config_value_cache();
}

// --- coding-agent core: trust-manager ---------------------------------------
//
// Thin wrappers over `pidgin_coding::core::trust_manager`, backing the native
Expand Down
Loading