markdown_exec 3.5.1 → 3.5.2

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 (105) 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 +12 -1
  7. data/Gemfile.lock +1 -1
  8. data/Rakefile +2 -0
  9. data/ai-principles.md +516 -0
  10. data/architecture-decisions.md +190 -0
  11. data/bats/block-hide.bats +1 -1
  12. data/bats/block-type-bash.bats +5 -5
  13. data/bats/block-type-link.bats +1 -1
  14. data/bats/block-type-opts.bats +3 -3
  15. data/bats/block-type-port.bats +2 -2
  16. data/bats/block-type-shell-require-ux.bats +2 -2
  17. data/bats/block-type-ux-allowed.bats +4 -4
  18. data/bats/block-type-ux-auto.bats +1 -1
  19. data/bats/block-type-ux-chained.bats +1 -1
  20. data/bats/block-type-ux-default.bats +1 -1
  21. data/bats/block-type-ux-echo-hash-transform.bats +1 -1
  22. data/bats/block-type-ux-echo-hash.bats +2 -2
  23. data/bats/block-type-ux-echo.bats +3 -3
  24. data/bats/block-type-ux-exec-hash-transform.bats +1 -1
  25. data/bats/block-type-ux-exec-hash.bats +2 -2
  26. data/bats/block-type-ux-exec.bats +1 -1
  27. data/bats/block-type-ux-force.bats +1 -1
  28. data/bats/block-type-ux-formats.bats +1 -1
  29. data/bats/block-type-ux-hidden.bats +1 -1
  30. data/bats/block-type-ux-invalid.bats +1 -1
  31. data/bats/block-type-ux-readonly.bats +1 -1
  32. data/bats/block-type-ux-require-chained.bats +2 -2
  33. data/bats/block-type-ux-require-context.bats +2 -2
  34. data/bats/block-type-ux-require.bats +2 -2
  35. data/bats/block-type-ux-required-variables.bats +1 -1
  36. data/bats/block-type-ux-row-format.bats +1 -1
  37. data/bats/block-type-ux-sources.bats +4 -4
  38. data/bats/block-type-ux-transform.bats +1 -1
  39. data/bats/block-type-vars.bats +3 -3
  40. data/bats/border.bats +1 -1
  41. data/bats/cli.bats +11 -11
  42. data/bats/command-substitution-options.bats +2 -2
  43. data/bats/command-substitution.bats +1 -1
  44. data/bats/document-shell.bats +1 -1
  45. data/bats/history.bats +5 -5
  46. data/bats/import-conflict.bats +1 -1
  47. data/bats/import-directive-line-continuation.bats +1 -1
  48. data/bats/import-directive-parameter-symbols.bats +1 -1
  49. data/bats/import-duplicates.bats +6 -6
  50. data/bats/import-parameter-symbols.bats +1 -1
  51. data/bats/import-with-text-substitution.bats +1 -1
  52. data/bats/import.bats +3 -3
  53. data/bats/indented-block-type-vars.bats +1 -1
  54. data/bats/indented-multi-line-output.bats +1 -1
  55. data/bats/line-decor-dynamic.bats +1 -1
  56. data/bats/line-wrapping.bats +1 -1
  57. data/bats/load-vars-state-demo.bats +4 -4
  58. data/bats/markup.bats +4 -4
  59. data/bats/mde.bats +4 -4
  60. data/bats/option-expansion.bats +1 -1
  61. data/bats/options-collapse.bats +4 -4
  62. data/bats/options.bats +47 -17
  63. data/bats/plain.bats +1 -1
  64. data/bats/publish.bats +2 -2
  65. data/bats/table-column-truncate.bats +1 -1
  66. data/bats/table.bats +2 -2
  67. data/bats/variable-expansion-multiline.bats +1 -1
  68. data/bats/variable-expansion.bats +6 -6
  69. data/conversation-template.md +611 -0
  70. data/docs/block-execution-modes.md +177 -0
  71. data/docs/block-filtering.md +252 -0
  72. data/docs/block-naming-patterns.md +210 -0
  73. data/docs/block-scanning-patterns.md +248 -0
  74. data/docs/cli-reference.md +370 -0
  75. data/docs/dev/block-hide.md +1 -1
  76. data/docs/dev/block-type-ux-transform.md +5 -4
  77. data/docs/dev/print_bytes.md +3 -0
  78. data/docs/dev/shebang.md +6 -0
  79. data/docs/docker-testing.md +5 -0
  80. data/docs/execution-control.md +384 -0
  81. data/docs/getting-started.md +209 -0
  82. data/docs/import-options.md +391 -0
  83. data/docs/tab-completion.md +7 -0
  84. data/docs/ux-blocks.md +376 -0
  85. data/examples/linked1.md +8 -1
  86. data/implementation-decisions.md +212 -0
  87. data/lib/cached_nested_file_reader.rb +138 -1
  88. data/lib/command_result.rb +27 -6
  89. data/lib/executed_shell_command.rb +512 -0
  90. data/lib/filter.rb +7 -7
  91. data/lib/hash_delegator.rb +403 -350
  92. data/lib/link_history.rb +22 -11
  93. data/lib/markdown_exec/version.rb +1 -1
  94. data/lib/mdoc.rb +103 -44
  95. data/lib/menu.src.yml +110 -83
  96. data/lib/menu.yml +149 -83
  97. data/lib/transformed_shell_command.rb +449 -0
  98. data/lib/wl.rb +15 -0
  99. data/lib/ww.rb +16 -5
  100. data/requirements.md +111 -0
  101. data/semantic-tokens.md +132 -0
  102. data/tasks.md +69 -0
  103. metadata +26 -4
  104. data/docs/ux-blocks-examples.md +0 -120
  105. data/docs/ux-blocks-init-act.md +0 -100
