prompt_manager 0.5.8 → 1.0.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 (95) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +33 -0
  3. data/README.md +206 -516
  4. data/Rakefile +0 -8
  5. data/docs/api/configuration.md +31 -327
  6. data/docs/api/constants.md +60 -0
  7. data/docs/api/index.md +14 -0
  8. data/docs/api/metadata.md +99 -0
  9. data/docs/api/parsed.md +98 -0
  10. data/docs/api/pm-module.md +131 -0
  11. data/docs/api/render-context.md +51 -0
  12. data/docs/architecture/design-decisions.md +70 -0
  13. data/docs/architecture/index.md +6 -0
  14. data/docs/architecture/processing-pipeline.md +112 -0
  15. data/docs/assets/css/custom.css +1 -0
  16. data/docs/assets/images/prompt_manager.gif +0 -0
  17. data/docs/assets/images/prompt_manager.mp4 +0 -0
  18. data/docs/examples/ai-agent-prompts.md +173 -0
  19. data/docs/examples/code-review-prompt.md +107 -0
  20. data/docs/examples/index.md +7 -0
  21. data/docs/examples/multi-file-composition.md +123 -0
  22. data/docs/getting-started/configuration.md +106 -0
  23. data/docs/getting-started/index.md +7 -0
  24. data/docs/getting-started/installation.md +10 -73
  25. data/docs/getting-started/quick-start.md +50 -225
  26. data/docs/guides/comment-stripping.md +64 -0
  27. data/docs/guides/custom-directives.md +115 -0
  28. data/docs/guides/erb-rendering.md +102 -0
  29. data/docs/guides/includes.md +146 -0
  30. data/docs/guides/index.md +11 -0
  31. data/docs/guides/parameters.md +96 -0
  32. data/docs/guides/parsing.md +127 -0
  33. data/docs/guides/shell-expansion.md +108 -0
  34. data/docs/index.md +54 -214
  35. data/lib/pm/configuration.rb +17 -0
  36. data/lib/pm/directives.rb +61 -0
  37. data/lib/pm/metadata.rb +17 -0
  38. data/lib/pm/parsed.rb +59 -0
  39. data/lib/pm/shell.rb +57 -0
  40. data/lib/pm/version.rb +5 -0
  41. data/lib/pm.rb +121 -0
  42. data/lib/prompt_manager.rb +2 -27
  43. data/mkdocs.yml +101 -66
  44. metadata +42 -101
  45. data/docs/.keep +0 -0
  46. data/docs/advanced/custom-keywords.md +0 -421
  47. data/docs/advanced/dynamic-directives.md +0 -535
  48. data/docs/advanced/performance.md +0 -612
  49. data/docs/advanced/search-integration.md +0 -635
  50. data/docs/api/directive-processor.md +0 -431
  51. data/docs/api/prompt-class.md +0 -354
  52. data/docs/api/storage-adapters.md +0 -462
  53. data/docs/assets/favicon.ico +0 -1
  54. data/docs/assets/logo.svg +0 -24
  55. data/docs/core-features/comments.md +0 -48
  56. data/docs/core-features/directive-processing.md +0 -38
  57. data/docs/core-features/erb-integration.md +0 -68
  58. data/docs/core-features/error-handling.md +0 -197
  59. data/docs/core-features/parameter-history.md +0 -76
  60. data/docs/core-features/parameterized-prompts.md +0 -500
  61. data/docs/core-features/shell-integration.md +0 -79
  62. data/docs/development/architecture.md +0 -544
  63. data/docs/development/contributing.md +0 -425
  64. data/docs/development/roadmap.md +0 -234
  65. data/docs/development/testing.md +0 -822
  66. data/docs/examples/advanced.md +0 -523
  67. data/docs/examples/basic.md +0 -688
  68. data/docs/examples/real-world.md +0 -776
  69. data/docs/examples.md +0 -337
  70. data/docs/getting-started/basic-concepts.md +0 -318
  71. data/docs/migration/v0.9.0.md +0 -459
  72. data/docs/migration/v1.0.0.md +0 -591
  73. data/docs/storage/activerecord-adapter.md +0 -348
  74. data/docs/storage/custom-adapters.md +0 -176
  75. data/docs/storage/filesystem-adapter.md +0 -236
  76. data/docs/storage/overview.md +0 -427
  77. data/examples/advanced_integrations.rb +0 -52
  78. data/examples/directives.rb +0 -102
  79. data/examples/prompts_dir/advanced_demo.txt +0 -79
  80. data/examples/prompts_dir/directive_example.json +0 -1
  81. data/examples/prompts_dir/directive_example.txt +0 -8
  82. data/examples/prompts_dir/todo.json +0 -1
  83. data/examples/prompts_dir/todo.txt +0 -7
  84. data/examples/prompts_dir/toy/8-ball.txt +0 -4
  85. data/examples/rgfzf +0 -44
  86. data/examples/simple.rb +0 -160
  87. data/examples/using_search_proc.rb +0 -68
  88. data/improvement_plan.md +0 -996
  89. data/lib/prompt_manager/directive_processor.rb +0 -47
  90. data/lib/prompt_manager/prompt.rb +0 -195
  91. data/lib/prompt_manager/storage/active_record_adapter.rb +0 -157
  92. data/lib/prompt_manager/storage/file_system_adapter.rb +0 -339
  93. data/lib/prompt_manager/storage.rb +0 -34
  94. data/lib/prompt_manager/version.rb +0 -5
  95. data/prompt_manager_logo.png +0 -0
