markdown_exec 3.5.1 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/.ai-agent-instructions +54 -0
  3. data/.cursorrules +198 -0
  4. data/.rubocop.wide.yml +5 -0
  5. data/.rubocop.yml +7 -2
  6. data/CHANGELOG.md +19 -1
  7. data/Gemfile.lock +1 -1
  8. data/README.md +1 -1
  9. data/Rakefile +2 -0
  10. data/ai-principles.md +516 -0
  11. data/architecture-decisions.md +190 -0
  12. data/bats/block-hide.bats +1 -1
  13. data/bats/block-type-bash.bats +5 -5
  14. data/bats/block-type-link.bats +1 -1
  15. data/bats/block-type-opts.bats +3 -3
  16. data/bats/block-type-port.bats +2 -2
  17. data/bats/block-type-shell-context-eval.bats +48 -0
  18. data/bats/block-type-shell-require-ux.bats +2 -2
  19. data/bats/block-type-ux-allowed.bats +4 -4
  20. data/bats/block-type-ux-auto.bats +1 -1
  21. data/bats/block-type-ux-chained.bats +1 -1
  22. data/bats/block-type-ux-default.bats +1 -1
  23. data/bats/block-type-ux-echo-hash-transform.bats +1 -1
  24. data/bats/block-type-ux-echo-hash.bats +2 -2
  25. data/bats/block-type-ux-echo.bats +4 -4
  26. data/bats/block-type-ux-exec-hash-transform.bats +1 -1
  27. data/bats/block-type-ux-exec-hash.bats +2 -2
  28. data/bats/block-type-ux-exec.bats +1 -1
  29. data/bats/block-type-ux-force.bats +2 -2
  30. data/bats/block-type-ux-formats.bats +1 -1
  31. data/bats/block-type-ux-hidden.bats +1 -1
  32. data/bats/block-type-ux-invalid.bats +2 -2
  33. data/bats/block-type-ux-readonly.bats +1 -1
  34. data/bats/block-type-ux-require-chained.bats +2 -2
  35. data/bats/block-type-ux-require-context.bats +2 -2
  36. data/bats/block-type-ux-require.bats +3 -3
  37. data/bats/block-type-ux-required-variables.bats +1 -1
  38. data/bats/block-type-ux-row-format.bats +1 -1
  39. data/bats/block-type-ux-sources.bats +4 -4
  40. data/bats/block-type-ux-transform.bats +1 -1
  41. data/bats/block-type-vars.bats +3 -3
  42. data/bats/border.bats +1 -1
  43. data/bats/cli.bats +11 -11
  44. data/bats/command-substitution-options.bats +2 -2
  45. data/bats/command-substitution.bats +1 -1
  46. data/bats/document-shell.bats +3 -3
  47. data/bats/history.bats +5 -5
  48. data/bats/import-conflict.bats +1 -1
  49. data/bats/import-directive-line-continuation.bats +1 -1
  50. data/bats/import-directive-parameter-symbols.bats +1 -1
  51. data/bats/import-duplicates.bats +6 -6
  52. data/bats/import-parameter-symbols.bats +1 -1
  53. data/bats/import-with-text-substitution.bats +1 -1
  54. data/bats/import.bats +4 -4
  55. data/bats/indented-block-type-vars.bats +1 -1
  56. data/bats/indented-multi-line-output.bats +1 -1
  57. data/bats/line-decor-dynamic.bats +1 -1
  58. data/bats/line-wrapping.bats +1 -1
  59. data/bats/load-vars-state-demo.bats +8 -8
  60. data/bats/markup.bats +4 -4
  61. data/bats/mde.bats +4 -4
  62. data/bats/option-expansion.bats +1 -1
  63. data/bats/options-collapse.bats +4 -4
  64. data/bats/options.bats +47 -17
  65. data/bats/plain.bats +1 -1
  66. data/bats/publish.bats +2 -2
  67. data/bats/table-column-truncate.bats +1 -1
  68. data/bats/table.bats +2 -2
  69. data/bats/variable-expansion-multiline.bats +1 -1
  70. data/bats/variable-expansion.bats +6 -6
  71. data/bin/tab_completion.sh +3 -3
  72. data/conversation-template.md +611 -0
  73. data/docs/block-execution-modes.md +177 -0
  74. data/docs/block-filtering.md +252 -0
  75. data/docs/block-naming-patterns.md +210 -0
  76. data/docs/block-scanning-patterns.md +248 -0
  77. data/docs/cli-reference.md +370 -0
  78. data/docs/dev/bats-document-configuration.md +1 -1
  79. data/docs/dev/block-hide.md +1 -1
  80. data/docs/dev/block-type-shell-context-eval.md +52 -0
  81. data/docs/dev/block-type-shell-require-ux.md +6 -2
  82. data/docs/dev/block-type-ux-echo.md +3 -3
  83. data/docs/dev/block-type-ux-force.md +1 -1
  84. data/docs/dev/block-type-ux-require-chained.md +1 -1
  85. data/docs/dev/block-type-ux-require.md +2 -2
  86. data/docs/dev/block-type-ux-transform.md +5 -4
  87. data/docs/dev/import-parameter-symbols.md +1 -1
  88. data/docs/dev/linked-file.md +1 -1
  89. data/docs/dev/load-vars-state-demo.md +1 -1
  90. data/docs/dev/print_bytes.md +3 -0
  91. data/docs/dev/requiring-blocks.md +1 -1
  92. data/docs/dev/shebang.md +6 -0
  93. data/docs/dev/specs.md +2 -2
  94. data/docs/docker-testing.md +5 -0
  95. data/docs/execution-control.md +384 -0
  96. data/docs/getting-started.md +209 -0
  97. data/docs/import-options.md +391 -0
  98. data/docs/shell-script-evaluation.md +78 -0
  99. data/docs/tab-completion.md +7 -0
  100. data/docs/ux-blocks.md +376 -0
  101. data/examples/link-blocks-vars.md +2 -2
  102. data/examples/linked.md +1 -1
  103. data/examples/linked1.md +1 -1
  104. data/examples/opts-blocks.md +2 -2
  105. data/examples/port-blocks.md +1 -1
  106. data/examples/variable-expansion.md +1 -1
  107. data/implementation-decisions.md +212 -0
  108. data/lib/cached_nested_file_reader.rb +145 -5
  109. data/lib/command_result.rb +27 -6
  110. data/lib/executed_shell_command.rb +512 -0
  111. data/lib/filter.rb +7 -7
  112. data/lib/hash_delegator.rb +699 -605
  113. data/lib/input_sequencer.rb +4 -3
  114. data/lib/link_history.rb +95 -36
  115. data/lib/markdown_exec/version.rb +1 -1
  116. data/lib/mdoc.rb +138 -51
  117. data/lib/menu.src.yml +115 -88
  118. data/lib/menu.yml +154 -88
  119. data/lib/transformed_shell_command.rb +449 -0
  120. data/lib/wl.rb +15 -0
  121. data/lib/ww.rb +17 -6
  122. data/requirements.md +111 -0
  123. data/semantic-tokens.md +132 -0
  124. data/tasks.md +69 -0
  125. metadata +29 -4
  126. data/docs/ux-blocks-examples.md +0 -120
  127. data/docs/ux-blocks-init-act.md +0 -100
