Skip to content

Commit c6cd76c

Browse files
committed
fix: instructions save
1 parent 146a61b commit c6cd76c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

codex-cli/src/utils/config.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ export const PRETTY_PRINT = Boolean(process.env["PRETTY_PRINT"] || "");
151151
export const PROJECT_DOC_MAX_BYTES = 32 * 1024; // 32 kB
152152

153153
const PROJECT_DOC_FILENAMES = ["codex.md", ".codex.md", "CODEX.md"];
154+
const PROJECT_DOC_SEPARATOR = "\n\n--- project-doc ---\n\n";
154155

155156
export function discoverProjectDocPath(startDir: string): string | null {
156157
const cwd = resolvePath(startDir);
@@ -305,7 +306,7 @@ export const loadConfig = (
305306

306307
const combinedInstructions = [userInstructions, projectDoc]
307308
.filter((s) => s && s.trim() !== "")
308-
.join("\n\n--- project-doc ---\n\n");
309+
.join(PROJECT_DOC_SEPARATOR);
309310

310311
// Treat empty string ("" or whitespace) as absence so we can fall back to
311312
// the latest DEFAULT_MODEL.
@@ -456,5 +457,10 @@ export const saveConfig = (
456457
writeFileSync(targetPath, JSON.stringify(configToSave, null, 2), "utf-8");
457458
}
458459

459-
writeFileSync(instructionsPath, config.instructions, "utf-8");
460+
if (config.instructions.includes(PROJECT_DOC_SEPARATOR)) {
461+
const userInstructions = config.instructions.split(PROJECT_DOC_SEPARATOR)[0];
462+
if (userInstructions !== undefined) {
463+
writeFileSync(instructionsPath, userInstructions, "utf-8");
464+
}
465+
}
460466
};

0 commit comments

Comments
 (0)