@@ -0,0 +1,123 @@
1
+ # Multi-File Composition
2
+
3
+ Compose prompts from shared components using the `include` directive.
4
+
5
+ ## Directory Structure
6
+
7
+ ```
8
+ prompts/
9
+ review.md
10
+ common/
11
+ system_context.md
12
+ output_format.md
13
+ ruby_standards.md
14
+ ```
15
+
16
+ ## Shared Components
17
+
18
+ `prompts/common/system_context.md`:
19
+
20
+ ```markdown
21
+ ---
22
+ title: System Context
23
+ ---
24
+ You are a senior software engineer with expertise in <%= language %>.
25
+ Current date: $(date +%Y-%m-%d)
26
+ User: $USER
27
+ ```
28
+
29
+ `prompts/common/output_format.md`:
30
+
31
+ ```markdown
32
+ ---
33
+ title: Output Format
34
+ ---
35
+ Format your response as:
36
+ 1. Summary (2-3 sentences)
37
+ 2. Issues found (bulleted list)
38
+ 3. Suggestions (numbered list)
39
+ 4. Revised code (if applicable)
40
+ ```
41
+
42
+ `prompts/common/ruby_standards.md`:
43
+
44
+ ```markdown
45
+ ---
46
+ title: Ruby Standards
47
+ ---
48
+ Follow these Ruby conventions:
49
+ - Use snake_case for methods and variables
50
+ - Prefer single-line blocks with braces for short expressions
51
+ - Use guard clauses over nested conditionals
52
+ - Avoid monkey-patching standard library classes
53
+ ```
54
+
55
+ ## The Composed Prompt
56
+
57
+ `prompts/review.md`:
58
+
59
+ ```markdown
60
+ ---
61
+ title: Full Code Review
62
+ parameters:
63
+ language: ruby
64
+ code: null
65
+ ---
66
+ <%= include 'common/system_context.md' %>
67
+
68
+ <%= include 'common/ruby_standards.md' %>
69
+
70
+ Review the following code:
71
+
72
+ <%= code %>
73
+
74
+ <%= include 'common/output_format.md' %>
75
+ ```
76
+
77
+ ## Usage
78
+
79
+ ```ruby
80
+ PM.configure { |c| c.prompts_dir = './prompts' }
81
+
82
+ parsed = PM.parse('review.md')
83
+ prompt = parsed.to_s('code' => File.read('app.rb'))
84
+ ```
85
+
86
+ The rendered prompt combines all four files into a single coherent prompt.
87
+
88
+ ## Inspecting the Include Tree
89
+
90
+ ```ruby
91
+ parsed.metadata.includes
92
+ #=> [
93
+ # { path: ".../common/system_context.md", depth: 1, metadata: {...}, includes: [] },
94
+ # { path: ".../common/ruby_standards.md", depth: 1, metadata: {...}, includes: [] },
95
+ # { path: ".../common/output_format.md", depth: 1, metadata: {...}, includes: [] }
96
+ # ]
97
+ ```
98
+
99
+ ## Nested Includes
100
+
101
+ Components can include other components. For example, `system_context.md` could include a `team_info.md`:
102
+
103
+ ```markdown
104
+ ---
105
+ title: System Context
106
+ ---
107
+ You are a senior software engineer.
108
+ <%= include 'common/team_info.md' %>
109
+ ```
110
+
111
+ The include tree reflects the nesting:
112
+
113
+ ```ruby
114
+ parsed.metadata.includes[0][:includes]
115
+ #=> [{ path: ".../common/team_info.md", depth: 2, metadata: {...}, includes: [] }]
116
+ ```
117
+
118
+ ## Benefits
119
+
120
+ - **Reuse** -- Shared components (system context, output format) written once
121
+ - **Consistency** -- Changes to a component propagate to all prompts that include it
122
+ - **Modularity** -- Swap components per use case (different standards for different languages)
123
+ - **Traceability** -- The includes tree shows exactly what went into each prompt
@@ -0,0 +1,106 @@
1
+ # Configuration
2
+
3
+ PM has three global settings controlled through `PM.configure`.
4
+
5
+ ## Setting Defaults
6
+
7
+ ```ruby
8
+ PM.configure do |config|
9
+ config.prompts_dir = '~/.prompts' # default: ''
10
+ config.shell = true # default: true
11
+ config.erb = true # default: true
12
+ end
13
+ ```
14
+
15
+ ## prompts_dir
16
+
17
+ Prepended to relative file paths passed to `PM.parse`. Absolute paths bypass it. Symbols and single words are converted to `.md` basenames first.
18
+
19
+ ```ruby
20
+ PM.configure { |c| c.prompts_dir = '/usr/share/prompts' }
21
+
22
+ PM.parse('code_review.md')
23
+ #=> reads /usr/share/prompts/code_review.md
24
+
25
+ PM.parse(:code_review)
26
+ #=> reads /usr/share/prompts/code_review.md
27
+
28
+ PM.parse('code_review')
29
+ #=> reads /usr/share/prompts/code_review.md
30
+
31
+ PM.parse('/absolute/path/review.md')
32
+ #=> reads /absolute/path/review.md (prompts_dir ignored)
33
+ ```
34
+
35
+ Subdirectories work naturally:
36
+
37
+ ```ruby
38
+ PM.configure { |c| c.prompts_dir = '~/.prompts' }
39
+
40
+ PM.parse('agents/summarize.md')
41
+ #=> reads ~/.prompts/agents/summarize.md
42
+ ```
43
+
44
+ ## shell
45
+
46
+ Controls whether shell expansion (`$VAR`, `$(command)`) runs during parsing. Defaults to `true`.
47
+
48
+ ```ruby
49
+ PM.configure { |c| c.shell = false }
50
+
51
+ # All files now skip shell expansion by default
52
+ ```
53
+
54
+ Per-file YAML metadata overrides the global setting:
55
+
56
+ ```markdown
57
+ ---
58
+ title: Override Example
59
+ shell: true
60
+ ---
61
+ This file gets shell expansion even when the global default is false.
62
+ User: $USER
63
+ ```
64
+
65
+ ## erb
66
+
67
+ Controls whether ERB rendering runs during `to_s`. Defaults to `true`.
68
+
69
+ ```ruby
70
+ PM.configure { |c| c.erb = false }
71
+
72
+ # All files now skip ERB rendering by default
73
+ ```
74
+
75
+ Per-file metadata overrides this too:
76
+
77
+ ```markdown
78
+ ---
79
+ title: Override Example
80
+ erb: true
81
+ ---
82
+ This file renders ERB even when the global default is false.
83
+ Result: <%= 2 + 2 %>
84
+ ```
85
+
86
+ ## Resetting
87
+
88
+ Restore all settings to their defaults:
89
+
90
+ ```ruby
91
+ PM.config.reset!
92
+
93
+ PM.config.prompts_dir #=> ''
94
+ PM.config.shell #=> true
95
+ PM.config.erb #=> true
96
+ ```
97
+
98
+ ## Accessing Current Settings
99
+
100
+ ```ruby
101
+ PM.config.prompts_dir
102
+ PM.config.shell
103
+ PM.config.erb
104
+ ```
105
+
106
+ `PM.config` returns the singleton `PM::Configuration` instance. `PM.configure` yields the same instance.
@@ -0,0 +1,7 @@
1
+ # Getting Started
2
+
3
+ This section covers everything you need to start using PM in your Ruby projects.
4
+
5
+ - [Installation](installation.md) -- Add PM to your project
6
+ - [Quick Start](quick-start.md) -- Parse your first prompt in a few lines
7
+ - [Configuration](configuration.md) -- Set global defaults for prompt directories, shell expansion, and ERB rendering
@@ -1,97 +1,34 @@
1
1
  # Installation
