Skip to content

Commit e10f569

Browse files
committed
Initial commit
0 parents  commit e10f569

File tree

5 files changed

+144
-0
lines changed

5 files changed

+144
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Chimit
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 all
13+
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 THE
21+
SOFTWARE.

README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Prompt
2+
3+
Prompt is a simple Laravel package for managing your AI prompts in Markdown files, with the full power of Blade.
4+
5+
## Installation
6+
7+
You can install the package via composer:
8+
9+
```bash
10+
composer require chimit/prompt
11+
```
12+
13+
## Usage
14+
15+
### Create Your Prompts
16+
17+
Create your prompt files in the `resources/prompts` directory using the `.md` extension. You can organize them in subdirectories as needed:
18+
19+
```
20+
resources/
21+
└── prompts/
22+
├── seo/
23+
│ └── product-meta.md
24+
└── welcome.md
25+
```
26+
27+
### Use Blade Syntax in Your Prompts
28+
29+
Your prompt files support full Blade syntax, including variables, PHP expressions, and unsafe HTML rendering. Here's an example `resources/prompts/seo/product-meta.md`:
30+
31+
```markdown
32+
You are an SEO expert specializing in e-commerce. Generate a compelling meta description for this product.
33+
34+
**Product:** {{ $product->name }}
35+
**Price:** ${{ number_format($product->price, 2) }}
36+
37+
**Product Description:**
38+
---
39+
{!! $product->description !!}
40+
---
41+
42+
@if($product->discount_percentage > 0)
43+
**Special Offer:** {{ $product->discount_percentage }}% OFF - Limited Time!
44+
@endif
45+
46+
Requirements:
47+
- Maximum 160 characters
48+
- Include the product name and key benefits
49+
- Create urgency if there's a discount
50+
- Target keywords: {{ implode(', ', $keywords) }}
51+
```
52+
53+
### Render Your Prompts
54+
55+
Use the `Prompt::get()` method to render your prompts with data, just like you would with Blade views:
56+
57+
```php
58+
use Chimit\Prompt;
59+
60+
$prompt = Prompt::get('seo/product-meta', [
61+
'product' => $product,
62+
'keywords' => ['wireless headphones', 'bluetooth', 'noise cancelling']
63+
]);
64+
```

composer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "chimit/prompt",
3+
"description": "Manage AI prompts in Blade style.",
4+
"type": "library",
5+
"license": "MIT",
6+
"keywords": [
7+
"laravel",
8+
"prompts",
9+
"blade",
10+
"ai"
11+
],
12+
"autoload": {
13+
"psr-4": {
14+
"Chimit\\": "src/"
15+
}
16+
},
17+
"authors": [
18+
{
19+
"name": "chimit",
20+
"email": "chimit@users.noreply.github.com",
21+
"homepage": "https://chimit.me"
22+
}
23+
],
24+
"require": {
25+
"illuminate/support": "^9.0 || ^10.0 || ^11.0 || ^12.0",
26+
"illuminate/filesystem": "^9.0 || ^10.0 || ^11.0 || ^12.0",
27+
"illuminate/view": "^9.0 || ^10.0 || ^11.0 || ^12.0"
28+
}
29+
}

src/Prompt.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Chimit;
4+
5+
use Illuminate\Contracts\Filesystem\FileNotFoundException;
6+
use Illuminate\Support\Facades\Blade;
7+
use Illuminate\Support\Facades\File;
8+
9+
class Prompt
10+
{
11+
/**
12+
* Get the content of a prompt and render it with Blade.
13+
*
14+
* @throws FileNotFoundException
15+
*/
16+
public static function get(string $name, array $data = []): string
17+
{
18+
$name = str_replace('.', '/', $name);
19+
$path = resource_path("prompts/{$name}.md");
20+
21+
if (! File::exists($path)) {
22+
throw new FileNotFoundException("Prompt [{$name}] not found.");
23+
}
24+
25+
$content = File::get($path);
26+
27+
return Blade::render($content, $data);
28+
}
29+
}

0 commit comments

Comments
 (0)