mirror of
https://github.com/openai/codex.git
synced 2026-11-22 07:13:50 +00:00
Add Cursor support to setup import (#33426)
## What changed - Detect and import supported Cursor settings, sandbox permissions, MCP servers, project instructions, hooks, agents, commands, plugins, and recent chat sessions. - Update the `/import` flow to check Claude Code and Cursor, prompting for a source when both have importable data. - Add `migrationSource` to the app-server detect and import requests so each operation uses the selected adapter, while retaining `source` for import attribution and backwards compatibility. ## Testing - Add coverage for Cursor config conversion, hooks, plugins, session discovery and conversion, app-server imports, and TUI source selection. GitOrigin-RevId: a65a1511b6c1c2f9e3e0cfe4f816bb435807282e
This commit is contained in:
1 parent
0f2321f244
commit
1c4af96394
47 files changed
+2962
-247
No files matched your search
@@ -0,0 +1,107 @@
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
const TEST_REWRITE_PROFILE: RewriteProfile =
|
||||
RewriteProfile::new(".source-rules", &["source agent"]);
|
||||
|
||||
#[test]
|
||||
fn imports_supported_cur_hooks_and_drops_failure_policy() {
|
||||
let root = tempfile::TempDir::new().expect("tempdir");
|
||||
let source_dir = root.path().join(".source");
|
||||
let source_hooks_dir = source_dir.join("hooks");
|
||||
let source_hooks = source_dir.join("hooks.json");
|
||||
let target_hooks = root.path().join(".codex/hooks.json");
|
||||
fs::create_dir_all(&source_hooks_dir).expect("source hooks directory");
|
||||
fs::write(source_hooks_dir.join("check.sh"), "echo check\n").expect("hook script");
|
||||
fs::write(
|
||||
&source_hooks,
|
||||
serde_json::json!({
|
||||
"hooks": {
|
||||
"preToolUse": [{
|
||||
"type": "command",
|
||||
"command": "sh .source/hooks/check.sh",
|
||||
"matcher": "Shell",
|
||||
"statusMessage": "Source agent check",
|
||||
"timeoutSec": "7",
|
||||
"failClosed": false
|
||||
}],
|
||||
"postToolUse": [{
|
||||
"type": "prompt",
|
||||
"command": "echo ignored"
|
||||
}],
|
||||
"subagentStart": [{
|
||||
"command": "echo subagent",
|
||||
"failClosed": true
|
||||
}],
|
||||
"beforeSubmitPrompt": [{
|
||||
"command": "echo ready",
|
||||
"matcher": "ignored"
|
||||
}],
|
||||
"preCompact": [{
|
||||
"command": "echo compact",
|
||||
"matcher": "auto"
|
||||
}]
|
||||
}
|
||||
})
|
||||
.to_string(),
|
||||
)
|
||||
.expect("hooks config");
|
||||
|
||||
assert!(
|
||||
import_hooks_cur(
|
||||
&source_dir,
|
||||
&source_hooks,
|
||||
&target_hooks,
|
||||
TEST_REWRITE_PROFILE,
|
||||
)
|
||||
.expect("import hooks")
|
||||
);
|
||||
|
||||
let target: JsonValue =
|
||||
serde_json::from_str(&fs::read_to_string(&target_hooks).expect("target hooks"))
|
||||
.expect("target hooks JSON");
|
||||
let rewritten_script = target_hooks
|
||||
.parent()
|
||||
.expect("target hooks parent")
|
||||
.join("hooks")
|
||||
.join("check.sh");
|
||||
assert_eq!(
|
||||
target,
|
||||
serde_json::json!({
|
||||
"hooks": {
|
||||
"PreToolUse": [{
|
||||
"matcher": "Shell",
|
||||
"hooks": [{
|
||||
"type": "command",
|
||||
"command": format!("sh '{}'", rewritten_script.display()),
|
||||
"timeout": 7,
|
||||
"statusMessage": "Codex check"
|
||||
}]
|
||||
}],
|
||||
"UserPromptSubmit": [{
|
||||
"hooks": [{
|
||||
"type": "command",
|
||||
"command": "echo ready"
|
||||
}]
|
||||
}],
|
||||
"PreCompact": [{
|
||||
"matcher": "auto",
|
||||
"hooks": [{
|
||||
"type": "command",
|
||||
"command": "echo compact"
|
||||
}]
|
||||
}],
|
||||
"SubagentStart": [{
|
||||
"hooks": [{
|
||||
"type": "command",
|
||||
"command": "echo subagent"
|
||||
}]
|
||||
}]
|
||||
}
|
||||
})
|
||||
);
|
||||
assert_eq!(
|
||||
fs::read_to_string(rewritten_script).expect("copied hook script"),
|
||||
"echo check\n"
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user