@@ -151,6 +151,7 @@ export const PRETTY_PRINT = Boolean(process.env["PRETTY_PRINT"] || "");
151
151
export const PROJECT_DOC_MAX_BYTES = 32 * 1024 ; // 32 kB
152
152
153
153
const PROJECT_DOC_FILENAMES = [ "codex.md" , ".codex.md" , "CODEX.md" ] ;
154
+ const PROJECT_DOC_SEPARATOR = "\n\n--- project-doc ---\n\n" ;
154
155
155
156
export function discoverProjectDocPath ( startDir : string ) : string | null {
156
157
const cwd = resolvePath ( startDir ) ;
@@ -305,7 +306,7 @@ export const loadConfig = (
305
306
306
307
const combinedInstructions = [ userInstructions , projectDoc ]
307
308
. filter ( ( s ) => s && s . trim ( ) !== "" )
308
- . join ( "\n\n--- project-doc ---\n\n" ) ;
309
+ . join ( PROJECT_DOC_SEPARATOR ) ;
309
310
310
311
// Treat empty string ("" or whitespace) as absence so we can fall back to
311
312
// the latest DEFAULT_MODEL.
@@ -456,5 +457,10 @@ export const saveConfig = (
456
457
writeFileSync ( targetPath , JSON . stringify ( configToSave , null , 2 ) , "utf-8" ) ;
457
458
}
458
459
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
+ }
460
466
} ;
0 commit comments