| 106 | * Returns the temp HOME path. Caller is responsible for cleanup. |
| 107 | */ |
| 108 | export function installSkillToTempHome( |
| 109 | skillDir: string, |
| 110 | skillName: string, |
| 111 | tempHome?: string, |
| 112 | ): string { |
| 113 | const home = tempHome || fs.mkdtempSync(path.join(os.tmpdir(), 'codex-e2e-')); |
| 114 | const destDir = path.join(home, '.codex', 'skills', skillName); |
| 115 | fs.mkdirSync(destDir, { recursive: true }); |
| 116 | |
| 117 | const srcSkill = path.join(skillDir, 'SKILL.md'); |
| 118 | if (fs.existsSync(srcSkill)) { |
| 119 | fs.copyFileSync(srcSkill, path.join(destDir, 'SKILL.md')); |
| 120 | } |
| 121 | |
| 122 | const srcOpenAIYaml = path.join(skillDir, 'agents', 'openai.yaml'); |
| 123 | if (fs.existsSync(srcOpenAIYaml)) { |
| 124 | const destAgentsDir = path.join(destDir, 'agents'); |
| 125 | fs.mkdirSync(destAgentsDir, { recursive: true }); |
| 126 | fs.copyFileSync(srcOpenAIYaml, path.join(destAgentsDir, 'openai.yaml')); |
| 127 | } |
| 128 | |
| 129 | return home; |
| 130 | } |
| 131 | |
| 132 | // --- Main runner --- |
| 133 | |