@@ -4,8 +4,8 @@ echo: $(basename `pwd`)
4
4
  name: VAR
5
5
  ```
6
6
  / This block is not visible. Execute to display the inherited lines for testing.
7
- ```opts :(menu_with_inherited_lines)
8
- menu_with_inherited_lines: true
7
+ ```opts :(menu_with_context_code)
8
+ menu_with_context_code: true
9
9
  ```
10
10
  / This block is not visible. Execute to set a new value, displayed by the block above.
11
11
  ```ux :(VAR_has_count)
@@ -22,6 +22,6 @@ echo: $VAR$VAR
22
22
  name: IAB
23
23
  ```
24
24
  ```opts :(document_opts)
25
- menu_with_inherited_lines: false
25
+ menu_with_context_code: false
26
26
  ```
27
27
  @import bats-document-configuration.md
@@ -15,6 +15,6 @@ name: Common_Name
15
15
  ! Common_Name! ${Common_Name}
16
16
  @import bats-document-configuration.md
17
17
  ```opts :(document_opts)
18
- dump_inherited_lines: true
18
+ dump_context_code: true
19
19
  table_center: false
20
20
  ```
@@ -28,6 +28,6 @@ init: false
28
28
  name: NAME2
29
29
  ```
30
30
  ```opts :(document_opts)