2
2
 
3
- ## System Requirements
3
+ ## Gemfile
4
4
 
5
- PromptManager requires:
6
-
7
- - **Ruby**: 2.7 or higher (3.0+ recommended)
8
- - **Operating System**: Linux, macOS, or Windows
9
- - **Dependencies**: No additional system dependencies required
10
-
11
- ## Install the Gem
12
-
13
- ### Using Bundler (Recommended)
14
-
15
- Add PromptManager to your project's `Gemfile`:
5
+ Add PM to your Gemfile:
16
6
 
17
7
  ```ruby
18
- # Gemfile
19
8
  gem 'prompt_manager'
20
9
  ```
21
10
 
22
- Then install:
11
+ Then run:
23
12
 
24
13
  ```bash
25
14
  bundle install
26
15
  ```
27
16
 
28
- ### Using RubyGems
29
-
30
- Install directly with gem:
17
+ ## Manual Install
31
18
 
32
19
  ```bash
33
20
  gem install prompt_manager
34
21
  ```
35
22
 
36
- ### Development Installation
37
-
38
- For development or to get the latest features:
39
-
40
- ```bash
41
- git clone https://github.com/MadBomber/prompt_manager.git
42
- cd prompt_manager
43
- bundle install
44
- ```
45
-
46
- ## Verify Installation
47
-
48
- Test that PromptManager is installed correctly:
23
+ ## Require
49
24
 
