mirror of
https://github.com/openai/codex.git
synced 2026-11-29 07:35:16 +00:00
## Summary Move `codex marketplace add` onto a shared core implementation so the CLI and app-server path can use one source of truth. This change: - adds shared marketplace-add orchestration in `codex-core` - switches the CLI command to call that shared implementation - removes duplicated CLI-only marketplace add helpers - preserves focused parser and add-path coverage while moving the shared behavior into core tests ## Why The new `marketplace/add` RPC should reuse the same underlying marketplace-add flow as the CLI. This refactor lands that consolidation first so the follow-up app-server PR can be mostly protocol and handler wiring. ## Validation - `cargo test -p codex-core marketplace_add` - `cargo test -p codex-cli marketplace_cmd` - `just fix -p codex-core` - `just fix -p codex-cli` - `just fmt`
41 lines
1.2 KiB
Rust
41 lines
1.2 KiB
Rust
use anyhow::Result;
|
|
use app_test_support::McpProcess;
|
|
use codex_app_server_protocol::MarketplaceAddParams;
|
|
use codex_app_server_protocol::RequestId;
|
|
use tempfile::TempDir;
|
|
use tokio::time::Duration;
|
|
use tokio::time::timeout;
|
|
|
|
const DEFAULT_TIMEOUT: Duration = Duration::from_secs(10);
|
|
|
|
#[tokio::test]
|
|
async fn marketplace_add_rejects_local_directory_source() -> Result<()> {
|
|
let codex_home = TempDir::new()?;
|
|
let mut mcp = McpProcess::new(codex_home.path()).await?;
|
|
timeout(DEFAULT_TIMEOUT, mcp.initialize()).await??;
|
|
|
|
let request_id = mcp
|
|
.send_marketplace_add_request(MarketplaceAddParams {
|
|
source: "./marketplace".to_string(),
|
|
ref_name: None,
|
|
sparse_paths: None,
|
|
})
|
|
.await?;
|
|
|
|
let err = timeout(
|
|
DEFAULT_TIMEOUT,
|
|
mcp.read_stream_until_error_message(RequestId::Integer(request_id)),
|
|
)
|
|
.await??;
|
|
|
|
assert_eq!(err.error.code, -32600);
|
|
assert!(
|
|
err.error.message.contains(
|
|
"local marketplace sources are not supported yet; use an HTTP(S) Git URL, SSH Git URL, or GitHub owner/repo"
|
|
),
|
|
"unexpected error: {}",
|
|
err.error.message
|
|
);
|
|
Ok(())
|
|
}
|