ukiryu 0.1.1 → 0.1.3

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 (113) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +58 -14
  3. data/.gitignore +3 -0
  4. data/.rubocop_todo.yml +170 -79
  5. data/Gemfile +1 -1
  6. data/README.adoc +1603 -576
  7. data/docs/.gitignore +1 -0
  8. data/docs/Gemfile +10 -0
  9. data/docs/INDEX.adoc +261 -0
  10. data/docs/_config.yml +180 -0
  11. data/docs/advanced/custom-tool-classes.adoc +581 -0
  12. data/docs/advanced/index.adoc +20 -0
  13. data/docs/features/configuration.adoc +657 -0
  14. data/docs/features/index.adoc +31 -0
  15. data/docs/features/platform-support.adoc +488 -0
  16. data/docs/getting-started/core-concepts.adoc +666 -0
  17. data/docs/getting-started/index.adoc +36 -0
  18. data/docs/getting-started/installation.adoc +216 -0
  19. data/docs/getting-started/quick-start.adoc +258 -0
  20. data/docs/guides/env-var-sets.adoc +388 -0
  21. data/docs/guides/index.adoc +20 -0
  22. data/docs/interfaces/cli.adoc +609 -0
  23. data/docs/interfaces/index.adoc +153 -0
  24. data/docs/interfaces/ruby-api.adoc +538 -0
  25. data/docs/lychee.toml +49 -0
  26. data/docs/reference/configuration-options.adoc +720 -0
  27. data/docs/reference/error-codes.adoc +634 -0
  28. data/docs/reference/index.adoc +20 -0
  29. data/docs/reference/ruby-api.adoc +1217 -0
  30. data/docs/understanding/index.adoc +20 -0
  31. data/lib/ukiryu/cli.rb +43 -58
  32. data/lib/ukiryu/cli_commands/base_command.rb +16 -27
  33. data/lib/ukiryu/cli_commands/cache_command.rb +100 -0
  34. data/lib/ukiryu/cli_commands/commands_command.rb +8 -8
  35. data/lib/ukiryu/cli_commands/commands_command.rb.fixed +1 -1
  36. data/lib/ukiryu/cli_commands/config_command.rb +49 -7
  37. data/lib/ukiryu/cli_commands/definitions_command.rb +254 -0
  38. data/lib/ukiryu/cli_commands/describe_command.rb +13 -7
  39. data/lib/ukiryu/cli_commands/describe_command.rb.fixed +1 -1
  40. data/lib/ukiryu/cli_commands/docs_command.rb +148 -0
  41. data/lib/ukiryu/cli_commands/exec_inline_command.rb.fixed +1 -1
  42. data/lib/ukiryu/cli_commands/extract_command.rb +2 -2
  43. data/lib/ukiryu/cli_commands/info_command.rb +7 -7
  44. data/lib/ukiryu/cli_commands/lint_command.rb +167 -0
  45. data/lib/ukiryu/cli_commands/list_command.rb +6 -6
  46. data/lib/ukiryu/cli_commands/opts_command.rb +2 -2
  47. data/lib/ukiryu/cli_commands/opts_command.rb.fixed +1 -1
  48. data/lib/ukiryu/cli_commands/register_command.rb +144 -0
  49. data/lib/ukiryu/cli_commands/resolve_command.rb +124 -0
  50. data/lib/ukiryu/cli_commands/run_command.rb +38 -14
  51. data/lib/ukiryu/cli_commands/run_file_command.rb +2 -2
  52. data/lib/ukiryu/cli_commands/system_command.rb +50 -32
  53. data/lib/ukiryu/cli_commands/validate_command.rb +452 -51
  54. data/lib/ukiryu/cli_commands/which_command.rb +5 -5
  55. data/lib/ukiryu/command_builder.rb +81 -23
  56. data/lib/ukiryu/config/env_provider.rb +3 -3
  57. data/lib/ukiryu/config/env_schema.rb +6 -6
  58. data/lib/ukiryu/config.rb +11 -11
  59. data/lib/ukiryu/definition/definition_cache.rb +238 -0
  60. data/lib/ukiryu/definition/definition_composer.rb +257 -0
  61. data/lib/ukiryu/definition/definition_linter.rb +460 -0
  62. data/lib/ukiryu/definition/definition_validator.rb +320 -0
  63. data/lib/ukiryu/definition/discovery.rb +239 -0
  64. data/lib/ukiryu/definition/documentation_generator.rb +429 -0
  65. data/lib/ukiryu/definition/lint_issue.rb +168 -0
  66. data/lib/ukiryu/definition/loader.rb +139 -0
  67. data/lib/ukiryu/definition/metadata.rb +159 -0
  68. data/lib/ukiryu/definition/source.rb +87 -0
  69. data/lib/ukiryu/definition/sources/file.rb +138 -0
  70. data/lib/ukiryu/definition/sources/string.rb +88 -0
  71. data/lib/ukiryu/definition/validation_result.rb +158 -0
  72. data/lib/ukiryu/definition/version_resolver.rb +194 -0
  73. data/lib/ukiryu/definition.rb +40 -0
  74. data/lib/ukiryu/errors.rb +6 -0
  75. data/lib/ukiryu/execution_context.rb +11 -11
  76. data/lib/ukiryu/executor.rb +6 -0
  77. data/lib/ukiryu/extractors/extractor.rb +6 -5
  78. data/lib/ukiryu/extractors/help_parser.rb +13 -19
  79. data/lib/ukiryu/logger.rb +3 -1
  80. data/lib/ukiryu/models/command_definition.rb +3 -3
  81. data/lib/ukiryu/models/command_info.rb +1 -1
  82. data/lib/ukiryu/models/components.rb +1 -3
  83. data/lib/ukiryu/models/env_var_definition.rb +11 -3
  84. data/lib/ukiryu/models/flag_definition.rb +15 -0
  85. data/lib/ukiryu/models/option_definition.rb +7 -7
  86. data/lib/ukiryu/models/platform_profile.rb +6 -3
  87. data/lib/ukiryu/models/routing.rb +1 -1
  88. data/lib/ukiryu/models/tool_definition.rb +2 -4
  89. data/lib/ukiryu/models/tool_metadata.rb +6 -6
  90. data/lib/ukiryu/models/validation_result.rb +1 -1
  91. data/lib/ukiryu/models/version_compatibility.rb +6 -3
  92. data/lib/ukiryu/models/version_detection.rb +10 -1
  93. data/lib/ukiryu/{registry.rb → register.rb} +54 -38
  94. data/lib/ukiryu/register_auto_manager.rb +268 -0
  95. data/lib/ukiryu/schema_validator.rb +31 -10
  96. data/lib/ukiryu/shell/base.rb +18 -0
  97. data/lib/ukiryu/shell/bash.rb +19 -1
  98. data/lib/ukiryu/shell/cmd.rb +11 -1
  99. data/lib/ukiryu/shell/powershell.rb +11 -1
  100. data/lib/ukiryu/shell.rb +1 -1
  101. data/lib/ukiryu/tool.rb +107 -95
  102. data/lib/ukiryu/tool_index.rb +22 -22
  103. data/lib/ukiryu/tools/base.rb +12 -25
  104. data/lib/ukiryu/tools/generator.rb +7 -7
  105. data/lib/ukiryu/tools.rb +3 -3
  106. data/lib/ukiryu/type.rb +20 -5
  107. data/lib/ukiryu/version.rb +1 -1
  108. data/lib/ukiryu/version_detector.rb +21 -2
  109. data/lib/ukiryu.rb +6 -3
  110. data/ukiryu-proposal.md +41 -41
  111. data/ukiryu.gemspec +1 -0
  112. metadata +64 -8
  113. data/.gitmodules +0 -3