50
25
  ```ruby
51
- require 'prompt_manager'
52
- puts PromptManager::VERSION
26
+ require 'pm'
53
27
  ```
54
28
 
55
- ## Dependencies
56
-
57
- PromptManager has minimal dependencies and automatically installs:
58
-
59
- - **No external system dependencies**
60
- - **Pure Ruby dependencies** only
61
- - **Lightweight footprint** for easy integration
62
-
63
- ## Troubleshooting
64
-
65
- ### Common Issues
66
-
67
- !!! warning "Ruby Version"
68
-
69
- If you see compatibility errors, ensure you're running Ruby 2.7+:
70
-
71
- ```bash
72
- ruby --version
73
- ```
74
-
75
- !!! tip "Bundler Issues"
76
-
77
- If bundle install fails, try updating bundler:
78
-
79
- ```bash
80
- gem update bundler
81
- bundle install
82
- ```
83
-
84
- ### Getting Help
85
-
86
- If you encounter installation issues:
87
-
88
- 1. Check the [GitHub Issues](https://github.com/MadBomber/prompt_manager/issues)
89
- 2. Search for similar problems in [Discussions](https://github.com/MadBomber/prompt_manager/discussions)
90
- 3. Create a new issue with:
91
- - Ruby version (`ruby --version`)
92
- - Gem version (`gem list prompt_manager`)
93
- - Error message and full stack trace
29
+ The `PM` module is the primary interface. All public methods are accessed through it.
94
30
 
95
- ## Next Steps
31
+ ## Requirements
96
32
 
97
- Once installed, continue to the [Quick Start](quick-start.md) guide to begin using PromptManager.
33
+ - Ruby >= 3.2.0
34
+ - No runtime dependencies beyond the standard library (plus `ostruct` on Ruby 4.0+)
@@ -1,256 +1,81 @@
1
1
  # Quick Start
2
2
 
3
- This guide will get you up and running with PromptManager in just a few minutes.
3
+ ## Parse a String
4
4
 
5
- ## 1. Install PromptManager
6
-
7
- ```bash
8
- gem install prompt_manager
9
- ```
10
-
11
- ## 2. Set Up Your First Prompt
12
-
13
- Create a directory for your prompts and your first prompt file:
14
-
15
- ```bash
16
- mkdir ~/.prompts
17
- ```
18
-
19
- Create your first prompt file:
20
-
21
- === "~/.prompts/greeting.txt"
22
-
23
- ```text
24
- # Description: A friendly greeting prompt
25
- # Keywords: NAME, LANGUAGE
26
-
27
- Hello [NAME]!
28
-
29
- I'm here to help you today. Please let me know how I can assist you,
30
- and I'll respond in [LANGUAGE].
31
-
32
- What would you like to know about?
33
- ```
34
-
35
- === "~/.prompts/greeting.json"
36
-
37
- ```json
38
- {
39
- "[NAME]": ["Alice", "Bob", "Charlie"],
40
- "[LANGUAGE]": ["English", "Spanish", "French"]
41
- }
42
- ```
43
-
44
- ## 3. Basic Usage
45
-
46
- Create a simple Ruby script to use your prompt:
47
-
48
- ```ruby title="quick_example.rb"
49
- #!/usr/bin/env ruby
50
-
51
- require 'prompt_manager'
52
-
53
- # Configure the FileSystem storage adapter
54
- PromptManager::Prompt.storage_adapter =
55
- PromptManager::Storage::FileSystemAdapter.config do |config|
56
- config.prompts_dir = File.expand_path('~/.prompts')
57
- end.new
58
-
59
- # Load your prompt
60
- prompt = PromptManager::Prompt.new(id: 'greeting')
61
-
62
- # Set parameter values
63
- prompt.parameters = {
64
- "[NAME]" => "Alice",
65
- "[LANGUAGE]" => "English"
66
- }
67
-
68
- # Generate the final prompt text
69
- puts "=== Generated Prompt ==="
70
- puts prompt.to_s
71
-
72
- # Save any parameter changes
73
- prompt.save
74
- ```
5
+ ```ruby
6
+ require 'pm'
75
7
 
76
- Run it:
8
+ parsed = PM.parse("---\ntitle: Hello\n---\nContent here")
77
9
 
78
- ```bash
79
- ruby quick_example.rb
10
+ parsed.metadata.title #=> "Hello"
11
+ parsed.content #=> "\nContent here\n"
80
12
  ```
81
13
 
82
- Expected output:
83
- ```
84
- === Generated Prompt ===
85
- Hello Alice!
14
+ ## Parse a File
86
15
 
87
- I'm here to help you today. Please let me know how I can assist you,
88
- and I'll respond in English.
16
+ Given `greeting.md`:
89
17
 
90
- What would you like to know about?
18
+ ```markdown
19
+ ---
20
+ title: Greeting
21
+ parameters:
22
+ name: null
23
+ ---
24
+ Hello, <%= name %>! Welcome.
91
25
  ```
92
26
 
93
- ## 4. Understanding the Workflow
27
+ ```ruby
28
+ # Any of these forms work:
29
+ parsed = PM.parse('greeting.md') # explicit .md extension
30
+ parsed = PM.parse(:greeting) # Symbol — .md appended
31
+ parsed = PM.parse('greeting') # single word — .md appended
94
32
 
95
- The basic PromptManager workflow involves:
33
+ parsed.metadata.title #=> "Greeting"
34
+ parsed.metadata.parameters #=> {"name" => nil}
96
35
 
97
- ```mermaid
98
- graph LR
99
- A[Create Prompt File] --> B[Configure Storage]
100
- B --> C[Load Prompt]
101
- C --> D[Set Parameters]
102
- D --> E[Generate Text]
103
- E --> F[Save Changes]
36
+ # Render with parameters
37
+ puts parsed.to_s('name' => 'Alice')
38
+ #=> "Hello, Alice! Welcome."
104
39
  ```
105
40
 
106
- ### Step by Step:
107
-
108
- 1. **Create Prompt File**: Write your template with `[KEYWORDS]`
109
- 2. **Configure Storage**: Choose FileSystem or ActiveRecord adapter
110
- 3. **Load Prompt**: Create a Prompt instance with an ID
111
- 4. **Set Parameters**: Provide values for your keywords
112
- 5. **Generate Text**: Call `to_s` to get the final prompt
113
- 6. **Save Changes**: Persist parameter updates
41
+ When parsing a file, PM also adds `directory`, `name`, `created_at`, and `modified_at` to the metadata.
114
42
 
115
- ## 5. Advanced Quick Start
43
+ ## Parameters
116
44
 
117
- Here's a more advanced example showing multiple features:
45
+ Parameters declared in the YAML front-matter define template variables:
118
46
 
119
- ```ruby title="advanced_example.rb"
120
- require 'prompt_manager'
47
+ - **`null` value** -- parameter is required; `to_s` raises `ArgumentError` if missing
48
+ - **Any other value** -- used as the default; can be overridden in `to_s`
121
49
 
122
- # Configure storage
123
- PromptManager::Prompt.storage_adapter =
124
- PromptManager::Storage::FileSystemAdapter.config do |config|
125
- config.prompts_dir = File.expand_path('~/.prompts')
126
- end.new
127
-
128
- # Create a prompt with directives and ERB
129
- prompt = PromptManager::Prompt.new(
130
- id: 'advanced_greeting',
131
- erb_flag: true,
132
- envar_flag: true
133
- )
134
-
135
- # Set parameters
136
- prompt.parameters = {
137
- "[USER_NAME]" => "Alice",
138
- "[TASK_TYPE]" => "translation",
139
- "[URGENCY]" => "high"
140
- }
141
-
142
- # Display available keywords
143
- puts "Available keywords: #{prompt.keywords.join(', ')}"
50
+ ```ruby
51
+ parsed = PM.parse("---\nparameters:\n lang: ruby\n code: null\n---\n<%= lang %>: <%= code %>")
144
52
 
145
- # Generate and display the result
146
- puts "\n=== Final Prompt ==="
147
- puts prompt.to_s
53
+ # Use defaults where available, supply required params
54
+ parsed.to_s('code' => 'puts "hi"') #=> "ruby: puts \"hi\""
148
55
 
149
- # Save changes
150
- prompt.save
151
- puts "\nPrompt saved successfully!"
56
+ # Override defaults
57
+ parsed.to_s('code' => 'print("hi")', 'lang' => 'python')
152
58
  ```
153
59
 
154
- === "~/.prompts/advanced_greeting.txt"
155
-
156
- ```text
157
- # Advanced greeting with directives and ERB
158
- //include common/header.txt
159
-
160
- Dear [USER_NAME],
161
-
162
- <% if '[URGENCY]' == 'high' %>
163
- 🚨 URGENT: This [TASK_TYPE] request requires immediate attention.
164
- <% else %>
165
- 📋 Standard [TASK_TYPE] request for processing.
166
- <% end %>
167
-
168
- Current system time: <%= Time.now.strftime('%Y-%m-%d %H:%M:%S') %>
169
- Working directory: <%= Dir.pwd %>
170
-
171
- __END__
172
- This section is ignored - useful for notes and documentation.
173
- ```
174
-
175
- ## 6. Next Steps
176
-
177
- Now that you have PromptManager working, explore these areas:
178
-
179
- ### Learn Core Features
180
- - [Parameterized Prompts](../core-features/parameterized-prompts.md) - Master keyword substitution
181
- - [Directive Processing](../core-features/directive-processing.md) - Include files and process commands
182
- - [ERB Integration](../core-features/erb-integration.md) - Dynamic templating
183
-
184
- ### Storage Options
185
- - [FileSystem Adapter](../storage/filesystem-adapter.md) - File-based storage
186
- - [ActiveRecord Adapter](../storage/activerecord-adapter.md) - Database storage
187
- - [Custom Adapters](../storage/custom-adapters.md) - Build your own
188
-
189
- ### Advanced Usage
190
- - [Custom Keywords](../advanced/custom-keywords.md) - Define your own keyword patterns
191
- - [Search Integration](../advanced/search-integration.md) - Find prompts quickly
192
- - [Performance Tips](../advanced/performance.md) - Optimize for large collections
193
-
194
- ### Real Examples
195
- - [Basic Examples](../examples/basic.md) - Simple use cases
196
- - [Advanced Examples](../examples/advanced.md) - Complex scenarios
197
- - [Real World Cases](../examples/real-world.md) - Production examples
198
-
199
- ## Common Patterns
60
+ ## Shell Expansion
200
61
 
201
- Here are some common patterns you'll use frequently:
62
+ Environment variables and commands are expanded at parse time:
202
63
 
203
- ### Parameter History
204
- ```ruby
205
- # Access parameter history (since v0.3.0)
206
- prompt.parameters["[NAME]"] # Returns ["Alice", "Bob", "Charlie"]
207
- latest_name = prompt.parameters["[NAME]"].last # "Charlie"
208
- ```
209
-
210
- ### Error Handling
211
- ```ruby
212
- begin
213
- prompt = PromptManager::Prompt.new(id: 'missing')
214
- rescue PromptManager::StorageError => e
215
- puts "Storage error: #{e.message}"
216
- rescue PromptManager::ParameterError => e
217
- puts "Parameter error: #{e.message}"
218
- end
64
+ ```markdown
65
+ ---
66
+ title: Info
67
+ ---
68
+ User: $USER
69
+ Date: $(date +%Y-%m-%d)
219
70
  ```
220
71
 
221
- ### Search and Discovery
222
72
  ```ruby
223
- # List all available prompts
224
- prompts = PromptManager::Prompt.list
225
- puts "Available prompts: #{prompts.join(', ')}"
226
-
227
- # Search for prompts (requires search_proc configuration)
228
- results = PromptManager::Prompt.search('greeting')
73
+ parsed = PM.parse('info.md')
74
+ parsed.content #=> "User: dewayne\nDate: 2025-01-15\n"
229
75
  ```
230
76
 
231
- ## Troubleshooting
232
-
233
- ### File Not Found
234
- If you get "file not found" errors, check:
235
-
236
- 1. **Prompt directory exists**: `ls ~/.prompts`
237
- 2. **File has correct extension**: Should be `.txt` by default
238
- 3. **Prompt ID matches filename**: `greeting` looks for `greeting.txt`
239
-
240
- ### Parameter Errors
241
- If parameters aren't substituting:
242
-
243
- 1. **Check keyword format**: Must be `[UPPERCASE]` by default
244
- 2. **Verify parameter keys match**: Case-sensitive matching
245
- 3. **Ensure parameters are set**: Call `prompt.parameters = {...}`
246
-
247
- ### Permission Issues
248
- If you can't write to the prompts directory:
249
-
250
- ```bash
251
- chmod 755 ~/.prompts
252
- chmod 644 ~/.prompts/*.txt
253
- chmod 644 ~/.prompts/*.json
254
- ```
77
+ ## Next Steps
255
78
 
256
- Need help? Check our [testing guide](../development/testing.md) or [open an issue](https://github.com/MadBomber/prompt_manager/issues).
79
+ - [Configuration](configuration.md) -- Set a prompts directory and global defaults
80
+ - [Parsing Guide](../guides/parsing.md) -- File vs string parsing in depth
81
+ - [Parameters Guide](../guides/parameters.md) -- Required and default parameters