31
- menu_with_inherited_lines: true
31
+ menu_with_context_code: true
32
32
  ```
33
33
  @import bats-document-configuration.md
@@ -29,7 +29,7 @@ ENTITY='Pongo tapanuliensis,Pongo'
29
29
  ```
30
30
  /
31
31
  / This block is not visible. Execute to display the inherited lines for testing.
32
- ```opts :(menu_with_inherited_lines)
33
- menu_with_inherited_lines: true
32
+ ```opts :(menu_with_context_code)
33
+ menu_with_context_code: true
34
34
  ```
35
35
  @import bats-document-configuration.md
@@ -4,7 +4,7 @@
4
4
  exec: basename $(pwd)
5
5
  name: Var0
6
6
  ```
7
- $(echo -n "$Var0" | hexdump -v -e '16/1 " %02x"')
7
+ $(print_bytes "$Var0")
8
8
  :::
9
9
  **With validate and transform, output has no newline.**
10
10
  ```ux :[document_ux_transform_1]
@@ -13,7 +13,7 @@ name: Var1
13
13
  transform: '%{name}'
14
14
  validate: (?<name>.+)
15
15
  ```
16
- $(echo -n "$Var1" | hexdump -v -e '16/1 " %02x"')
16
+ $(print_bytes "$Var1")
17
17
  :::
18
18
  **With transform `:chomp`, output has no newline.**
19
19
  ```ux :[document_ux_transform_2]
@@ -21,7 +21,7 @@ exec: basename $(pwd)
21
21
  name: Var2
22
22
  transform: :chomp
23
23
  ```
24
- $(echo -n "$Var2" | hexdump -v -e '16/1 " %02x"')
24
+ $(print_bytes "$Var2")
25
25
  :::
26
26
  **With transform `:upcase`, output is in upper case w/ newline.**
27
27
  ```ux :[document_ux_transform_3]
@@ -29,8 +29,9 @@ exec: basename $(pwd)
29
29
  name: Var3
30
30
  transform: :upcase
31
31
  ```
32
- $(echo -n "$Var3" | hexdump -v -e '16/1 " %02x"')
32
+ $(print_bytes "$Var3")
33
33
  @import bats-document-configuration.md
34
+ @import print_bytes.md
34
35
  ```opts :(document_opts)
35
36
  divider4_collapsible: false
36
37
  screen_width: 80
@@ -10,5 +10,5 @@ name: COMMON_NAME
10
10
  NAMEV:vq=COMMON_NAME
11
11
  @import bats-document-configuration.md
12
12
  ```opts :(document_opts)
13
- dump_inherited_lines: false
13
+ dump_context_code: false
14
14
  ```
@@ -2,5 +2,5 @@
2
2
  echo "ARG1: $ARG1"
3
3
  ```
4
4
  ```opts :(document_opts)
5
- menu_with_inherited_lines: true
5
+ menu_with_context_code: true
6
6
  ```
@@ -28,7 +28,7 @@ mode: replace
28
28
  /
29
29
  @import bats-document-configuration.md
30
30
  ```opts :(document_opts)
31
- dump_inherited_lines: true
31
+ dump_context_code: true
32
32
  # menu_for_saved_lines: true
33
33
 
34
34
  screen_width: 64
@@ -0,0 +1,3 @@
1
+ ```bash :(document_shell)
2
+ print_bytes () { printf %s "$1" | hexdump -v -e '16/1 " %02x"' ; }
3
+ ```
@@ -21,5 +21,5 @@ echo "ARG1: $ARG1"
21
21
  @import bats-document-configuration.md
22
22
  ```opts :(document_opts)
23
23
  menu_with_exit: true
24
- menu_with_inherited_lines: true
24
+ menu_with_context_code: true
25
25
  ```
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env -S bin/bmde
2
+ Demonstrate opening the document via Shebang.
3
+ ```bash :print-test
4
+ echo Test
5
+ ```
6
+ @import bats-document-configuration.md
data/docs/dev/specs.md CHANGED
@@ -72,7 +72,7 @@ dump_blocks_in_file: false
72
72
  dump_dependencies: false
73
73
  dump_inherited_block_names: false
74
74
  dump_inherited_dependencies: false
75
- dump_inherited_lines: false
75
+ dump_context_code: false
76
76
  dump_menu_blocks: false
77
77
  ```
