@@ -3,10 +3,10 @@ import { parseFrontmatter } from "./parse";
33import { parseCliArgs , handleMaCommands } from "./cli" ;
44import { substituteTemplateVars , extractTemplateVars } from "./template" ;
55import { isRemoteUrl , fetchRemote , cleanupRemote } from "./remote" ;
6- import { resolveCommand , buildArgs , runCommand , extractPositionalMappings , extractEnvVars , killCurrentChildProcess } from "./command" ;
6+ import { resolveCommand , buildArgs , runCommand , extractPositionalMappings , extractEnvVars , killCurrentChildProcess , hasInteractiveMarker } from "./command" ;
77import { expandImports , hasImports } from "./imports" ;
88import { loadEnvFiles } from "./env" ;
9- import { loadGlobalConfig , getCommandDefaults , applyDefaults } from "./config" ;
9+ import { loadGlobalConfig , getCommandDefaults , applyDefaults , applyInteractiveMode } from "./config" ;
1010import { initLogger , getParseLogger , getTemplateLogger , getCommandLogger , getImportLogger , getCurrentLogPath } from "./logger" ;
1111import { isDomainTrusted , promptForTrust , addTrustedDomain , extractDomain } from "./trust" ;
1212import { dirname , resolve } from "path" ;
@@ -236,7 +236,13 @@ async function main() {
236236 // Load global config and apply command defaults
237237 await loadGlobalConfig ( ) ;
238238 const commandDefaults = await getCommandDefaults ( command ) ;
239- const frontmatter = applyDefaults ( baseFrontmatter , commandDefaults ) ;
239+ let frontmatter = applyDefaults ( baseFrontmatter , commandDefaults ) ;
240+
241+ // Check for .i. interactive marker in filename
242+ const interactiveFromFilename = hasInteractiveMarker ( localFilePath ) ;
243+
244+ // Apply $interactive mode transformations (converts print defaults to interactive mode per command)
245+ frontmatter = applyInteractiveMode ( frontmatter , command , interactiveFromFilename ) ;
240246
241247 // Extract and apply environment variables (object form) to process.env
242248 // This must happen BEFORE import expansion so !`command` inlines can use them
@@ -377,21 +383,27 @@ async function main() {
377383 console . log ( "═══════════════════════════════════════════════════════════\n" ) ;
378384
379385 // Build final args with positional mappings applied (same as runCommand)
380- const finalArgs = [ ...args ] ;
386+ let dryRunArgs = [ ...args ] ;
387+
388+ // Handle codex $exec: prepend 'exec' to args
389+ if ( frontmatter . $exec && command === "codex" ) {
390+ dryRunArgs = [ "exec" , ...dryRunArgs ] ;
391+ }
392+
381393 for ( let i = 0 ; i < positionals . length ; i ++ ) {
382394 const pos = i + 1 ;
383395 const value = positionals [ i ] ;
384396 if ( positionalMappings . has ( pos ) ) {
385397 const flagName = positionalMappings . get ( pos ) ! ;
386398 const flag = flagName . length === 1 ? `-${ flagName } ` : `--${ flagName } ` ;
387- finalArgs . push ( flag , `"${ value . replace ( / " / g, '\\"' ) } "` ) ;
399+ dryRunArgs . push ( flag , `"${ value . replace ( / " / g, '\\"' ) } "` ) ;
388400 } else {
389- finalArgs . push ( `"${ value . replace ( / " / g, '\\"' ) } "` ) ;
401+ dryRunArgs . push ( `"${ value . replace ( / " / g, '\\"' ) } "` ) ;
390402 }
391403 }
392404
393405 console . log ( "Command:" ) ;
394- console . log ( ` ${ command } ${ finalArgs . join ( " " ) } \n` ) ;
406+ console . log ( ` ${ command } ${ dryRunArgs . join ( " " ) } \n` ) ;
395407
396408 console . log ( "Final Prompt:" ) ;
397409 console . log ( "───────────────────────────────────────────────────────────" ) ;
@@ -443,11 +455,18 @@ async function main() {
443455 }
444456 }
445457
446- getCommandLogger ( ) . info ( { command, argsCount : args . length , promptLength : finalBody . length } , "Executing command" ) ;
458+ // Handle codex $exec: prepend 'exec' to args (codex exec is the non-interactive subcommand)
459+ let finalCommand = command ;
460+ let finalRunArgs = args ;
461+ if ( frontmatter . $exec && command === "codex" ) {
462+ finalRunArgs = [ "exec" , ...args ] ;
463+ }
464+
465+ getCommandLogger ( ) . info ( { command : finalCommand , argsCount : finalRunArgs . length , promptLength : finalBody . length } , "Executing command" ) ;
447466
448467 const runResult = await runCommand ( {
449- command,
450- args,
468+ command : finalCommand ,
469+ args : finalRunArgs ,
451470 positionals,
452471 positionalMappings,
453472 captureOutput : false ,
0 commit comments