@@ -0,0 +1,388 @@
1
+ ---
2
+ layout: default
3
+ title: Environment Variable Sets
4
+ parent: Guides
5
+ nav_order: 1
6
+ ---
7
+
8
+ == Environment Variable Sets
9
+
10
+ The `env_var_sets` feature allows you to define reusable named sets of environment variables at the profile level and apply them to commands via `use_env_vars`. This is useful for:
11
+
12
+ * **Headless mode**: Running GUI tools without displaying windows
13
+ * **Debug mode**: Enabling verbose logging
14
+ * **Safe mode**: Setting security policies
15
+ * **Performance tuning**: Memory limits, cache settings
16
+ * **Custom configurations**: Any tool-specific environment variables
17
+
18
+ == Purpose
19
+
20
+ This guide explains how to define and use `env_var_sets` to manage environment variables declaratively in your tool profiles, eliminating the need for manual environment variable manipulation in application code.
21
+
22
+ == Defining Env Var Sets
23
+
24
+ Env var sets are defined at the profile level using the `env_var_sets` field:
25
+
26
+ [source,yaml]
27
+ ----
28
+ profiles:
29
+ - name: modern_unix
30
+ platforms: [macos, linux]
31
+ shells: [bash, zsh, fish]
32
+
33
+ env_var_sets:
34
+ headless:
35
+ - name: DISPLAY
36
+ value: ''
37
+ platforms: [macos, linux]
38
+ description: Disable display for headless operation
39
+
40
+ debug:
41
+ - name: DEBUG
42
+ value: '1'
43
+ - name: VERBOSE
44
+ value: '1'
45
+ - name: TOOL_LOG_LEVEL
46
+ value: 'trace'
47
+
48
+ low_memory:
49
+ - name: MALLOC_ARENA_MAX
50
+ value: '2'
51
+ - name: MAGICK_MEMORY_LIMIT
52
+ value: '256MB'
53
+ platforms: [linux]
54
+
55
+ commands:
56
+ - name: export
57
+ use_env_vars: [headless]
58
+
59
+ - name: debug_export
60
+ use_env_vars: [headless, debug]
61
+ ----
62
+
63
+ === Env Var Definition Fields
64
+
65
+ Each environment variable in a set supports:
66
+
67
+ [cols="1,1,3"]
68
+ |===
69
+ |Field |Type |Description
70
+
71
+ |`name` |string (required) |Environment variable name
72
+
73
+ |`value` |string (required) |Value to set
74
+
75
+ |`platforms` |array |Limit to specific platforms: `[macos, linux, windows]`
76
+
77
+ |`description` |string |Documentation for the env var
78
+ |===
79
+
80
+ == Using Env Var Sets
81
+
82
+ Commands opt-in to env var sets via the `use_env_vars` field:
83
+
84
+ [source,yaml]
85
+ ----
86
+ commands:
87
+ - name: export
88
+ use_env_vars: [headless] # Just headless
89
+
90
+ - name: debug_export
91
+ use_env_vars: [headless, debug] # Both headless and debug
92
+
93
+ - name: safe_convert
94
+ use_env_vars: [headless, low_memory] # Combine different sets
95
+ ----
96
+
97
+ When a command executes, Ukiryu:
98
+
99
+ 1. Resolves each named env var set from the profile
100
+ 2. Filters env vars by current platform
101
+ 3. Applies env vars to the command execution
102
+ 4. Allows command-level `env_vars` to override set values
103
+
104
+ === Command-Level Env Vars
105
+
106
+ Commands can also define their own environment variables, which are applied after env var sets and can override values from sets:
107
+
108
+ [source,yaml]
109
+ ----
110
+ commands:
111
+ - name: export
112
+ use_env_vars: [headless]
113
+ env_vars:
114
+ - name: MY_TOOL_TIMEOUT
115
+ value: '30'
116
+ description: Timeout in seconds
117
+ - name: DISPLAY
118
+ value: ':1' # Overrides the headless set's DISPLAY=''
119
+ ----
120
+
121
+ === Platform-Specific Env Vars
122
+
123
+ Environment variables can be limited to specific platforms:
124
+
125
+ [source,yaml]
126
+ ----
127
+ env_var_sets:
128
+ headless:
129
+ - name: DISPLAY
130
+ value: ''
131
+ platforms: [macos, linux] # Only Unix systems
132
+ - name: MY_APP_WIN_STYLE
133
+ value: '1'
134
+ platforms: [windows] # Only Windows
135
+ ----
136
+
137
+ == Example 1: Headless Mode
138
+
139
+ Headless mode allows GUI applications to run without displaying windows. This is essential for:
140
+
141
+ * **Server environments**: CI/CD pipelines, Docker containers
142
+ * **Batch processing**: Automated conversion jobs
143
+ * **Background tasks**: Scheduled jobs, cron jobs
144
+
145
+ === Profile Definition
146
+
147
+ [source,yaml]
148
+ ----
149
+ # register/tools/inkscape/1.0.yaml
150
+ profiles:
151
+ - name: modern_unix
152
+ platforms: [macos, linux]
153
+ shells: [bash, zsh, fish]
154
+ env_var_sets:
155
+ headless:
156
+ - name: DISPLAY
157
+ value: ''
158
+ platforms: [macos, linux]
159
+ description: Disable display for headless operation
160
+ commands:
161
+ - name: export
162
+ use_env_vars: [headless]
163
+ - name: query
164
+ use_env_vars: [headless]
165
+ ----
166
+
167
+ === Usage
168
+
169
+ [source,ruby]
170
+ ----
171
+ require 'ukiryu'
172
+
173
+ tool = Ukiryu::Tool.get(:inkscape)
174
+
175
+ # Runs in headless mode automatically!
176
+ result = tool.execute(:export, {
177
+ inputs: ['drawing.svg'],
178
+ output: 'drawing.png',
179
+ format: :png
180
+ })
181
+ ----
182
+
183
+ == Example 2: Debug Mode
184
+
185
+ Debug mode enables verbose logging for troubleshooting:
186
+
187
+ === Profile Definition
188
+
189
+ [source,yaml]
190
+ ----
191
+ env_var_sets:
192
+ debug:
193
+ - name: DEBUG
194
+ value: '1'
195
+ - name: VERBOSE
196
+ value: '1'
197
+ - name: TOOL_LOG_LEVEL
198
+ value: 'trace'
199
+
200
+ commands:
201
+ - name: export
202
+ use_env_vars: [headless]
203
+
204
+ - name: export_debug
205
+ use_env_vars: [headless, debug]
206
+ ----
207
+
208
+ === Usage
209
+
210
+ [source,ruby]
211
+ ----
212
+ # Normal execution
213
+ tool.execute(:export, params)
214
+
215
+ # Debug execution with verbose logging
216
+ tool.execute(:export_debug, params)
217
+ ----
218
+
219
+ == Example 3: Safe Mode
220
+
221
+ Safe mode applies security policies for untrusted input:
222
+
223
+ === Profile Definition
224
+
225
+ [source,yaml]
226
+ ----
227
+ env_var_sets:
228
+ safe:
229
+ - name: SANDBOX_MODE
230
+ value: '1'
231
+ - name: SECURITY_POLICY
232
+ value: 'strict'
233
+ - name: DISABLE_PLUGINS
234
+ value: '1'
235
+
236
+ commands:
237
+ - name: convert_untrusted
238
+ use_env_vars: [headless, safe]
239
+ ----
240
+
241
+ === Usage
242
+
243
+ [source,ruby]
244
+ ----
245
+ # Convert untrusted input with security policies
246
+ tool.execute(:convert_untrusted, {
247
+ inputs: ['untrusted.svg'],
248
+ output: 'safe.pdf'
249
+ })
250
+ ----
251
+
252
+ == Example 4: Memory Limits
253
+
254
+ Limit memory usage for resource-constrained environments:
255
+
256
+ === Profile Definition
257
+
258
+ [source,yaml]
259
+ ----
260
+ env_var_sets:
261
+ low_memory:
262
+ - name: MALLOC_ARENA_MAX
263
+ value: '2'
264
+ platforms: [linux]
265
+ - name: MAGICK_MEMORY_LIMIT
266
+ value: '256MB'
267
+ platforms: [linux]
268
+ - name: OMP_THREAD_LIMIT
269
+ value: '2'
270
+
271
+ commands:
272
+ - name: batch_convert
273
+ use_env_vars: [headless, low_memory]
274
+ ----
275
+
276
+ === Usage
277
+
278
+ [source,ruby]
279
+ ----
280
+ # Process many files with limited memory
281
+ files.each do |input|
282
+ tool.execute(:batch_convert, {
283
+ inputs: [input],
284
+ output: input.sub('.png', '.jpg')
285
+ })
286
+ end
287
+ ----
288
+
289
+ == Verifying Env Var Sets
290
+
291
+ === Check Which Commands Use Env Var Sets
292
+
293
+ [source,bash]
294
+ ----
295
+ # See which commands use env var sets
296
+ ukiryu describe inkscape
297
+ ----
298
+
299
+ Output shows env var sets:
300
+
301
+ [source]
302
+ ----
303
+ Commands (2):
304
+ export Export document to different format
305
+ Env Var Sets: headless
306
+ query Query document dimensions
307
+ Env Var Sets: headless
308
+ ----
309
+
310
+ === Check Active Env Vars
311
+
312
+ [source,ruby]
313
+ ----
314
+ # Enable debug mode to see env vars
315
+ ENV['UKIRYU_DEBUG'] = '1'
316
+
317
+ result = tool.execute(:export, params)
318
+
319
+ # Check execution info
320
+ puts "Env vars: #{result.command_info.env_vars}"
321
+ #=> { "DISPLAY" => "" }
322
+ ----
323
+
324
+ == Best Practices
325
+
326
+ === For Server Environments
327
+
328
+ * **Always use headless mode** for GUI tools on servers
329
+ * **Set appropriate timeouts** for batch operations
330
+ * **Monitor command duration** for performance issues
331
+ * **Log stderr** for debugging
332
+
333
+ [source,ruby]
334
+ ----
335
+ # Server-ready configuration
336
+ tool = Ukiryu::Tool.get(:inkscape)
337
+ result = tool.execute(:export, params, timeout: 120)
338
+
339
+ if result.failure?
340
+ logger.error("Conversion failed", {
341
+ command: result.command_info.full_command,
342
+ stderr: result.stderr,
343
+ duration: result.metadata.duration_seconds
344
+ })
345
+ end
346
+ ----
347
+
348
+ === For CI/CD Pipelines
349
+
350
+ * **Use fixed timeouts** for predictable behavior
351
+ * **Capture all output** for debugging
352
+ * **Fail fast** on errors
353
+
354
+ [source,yaml]
355
+ ----
356
+ # GitHub Actions example
357
+ - name: Convert images
358
+ env:
359
+ UKIRYU_TIMEOUT: 60
360
+ run: |
361
+ ukiryu exec inkscape export \
362
+ inputs=drawing.svg \
363
+ output=drawing.png \
364
+ format=png
365
+ ----
366
+
367
+ === For Docker
368
+
369
+ * **Remove DISPLAY** from environment (or leave empty)
370
+ * **Use official tool images** when available
371
+ * **Multi-stage builds** to reduce image size
372
+
373
+ [source,dockerfile]
374
+ ----
375
+ # Remove GUI dependencies
376
+ ENV DISPLAY=
377
+
378
+ # Use only CLI tools
379
+ RUN apt-get install -y \
380
+ inkscape-cli \
381
+ --no-install-recommends
382
+ ----
383
+
384
+ == See Also
385
+
386
+ * link:../features/configuration.adoc[Configuration Options] - Complete configuration documentation
387
+ * link:../guides/writing-profiles.adoc[Writing Tool Profiles] - How to create profiles
388
+ * link:../reference/tool-profile-schema.adoc[Schema Reference] - Complete schema documentation
@@ -0,0 +1,20 @@
1
+ ---
2
+ layout: default
3
+ title: Guides
4
+ nav_order: 6
5
+ has_children: true
6
+ ---
7
+
8
+ = Guides
9
+
10
+ Task-oriented tutorials for common Ukiryu workflows.
11
+
12
+ // Overview
13
+ == Overview
14
+
15
+ Practical guides for real-world usage:
16
+
17
+ * link:/guides/headless-graphics[Headless Graphics Processing] - Batch convert images on servers
18
+ * link:/guides/ci-cd-integration[CI/CD Integration] - Use Ukiryu in GitHub Actions
19
+ * link:/guides/debugging[Debugging] - Troubleshoot tool execution issues
20
+ * link:/guides/testing[Testing with Ukiryu] - Test tools in RSpec suites