prompt_manager 1.0.2 → 1.2.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +138 -27
- data/README.md +127 -271
- data/lib/pm/configuration.rb +34 -4
- data/lib/pm/core_directives.rb +21 -20
- data/lib/pm/directive.rb +26 -34
- data/lib/pm/directives.rb +55 -16
- data/lib/pm/errors.rb +71 -0
- data/lib/pm/metadata.rb +110 -9
- data/lib/pm/parsed.rb +51 -46
- data/lib/pm/render_scope.rb +74 -0
- data/lib/pm/renderer.rb +59 -0
- data/lib/pm/shell.rb +95 -40
- data/lib/pm/version.rb +1 -1
- data/lib/pm.rb +116 -57
- data/lib/prompt_manager.rb +6 -0
- metadata +13 -113
- data/.envrc +0 -3
- data/.irbrc +0 -14
- data/COMMITS.md +0 -196
- data/Rakefile +0 -12
- data/docs/api/configuration.md +0 -59
- data/docs/api/constants.md +0 -60
- data/docs/api/index.md +0 -14
- data/docs/api/metadata.md +0 -99
- data/docs/api/parsed.md +0 -98
- data/docs/api/pm-module.md +0 -169
- data/docs/api/render-context.md +0 -51
- data/docs/architecture/design-decisions.md +0 -70
- data/docs/architecture/index.md +0 -6
- data/docs/architecture/processing-pipeline.md +0 -112
- data/docs/assets/css/custom.css +0 -1
- data/docs/assets/images/prompt_manager.gif +0 -0
- data/docs/assets/images/prompt_manager.mp4 +0 -0
- data/docs/examples/ai-agent-prompts.md +0 -173
- data/docs/examples/code-review-prompt.md +0 -107
- data/docs/examples/index.md +0 -7
- data/docs/examples/multi-file-composition.md +0 -123
- data/docs/getting-started/configuration.md +0 -106
- data/docs/getting-started/index.md +0 -7
- data/docs/getting-started/installation.md +0 -34
- data/docs/getting-started/quick-start.md +0 -94
- data/docs/guides/comment-stripping.md +0 -64
- data/docs/guides/custom-directives.md +0 -180
- data/docs/guides/erb-rendering.md +0 -102
- data/docs/guides/includes.md +0 -184
- data/docs/guides/index.md +0 -11
- data/docs/guides/parameters.md +0 -96
- data/docs/guides/parsing.md +0 -151
- data/docs/guides/shell-expansion.md +0 -108
- data/docs/index.md +0 -70
- data/mkdocs.yml +0 -181
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 19379206907c5abb7a46bc56a035d93ab2ccc384de6ce516080604019aecaf9d
|
|
4
|
+
data.tar.gz: c5a88a56de993fe7ff0e65ccd5a7d07572a3696ddca2b2787b63e8ff460c1a6f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dba13493af0167fd8f9a5f75ee5259b2731ad3fd849fd6ec3427fdf25389c2a9e51b888280238069e231e2a4e7aaf84ba93bbc6eaf87e38667fa41a67ce86285
|
|
7
|
+
data.tar.gz: 405110550b15a0d180aa76ef537a76169a042d373dc94f3fc8c19f9dfd4beedff86fec1dcd97abcea446d12ba5ff233673606989863e893928083e84b49f21c2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,28 +1,139 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
|
|
5
|
+
[Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [1.2.0] - 2026-11-01
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **Parameters named after private Kernel methods.** A parameter called
|
|
12
|
+
`format`, `test`, `system` or another private `Kernel` method rendered the
|
|
13
|
+
method instead of the value (`<%= format %>` raised `ArgumentError`).
|
|
14
|
+
Parameters now shadow private as well as public `Object` methods. Called
|
|
15
|
+
with arguments or a block (`format('%d', 1)`), the name is still the
|
|
16
|
+
method. `binding` is never shadowed.
|
|
17
|
+
|
|
18
|
+
## [1.1.0] - 2026-11-01
|
|
19
|
+
|
|
20
|
+
A hardening release. Shell expansion can no longer be hijacked by its own
|
|
21
|
+
output, the include chain works as documented, every failure PM raises has a
|
|
22
|
+
class of its own, and the gem ships with zero runtime dependencies at 23 KB
|
|
23
|
+
instead of 9.6 MB. No template syntax changed; see **Upgrading** for the
|
|
24
|
+
behaviour that did.
|
|
25
|
+
|
|
26
|
+
### Upgrading from 1.0.x
|
|
27
|
+
|
|
28
|
+
- **Ruby 4.0.9 or later is required** (was 3.2).
|
|
29
|
+
- **Errors are typed.** Failures that raised `RuntimeError` now raise a
|
|
30
|
+
`PM::Error` subclass (`PM::CircularIncludeError`, `PM::ShellCommandError`,
|
|
31
|
+
`PM::FileNotFoundError`, ...). `rescue RuntimeError` no longer catches them;
|
|
32
|
+
`rescue PM::Error` does. Missing-parameter errors are still `ArgumentError`s
|
|
33
|
+
with the same message, via `PM::MissingParameterError`.
|
|
34
|
+
- **Two silent cases now raise:** an unmatched `$(` (`PM::ShellExpansionError`)
|
|
35
|
+
and a `shell:` / `erb:` value that is not a boolean or true/false/yes/no/on/off
|
|
36
|
+
(`PM::MetadataError`).
|
|
37
|
+
- **`PM::Metadata` is no longer an `OpenStruct`.** Dot access, predicates, `[]`,
|
|
38
|
+
`respond_to?`, and `to_h` are unchanged; only `is_a?(OpenStruct)` checks break.
|
|
39
|
+
- **`PM::Parsed` and `PM::RenderContext` are immutable `Data` objects.** Readers
|
|
40
|
+
are unchanged; writers such as `parsed.content = ...` are gone.
|
|
41
|
+
- **`PM.directives` returns a frozen snapshot.** Use `PM.register` and
|
|
42
|
+
`PM.reset_directives!` to change the registry.
|
|
43
|
+
- **The gem no longer contains `docs/`, examples, or media.** Documentation is
|
|
44
|
+
at <https://madbomber.github.io/prompt_manager>.
|
|
45
|
+
|
|
46
|
+
### Added
|
|
47
|
+
|
|
48
|
+
- **Error hierarchy** rooted at `PM::Error`: `MetadataError`,
|
|
49
|
+
`ShellExpansionError` > `ShellCommandError` (`#command`, `#status`, `#stderr`),
|
|
50
|
+
`IncludeError` > `CircularIncludeError` / `IncludeDepthError` /
|
|
51
|
+
`IncludeContextError`, `FileNotFoundError`, `DirectiveAlreadyRegisteredError`;
|
|
52
|
+
plus `ParameterError` > `MissingParameterError` / `UnknownParameterError`
|
|
53
|
+
under `ArgumentError`.
|
|
54
|
+
- **Configuration:** `lock!` / `unlock!` / `locked?` make the global `shell` and
|
|
55
|
+
`erb` final so a file cannot re-enable a stage; `max_include_depth` (default 10,
|
|
56
|
+
`nil` = unlimited); `strict_parameters` turns an unknown template name into
|
|
57
|
+
`PM::UnknownParameterError` instead of `""`. `PM.configure` returns the config.
|
|
58
|
+
- **Shell expansion:** `\$` writes a literal `$`; fenced code blocks (``` / ~~~)
|
|
59
|
+
are skipped; `PM.expand_shell(str, erb_safe: true)` escapes `<%` in command output.
|
|
60
|
+
- **`PM::Parsed`:** `#to_h`, `#to_markdown` (round-trippable front matter +
|
|
61
|
+
content, derived keys omitted), `#parameters`, `#key?`.
|
|
62
|
+
- **`PM::Metadata`:** `Enumerable`, plus `dig`, `fetch`, `keys`, `values`,
|
|
63
|
+
`size`, `empty?`, `delete`, `each_pair`, `==`.
|
|
64
|
+
- **`PM.directive?(name)`.**
|
|
65
|
+
- **CI:** GitHub Actions on Ubuntu and macOS with a 100% line-coverage gate
|
|
66
|
+
(SimpleCov); `.ruby-version` pins development to 4.0.9.
|
|
67
|
+
- **Docs:** new Security guide and Errors reference.
|
|
68
|
+
|
|
69
|
+
### Changed
|
|
70
|
+
|
|
71
|
+
- **Shell expansion is one left-to-right pass.** Command output is spliced in
|
|
72
|
+
verbatim and never re-scanned, so `$VAR`, `$(...)`, or `<%` printed by a
|
|
73
|
+
command stays text. Command stderr goes to `$stderr` on success and into
|
|
74
|
+
`ShellCommandError` on failure.
|
|
75
|
+
- **`include` tracks ancestors, not every rendered file,** so the same fragment
|
|
76
|
+
can be included twice in one prompt. Included files may have any extension.
|
|
77
|
+
- **Front matter is validated:** must be a mapping (or empty); `parameters:`
|
|
78
|
+
must be a mapping; flags are coerced as described under Upgrading.
|
|
79
|
+
- **Directive registry policy:** `PM.register` is atomic (nothing is registered
|
|
80
|
+
if any name is taken). `PM::Directive.register_all` is idempotent, lets a later
|
|
81
|
+
subclass override an earlier one, and raises if a name was claimed with
|
|
82
|
+
`PM.register`.
|
|
83
|
+
- **Template name resolution is defined:** parameter (called without arguments)
|
|
84
|
+
> directive > `nil` (or error in strict mode).
|
|
85
|
+
- **Internals:** rendering moved from `Parsed` into `PM::Renderer` and
|
|
86
|
+
`PM::RenderScope`; `Parsed#render_with` remains for `include`.
|
|
87
|
+
- **Packaging:** gemspec allow-lists `lib/**/*.rb`, `README.md`, `CHANGELOG.md`,
|
|
88
|
+
`LICENSE`; adds `changelog_uri`, `documentation_uri`, `bug_tracker_uri`;
|
|
89
|
+
development dependencies move to the Gemfile.
|
|
90
|
+
|
|
91
|
+
### Fixed
|
|
92
|
+
|
|
93
|
+
- Including the same file twice raised "Circular include detected".
|
|
94
|
+
- Empty (`---\n---`) or scalar front matter raised `NoMethodError`.
|
|
95
|
+
- `include` of a path without `.md` parsed the path string as the prompt.
|
|
96
|
+
- `created_at` raised `NotImplementedError` on filesystems without birthtime;
|
|
97
|
+
it now falls back to `ctime`.
|
|
98
|
+
- `erb: 'true'` (a string) silently disabled ERB.
|
|
99
|
+
- A metadata key named like an `Object` method (`hash`, `method`, `display`)
|
|
100
|
+
returned the method instead of the value.
|
|
101
|
+
- Two tests asserted nothing and produced `ruby -w` warnings; `.irbrc` used the
|
|
102
|
+
removed 0.x API.
|
|
103
|
+
- Documentation corrections throughout: built-in directive lists, error messages,
|
|
104
|
+
`content` newline examples, `Struct` signatures, hard-coded version, an opening
|
|
105
|
+
example that registered the built-in `:read`, and fences nested inside fences.
|
|
106
|
+
|
|
107
|
+
### Removed
|
|
108
|
+
|
|
109
|
+
- The `ostruct` runtime dependency. PM now has none.
|
|
110
|
+
- `test/pm_test.rb` (redundant with the Rakefile glob).
|
|
111
|
+
- Documentation, examples, and media from the packaged gem.
|
|
112
|
+
|
|
113
|
+
## [1.0.2] - 2026-02-09
|
|
114
|
+
|
|
115
|
+
### Changed
|
|
4
116
|
- Made `PM.parse_string` a public class method so it can be called directly for parsing strings without file-based metadata enrichment.
|
|
5
117
|
|
|
6
|
-
|
|
118
|
+
## [1.0.1] - 2026-02-04
|
|
7
119
|
|
|
8
|
-
|
|
120
|
+
### Added
|
|
9
121
|
- **`PM::Directive` base class** — class-based DSL for defining directive categories. Use `desc` before method definitions to mark them as directives, and `alias_method` for aliases. Subclass tracking, `register_all`, `category_name`, and `build_dispatch_block` are all built-in.
|
|
10
122
|
- **Built-in `insert` directive** (alias: `read`) — insert any file's raw content into a prompt. Unlike `include`, the inserted content is not parsed, shell-expanded, or ERB-rendered.
|
|
11
123
|
- New test file `directive_base_test.rb` with tests for the `PM::Directive` DSL, subclass tracking, category naming, and dispatch block building.
|
|
12
124
|
- New test fixtures for `insert`/`read` directive coverage.
|
|
13
125
|
|
|
14
|
-
|
|
126
|
+
### Changed
|
|
15
127
|
- **`PM::CoreDirectives`** — built-in `include`, `insert`/`read` directives refactored as a `PM::Directive` subclass using the `desc` DSL.
|
|
16
128
|
- `PM.register` directive aliases now support registration via `alias_method` in `PM::Directive` subclasses, with automatic detection via `UnboundMethod#original_name`.
|
|
17
129
|
- Directive registry simplified; `PM.reset_directives!` now delegates to `PM::Directive.register_all`.
|
|
18
130
|
- Updated README and documentation guides for custom directives and includes.
|
|
19
131
|
|
|
20
|
-
##
|
|
21
|
-
### [1.0.0] = 2026-02-03
|
|
132
|
+
## [1.0.0] - 2026-02-03
|
|
22
133
|
|
|
23
134
|
**Complete rewrite** — repositioned from a prompt management system with storage adapters to a focused prompt parsing and rendering engine.
|
|
24
135
|
|
|
25
|
-
|
|
136
|
+
### Breaking Changes
|
|
26
137
|
- **New `PM` module replaces `PromptManager`** — the entire codebase has been restructured under the `PM` namespace. A backward-compatibility alias (`PromptManager = PM`) is provided via `require 'prompt_manager'`.
|
|
27
138
|
- **Storage adapters removed** — `FileSystemAdapter`, `ActiveRecordAdapter`, and all database-backed persistence have been removed. The library now operates on strings, files, and Pathnames directly.
|
|
28
139
|
- **`Prompt` class removed** — replaced by the lightweight `PM::Parsed` struct.
|
|
@@ -30,7 +141,7 @@
|
|
|
30
141
|
- **Parameter history removed** — the library no longer tracks historical parameter values per keyword.
|
|
31
142
|
- **Configuration simplified** — only three settings remain: `prompts_dir`, `shell`, and `erb`. Options like `parameter_regex` and `search_proc` have been removed.
|
|
32
143
|
|
|
33
|
-
|
|
144
|
+
### New Features
|
|
34
145
|
- **Symbol and single-word parsing** — `PM.parse(:code_review)` and `PM.parse('code_review')` automatically resolve to `code_review.md` in the configured `prompts_dir`.
|
|
35
146
|
- **Directive aliases** — `PM.register(:webpage, :website, :web) { |ctx, url| ... }` registers multiple names for a single directive with rollback on duplicate detection.
|
|
36
147
|
- **`PM::Metadata`** — OpenStruct-based metadata with automatic predicate methods for boolean fields (e.g., `metadata.shell?`).
|
|
@@ -38,7 +149,7 @@
|
|
|
38
149
|
- **Built-in `include` directive** — compose prompts from multiple files with loop protection.
|
|
39
150
|
- **Streamlined parsing pipeline** — strip HTML comments, extract YAML front matter, optional shell expansion (`$VAR`, `${VAR}`, `$(command)`), optional ERB rendering.
|
|
40
151
|
|
|
41
|
-
|
|
152
|
+
### Removed
|
|
42
153
|
- `PromptManager::Prompt` class
|
|
43
154
|
- `PromptManager::DirectiveProcessor` class
|
|
44
155
|
- `PromptManager::Storage::FileSystemAdapter`
|
|
@@ -46,35 +157,35 @@
|
|
|
46
157
|
- Custom error classes (`PromptManager::Error` hierarchy)
|
|
47
158
|
- Development dependencies on `activerecord`, `sqlite3`, and `tocer`
|
|
48
159
|
|
|
49
|
-
|
|
160
|
+
### Added
|
|
50
161
|
- Runtime dependency on `ostruct`
|
|
51
162
|
- Comprehensive test suite (8 test files, 19 fixtures)
|
|
52
163
|
- Full documentation site under `docs/` with guides for parsing, shell expansion, ERB rendering, custom directives, and prompt composition
|
|
53
164
|
|
|
54
|
-
|
|
165
|
+
## [0.5.8] - 2025-09-01
|
|
55
166
|
- fixed issue where removed keywords from prompt text were still being included in parameters if they existed in the JSON file (addresses AIA issue #105)
|
|
56
167
|
- parameters now only include keywords currently present in the prompt text, while preserving historical values for existing keywords
|
|
57
168
|
|
|
58
|
-
|
|
169
|
+
## [0.5.7] - 2025-06-25
|
|
59
170
|
- fixed a problem when the value of a parameter is an empty array
|
|
60
171
|
- fixed a failing test
|
|
61
172
|
|
|
62
|
-
|
|
173
|
+
## [0.5.6] - 2025-06-04
|
|
63
174
|
- fixed a problem where shell integration was not working correctly for $(shell command)
|
|
64
175
|
|
|
65
|
-
|
|
176
|
+
## [0.5.5] - 2025-05-21
|
|
66
177
|
- fixed bug in parameter substitution when value is an Array now uses last entry
|
|
67
178
|
|
|
68
|
-
|
|
179
|
+
## [0.5.4] - 2025-05-18
|
|
69
180
|
- fixed typo in the Prompt class envvar should have been envar which prevented shell integration from taking place.
|
|
70
181
|
|
|
71
|
-
|
|
182
|
+
## [0.5.3] - 2025-05-14
|
|
72
183
|
- fixed issue were directives were not getting their content added to the prompt text
|
|
73
184
|
- Updated documentation and versioning.
|
|
74
185
|
- Added new error classes for better error handling.
|
|
75
186
|
- Improved parameter handling and directive processing.
|
|
76
187
|
|
|
77
|
-
|
|
188
|
+
## [0.5.0] - 2025-03-29
|
|
78
189
|
- Major refactoring of to improve processing of parameters and directives.
|
|
79
190
|
- Added PromptManager::DirectiveProcessor as an example of how to implement custom directives.
|
|
80
191
|
- Added support for //include directive that protects against loops.
|
|
@@ -82,33 +193,33 @@
|
|
|
82
193
|
- Added support for ERB processing within a prompt.
|
|
83
194
|
- Improved test coverage.
|
|
84
195
|
|
|
85
|
-
|
|
196
|
+
## [0.4.2] - 2024-10-26
|
|
86
197
|
- Added configurable parameter_regex to customize keyword pattern
|
|
87
198
|
|
|
88
|
-
|
|
199
|
+
## [0.4.1] - 2023-12-29
|
|
89
200
|
- Changed @directives from Hash to an Array
|
|
90
201
|
- Fixed keywords not being substituted in directives
|
|
91
202
|
|
|
92
|
-
|
|
203
|
+
## [0.4.0] - 2023-12-19
|
|
93
204
|
- Add "//directives param(s)" with keywords just like the prompt text.
|
|
94
205
|
|
|
95
|
-
|
|
206
|
+
## [0.3.3] - 2023-12-01
|
|
96
207
|
- Added example of using the `search_proc` config parameter with the FileSystemAdapter.
|
|
97
208
|
|
|
98
|
-
|
|
209
|
+
## [0.3.2] - 2023-12-01
|
|
99
210
|
|
|
100
211
|
- The ActiveRecordAdapter is passing its unit tests
|
|
101
212
|
- Dropped the concept of an sqlite3 adapter since active record can be used to access sqlite3 databases as well as the big boys.
|
|
102
213
|
|
|
103
|
-
|
|
214
|
+
## [0.3.0] - 2023-11-28
|
|
104
215
|
|
|
105
216
|
- **Breaking change** The value of the parameters Hash for a keyword is now an Array instead of a single value. The last value in the Array is always the most recent value used for the given keyword. This was done to support the use of a Readline::History object editing in the [aia](https://github.com/MadBomber/aia) CLI tool
|
|
106
217
|
|
|
107
|
-
|
|
218
|
+
## [0.2.0] - 2023-11-21
|
|
108
219
|
|
|
109
220
|
- **Breaking change to FileSystemAdapter config process**
|
|
110
221
|
- added list and path as extra methods in FileSystemAdapter
|
|
111
222
|
|
|
112
|
-
|
|
223
|
+
## [0.1.0] - 2023-11-16
|
|
113
224
|
|
|
114
225
|
- Initial release using the FileSystemAdapter
|