@@ -0,0 +1,132 @@
1
+ # Semantic Tokens
2
+
3
+ **STDD Methodology Version**: 1.0.0
4
+
5
+ ## Overview
6
+ This document defines semantic tokens (keywords, identifiers, and concepts) that tie together all documentation, code, and tests. These tokens provide a consistent vocabulary for discussing the system.
7
+
8
+ ## Token Format
9
+
10
+ ```
11
+ [TYPE:IDENTIFIER]
12
+ ```
13
+
14
+ ## Token Types
15
+
16
+ - `[REQ:*]` - Requirements (functional/non-functional) - **The source of intent**
17
+ - `[ARCH:*]` - Architecture decisions - **High-level design choices that preserve intent**
18
+ - `[IMPL:*]` - Implementation decisions - **Low-level choices that preserve intent**
19
+ - `[TEST:*]` - Test specifications - **Validation of intent**
20
+
21
+ ## Token Naming Convention
22
+
23
+ - Use UPPER_SNAKE_CASE for identifiers
24
+ - Be descriptive but concise
25
+ - Example: `[REQ:DUPLICATE_PREVENTION]` not `[REQ:DP]`
26
+
27
+ ## Cross-Reference Format
28
+
29
+ When referencing other tokens:
30
+
31
+ ```markdown
32
+ [IMPL:EXAMPLE] Description [ARCH:DESIGN] [REQ:REQUIREMENT]
33
+ ```
34
+
35
+ ## Requirements Tokens
36
+
37
+ ### Core Functionality
38
+ - `[REQ:SHEBANG_HIDING]` - CLI option to hide shebang lines in document output (default enabled)
39
+ - `[REQ:EXAMPLE_FEATURE]` - Example feature requirement
40
+ - Add your requirements tokens here
41
+
42
+ ### Non-Functional Requirements
43
+ - `[REQ:PERFORMANCE]` - Performance requirements
44
+ - `[REQ:RELIABILITY]` - Reliability requirements
45
+ - `[REQ:MAINTAINABILITY]` - Maintainability requirements
46
+ - `[REQ:USABILITY]` - Usability requirements
47
+
48
+ ## Architecture Tokens
49
+
50
+ ### Core Architecture Decisions
51
+ - `[ARCH:LANGUAGE_SELECTION]` - Language and runtime selection
52
+ - `[ARCH:PROJECT_STRUCTURE]` - Project structure decision
53
+ - `[ARCH:SHEBANG_EXTRACTION]` - Extract shebang lines during cached nested read [REQ:SHEBANG_HIDING]
54
+ - `[ARCH:CLI_OPTION_DESIGN]` - CLI option design for shebang hiding [REQ:SHEBANG_HIDING]
55
+ - `[ARCH:EXAMPLE_DECISION]` - Example architecture decision [REQ:EXAMPLE_FEATURE]
56
+ - Add your architecture tokens here
57
+
58
+ ## Implementation Tokens
59
+
60
+ ### Core Implementation Decisions
61
+ - `[IMPL:CONFIG_STRUCT]` - Configuration structure implementation [ARCH:CONFIG_STRUCTURE] [REQ:CONFIGURATION]
62
+ - `[IMPL:SHEBANG_DETECTION]` - Shebang line detection logic [ARCH:SHEBANG_EXTRACTION] [REQ:SHEBANG_HIDING]
63
+ - `[IMPL:SHEBANG_FILTERING]` - Filter shebang lines from processed output [ARCH:SHEBANG_EXTRACTION] [REQ:SHEBANG_HIDING]
64
+ - `[IMPL:CLI_OPTION_IMPLEMENTATION]` - CLI option implementation in menu system [ARCH:CLI_OPTION_DESIGN] [REQ:SHEBANG_HIDING]
65
+ - `[IMPL:EXAMPLE_IMPLEMENTATION]` - Example implementation [ARCH:EXAMPLE_DECISION] [REQ:EXAMPLE_FEATURE]
66
+ - Add your implementation tokens here
67
+
68
+ ## Test Tokens
69
+
70
+ ### Test Specifications
71
+ - `[TEST:SHELL_COMMAND]` - Comprehensive test suite for ShellCommand class covering execution, memoization, outputs, metadata, and edge cases
72
+ - Add your test tokens here
73
+
74
+ ## Token Relationships
75
+
76
+ ### Hierarchical Relationships
77
+ - `[REQ:PARENT_FEATURE]` contains `[REQ:SUB_FEATURE_1]`, `[REQ:SUB_FEATURE_2]`
78
+ - `[ARCH:FEATURE]` includes `[ARCH:COMPONENT_1]`, `[ARCH:COMPONENT_2]`
79
+
80
+ ### Flow Relationships
81
+ - `[REQ:FEATURE]` → `[ARCH:DESIGN]` → `[IMPL:IMPLEMENTATION]` → Code + Tests
82
+
83
+ ### Dependency Relationships
84
+ - `[IMPL:FEATURE]` depends on `[ARCH:DESIGN]` and `[REQ:FEATURE]`
85
+ - `[ARCH:DESIGN]` depends on `[REQ:FEATURE]`
86
+
87
+ ## Usage Examples
88
+
89
+ ### In Code Comments
90
+ ```[your-language]
91
+ // [REQ:EXAMPLE_FEATURE] Implementation of example feature
92
+ // [IMPL:EXAMPLE_IMPLEMENTATION] [ARCH:EXAMPLE_DECISION] [REQ:EXAMPLE_FEATURE]
93
+ function exampleFunction() {
94
+ // ...
95
+ }
96
+ ```
97
+
98
+ ### In Tests
99
+ ```[your-language]
100
+ // Test validates [REQ:EXAMPLE_FEATURE] is met
101
+ func TestExampleFeature_REQ_EXAMPLE_FEATURE(t *testing.T) {
102
+ // ...
103
+ }
104
+ ```
105
+
106
+ ### In Documentation
107
+ ```markdown
108
+ The feature uses [ARCH:EXAMPLE_DECISION] to fulfill [REQ:EXAMPLE_FEATURE].
109
+ Implementation details are documented in [IMPL:EXAMPLE_IMPLEMENTATION].
110
+ ```
111
+
112
+ ## Token Index by Category
113
+
114
+ ### Requirements
115
+ - `[REQ:SHEBANG_HIDING]` - CLI option to hide shebang lines in document output
116
+ - Add your requirement tokens here
117
+
118
+ ### Architecture
119
+ - `[ARCH:SHEBANG_EXTRACTION]` - Extract shebang lines during cached nested read
120
+ - `[ARCH:CLI_OPTION_DESIGN]` - CLI option design for shebang hiding
121
+ - Add your architecture tokens here
122
+
123
+ ### Implementation
124
+ - `[IMPL:SHEBANG_DETECTION]` - Shebang line detection logic
125
+ - `[IMPL:SHEBANG_FILTERING]` - Filter shebang lines from processed output
126
+ - `[IMPL:CLI_OPTION_IMPLEMENTATION]` - CLI option implementation in menu system
127
+ - Add your implementation tokens here
128
+
129
+ ### Tests
130
+ - `[TEST:SHELL_COMMAND]` - Comprehensive test suite for ExecutedShellCommand class
131
+ - Add your test tokens here
132
+
data/tasks.md ADDED
@@ -0,0 +1,69 @@
1
+ # Tasks and Incomplete Subtasks
2
+
3
+ **STDD Methodology Version**: 1.0.0
4
+
5
+ ## Overview
6
+ This document tracks all tasks and subtasks for implementing your project. Tasks are organized by priority and implementation phase.
7
+
8
+ ## Priority Levels
9
+
10
+ - **P0 (Critical)**: Must have - Core functionality, blocks other work
11
+ - **P1 (Important)**: Should have - Enhanced functionality, better error handling
12
+ - **P2 (Nice-to-Have)**: Could have - UI/UX improvements, convenience features
13
+ - **P3 (Future)**: Won't have now - Deferred features, experimental ideas
14
+
15
+ ## Task Format
16
+
17
+ ```markdown
18
+ ## P0: Task Name [REQ:IDENTIFIER] [ARCH:IDENTIFIER] [IMPL:IDENTIFIER]
19
+
20
+ **Status**: 🟡 In Progress | ✅ Complete | ⏸️ Blocked | ⏳ Pending
21
+
22
+ **Description**: Brief description of what this task accomplishes.
23
+
24
+ **Dependencies**: List of other tasks/tokens this depends on.
25
+
26
+ **Subtasks**:
27
+ - [ ] Subtask 1 [REQ:X] [IMPL:Y]
28
+ - [ ] Subtask 2 [REQ:X] [IMPL:Z]
29
+ - [ ] Subtask 3 [TEST:X]
30
+
31
+ **Completion Criteria**:
32
+ - [ ] All subtasks complete
33
+ - [ ] Code implements requirement
34
+ - [ ] Tests pass with semantic token references
35
+ - [ ] Documentation updated
36
+
37
+ **Priority Rationale**: Why this is P0/P1/P2/P3
38
+ ```
39
+
40
+ ## P1: Implement CLI Option for Hiding Shebang Lines [REQ:SHEBANG_HIDING] [ARCH:CLI_OPTION_DESIGN] [ARCH:SHEBANG_EXTRACTION] [IMPL:CLI_OPTION_IMPLEMENTATION] [IMPL:SHEBANG_DETECTION] [IMPL:SHEBANG_FILTERING]
41
+
42
+ **Status**: ✅ Complete
43
+
44
+ **Description**: Implement CLI option `hide_shebang` (default: true) that extracts and hides shebang lines from document output during cached nested read process.
45
+
46
+ **Dependencies**: None
47
+
48
+ **Subtasks**:
49
+ - [x] Add `hide_shebang` option to `lib/menu.src.yml` [IMPL:CLI_OPTION_IMPLEMENTATION] [ARCH:CLI_OPTION_DESIGN] [REQ:SHEBANG_HIDING]
50
+ - [x] Implement shebang detection logic in `CachedNestedFileReader` [IMPL:SHEBANG_DETECTION] [ARCH:SHEBANG_EXTRACTION] [REQ:SHEBANG_HIDING]
51
+ - [x] Implement shebang filtering logic in `CachedNestedFileReader#readlines` [IMPL:SHEBANG_FILTERING] [ARCH:SHEBANG_EXTRACTION] [REQ:SHEBANG_HIDING]
52
+ - [x] Pass `hide_shebang` option from `MarkParse` to `CachedNestedFileReader` [IMPL:CLI_OPTION_IMPLEMENTATION] [ARCH:SHEBANG_EXTRACTION] [REQ:SHEBANG_HIDING]
53
+ - [x] Write unit tests for shebang detection [REQ:SHEBANG_HIDING]
54
+ - [x] Write unit tests for shebang filtering [REQ:SHEBANG_HIDING]
55
+ - [x] Write integration tests for CLI option behavior [REQ:SHEBANG_HIDING]
56
+ - [x] Write integration tests for nested imports with shebang lines [REQ:SHEBANG_HIDING]
57
+ - [x] Update CLI documentation to include new option [REQ:SHEBANG_HIDING]
58
+
59
+ **Completion Criteria**:
60
+ - [x] All subtasks complete
61
+ - [x] Code implements [REQ:SHEBANG_HIDING]
62
+ - [x] Tests pass with semantic token references
63
+ - [x] Documentation updated
64
+ - [x] Option defaults to enabled (true)
65
+ - [x] Option works with nested imports
66
+ - [x] Option accessible via CLI flag and environment variable
67
+
68
+ **Priority Rationale**: P1 (Important) - Enhances document processing functionality and improves user experience by hiding execution directives from document output. Not critical for core functionality but important for professional document presentation.
69
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdown_exec
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.1
4
+ version: 3.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fareed Stevenson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-11-14 00:00:00.000000000 Z
11
+ date: 2025-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard
@@ -91,8 +91,11 @@ executables:
91
91
  extensions: []
