prompt_manager 1.0.1 → 1.0.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +8 -0
- data/docs/api/pm-module.md +38 -0
- data/docs/getting-started/quick-start.md +13 -0
- data/docs/guides/parsing.md +24 -0
- data/lib/pm/version.rb +1 -1
- data/lib/pm.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f2de9f9b60b1bad9884fba07f280c00316c05dbd8d5f6b86e01805e461aaf968
|
|
4
|
+
data.tar.gz: 73162b249b9676d13bdf015a7cba72949d3fe9834ff6b6441fbe452048613e04
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eb50e40c8eeb0873a68b1d84481391a1fa7b0c8f1971a461b662b86faa101bd3fd58a584f4364f2510e9df282904e3329f64b6319a16a684020b574f3aa0f1a1
|
|
7
|
+
data.tar.gz: 20f9e743881dca244716a5e14e97a34a050e07afb6ac954122988acf0cd7fd3b9bdf20c726ab73885c1a10301cc5ccdd194bcc38c50611340b6f77c06e87d2ab
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -95,6 +95,14 @@ parsed = PM.parse("---\ntitle: Hello\n---\nContent here")
|
|
|
95
95
|
|
|
96
96
|
When given a file path, `parse` adds `directory`, `name`, `created_at`, and `modified_at` to the metadata. Both forms run the full processing pipeline.
|
|
97
97
|
|
|
98
|
+
Note that `PM.parse` treats single words (e.g. `'hello'`) as prompt IDs and appends `.md` to look them up as files. To parse a single word as literal string content, use `PM.parse_string`:
|
|
99
|
+
|
|
100
|
+
```ruby
|
|
101
|
+
PM.parse('hello') #=> looks for hello.md in prompts_dir
|
|
102
|
+
PM.parse_string('hello') #=> parses "hello" as string content
|
|
103
|
+
PM.parse_string('Any string') #=> always parsed as content, never as a file
|
|
104
|
+
```
|
|
105
|
+
|
|
98
106
|
Given a file `code_review.md`:
|
|
99
107
|
|
|
100
108
|
```md
|
data/docs/api/pm-module.md
CHANGED
|
@@ -38,6 +38,44 @@ parsed = PM.parse("---\ntitle: Hello\n---\nContent")
|
|
|
38
38
|
|
|
39
39
|
---
|
|
40
40
|
|
|
41
|
+
### PM.parse_string(string) → Parsed
|
|
42
|
+
|
|
43
|
+
Parse a string directly through the processing pipeline, bypassing all file-detection logic. Unlike `PM.parse`, single words are never treated as prompt IDs.
|
|
44
|
+
|
|
45
|
+
**Parameters:**
|
|
46
|
+
|
|
47
|
+
| Name | Type | Description |
|
|
48
|
+
|------|------|-------------|
|
|
49
|
+
| `string` | String | Raw string content to parse |
|
|
50
|
+
|
|
51
|
+
**Returns:** `PM::Parsed` (Struct with `metadata` and `content`)
|
|
52
|
+
|
|
53
|
+
**Behavior:**
|
|
54
|
+
|
|
55
|
+
- Always parses the input as string content — never looks up files
|
|
56
|
+
- Runs the same pipeline as `PM.parse`: strip comments → extract YAML → shell expansion
|
|
57
|
+
- Does not add `directory`, `name`, `created_at`, or `modified_at` to metadata
|
|
58
|
+
|
|
59
|
+
```ruby
|
|
60
|
+
# Single words are parsed as content, not treated as file basenames
|
|
61
|
+
parsed = PM.parse_string('hello')
|
|
62
|
+
parsed.content #=> "hello"
|
|
63
|
+
|
|
64
|
+
# Strings with YAML front-matter work as expected
|
|
65
|
+
parsed = PM.parse_string("---\ntitle: Hello\n---\nContent")
|
|
66
|
+
parsed.metadata.title #=> "Hello"
|
|
67
|
+
parsed.content #=> "Content\n"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**When to use `parse_string` instead of `parse`:**
|
|
71
|
+
|
|
72
|
+
```ruby
|
|
73
|
+
PM.parse('summarize') #=> looks for summarize.md
|
|
74
|
+
PM.parse_string('summarize') #=> parses "summarize" as content
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
41
79
|
## Configuration
|
|
42
80
|
|
|
43
81
|
### PM.config → Configuration
|
|
@@ -40,6 +40,19 @@ puts parsed.to_s('name' => 'Alice')
|
|
|
40
40
|
|
|
41
41
|
When parsing a file, PM also adds `directory`, `name`, `created_at`, and `modified_at` to the metadata.
|
|
42
42
|
|
|
43
|
+
## Parse a String Directly
|
|
44
|
+
|
|
45
|
+
`PM.parse` treats single words as prompt IDs and looks them up as files. To always parse a string as content, use `PM.parse_string`:
|
|
46
|
+
|
|
47
|
+
```ruby
|
|
48
|
+
PM.parse('hello') #=> looks for hello.md in prompts_dir
|
|
49
|
+
PM.parse_string('hello') #=> parses "hello" as string content
|
|
50
|
+
|
|
51
|
+
parsed = PM.parse_string("---\ntitle: Inline\n---\nSome content")
|
|
52
|
+
parsed.metadata.title #=> "Inline"
|
|
53
|
+
parsed.content #=> "Some content\n"
|
|
54
|
+
```
|
|
55
|
+
|
|
43
56
|
## Parameters
|
|
44
57
|
|
|
45
58
|
Parameters declared in the YAML front-matter define template variables:
|
data/docs/guides/parsing.md
CHANGED
|
@@ -69,6 +69,30 @@ String-parsed prompts do not have `directory`, `name`, `created_at`, or `modifie
|
|
|
69
69
|
!!! warning "Include limitations"
|
|
70
70
|
The `include` directive requires file context to resolve relative paths. It raises an error when used with string-parsed prompts.
|
|
71
71
|
|
|
72
|
+
### PM.parse_string vs PM.parse
|
|
73
|
+
|
|
74
|
+
Because `PM.parse` treats single words as prompt IDs (appending `.md` and looking them up as files), short strings like `"hello"` or `"summarize"` will trigger a file lookup instead of being parsed as content. Use `PM.parse_string` to always parse a string as content:
|
|
75
|
+
|
|
76
|
+
```ruby
|
|
77
|
+
# PM.parse treats single words as prompt IDs
|
|
78
|
+
PM.parse('hello') #=> looks for hello.md in prompts_dir
|
|
79
|
+
PM.parse('summarize') #=> looks for summarize.md in prompts_dir
|
|
80
|
+
|
|
81
|
+
# PM.parse_string always parses as string content
|
|
82
|
+
PM.parse_string('hello') #=> Parsed with content "hello"
|
|
83
|
+
PM.parse_string('summarize') #=> Parsed with content "summarize"
|
|
84
|
+
|
|
85
|
+
# Multi-word strings without .md extension work the same in both
|
|
86
|
+
PM.parse("Hello world") #=> Parsed with content "Hello world"
|
|
87
|
+
PM.parse_string("Hello world") #=> Parsed with content "Hello world"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Use `PM.parse_string` when:
|
|
91
|
+
|
|
92
|
+
- Your input may be a single word that should not be treated as a file
|
|
93
|
+
- You know the source is always a string, never a file path
|
|
94
|
+
- You want to skip the file-detection logic entirely
|
|
95
|
+
|
|
72
96
|
## Metadata Extraction
|
|
73
97
|
|
|
74
98
|
YAML front-matter is delimited by `---` fences:
|
data/lib/pm/version.rb
CHANGED
data/lib/pm.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: prompt_manager
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dewayne VanHoozer
|
|
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
159
159
|
- !ruby/object:Gem::Version
|
|
160
160
|
version: '0'
|
|
161
161
|
requirements: []
|
|
162
|
-
rubygems_version: 4.0.
|
|
162
|
+
rubygems_version: 4.0.6
|
|
163
163
|
specification_version: 4
|
|
164
164
|
summary: Parse YAML metadata from markdown prompts with shell expansion and ERB rendering
|
|
165
165
|
test_files: []
|