ruby_llm-registry 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b8cc22de69b90a698ba2fe765043e40881411bdef7d689fc38c3f4571a337a80
4
+ data.tar.gz: 461d0a268c6cf3970f3ba03e120085ec6620ae46c390ff0ba9648961cf3ae01b
5
+ SHA512:
6
+ metadata.gz: a9d1f5d97587744bf9090e7ba493cdbbb53842690a3faef1879acc6b99105c95f2a8937829e3b5c7f64ae60a8ac13c1ec823f1461bf7db3783cdad7bdfa53295
7
+ data.tar.gz: e6f9d1b75b75eb40e08b1534aaceec12e9d34b72f9a50b88a1b9fcdfd011d9059900592dbb2f1f367e11d3aec9dd7e0e74eb3893d7b830411d697afc5e170004
data/.idea/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Editor-based HTTP Client requests
5
+ /httpRequests/
@@ -0,0 +1,5 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ </profile>
5
+ </component>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="JavaScriptLibraryMappings">
4
+ <includedPredefinedLibrary name="Node.js Core" />
5
+ </component>
6
+ </project>
data/.idea/misc.xml ADDED
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="JavaScriptSettings">
4
+ <option name="languageLevel" value="ES6" />
5
+ </component>
6
+ <component name="JsFlowSettings">
7
+ <service-enabled>true</service-enabled>
8
+ <exe-path />
9
+ <annotation-enable>false</annotation-enable>
10
+ <other-services-enabled>true</other-services-enabled>
11
+ <auto-save>true</auto-save>
12
+ </component>
13
+ <component name="ProjectDictionaryState">
14
+ <dictionary name="washu" />
15
+ </component>
16
+ <component name="ProjectRootManager" version="2" project-jdk-name="rbenv: 2.4.2" project-jdk-type="RUBY_SDK" />
17
+ </project>
data/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/ruby_llm-registry.iml" filepath="$PROJECT_DIR$/.idea/ruby_llm-registry.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,79 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="ModuleRunConfigurationManager">
4
+ <shared />
5
+ </component>
6
+ <component name="NewModuleRootManager">
7
+ <content url="file://$MODULE_DIR$">
8
+ <sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
9
+ <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
10
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
11
+ </content>
12
+ <orderEntry type="jdk" jdkName="rbenv: 3.4.9" jdkType="RUBY_SDK" />
13
+ <orderEntry type="sourceFolder" forTests="false" />
14
+ <orderEntry type="library" scope="PROVIDED" name="activemodel (v8.1.3, rbenv: 3.4.9) [gem]" level="application" />
15
+ <orderEntry type="library" scope="TEST" name="activerecord (v8.1.3, rbenv: 3.4.9) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="activesupport (v8.1.3, rbenv: 3.4.9) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.3, rbenv: 3.4.9) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="aws-eventstream (v1.4.0, rbenv: 3.4.9) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="aws-partitions (v1.1257.0, rbenv: 3.4.9) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="aws-sdk-core (v3.251.0, rbenv: 3.4.9) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="aws-sdk-kms (v1.129.0, rbenv: 3.4.9) [gem]" level="application" />
22
+ <orderEntry type="library" scope="TEST" name="aws-sdk-s3 (v1.225.0, rbenv: 3.4.9) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="aws-sigv4 (v1.12.1, rbenv: 3.4.9) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="base64 (v0.3.0, rbenv: 3.4.9) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="bigdecimal (v4.1.2, rbenv: 3.4.9) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="bson (v5.2.0, rbenv: 3.4.9) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v2.6.9, rbenv: 3.4.9) [gem]" level="application" />
28
+ <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.3.6, rbenv: 3.4.9) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="connection_pool (v3.0.2, rbenv: 3.4.9) [gem]" level="application" />
30
+ <orderEntry type="library" scope="PROVIDED" name="date (v3.5.1, rbenv: 3.4.9) [gem]" level="application" />
31
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.6.2, rbenv: 3.4.9) [gem]" level="application" />
32
+ <orderEntry type="library" scope="PROVIDED" name="docile (v1.4.1, rbenv: 3.4.9) [gem]" level="application" />
33
+ <orderEntry type="library" scope="PROVIDED" name="drb (v2.2.3, rbenv: 3.4.9) [gem]" level="application" />
34
+ <orderEntry type="library" scope="PROVIDED" name="erb (v6.0.4, rbenv: 3.4.9) [gem]" level="application" />
35
+ <orderEntry type="library" scope="PROVIDED" name="i18n (v1.14.8, rbenv: 3.4.9) [gem]" level="application" />
36
+ <orderEntry type="library" scope="PROVIDED" name="io-console (v0.8.2, rbenv: 3.4.9) [gem]" level="application" />
37
+ <orderEntry type="library" scope="PROVIDED" name="irb (v1.18.0, rbenv: 3.4.9) [gem]" level="application" />
38
+ <orderEntry type="library" scope="PROVIDED" name="jmespath (v1.6.2, rbenv: 3.4.9) [gem]" level="application" />
39
+ <orderEntry type="library" scope="PROVIDED" name="json (v2.19.8, rbenv: 3.4.9) [gem]" level="application" />
40
+ <orderEntry type="library" scope="PROVIDED" name="language_server-protocol (v3.17.0.5, rbenv: 3.4.9) [gem]" level="application" />
41
+ <orderEntry type="library" scope="PROVIDED" name="lint_roller (v1.1.0, rbenv: 3.4.9) [gem]" level="application" />
42
+ <orderEntry type="library" scope="PROVIDED" name="logger (v1.7.0, rbenv: 3.4.9) [gem]" level="application" />
43
+ <orderEntry type="library" scope="PROVIDED" name="minitest (v6.0.6, rbenv: 3.4.9) [gem]" level="application" />
44
+ <orderEntry type="library" scope="TEST" name="mongo (v2.24.1, rbenv: 3.4.9) [gem]" level="application" />
45
+ <orderEntry type="library" scope="PROVIDED" name="parallel (v2.1.0, rbenv: 3.4.9) [gem]" level="application" />
46
+ <orderEntry type="library" scope="PROVIDED" name="parser (v3.3.11.1, rbenv: 3.4.9) [gem]" level="application" />
47
+ <orderEntry type="library" scope="PROVIDED" name="pp (v0.6.3, rbenv: 3.4.9) [gem]" level="application" />
48
+ <orderEntry type="library" scope="PROVIDED" name="prettyprint (v0.2.0, rbenv: 3.4.9) [gem]" level="application" />
49
+ <orderEntry type="library" scope="PROVIDED" name="prism (v1.9.0, rbenv: 3.4.9) [gem]" level="application" />
50
+ <orderEntry type="library" scope="PROVIDED" name="psych (v5.4.0, rbenv: 3.4.9) [gem]" level="application" />
51
+ <orderEntry type="library" scope="PROVIDED" name="racc (v1.8.1, rbenv: 3.4.9) [gem]" level="application" />
52
+ <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, rbenv: 3.4.9) [gem]" level="application" />
53
+ <orderEntry type="library" scope="PROVIDED" name="rake (v13.4.2, rbenv: 3.4.9) [gem]" level="application" />
54
+ <orderEntry type="library" scope="PROVIDED" name="rdoc (v7.2.0, rbenv: 3.4.9) [gem]" level="application" />
55
+ <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.12.0, rbenv: 3.4.9) [gem]" level="application" />
56
+ <orderEntry type="library" scope="PROVIDED" name="reline (v0.6.3, rbenv: 3.4.9) [gem]" level="application" />
57
+ <orderEntry type="library" scope="TEST" name="rexml (v3.4.4, rbenv: 3.4.9) [gem]" level="application" />
58
+ <orderEntry type="library" scope="TEST" name="rspec (v3.13.2, rbenv: 3.4.9) [gem]" level="application" />
59
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.13.6, rbenv: 3.4.9) [gem]" level="application" />
60
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.13.5, rbenv: 3.4.9) [gem]" level="application" />
61
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.13.8, rbenv: 3.4.9) [gem]" level="application" />
62
+ <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.13.7, rbenv: 3.4.9) [gem]" level="application" />
63
+ <orderEntry type="library" scope="PROVIDED" name="rubocop (v1.87.0, rbenv: 3.4.9) [gem]" level="application" />
64
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.49.1, rbenv: 3.4.9) [gem]" level="application" />
65
+ <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.13.0, rbenv: 3.4.9) [gem]" level="application" />
66
+ <orderEntry type="library" scope="PROVIDED" name="securerandom (v0.4.1, rbenv: 3.4.9) [gem]" level="application" />
67
+ <orderEntry type="library" scope="TEST" name="simplecov (v0.22.0, rbenv: 3.4.9) [gem]" level="application" />
68
+ <orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.13.2, rbenv: 3.4.9) [gem]" level="application" />
69
+ <orderEntry type="library" scope="PROVIDED" name="simplecov_json_formatter (v0.1.4, rbenv: 3.4.9) [gem]" level="application" />
70
+ <orderEntry type="library" scope="TEST" name="sqlite3 (v2.9.4, rbenv: 3.4.9) [gem]" level="application" />
71
+ <orderEntry type="library" scope="PROVIDED" name="stringio (v3.2.0, rbenv: 3.4.9) [gem]" level="application" />
72
+ <orderEntry type="library" scope="PROVIDED" name="timeout (v0.6.1, rbenv: 3.4.9) [gem]" level="application" />
73
+ <orderEntry type="library" scope="PROVIDED" name="tsort (v0.2.0, rbenv: 3.4.9) [gem]" level="application" />
74
+ <orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.6, rbenv: 3.4.9) [gem]" level="application" />
75
+ <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v3.2.0, rbenv: 3.4.9) [gem]" level="application" />
76
+ <orderEntry type="library" scope="PROVIDED" name="unicode-emoji (v4.2.0, rbenv: 3.4.9) [gem]" level="application" />
77
+ <orderEntry type="library" scope="PROVIDED" name="uri (v1.1.1, rbenv: 3.4.9) [gem]" level="application" />
78
+ </component>
79
+ </module>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,65 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ TargetRubyVersion: 3.3
4
+
5
+ Style/StringLiterals:
6
+ EnforcedStyle: double_quotes
7
+
8
+
9
+ Layout/LineLength:
10
+ Enabled: false
11
+
12
+ Layout/TrailingEmptyLines:
13
+ Enabled: false
14
+
15
+ Metrics/AbcSize:
16
+ Enabled: false
17
+
18
+ Metrics/BlockLength:
19
+ Enabled: false
20
+
21
+ Metrics/ClassLength:
22
+ Enabled: false
23
+
24
+ Metrics/MethodLength:
25
+ Enabled: false
26
+
27
+ Metrics/ParameterLists:
28
+ Enabled: false
29
+
30
+ Metrics/CyclomaticComplexity:
31
+ Enabled: false
32
+
33
+ Metrics/PerceivedComplexity:
34
+ Enabled: false
35
+
36
+ Style/Documentation:
37
+ Enabled: false
38
+
39
+ Lint/ConstantDefinitionInBlock:
40
+ Enabled: false
41
+
42
+ Lint/MissingSuper:
43
+ Enabled: false
44
+
45
+ Lint/UselessAssignment:
46
+ Enabled: false
47
+
48
+ Lint/UnusedBlockArgument:
49
+ Enabled: false
50
+
51
+ Style/ArgumentsForwarding:
52
+ Enabled: false
53
+
54
+ Style/IfUnlessModifier:
55
+ Enabled: false
56
+
57
+ Style/MultilineBlockChain:
58
+ Enabled: false
59
+
60
+ Style/SafeNavigation:
61
+ Enabled: false
62
+
63
+ Style/StringLiteralsInInterpolation:
64
+ Enabled: false
65
+
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2026-06-05
4
+
5
+ - Initial release
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Sal Scotto
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # RubyLlm::Registry
2
+
3
+ [![CI](https://github.com/washu/ruby_llm-registry/actions/workflows/ci.yml/badge.svg)](https://github.com/washu/ruby_llm-registry/actions/workflows/ci.yml)
4
+
5
+ Local-first, versioned prompt storage and rendering for RubyLLM applications.
6
+
7
+ ## What it does
8
+
9
+ `RubyLlm::Registry` treats prompts as immutable artifacts stored outside your app code. It can:
10
+
11
+ - load the latest or a specific semantic version
12
+ - resolve labels like `production` or `staging`
13
+ - read prompt files from a filesystem-backed registry
14
+ - render ERB templates with required-variable validation
15
+ - export/import prompts as YAML, JSON, or markdown
16
+ - compare prompt revisions and surface a field/body diff
17
+ - optionally store prompts in SQLite, ActiveRecord, MongoDB, or S3 backends when those gems/services are loaded
18
+
19
+ ## Quick start
20
+
21
+ ```ruby
22
+ prompt = RubyLlm::Registry.get("email/summarizer", label: :production)
23
+
24
+ rendered = prompt.render(
25
+ user_name: "Ava",
26
+ email_body: "Thanks for the update",
27
+ summary_length: "concise"
28
+ )
29
+
30
+ diff = RubyLlm::Registry.diff(prompt, prompt.export(format: :markdown))
31
+ puts diff.changed_fields
32
+ ```
33
+
34
+ ## Optional adapters
35
+
36
+ The gem stays filesystem-first by default. If you need a different store, opt in explicitly:
37
+
38
+ ```ruby
39
+ sqlite = RubyLlm::Registry.database_backend(:sqlite, path: "tmp/prompts.db")
40
+
41
+ # or, when those integrations are available in your app:
42
+ # RubyLlm::Registry.database_backend(:active_record)
43
+ # RubyLlm::Registry.database_backend(:mongo, collection: MyCollection)
44
+ # RubyLlm::Registry.backend(:s3, client: s3_client, bucket: "my-bucket")
45
+ ```
46
+
47
+ All non-filesystem adapters are loaded lazily, so your app only pulls in the storage stack it actually uses.
48
+
49
+ ## Prompt file layout
50
+
51
+ ```text
52
+ prompts/
53
+ └── email/
54
+ └── summarizer/
55
+ ├── v1.0.0.md
56
+ ├── v1.1.0.md
57
+ └── v1.2.3.md
58
+ ```
59
+
60
+ Each file may include YAML front matter:
61
+
62
+ ```markdown
63
+ ---
64
+ version: 1.2.3
65
+ labels: [production]
66
+ required_vars: [user_name, email_body]
67
+ metadata:
68
+ description: Concise email thread summarizer
69
+ ---
70
+
71
+ Hello <%= user_name %>
72
+ ```
73
+
74
+ ## Development
75
+
76
+ Run the test suite with:
77
+
78
+ ```bash
79
+ bundle exec rspec
80
+ ```
81
+
82
+ SimpleCov enforces a 90% minimum coverage threshold, and the latest verified local run is 93%.
83
+
84
+ The integration specs exercise real fixtures plus optional Docker-backed services:
85
+
86
+ - SQLite and ActiveRecord use local temp databases
87
+ - MongoDB spins up a `mongo:8` container when Docker is available
88
+ - S3 uses a `minio/minio` container for compatibility testing
89
+
90
+ If Docker is unavailable, those examples skip cleanly.
91
+
92
+ ## License
93
+
94
+ MIT
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/build_release.sh ADDED
@@ -0,0 +1,13 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ # Extract version from version.rb
5
+ VERSION=$(ruby -r ./lib/ruby_llm/registry/version.rb -e "puts RubyLLM::Registry::VERSION")
6
+
7
+ echo "Building gem version ${VERSION}..."
8
+ gem build ruby_llm-registry.gemspec
9
+
10
+ echo "Pushing to RubyGems..."
11
+ gem push ruby_llm-registry-${VERSION}.gem
12
+
13
+ echo "Done!"
@@ -0,0 +1,115 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module RubyLLM
6
+ module Registry
7
+ module Adapters
8
+ # ActiveRecord-backed prompt repository.
9
+ class ActiveRecord < Base
10
+ def initialize(model: nil, table_name: "ruby_llm_registry_prompts")
11
+ require_active_record!
12
+ @model = model || build_model(table_name)
13
+ ensure_schema!
14
+ end
15
+
16
+ def get(path, version: nil, label: nil)
17
+ scope = model.where(path: path)
18
+ raise PromptNotFoundError, "Prompt path not found: #{path}" if scope.none?
19
+
20
+ record = if version
21
+ scope.find_by(version: Version.parse(version).to_s)
22
+ elsif label
23
+ label = label.to_sym
24
+ scope.to_a.find { |row| labels_for(row).include?(label) } || scope.find_by(version: label.to_s)
25
+ else
26
+ scope.to_a.max_by { |row| Version.parse(row.version) }
27
+ end
28
+
29
+ raise PromptNotFoundError, "Prompt not found: #{path}" unless record
30
+
31
+ prompt_from_record(record)
32
+ end
33
+
34
+ def available_versions(path)
35
+ model.where(path: path).map { |row| Version.parse(row.version) }.sort
36
+ end
37
+
38
+ def store(prompt, overwrite: false)
39
+ existing = model.find_by(path: prompt.path, version: prompt.version.to_s)
40
+ raise Error, "Prompt #{prompt.path}@#{prompt.version} already exists" if existing && !overwrite
41
+
42
+ attrs = serialize_prompt(prompt)
43
+ existing ? existing.update!(attrs) : model.create!(attrs)
44
+ prompt
45
+ end
46
+
47
+ private
48
+
49
+ attr_reader :model
50
+
51
+ def require_active_record!
52
+ require "active_record"
53
+ rescue LoadError
54
+ raise LoadError, "active_record gem is required for the ActiveRecord adapter"
55
+ end
56
+
57
+ def build_model(table_name)
58
+ Class.new(::ActiveRecord::Base) do
59
+ self.table_name = table_name
60
+ end
61
+ end
62
+
63
+ def ensure_schema!
64
+ return if model.connection.data_source_exists?(model.table_name)
65
+
66
+ model.connection.create_table(model.table_name) do |table|
67
+ table.string :path, null: false
68
+ table.string :namespace, null: false
69
+ table.string :name, null: false
70
+ table.string :version, null: false
71
+ table.text :body, null: false
72
+ table.text :labels_json, null: false, default: "[]"
73
+ table.text :metadata_json, null: false, default: "{}"
74
+ table.text :required_vars_json, null: false, default: "[]"
75
+ table.string :source_path
76
+ table.timestamps null: false
77
+ table.index %i[path version], unique: true
78
+ end
79
+ end
80
+
81
+ def serialize_prompt(prompt)
82
+ {
83
+ path: prompt.path,
84
+ namespace: prompt.namespace,
85
+ name: prompt.name,
86
+ version: prompt.version.to_s,
87
+ body: prompt.body,
88
+ labels_json: JSON.generate(prompt.labels),
89
+ metadata_json: JSON.generate(prompt.metadata),
90
+ required_vars_json: JSON.generate(prompt.required_vars),
91
+ source_path: prompt.source_path
92
+ }
93
+ end
94
+
95
+ def prompt_from_record(record)
96
+ Prompt.new(
97
+ name: record.name,
98
+ namespace: record.namespace,
99
+ version: record.version,
100
+ body: record.body,
101
+ source_path: record.source_path,
102
+ labels: JSON.parse(record.labels_json || "[]"),
103
+ metadata: JSON.parse(record.metadata_json || "{}"),
104
+ required_vars: JSON.parse(record.required_vars_json || "[]")
105
+ )
106
+ end
107
+
108
+ def labels_for(record)
109
+ JSON.parse(record.labels_json || "[]").map(&:to_sym)
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
115
+
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLLM
4
+ module Registry
5
+ module Adapters
6
+ # Shared adapter behavior for prompt storage backends.
7
+ class Base
8
+ def get(_path, version: nil, label: nil)
9
+ raise NotImplementedError, "#{self.class} must implement #get"
10
+ end
11
+
12
+ def available_versions(_path)
13
+ []
14
+ end
15
+
16
+ def store(_prompt, **)
17
+ raise NotImplementedError, "#{self.class} must implement #store"
18
+ end
19
+
20
+ def export(path, version: nil, label: nil, format: :markdown, **options)
21
+ prompt = get(path, version: version, label: label)
22
+ Exporter.new(prompt).public_send(exporter_method(format), **options)
23
+ end
24
+
25
+ def import(payload, format: :auto, **options)
26
+ prompt = Importer.new(payload, format: format, **options).to_prompt
27
+ store(prompt)
28
+ prompt
29
+ end
30
+
31
+ private
32
+
33
+ def exporter_method(format)
34
+ case format.to_sym
35
+ when :yaml then :to_yaml
36
+ when :json then :to_json
37
+ when :markdown, :md then :to_markdown
38
+ when :hash then :to_h
39
+ else
40
+ raise ArgumentError, "Unsupported export format: #{format.inspect}"
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+