92
92
  extra_rdoc_files: []
93
93
  files:
94
+ - ".ai-agent-instructions"
95
+ - ".cursorrules"
94
96
  - ".pryrc"
95
97
  - ".reek"
98
+ - ".rubocop.wide.yml"
96
99
  - ".rubocop.yml"
97
100
  - CHANGELOG.md
98
101
  - CODE_OF_CONDUCT.md
@@ -102,6 +105,8 @@ files:
102
105
  - LICENSE.txt
103
106
  - README.md
104
107
  - Rakefile
108
+ - ai-principles.md
109
+ - architecture-decisions.md
105
110
  - assets/approve_code.png
106
111
  - assets/example_blocks.png
107
112
  - assets/output_of_execution.png
@@ -177,8 +182,14 @@ files:
177
182
  - bin/setup
178
183
  - bin/tab_completion.sh
179
184
  - bin/tab_completion.sh.erb
185
+ - conversation-template.md
180
186
  - demo/trap.demo1.gif
181
187
  - demo/trap.demo1.mp4
188
+ - docs/block-execution-modes.md
189
+ - docs/block-filtering.md
190
+ - docs/block-naming-patterns.md
191
+ - docs/block-scanning-patterns.md
192
+ - docs/cli-reference.md
182
193
  - docs/dev/bats-document-configuration.md
