mirror of
https://github.com/openai/codex.git
synced 2026-11-26 23:40:43 +00:00
Add file-backed personality support and listing
This commit is contained in:
@@ -176,6 +176,7 @@ Example with notification opt-out:
|
||||
- `experimentalFeature/enablement/set` — patch the in-memory process-wide runtime feature enablement for the currently supported feature keys (`apps`, `plugins`). For each feature, precedence is: cloud requirements > --enable <feature_name> > config.toml > experimentalFeature/enablement/set (new) > code default.
|
||||
- `collaborationMode/list` — list available collaboration mode presets (experimental, no pagination). This response omits built-in developer instructions; clients should either pass `settings.developer_instructions: null` when setting a mode to use Codex's built-in instructions, or provide their own instructions explicitly.
|
||||
- `skills/list` — list skills for one or more `cwd` values (optional `forceReload`).
|
||||
- `personalities/list` — list built-in and file-backed personalities for one or more `cwd` values.
|
||||
- `plugin/list` — list discovered plugin marketplaces and plugin state, including effective marketplace install/auth policy metadata, fail-open `marketplaceLoadErrors` entries for marketplace files that could not be parsed or loaded, and best-effort `featuredPluginIds` for the official curated marketplace. `interface.category` uses the marketplace category when present; otherwise it falls back to the plugin manifest category. Pass `forceRemoteSync: true` to refresh curated plugin state before listing (**under development; do not call from production clients yet**).
|
||||
- `plugin/read` — read one plugin by `marketplacePath` plus `pluginName`, returning marketplace info, a list-style `summary`, manifest descriptions/interface metadata, and bundled skills/apps/MCP server names. Returned plugin skills include their current `enabled` state after local config filtering. Plugin app summaries also include `needsAuth` when the server can determine connector accessibility (**under development; do not call from production clients yet**).
|
||||
- `skills/changed` — notification emitted when watched local skill files change.
|
||||
@@ -237,7 +238,7 @@ Start a fresh thread when you need a new Codex conversation.
|
||||
{ "method": "thread/started", "params": { "thread": { … } } }
|
||||
```
|
||||
|
||||
Valid `personality` values are `"friendly"`, `"pragmatic"`, and `"none"`. When `"none"` is selected, the personality placeholder is replaced with an empty string.
|
||||
Built-in `personality` values are `"friendly"`, `"pragmatic"`, and `"none"`. Clients may also pass custom personality ids discovered via `personalities/list`. Custom personalities are loaded from Markdown files in `.codex/personalities` for the active repo and `$CODEX_HOME/personalities` for the user; invalid files are logged and ignored. When `"none"` is selected, no personality instructions are injected.
|
||||
|
||||
To continue a stored session, call `thread/resume` with the `thread.id` you previously recorded. The response shape matches `thread/start`, and no additional notifications are emitted. You can also pass the same configuration overrides supported by `thread/start`, including `approvalsReviewer`.
|
||||
|
||||
@@ -1185,6 +1186,31 @@ The server also emits `skills/changed` notifications when watched local skill fi
|
||||
}
|
||||
```
|
||||
|
||||
Use `personalities/list` to fetch the available built-in and file-backed personalities for one or more working directories.
|
||||
|
||||
```json
|
||||
{ "method": "personalities/list", "id": 26, "params": {
|
||||
"cwds": ["/Users/me/project"]
|
||||
} }
|
||||
{ "id": 26, "result": { "data": [{
|
||||
"cwd": "/Users/me/project",
|
||||
"personalities": [
|
||||
{
|
||||
"name": "friendly",
|
||||
"description": "Warm, collaborative, and helpful.",
|
||||
"scope": "builtin",
|
||||
"isBuiltIn": true
|
||||
},
|
||||
{
|
||||
"name": "night-owl",
|
||||
"description": "Late-night, direct, and fast.",
|
||||
"scope": "repo",
|
||||
"isBuiltIn": false
|
||||
}
|
||||
]
|
||||
}] } }
|
||||
```
|
||||
|
||||
To enable or disable a skill by absolute path:
|
||||
|
||||
```json
|
||||
|
||||
@@ -83,6 +83,8 @@ use codex_app_server_protocol::MockExperimentalMethodParams;
|
||||
use codex_app_server_protocol::MockExperimentalMethodResponse;
|
||||
use codex_app_server_protocol::ModelListParams;
|
||||
use codex_app_server_protocol::ModelListResponse;
|
||||
use codex_app_server_protocol::PersonalitiesListParams;
|
||||
use codex_app_server_protocol::PersonalitiesListResponse;
|
||||
use codex_app_server_protocol::PluginDetail;
|
||||
use codex_app_server_protocol::PluginInstallParams;
|
||||
use codex_app_server_protocol::PluginInstallResponse;
|
||||
@@ -779,6 +781,10 @@ impl CodexMessageProcessor {
|
||||
self.skills_list(to_connection_request_id(request_id), params)
|
||||
.await;
|
||||
}
|
||||
ClientRequest::PersonalitiesList { request_id, params } => {
|
||||
self.personalities_list(to_connection_request_id(request_id), params)
|
||||
.await;
|
||||
}
|
||||
ClientRequest::PluginList { request_id, params } => {
|
||||
self.plugin_list(to_connection_request_id(request_id), params)
|
||||
.await;
|
||||
@@ -5787,6 +5793,61 @@ impl CodexMessageProcessor {
|
||||
.await;
|
||||
}
|
||||
|
||||
async fn personalities_list(
|
||||
&self,
|
||||
request_id: ConnectionRequestId,
|
||||
params: PersonalitiesListParams,
|
||||
) {
|
||||
let cwds = params
|
||||
.cwds
|
||||
.map(|cwds| {
|
||||
cwds.into_iter()
|
||||
.map(codex_utils_absolute_path::AbsolutePathBuf::into_path_buf)
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
.filter(|cwds| !cwds.is_empty())
|
||||
.unwrap_or_else(|| vec![self.config.cwd.to_path_buf()]);
|
||||
|
||||
let cli_overrides = self.current_cli_overrides();
|
||||
let mut data = Vec::new();
|
||||
for cwd in cwds {
|
||||
let cwd_abs = match AbsolutePathBuf::try_from(cwd.as_path()) {
|
||||
Ok(path) => path,
|
||||
Err(err) => {
|
||||
self.send_invalid_request_error(request_id, err.to_string())
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
let config_layer_stack = match load_config_layers_state(
|
||||
&self.config.codex_home,
|
||||
Some(cwd_abs),
|
||||
&cli_overrides,
|
||||
LoaderOverrides::default(),
|
||||
CloudRequirementsLoader::default(),
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(config_layer_stack) => config_layer_stack,
|
||||
Err(err) => {
|
||||
self.outgoing
|
||||
.send_error(request_id, config_load_error(&err))
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
let catalog = codex_core::personalities::catalog_from_layer_stack(&config_layer_stack);
|
||||
data.push(codex_app_server_protocol::PersonalitiesListEntry {
|
||||
cwd,
|
||||
personalities: personalities_to_info(catalog.personalities()),
|
||||
});
|
||||
}
|
||||
|
||||
self.outgoing
|
||||
.send_response(request_id, PersonalitiesListResponse { data })
|
||||
.await;
|
||||
}
|
||||
|
||||
async fn plugin_list(&self, request_id: ConnectionRequestId, params: PluginListParams) {
|
||||
let plugins_manager = self.thread_manager.plugins_manager();
|
||||
let PluginListParams {
|
||||
@@ -6390,7 +6451,7 @@ impl CodexMessageProcessor {
|
||||
summary: params.summary,
|
||||
service_tier: params.service_tier,
|
||||
collaboration_mode,
|
||||
personality: params.personality,
|
||||
personality: params.personality.clone(),
|
||||
},
|
||||
)
|
||||
.await;
|
||||
@@ -7986,6 +8047,32 @@ fn skills_to_info(
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn personalities_to_info(
|
||||
personalities: &[codex_core::personalities::PersonalityDefinition],
|
||||
) -> Vec<codex_app_server_protocol::PersonalityMetadata> {
|
||||
personalities
|
||||
.iter()
|
||||
.map(
|
||||
|personality| codex_app_server_protocol::PersonalityMetadata {
|
||||
name: personality.name.to_string(),
|
||||
description: personality.description.clone(),
|
||||
scope: match personality.scope {
|
||||
codex_core::personalities::PersonalityScope::Builtin => {
|
||||
codex_app_server_protocol::PersonalityScope::Builtin
|
||||
}
|
||||
codex_core::personalities::PersonalityScope::User => {
|
||||
codex_app_server_protocol::PersonalityScope::User
|
||||
}
|
||||
codex_core::personalities::PersonalityScope::Repo => {
|
||||
codex_app_server_protocol::PersonalityScope::Repo
|
||||
}
|
||||
},
|
||||
is_built_in: personality.is_builtin,
|
||||
},
|
||||
)
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn plugin_skills_to_info(
|
||||
skills: &[codex_core::skills::SkillMetadata],
|
||||
disabled_skill_paths: &std::collections::HashSet<PathBuf>,
|
||||
|
||||
@@ -490,6 +490,15 @@ impl McpProcess {
|
||||
self.send_request("skills/list", params).await
|
||||
}
|
||||
|
||||
/// Send a `personalities/list` JSON-RPC request.
|
||||
pub async fn send_personalities_list_request(
|
||||
&mut self,
|
||||
params: codex_app_server_protocol::PersonalitiesListParams,
|
||||
) -> anyhow::Result<i64> {
|
||||
let params = Some(serde_json::to_value(params)?);
|
||||
self.send_request("personalities/list", params).await
|
||||
}
|
||||
|
||||
/// Send a `plugin/install` JSON-RPC request.
|
||||
pub async fn send_plugin_install_request(
|
||||
&mut self,
|
||||
|
||||
@@ -17,6 +17,7 @@ mod initialize;
|
||||
mod mcp_server_elicitation;
|
||||
mod model_list;
|
||||
mod output_schema;
|
||||
mod personalities_list;
|
||||
mod plan_item;
|
||||
mod plugin_install;
|
||||
mod plugin_list;
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::Result;
|
||||
use anyhow::anyhow;
|
||||
use app_test_support::McpProcess;
|
||||
use app_test_support::to_response;
|
||||
use codex_app_server_protocol::JSONRPCResponse;
|
||||
use codex_app_server_protocol::PersonalitiesListParams;
|
||||
use codex_app_server_protocol::PersonalitiesListResponse;
|
||||
use codex_app_server_protocol::PersonalityScope;
|
||||
use codex_app_server_protocol::RequestId;
|
||||
use pretty_assertions::assert_eq;
|
||||
use tempfile::TempDir;
|
||||
use tokio::time::timeout;
|
||||
|
||||
const DEFAULT_TIMEOUT: Duration = Duration::from_secs(10);
|
||||
|
||||
fn write_personality(
|
||||
root: &std::path::Path,
|
||||
name: &str,
|
||||
description: &str,
|
||||
body: &str,
|
||||
) -> Result<()> {
|
||||
std::fs::create_dir_all(root)?;
|
||||
std::fs::write(
|
||||
root.join(format!("{name}.md")),
|
||||
format!("---\nname: {name}\ndescription: {description}\n---\n\n{body}\n"),
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn personalities_list_returns_builtin_and_file_backed_personalities() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
let repo = TempDir::new()?;
|
||||
let repo_personalities = repo.path().join(".codex/personalities");
|
||||
let user_personalities = codex_home.path().join("personalities");
|
||||
|
||||
write_personality(
|
||||
&user_personalities,
|
||||
"night-owl",
|
||||
"User personality",
|
||||
"User instructions",
|
||||
)?;
|
||||
write_personality(
|
||||
&repo_personalities,
|
||||
"night-owl",
|
||||
"Repo personality",
|
||||
"Repo instructions",
|
||||
)?;
|
||||
write_personality(
|
||||
&repo_personalities,
|
||||
"ship-it",
|
||||
"Repo only",
|
||||
"Ship it instructions",
|
||||
)?;
|
||||
std::fs::write(
|
||||
repo_personalities.join("broken.md"),
|
||||
"# missing frontmatter\n",
|
||||
)?;
|
||||
|
||||
let mut mcp = McpProcess::new(codex_home.path()).await?;
|
||||
timeout(DEFAULT_TIMEOUT, mcp.initialize()).await??;
|
||||
|
||||
let request_id = mcp
|
||||
.send_personalities_list_request(PersonalitiesListParams {
|
||||
cwds: Some(vec![repo.path().to_path_buf().try_into()?]),
|
||||
})
|
||||
.await?;
|
||||
|
||||
let response: JSONRPCResponse = timeout(
|
||||
DEFAULT_TIMEOUT,
|
||||
mcp.read_stream_until_response_message(RequestId::Integer(request_id)),
|
||||
)
|
||||
.await??;
|
||||
let PersonalitiesListResponse { data } = to_response(response)?;
|
||||
|
||||
assert_eq!(data.len(), 1);
|
||||
assert_eq!(data[0].cwd, repo.path().to_path_buf());
|
||||
|
||||
let personalities = &data[0].personalities;
|
||||
let names = personalities
|
||||
.iter()
|
||||
.map(|personality| personality.name.as_str())
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(
|
||||
names,
|
||||
vec!["friendly", "none", "pragmatic", "night-owl", "ship-it"]
|
||||
);
|
||||
assert!(personalities.iter().any(|personality| {
|
||||
personality.name == "friendly"
|
||||
&& personality.is_built_in
|
||||
&& personality.scope == PersonalityScope::Builtin
|
||||
}));
|
||||
assert!(personalities.iter().any(|personality| {
|
||||
personality.name == "pragmatic"
|
||||
&& personality.is_built_in
|
||||
&& personality.scope == PersonalityScope::Builtin
|
||||
}));
|
||||
assert!(personalities.iter().any(|personality| {
|
||||
personality.name == "none"
|
||||
&& personality.is_built_in
|
||||
&& personality.scope == PersonalityScope::Builtin
|
||||
}));
|
||||
|
||||
let night_owl = personalities
|
||||
.iter()
|
||||
.find(|personality| personality.name == "night-owl")
|
||||
.ok_or_else(|| anyhow!("night-owl personality missing"))?;
|
||||
assert_eq!(night_owl.description, "Repo personality");
|
||||
assert_eq!(night_owl.scope, PersonalityScope::Repo);
|
||||
assert!(!night_owl.is_built_in);
|
||||
|
||||
let ship_it = personalities
|
||||
.iter()
|
||||
.find(|personality| personality.name == "ship-it")
|
||||
.ok_or_else(|| anyhow!("ship-it personality missing"))?;
|
||||
assert_eq!(ship_it.description, "Repo only");
|
||||
assert_eq!(ship_it.scope, PersonalityScope::Repo);
|
||||
assert!(!ship_it.is_built_in);
|
||||
|
||||
assert!(
|
||||
personalities
|
||||
.iter()
|
||||
.all(|personality| personality.name != "broken")
|
||||
);
|
||||
assert_eq!(
|
||||
personalities
|
||||
.iter()
|
||||
.filter(|personality| personality.name == "night-owl")
|
||||
.count(),
|
||||
1
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
@@ -1809,7 +1809,7 @@ async fn thread_resume_accepts_personality_override() -> Result<()> {
|
||||
.send_thread_resume_request(ThreadResumeParams {
|
||||
thread_id: thread.id,
|
||||
model: Some("gpt-5.2-codex".to_string()),
|
||||
personality: Some(Personality::Friendly),
|
||||
personality: Some(Personality::friendly()),
|
||||
..Default::default()
|
||||
})
|
||||
.await?;
|
||||
|
||||
@@ -719,7 +719,7 @@ async fn turn_start_accepts_personality_override_v2() -> Result<()> {
|
||||
text: "Hello".to_string(),
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
personality: Some(Personality::Friendly),
|
||||
personality: Some(Personality::friendly()),
|
||||
..Default::default()
|
||||
})
|
||||
.await?;
|
||||
@@ -824,7 +824,7 @@ async fn turn_start_change_personality_mid_thread_v2() -> Result<()> {
|
||||
text: "Hello again".to_string(),
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
personality: Some(Personality::Friendly),
|
||||
personality: Some(Personality::friendly()),
|
||||
..Default::default()
|
||||
})
|
||||
.await?;
|
||||
@@ -897,7 +897,7 @@ async fn turn_start_uses_migrated_pragmatic_personality_without_override_v2() ->
|
||||
let persisted_toml: ConfigToml = toml::from_str(&std::fs::read_to_string(
|
||||
codex_home.path().join("config.toml"),
|
||||
)?)?;
|
||||
assert_eq!(persisted_toml.personality, Some(Personality::Pragmatic));
|
||||
assert_eq!(persisted_toml.personality, Some(Personality::pragmatic()));
|
||||
assert!(
|
||||
codex_home
|
||||
.path()
|
||||
|
||||
Reference in New Issue
Block a user