Files
codex/codex-rs/external-agent-migration/src/detect/memory.rs
T
charlesgong-openai e7efc5b04b Move external agent migration into its crate (#33456)
## What changed

- Move migration detection, import orchestration, models, and reporting from
  `codex-app-server` into `codex-external-agent-migration`.
- Keep app-server protocol conversion in a dedicated boundary module.
- Organize source-specific configuration, sessions, hooks, plugins, commands,
  subagents, and memory handling behind shared migration adapters.
- Relocate and split the migration tests alongside the extracted service.

GitOrigin-RevId: 3378ec2064806a28136d6ac98664ca1d75414a4e
2026-07-16 00:34:36 +00:00

34 lines
1.1 KiB
Rust

use crate::discover_external_memory_files;
use crate::memory_import::projects_needing_import;
use crate::memory_import::resources_root;
use crate::model::ExternalAgentConfigMigrationItem;
use crate::model::ExternalAgentConfigMigrationItemType;
use crate::model::MigrationDetails;
use std::io;
use std::path::Path;
pub(super) fn detect(
codex_home: &Path,
external_agent_home: &Path,
) -> io::Result<Option<ExternalAgentConfigMigrationItem>> {
let memory_files = discover_external_memory_files(external_agent_home)?;
let memory = projects_needing_import(codex_home, &memory_files)?;
if memory.is_empty() {
return Ok(None);
}
Ok(Some(ExternalAgentConfigMigrationItem {
item_type: ExternalAgentConfigMigrationItemType::Memory,
description: format!(
"Import memory files from {} to {}",
external_agent_home.join("projects").display(),
resources_root(codex_home).display()
),
cwd: None,
details: Some(MigrationDetails {
memory: memory.into_iter().collect(),
..Default::default()
}),
}))
}