183
194
  - docs/dev/block-hide.md
184
195
  - docs/dev/block-type-bash.md
@@ -258,8 +269,10 @@ files:
258
269
  - docs/dev/option-expansion.md
259
270
  - docs/dev/options-collapse.md
260
271
  - docs/dev/pass-through-arguments.md
272
+ - docs/dev/print_bytes.md
261
273
  - docs/dev/requiring-blocks.md
262
274
  - docs/dev/screen-width.md
275
+ - docs/dev/shebang.md
263
276
  - docs/dev/specs-import.md
264
277
  - docs/dev/specs.md
265
278
  - docs/dev/table-column-truncate.md
@@ -269,9 +282,11 @@ files:
269
282
  - docs/dev/variable-expansion-multiline.md
270
283
  - docs/dev/variable-expansion.md
271
284
  - docs/docker-testing.md
285
+ - docs/execution-control.md
286
+ - docs/getting-started.md
287
+ - docs/import-options.md
272
288
  - docs/tab-completion.md
273
- - docs/ux-blocks-examples.md
274
- - docs/ux-blocks-init-act.md
289
+ - docs/ux-blocks.md
275
290
  - examples/bash-blocks.md
276
291
  - examples/block-names.md
277
292
  - examples/block-types.md
@@ -323,6 +338,7 @@ files:
323
338
  - examples/variable-expansion.md