78
78
 
@@ -80,5 +80,5 @@ dump_menu_blocks: false
80
80
  ```opts :(document_opts) +(disable_dump_*)
81
81
  menu_note_color: 'plain'
82
82
  menu_with_exit: true
83
- menu_with_inherited_lines: false
83
+ menu_with_context_code: false
84
84
  ```
@@ -83,6 +83,11 @@ docker run --rm markdown-exec-test bundle exec rake minitest
83
83
  - **BATS Location**: `/markdown_exec/test/bats/bin/bats` (symlinked to `/usr/local/bin/bats`)
84
84
  - **Test Helpers**: Located in `/markdown_exec/test/test_helper/`
85
85
 
86
+ ## Related Documentation
87
+
88
+ - [Option Documentation Process](option-documentation-process.md) - Process for documenting options
89
+ - [Option Documentation Tasks](option-documentation-tasks.md) - Task list for documentation
90
+
86
91
  ## Troubleshooting
87
92
 
88
93
  ### Submodules not initialized
@@ -0,0 +1,384 @@
1
+ # Execution Control Options
2
+
3
+ This document describes options that control how scripts are executed, including approval requirements, execution modes, and flow control.
4
+
5
+ ## Overview
6
+
7
+ Execution control options allow you to:
8
+ - Require user approval before executing scripts
9
+ - Control where scripts execute (current terminal vs. new window)
10
+ - Pause execution flow for review
11
+ - Prevent accidental re-execution of the same block
12
+ - Display scripts before execution
13
+
14
+ These options provide safety and control mechanisms for script execution, especially useful when working with potentially destructive operations or when you need to review scripts before they run.
15
+
16
+ ## Configuration Options
17
+
18
+ ### `user-must-approve` / `-q`
19
+
20
+ - **Option**: `user_must_approve`
21
+ - **Long Name**: `--user-must-approve`
22
+ - **Short Name**: `-q`
23
+ - **Environment Variable**: `MDE_USER_MUST_APPROVE`
24
+ - **Argument**: `BOOL`
25
+ - **Default**: `false`
26
+ - **Description**: Requires user approval before executing a script
27
+
28
+ When enabled, displays the complete generated script (including all required dependencies) and prompts the user for confirmation before execution. This is a critical safety feature for reviewing scripts before they run.
29
+
30
+ **Usage:**
31
+ ```bash
32
+ mde my-document.md --user-must-approve 1
33
+ mde my-document.md -q 1
34
+ ```
35
+
36
+ **Examples:**
37
+ ```bash
38
+ # Require approval for all executions
39
+ mde README.md -b deploy --user-must-approve 1
40
+
41
+ # Set via environment variable
42
+ export MDE_USER_MUST_APPROVE=1
43
+ mde README.md -b deploy
44
+
45
+ # In configuration file
46
+ # .mde.yml
47
+ user_must_approve: true
48
+ ```
49
+
50
+ **Behavior:**
51
+ - The full script (including all required dependencies) is displayed
52
+ - User is prompted with "Process?" (configurable via `prompt_approve_block`)
53
+ - Execution only proceeds if user confirms (Yes/No)
54
+ - Works in both interactive menu mode and command-line mode
55
+ - When combined with `output_script`, the script is displayed regardless
56
+
57
+ **Related Options:**
58
+ - `output_script`: Display script before execution (doesn't require approval)
59
+ - `prompt_approve_block`: Customize the approval prompt text
60
+
61
+ ### `execute-in-own-window` / `-w`
62
+
63
+ - **Option**: `execute_in_own_window`
64
+ - **Long Name**: `--execute-in-own-window`
65
+ - **Short Name**: `-w`
66
+ - **Environment Variable**: `MDE_EXECUTE_IN_OWN_WINDOW`
67
+ - **Argument**: `BOOL`
68
+ - **Default**: `false`
69
+ - **Description**: Execute script in own window
70
+
71
+ When enabled, executes the script in a new terminal window (iTerm on macOS) instead of the current terminal. Useful for long-running scripts or when you want to keep the main terminal free for other operations.
72
+
73
+ **Usage:**
74
+ ```bash
75
+ mde my-document.md --execute-in-own-window 1
76
+ mde my-document.md -w 1
77
+ ```
78
+
79
+ **Examples:**
80
+ ```bash
81
+ # Execute in new window
82
+ mde README.md -b long-running-task -w 1
83
+
84
+ # Combine with approval
85
+ mde README.md -b deploy -q 1 -w 1
86
+
87
+ # Set via environment variable
88
+ export MDE_EXECUTE_IN_OWN_WINDOW=1
89
+ mde README.md -b deploy
90
+ ```
91
+
92
+ **Requirements:**
93
+ - Requires `execute_command_format` to be configured (defaults to AppleScript for iTerm on macOS)
94
+ - Script and output files must be saved before execution (handled automatically)
95
+ - Window title includes timestamp, document name, and block name
96
+
97
+ **Window Title Format:**
98
+ The window title uses `execute_command_title_time_format` (default: `"%T"`) and includes:
99
+ - Timestamp (formatted)
100
+ - Document filename
101
+ - Block name
102
+
103
+ **Customization:**
104
+ For other terminal emulators or platforms, customize `execute_command_format` to use different commands or scripts.
105
+
106
+ **Related Options:**
107
+ - `execute_command_format`: AppleScript or command template for window execution
108
+ - `execute_command_title_time_format`: Time format for window title
109
+
110
+ ### `output-script`
111
+
112
+ - **Option**: `output_script`
113
+ - **Long Name**: `--output-script`
114
+ - **Environment Variable**: `MDE_OUTPUT_SCRIPT`
115
+ - **Argument**: `BOOL`
116
+ - **Default**: `false`
117
+ - **Description**: Display script prior to execution
118
+
119
+ When enabled, displays the generated script (including all required dependencies) before execution, even if `user_must_approve` is disabled. Useful for debugging, reviewing what will be executed, or logging.
120
+
121
+ **Usage:**
122
+ ```bash
123
+ mde my-document.md --output-script 1
124
+ ```
125
+
126
+ **Examples:**
127
+ ```bash
128
+ # Display script before execution
129
+ mde README.md -b deploy --output-script 1
130
+
131
+ # Combine with approval for review
132
+ mde README.md -b deploy --output-script 1 --user-must-approve 1
133
+
134
+ # Set via environment variable
135
+ export MDE_OUTPUT_SCRIPT=1
136
+ mde README.md -b deploy
137
+ ```
138
+
139
+ **Behavior:**
140
+ - Script is displayed with frame markers (configurable via `script_preview_head` and `script_preview_tail`)
141
+ - Includes all required dependencies in execution order
142
+ - Execution proceeds automatically (unless `user_must_approve` is also enabled)
143
+ - Useful for debugging or understanding what will execute
144
+
145
+ **Related Options:**
146
+ - `user_must_approve`: Require approval after displaying script
147
+ - `script_preview_head`: Text displayed before script preview
148
+ - `script_preview_tail`: Text displayed after script preview
149
+ - `script_preview_frame_color`: Color for preview frame
150
+
151
+ ### `debounce-execution`
152
+
153
+ - **Option**: `debounce_execution`
154
+ - **Environment Variable**: `MDE_DEBOUNCE_EXECUTION`
155
+ - **Argument**: `BOOL`
156
+ - **Default**: `true`
157
+ - **Description**: Whether to prompt before re-executing the same block multiple times
158
+
159
+ When enabled, prevents accidental re-execution of the same block by prompting for confirmation if you try to execute a block that was just executed. This helps prevent accidental duplicate executions.
160
+
161
+ **Usage:**
162
+ ```bash
163
+ # Via environment variable (no CLI flag)
164
+ export MDE_DEBOUNCE_EXECUTION=0 # Disable
165
+ export MDE_DEBOUNCE_EXECUTION=1 # Enable (default)
166
+ ```
167
+
168
+ **Examples:**
169
+ ```bash
170
+ # Disable debouncing (allow immediate re-execution)
171
+ export MDE_DEBOUNCE_EXECUTION=0
172
+ mde README.md
173
+
174
+ # Enable debouncing (default behavior)
175
+ export MDE_DEBOUNCE_EXECUTION=1
176
+ mde README.md
177
+ ```
178
+
179
+ **Behavior:**
180
+ - When enabled, if you select the same block that was just executed, you're prompted with "Repeat this block?" (configurable via `prompt_debounce`)
181
+ - Blocks executed from CLI (via `--block-name`) bypass debouncing
182
+ - Debounce state is reset when navigating back or selecting different menu options
183
+ - Only applies to interactive menu selections, not CLI-specified blocks
184
+
185
+ **Related Options:**
186
+ - `prompt_debounce`: Customize the debounce prompt text
187
+
188
+ ### `pause-after-script-execution`
189
+
190
+ - **Option**: `pause_after_script_execution`
191
+ - **Long Name**: `--pause-after-script-execution`
192
+ - **Environment Variable**: `MDE_PAUSE_AFTER_SCRIPT_EXECUTION`
193
+ - **Argument**: `BOOL`
194
+ - **Default**: `false`
195
+ - **Description**: Whether to pause after manually executing a block and before the next menu
196
+
197
+ When enabled, pauses execution after a block completes and before displaying the next menu. Useful for reviewing execution results before continuing.
198
+
199
+ **Usage:**
200
+ ```bash
201
+ mde my-document.md --pause-after-script-execution 1
202
+ ```
203
+
204
+ **Examples:**
205
+ ```bash
206
+ # Pause after execution
207
+ mde README.md -b deploy --pause-after-script-execution 1
208
+
209
+ # Set via environment variable
210
+ export MDE_PAUSE_AFTER_SCRIPT_EXECUTION=1
211
+ mde README.md -b deploy
212
+
213
+ # In configuration file
214
+ # .mde.yml
215
+ pause_after_script_execution: true
216
+ ```
217
+
218
+ **Behavior:**
219
+ - After script execution completes, displays the prompt (configurable via `prompt_after_script_execution`, default: "\nContinue?")
220
+ - User must press Enter or respond to continue
221
+ - Useful for reviewing execution output before the menu reappears
222
+ - Works in interactive mode
223
+
224
+ **Related Options:**
225
+ - `prompt_after_script_execution`: Customize the pause prompt text
226
+ - `prompt_color_after_script_execution`: Color for the pause prompt
227
+
228
+ ### `execute-command-format`
229
+
230
+ - **Option**: `execute_command_format`
231
+ - **Environment Variable**: `MDE_EXECUTE_COMMAND_FORMAT`
232
+ - **Default**: AppleScript template for iTerm
233
+ - **Description**: AppleScript to execute a command in a window
234
+
235
+ Template string used when `execute_in_own_window` is enabled. The default is an AppleScript that creates a new iTerm window and executes the script there.
236
+
237
+ **Usage:**
238
+ ```bash
239
+ # Set via environment variable
240
+ export MDE_EXECUTE_COMMAND_FORMAT='your-custom-template'
241
+ ```
242
+
243
+ **Default Template:**
244
+ The default template uses AppleScript to:
245
+ 1. Create a new iTerm window
246
+ 2. Set environment variables for script and output files
247
+ 3. Change to the working directory
248
+ 4. Set the window title
249
+ 5. Execute the script with output redirected to a log file
250
+
251
+ **Customization:**
252
+ For other terminal emulators or platforms, customize this template to use different commands. The template supports format placeholders:
253
+ - `%{batch_index}`: Batch index
254
+ - `%{home}`: Working directory
255
+ - `%{output_filespec}`: Output file path
256
+ - `%{script_filespec}`: Script file path
257
+ - `%{started_at}`: Execution start time
258
+ - `%{document_filename}`: Document filename
259
+ - `%{block_name}`: Block name
260
+ - `%{rest}`: Additional arguments
261
+
262
+ **Related Options:**
263
+ - `execute_in_own_window`: Enable window execution
264
+ - `execute_command_title_time_format`: Time format for window title
265
+
266
+ ### `execute-command-title-time-format`
267
+
268
+ - **Option**: `execute_command_title_time_format`
269
+ - **Environment Variable**: `MDE_EXECUTE_COMMAND_TITLE_TIME_FORMAT`
270
+ - **Default**: `"%T"`
271
+ - **Description**: Format for time in window title
272
+
273
+ Time format string used in the window title when `execute_in_own_window` is enabled. Uses Ruby `Time#strftime` format.
274
+
275
+ **Usage:**
276
+ ```bash
277
+ # Set via environment variable
278
+ export MDE_EXECUTE_COMMAND_TITLE_TIME_FORMAT="%H:%M:%S"
279
+ ```
280
+
281
+ **Examples:**
282
+ ```bash
283
+ # 24-hour time
284
+ export MDE_EXECUTE_COMMAND_TITLE_TIME_FORMAT="%H:%M:%S"
285
+
286
+ # Full timestamp
287
+ export MDE_EXECUTE_COMMAND_TITLE_TIME_FORMAT="%Y-%m-%d %H:%M:%S"
288
+
289
+ # ISO 8601
290
+ export MDE_EXECUTE_COMMAND_TITLE_TIME_FORMAT="%FT%TZ"
291
+ ```
292
+
293
+ **Common Format Codes:**
294
+ - `%H`: Hour (00-23)
295
+ - `%M`: Minute (00-59)
296
+ - `%S`: Second (00-59)
297
+ - `%Y`: Year (4 digits)
298
+ - `%m`: Month (01-12)
299
+ - `%d`: Day (01-31)
300
+ - `%T`: Time (equivalent to `%H:%M:%S`)
301
+ - `%F`: Date (equivalent to `%Y-%m-%d`)
302
+
303
+ ## How It Works
304
+
305
+ ### Execution Flow
306
+
307
+ 1. **Script Generation**: The complete script is generated, including all required dependencies
308
+ 2. **Display Check**: If `output_script` or `user_must_approve` is enabled, the script is displayed
309
+ 3. **Approval Check**: If `user_must_approve` is enabled, user confirmation is required
310
+ 4. **Execution Mode**: Script executes either:
311
+ - In current terminal (default)
312
+ - In new window (if `execute_in_own_window` is enabled)
313
+ 5. **Post-Execution**: If `pause_after_script_execution` is enabled, execution pauses before menu
314
+
315
+ ### Debouncing Logic
316
+
317
+ The debouncing mechanism tracks the last executed block:
318
+ - If the same block is selected again, user is prompted
319
+ - Blocks executed from CLI bypass debouncing
320
+ - Debounce state resets on navigation or different block selection
321
+
322
+ ### Window Execution
323
+
324
+ When `execute_in_own_window` is enabled:
325
+ 1. Script is saved to a temporary file
326
+ 2. Output file path is determined
327
+ 3. `execute_command_format` template is populated with values
328
+ 4. Template is executed (typically AppleScript for iTerm)
329
+ 5. New window opens and executes the script
330
+
331
+ ## Usage Examples
332
+
333
+ ### Safe Execution with Approval
334
+
335
+ ```bash
336
+ # Require approval for all executions
337
+ mde README.md -b deploy --user-must-approve 1
338
+
339
+ # Or set globally
340
+ export MDE_USER_MUST_APPROVE=1
341
+ mde README.md -b deploy
342
+ ```
343
+
344
+ ### Review Script Before Execution
345
+
346
+ ```bash
347
+ # Display script and require approval
348
+ mde README.md -b deploy --output-script 1 --user-must-approve 1
349
+ ```
350
+
351
+ ### Long-Running Scripts in New Window
352
+
353
+ ```bash
354
+ # Execute in new window
355
+ mde README.md -b long-task --execute-in-own-window 1
356
+
357
+ # With approval
358
+ mde README.md -b long-task -q 1 -w 1
359
+ ```
360
+
361
+ ### Pause After Execution
362
+
363
+ ```bash
364
+ # Pause to review results
365
+ mde README.md -b deploy --pause-after-script-execution 1
366
+ ```
367
+
368
+ ### Configuration File Example
369
+
370
+ ```yaml
371
+ # .mde.yml
372
+ user_must_approve: true
373
+ output_script: true
374
+ pause_after_script_execution: true
375
+ execute_in_own_window: false
376
+ ```
377
+
378
+ ## Related Documentation
379
+
380
+ - [CLI Reference](cli-reference.md) - Command-line usage patterns
381
+ - [Block Execution Modes](block-execution-modes.md) - Batch, interactive, and default execution modes
382
+ - [Block Filtering](block-filtering.md) - Filtering and selecting blocks
383
+ - [Block Naming Patterns](block-naming-patterns.md) - How block names are parsed and matched
384
+