324
339
  - examples/vars-blocks.md
325
340
  - examples/wrapped-blocks.md
341
+ - implementation-decisions.md
326
342
  - lib/ansi_formatter.rb
327
343
  - lib/ansi_string.rb
328
344
  - lib/argument_processor.rb
@@ -345,6 +361,7 @@ files:
345
361
  - lib/error_reporting.rb
346
362
  - lib/evaluate_shell_expressions.rb
347
363
  - lib/exceptions.rb
364
+ - lib/executed_shell_command.rb
348
365
  - lib/fcb.rb
349
366
  - lib/filter.rb
350
367
  - lib/find_files.rb
@@ -381,8 +398,13 @@ files:
381
398
  - lib/table_extractor.rb
382
399
  - lib/tap.rb
383
400
  - lib/text_analyzer.rb
401
+ - lib/transformed_shell_command.rb
384
402
  - lib/value_or_exception.rb
403
+ - lib/wl.rb
385
404
  - lib/ww.rb
405
+ - requirements.md
406
+ - semantic-tokens.md
407
+ - tasks.md
386
408
  homepage: https://rubygems.org/gems/markdown_exec
387
409
  licenses:
388
410
  - MIT
@@ -1,120 +0,0 @@
1
- # UX Block Examples
2
-
3
- This file contains a collection of unique UX block examples from the documentation.
4
-
5
- ## Basic Examples
6
-
7
- ### Simple Variable Display and Edit
8
- ```ux
9
- init: Guest
10
- name: USER_NAME
11
- prompt: Enter your name
12
- ```
13
-
14
- ### Command Output Initialization
15
- ```ux
16
- name: CURRENT_DIR
17
- init: :exec
18
- exec: basename $(pwd)
19
- transform: :chomp
20
- ```
21
-
22
- ### Echo-based Initialization
23
- ```ux
24
- name: SHELL_VERSION
25
- init: :echo
26
- echo: $SHELL
27
- ```
28
-
29
- ### Selection from Allowed Values
30
- ```ux
31
- name: ENVIRONMENT
32
- allow:
33
- - development
34
- - staging
35
- - production
36
- prompt: Select environment
37
- ```
38
-
39
- ## Validation Examples
40
-
41
- ### Email Validation
42
- ```ux
43
- name: USER_EMAIL
44
- prompt: Enter email address
45
- validate: '(?<local>[^@]+)@(?<domain>[^@]+)'
46
- transform: '%{local}@%{domain}'
47
- ```
48
-
49
- ### Version Number Validation
50
- ```ux
51
- name: VERSION
52
- prompt: Enter version number
53
- validate: '(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)'
54
- transform: '%{major}.%{minor}.%{patch}'
55
- ```
56
-
57
- ## Complex Examples
58
-
59
- ### Git Branch Selection with Validation
60
- ```ux
61
- name: BRANCH_NAME
62
- init: ":exec"
63
- exec: "git branch --format='%(refname:short)'"
64
- validate: '^(?<type>feature|bugfix|hotfix)/(?<ticket>[A-Z]+-\d+)-(?<desc>.+)$'
65
- transform: "${type}/${ticket}-${desc}"
66
- prompt: "Select or enter branch name"
67
- ```
68
-
69
- ### Environment Configuration with Dependencies
70
- ```ux
71
- name: DATABASE_URL
72
- require:
73
- - ENVIRONMENT
74
- - DB_HOST
75
- - DB_PORT
76
- format: "postgresql://${DB_USER}:${DB_PASS}@${DB_HOST}:${DB_PORT}/${DB_NAME}"
77
- ```
78
-
79
- ### Multi-step Configuration
80
- ```ux
81
- name: DEPLOY_CONFIG
82
- require:
83
- - ENVIRONMENT
84
- - VERSION
85
- init: ":echo"
86
- echo: "Deploying ${VERSION} to ${ENVIRONMENT}"
87
- act: ":exec"
88
- exec: "deploy.sh ${ENVIRONMENT} ${VERSION}"
89
- ```
90
-
91
- ### Conditional Initialization
92
- ```ux
93
- name: API_KEY
94
- init: ":allow"
95
- allow:
96
- - ${PROD_API_KEY}
97
- - ${STAGING_API_KEY}
98
- - ${DEV_API_KEY}
99
- require:
100
- - ENVIRONMENT
101
- ```
102
-
103
- ### Formatted Output with Validation
104
- ```ux
105
- name: PHONE_NUMBER
106
- prompt: "Enter phone number"
107
- validate: '(?<country>\d{1,3})(?<area>\d{3})(?<number>\d{7})'
108
- transform: "+${country} (${area}) ${number}"
109
- format: "Phone: ${PHONE_NUMBER}"
110
- ```
111
-
112
- ### Command Output with Transformation
113
- ```ux
114
- name: GIT_STATUS
115
- init: ":exec"
116
- exec: "git status --porcelain"
117
- validate: '(?<status>[AMDR])\s+(?<file>.+)'
118
- transform: "${status}: ${file}"
119
- format: "Changes: ${GIT_STATUS}"
120
- ```
@@ -1,100 +0,0 @@
1
- # UX Block Init and Act Keys
2
-
3
- The `init` and `act` keys determine which other key is read for processing during initialization and activation respectively.
4
-
5
- ## Algorithm
6
-
7
- 1. **Init Phase** (when document is loaded) per FCB.init_source:
8
- - If `init` is `false`: No initialization occurs
9
- - If `init` is a string: That string becomes the initial value
10
- - If `init` is `:allow`: First value from `allow` list is used
11
- - If `init` is `:echo`: Value from `echo` key is evaluated and returned
12
- - If `init` is `:exec`: Command from `exec` key is executed and stdout is returned
13
- - If `init` is not present: Defaults to first available in order:
14
- - `:allow` if `allow` exists
15
- - `:default` if `default` exists
16
- - `:echo` if `echo` exists
17
- - `:exec` if `exec` exists
18
- - `false` if none of the above exist
19
-
20
- 2. **Act Phase** (when block is activated) per FCB.act_source:
21
- - If `act` is `false`: Block cannot be activated
22
- - If `act` is `:allow`: User selects from `allow` list
23
- - If `act` is `:echo`: Value from `echo` key is evaluated and returned
24
- - If `act` is `:edit`: User is prompted for input
25
- - If `act` is `:exec`: Command from `exec` key is executed and stdout is returned
26
- - If `act` is not present: Defaults to:
27
- - If `init` is `false`:
28
- - First available in order: `:allow`, `:echo`, `:edit`, `:exec`
29
- - Otherwise:
30
- - `:allow` if `allow` exists
31
- - `:edit` if `allow` does not exist
32
-
33
- ## Examples
34
-
35
- ### Echo on Init, Exec on Act
36
- ```ux
37
- name: DEPLOY_CONFIG
38
- init: :echo
39
- echo: "Deploying ${VERSION} to ${ENVIRONMENT}"
40
- act: :exec
41
- exec: "deploy.sh ${ENVIRONMENT} ${VERSION}"
42
- ```
43
- Behavior:
44
- - On init: Evaluates echo string "Deploying ${VERSION} to ${ENVIRONMENT}"
45
- - On act: Executes deploy.sh with environment and version parameters
46
-
47
- ### Allow on Init, Edit on Act
48
- ```ux
49
- name: ENVIRONMENT
50
- init: :allow
51
- allow:
52
- - development
53
- - staging
54
- - production
55
- act: :edit
56
- prompt: Select environment
57
- ```
58
- Behavior:
59
- - On init: Uses first allowed value (development)
60
- - On act: Prompts user to select from allowed values
61
-
62
- ### Exec on Init, Echo on Act
63
- ```ux
64
- name: CURRENT_DIR
65
- init: :exec
66
- exec: basename $(pwd)
67
- act: :echo
68
- echo: "Current directory: ${CURRENT_DIR}"
69
- ```
70
- Behavior:
71
- - On init: Executes basename command on current directory
72
- - On act: Evaluates echo string with current directory value
73
-
74
- ### Allow on Both
75
- ```ux
76
- name: API_KEY
77
- init: :allow
78
- allow:
79
- - ${PROD_API_KEY}
80
- - ${STAGING_API_KEY}
81
- - ${DEV_API_KEY}
82
- act: :allow
83
- require:
84
- - ENVIRONMENT
85
- ```
86
- Behavior:
87
- - On init: Uses first allowed API key
88
- - On act: Shows menu of allowed API keys for selection
89
-
90
- ### Echo on Both
91
- ```ux
92
- name: SHELL_VERSION
93
- init: :echo
94
- echo: $SHELL
95
- act: :echo
96
- echo: "Using shell: ${SHELL_VERSION}"
97
- ```
98
- Behavior:
99
- - On init: Gets shell value from environment
100
- - On act: Evaluates echo string with current shell value