@ekaone/prompt-kit 0.0.1
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.
- package/LICENSE +21 -0
- package/README.md +256 -0
- package/dist/index.d.mts +29 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +10 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Eka Prasetia <ekaone3033@gmail.com> (https://prasetia.me)
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# @ekaone/prompt-kit
|
|
2
|
+
|
|
3
|
+
A lightweight, zero-dependency prompt template engine for Node.js. Build dynamic AI prompts from inline strings or `.md` files with YAML frontmatter support.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @ekaone/prompt-kit
|
|
9
|
+
|
|
10
|
+
pnpm add @ekaone/prompt-kit
|
|
11
|
+
|
|
12
|
+
yarn add @ekaone/prompt-kit
|
|
13
|
+
|
|
14
|
+
bun add @ekaone/prompt-kit
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- `{{variable}}` injection with strict or passthrough mode
|
|
20
|
+
- YAML frontmatter parser — zero dependencies, hand-rolled
|
|
21
|
+
- File-based prompt loading from `.md` files
|
|
22
|
+
- Minifier to strip comments and collapse whitespace
|
|
23
|
+
- Lifecycle hooks — `onSuccess` and `onError`
|
|
24
|
+
- Zero dependencies
|
|
25
|
+
- ESM + CJS dual output
|
|
26
|
+
- TypeScript-first
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { build } from "@ekaone/prompt-kit";
|
|
32
|
+
|
|
33
|
+
const prompt = build(
|
|
34
|
+
"You are a {{role}} assistant. Help the user with {{topic}}.",
|
|
35
|
+
{ role: "TypeScript", topic: "code review" }
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
console.log(prompt);
|
|
39
|
+
// → "You are a TypeScript assistant. Help the user with code review."
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## API
|
|
43
|
+
|
|
44
|
+
### `build(template, vars, options?)`
|
|
45
|
+
|
|
46
|
+
Injects variables into a template string and returns the built prompt.
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { build } from "@ekaone/prompt-kit";
|
|
50
|
+
|
|
51
|
+
const prompt = build(
|
|
52
|
+
"Summarize {{topic}} in {{words}} words.",
|
|
53
|
+
{ topic: "Rust", words: "100" }
|
|
54
|
+
);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Parameters**
|
|
58
|
+
|
|
59
|
+
| Parameter | Type | Description |
|
|
60
|
+
| ---------- | ------------- | ---------------------------------- |
|
|
61
|
+
| `template` | `string` | Prompt string with `{{var}}` placeholders |
|
|
62
|
+
| `vars` | `Vars` | Key-value map of variable values |
|
|
63
|
+
| `options` | `BuildOptions`| Optional config (see below) |
|
|
64
|
+
|
|
65
|
+
**BuildOptions**
|
|
66
|
+
|
|
67
|
+
| Option | Type | Default | Description |
|
|
68
|
+
| ----------- | --------------------------- | ------- | ------------------------------------------------ |
|
|
69
|
+
| `strict` | `boolean` | `true` | Throw on undefined variables |
|
|
70
|
+
| `onSuccess` | `(result: string) => void` | — | Called after a successful build |
|
|
71
|
+
| `onError` | `(error: Error) => void` | — | Called when build throws |
|
|
72
|
+
|
|
73
|
+
#### Strict mode (default)
|
|
74
|
+
|
|
75
|
+
Throws if a variable is referenced in the template but not provided in `vars`.
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
build("Hello {{name}}", {});
|
|
79
|
+
// → Error: [prompt-kit] Undefined variable: "{{name}}"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### Passthrough mode
|
|
83
|
+
|
|
84
|
+
Leaves undefined `{{variables}}` intact in the output.
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
const prompt = build(
|
|
88
|
+
"Hello {{name}}, your score is {{score}}.",
|
|
89
|
+
{ name: "Eka" },
|
|
90
|
+
{ strict: false }
|
|
91
|
+
);
|
|
92
|
+
// → "Hello Eka, your score is {{score}}."
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### Lifecycle hooks
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
const prompt = build(
|
|
99
|
+
"Review {{language}} code.",
|
|
100
|
+
{ language: "TypeScript" },
|
|
101
|
+
{
|
|
102
|
+
onSuccess: (result) => console.log("Built:", result.length, "chars"),
|
|
103
|
+
onError: (err) => console.error("Failed:", err.message),
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
### `buildFromFile(filePath, vars, options?)`
|
|
111
|
+
|
|
112
|
+
Loads a `.md` file, parses the frontmatter, and builds the prompt from the body.
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
import { buildFromFile } from "@ekaone/prompt-kit";
|
|
116
|
+
|
|
117
|
+
const prompt = await buildFromFile("./prompts/review.md", {
|
|
118
|
+
language: "TypeScript",
|
|
119
|
+
focus: "type safety",
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Prompt file format** — `./prompts/review.md`
|
|
124
|
+
|
|
125
|
+
```md
|
|
126
|
+
---
|
|
127
|
+
name: code-review
|
|
128
|
+
version: 1
|
|
129
|
+
tags: [typescript, review]
|
|
130
|
+
---
|
|
131
|
+
You are a senior {{language}} engineer.
|
|
132
|
+
Review the code for correctness, performance, and style.
|
|
133
|
+
Focus on: {{focus}}.
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
### `loadPromptFile(filePath)`
|
|
139
|
+
|
|
140
|
+
Reads and parses a `.md` file, returning `frontmatter` and `body` separately. Useful for reading metadata without triggering a build.
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
import { loadPromptFile } from "@ekaone/prompt-kit";
|
|
144
|
+
|
|
145
|
+
const { frontmatter, body } = await loadPromptFile("./prompts/review.md");
|
|
146
|
+
|
|
147
|
+
console.log(frontmatter.name); // → "code-review"
|
|
148
|
+
console.log(frontmatter.version); // → 1
|
|
149
|
+
console.log(frontmatter.tags); // → ["typescript", "review"]
|
|
150
|
+
console.log(body); // → "You are a senior {{language}} engineer..."
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
### `parseFrontmatter(source)`
|
|
156
|
+
|
|
157
|
+
Parses a raw markdown string into `{ frontmatter, body }`. Useful when you load file content yourself.
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
import { parseFrontmatter } from "@ekaone/prompt-kit";
|
|
161
|
+
|
|
162
|
+
const source = `---
|
|
163
|
+
name: summarizer
|
|
164
|
+
model: claude-opus-4-5
|
|
165
|
+
---
|
|
166
|
+
Summarize the following: {{input}}`;
|
|
167
|
+
|
|
168
|
+
const { frontmatter, body } = parseFrontmatter(source);
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Supported frontmatter value types**
|
|
172
|
+
|
|
173
|
+
| Type | Example |
|
|
174
|
+
| ------- | ------------------------- |
|
|
175
|
+
| String | `name: code-review` |
|
|
176
|
+
| Number | `version: 1` |
|
|
177
|
+
| Boolean | `strict: true` |
|
|
178
|
+
| Array | `tags: [a, b, c]` |
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
### `minify(input)`
|
|
183
|
+
|
|
184
|
+
Strips Markdown comments and collapses excess blank lines. Useful for reducing token usage before sending to an AI SDK.
|
|
185
|
+
|
|
186
|
+
```ts
|
|
187
|
+
import { buildFromFile, minify } from "@ekaone/prompt-kit";
|
|
188
|
+
|
|
189
|
+
const raw = await buildFromFile("./prompts/verbose.md", vars);
|
|
190
|
+
const prompt = minify(raw);
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Strips `[//]: # (internal note)` style comments and collapses 3+ blank lines into one.
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Types
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
type Vars = Record<string, string | number | boolean>;
|
|
201
|
+
|
|
202
|
+
interface BuildOptions {
|
|
203
|
+
strict?: boolean;
|
|
204
|
+
onSuccess?: (result: string) => void;
|
|
205
|
+
onError?: (error: Error) => void;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
interface FrontMatter {
|
|
209
|
+
[key: string]: string | number | boolean | string[];
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
interface ParsedPrompt {
|
|
213
|
+
frontmatter: FrontMatter;
|
|
214
|
+
body: string;
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Real-world pattern
|
|
221
|
+
|
|
222
|
+
```ts
|
|
223
|
+
import { buildFromFile, minify } from "@ekaone/prompt-kit";
|
|
224
|
+
import Anthropic from "@anthropic-ai/sdk";
|
|
225
|
+
|
|
226
|
+
const client = new Anthropic();
|
|
227
|
+
|
|
228
|
+
const prompt = minify(
|
|
229
|
+
await buildFromFile("./prompts/review.md", {
|
|
230
|
+
language: "TypeScript",
|
|
231
|
+
focus: "type safety",
|
|
232
|
+
})
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
const response = await client.messages.create({
|
|
236
|
+
model: "claude-opus-4-5",
|
|
237
|
+
max_tokens: 1024,
|
|
238
|
+
messages: [{ role: "user", content: prompt }],
|
|
239
|
+
});
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## License
|
|
245
|
+
|
|
246
|
+
MIT © [Eka Prasetia](https://prasetia.me/)
|
|
247
|
+
|
|
248
|
+
## Links
|
|
249
|
+
|
|
250
|
+
- [npm Package](https://www.npmjs.com/package/@ekaone/prompt-kit)
|
|
251
|
+
- [GitHub Repository](https://github.com/ekaone/prompt-kit)
|
|
252
|
+
- [Issue Tracker](https://github.com/ekaone/prompt-kit/issues)
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
⭐ If this library helps you, please consider giving it a star on GitHub!
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
type Vars = Record<string, string | number | boolean>;
|
|
2
|
+
interface BuildOptions {
|
|
3
|
+
/** Throw on undefined variables. Default: true */
|
|
4
|
+
strict?: boolean;
|
|
5
|
+
/** Called after a successful build */
|
|
6
|
+
onSuccess?: (result: string) => void;
|
|
7
|
+
/** Called when build throws */
|
|
8
|
+
onError?: (error: Error) => void;
|
|
9
|
+
}
|
|
10
|
+
interface FrontMatter {
|
|
11
|
+
[key: string]: string | number | boolean | string[];
|
|
12
|
+
}
|
|
13
|
+
interface ParsedPrompt {
|
|
14
|
+
frontmatter: FrontMatter;
|
|
15
|
+
body: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare function build(template: string, vars?: Vars, options?: BuildOptions): string;
|
|
19
|
+
|
|
20
|
+
declare function inject(template: string, vars: Vars, options?: BuildOptions): string;
|
|
21
|
+
|
|
22
|
+
declare function loadPromptFile(filePath: string): Promise<ParsedPrompt>;
|
|
23
|
+
declare function buildFromFile(filePath: string, vars?: Vars, options?: BuildOptions): Promise<string>;
|
|
24
|
+
|
|
25
|
+
declare function parseFrontmatter(source: string): ParsedPrompt;
|
|
26
|
+
|
|
27
|
+
declare function minify(input: string): string;
|
|
28
|
+
|
|
29
|
+
export { type BuildOptions, type FrontMatter, type ParsedPrompt, type Vars, build, buildFromFile, inject, loadPromptFile, minify, parseFrontmatter };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
type Vars = Record<string, string | number | boolean>;
|
|
2
|
+
interface BuildOptions {
|
|
3
|
+
/** Throw on undefined variables. Default: true */
|
|
4
|
+
strict?: boolean;
|
|
5
|
+
/** Called after a successful build */
|
|
6
|
+
onSuccess?: (result: string) => void;
|
|
7
|
+
/** Called when build throws */
|
|
8
|
+
onError?: (error: Error) => void;
|
|
9
|
+
}
|
|
10
|
+
interface FrontMatter {
|
|
11
|
+
[key: string]: string | number | boolean | string[];
|
|
12
|
+
}
|
|
13
|
+
interface ParsedPrompt {
|
|
14
|
+
frontmatter: FrontMatter;
|
|
15
|
+
body: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare function build(template: string, vars?: Vars, options?: BuildOptions): string;
|
|
19
|
+
|
|
20
|
+
declare function inject(template: string, vars: Vars, options?: BuildOptions): string;
|
|
21
|
+
|
|
22
|
+
declare function loadPromptFile(filePath: string): Promise<ParsedPrompt>;
|
|
23
|
+
declare function buildFromFile(filePath: string, vars?: Vars, options?: BuildOptions): Promise<string>;
|
|
24
|
+
|
|
25
|
+
declare function parseFrontmatter(source: string): ParsedPrompt;
|
|
26
|
+
|
|
27
|
+
declare function minify(input: string): string;
|
|
28
|
+
|
|
29
|
+
export { type BuildOptions, type FrontMatter, type ParsedPrompt, type Vars, build, buildFromFile, inject, loadPromptFile, minify, parseFrontmatter };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';var promises=require('fs/promises'),path=require('path');var d=/\{\{(\s*[\w.]+\s*)\}\}/g;function m(t,o,r={}){let{strict:n=true}=r;return t.replace(d,(s,e)=>{let i=e.trim();if(i in o)return String(o[i]);if(n)throw new Error(`[prompt-kit] Undefined variable: "{{${i}}}"`);return s})}function p(t,o={},r={}){let{onSuccess:n,onError:s}=r;try{let e=m(t,o,r);return n?.(e),e}catch(e){let i=e instanceof Error?e:new Error(String(e));throw s?.(i),i}}var y=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;function g(t){let o=t.indexOf(":");if(o===-1)return null;let r=t.slice(0,o).trim(),n=t.slice(o+1).trim();if(!r)return null;if(n==="true")return [r,true];if(n==="false")return [r,false];let s=Number(n);if(n!==""&&!isNaN(s))return [r,s];if(n.startsWith("[")&&n.endsWith("]")){let e=n.slice(1,-1).split(",").map(i=>i.trim().replace(/^['"]|['"]$/g,"")).filter(Boolean);return [r,e]}return [r,n.replace(/^['"]|['"]$/g,"")]}function a(t){let o=t.match(y);if(!o)return {frontmatter:{},body:t.trim()};let[,r,n]=o,s={};for(let e of r.split(/\r?\n/)){let i=e.trim();if(!i||i.startsWith("#"))continue;let c=g(i);if(c){let[f,l]=c;s[f]=l;}}return {frontmatter:s,body:n.trim()}}async function u(t){let o=path.resolve(t),r;try{r=await promises.readFile(o,"utf-8");}catch{throw new Error(`[prompt-kit] Cannot read file: "${t}"`)}return a(r)}async function E(t,o={},r={}){let{body:n}=await u(t);return p(n,o,r)}var P=/\[\/\/\]:\s*#\s*\(.*?\)\n?/g,w=/\n{3,}/g;function b(t){return t.replace(P,"").replace(w,`
|
|
2
|
+
|
|
3
|
+
`).trim()}/**
|
|
4
|
+
* @file index.ts
|
|
5
|
+
* @description Core entry point for @ekaone/prompt-kit
|
|
6
|
+
* @author Eka Prasetia
|
|
7
|
+
* @website https://prasetia.me
|
|
8
|
+
* @license MIT
|
|
9
|
+
*/exports.build=p;exports.buildFromFile=E;exports.inject=m;exports.loadPromptFile=u;exports.minify=b;exports.parseFrontmatter=a;//# sourceMappingURL=index.js.map
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/injector.ts","../src/core/builder.ts","../src/parser/frontmatter.ts","../src/loader/file.ts","../src/utils/minify.ts"],"names":["VARIABLE_RE","inject","template","vars","options","strict","match","rawKey","key","build","onSuccess","onError","result","err","error","FRONTMATTER_RE","parseLine","line","colonIdx","raw","num","items","s","parseFrontmatter","source","rawFm","rawBody","frontmatter","trimmed","parsed","value","loadPromptFile","filePath","abs","resolve","readFile","buildFromFile","body","MD_COMMENT_RE","EXCESS_BLANK_RE","minify","input"],"mappings":"sEAEA,IAAMA,CAAAA,CAAc,0BAEb,SAASC,CAAAA,CACdC,EACAC,CAAAA,CACAC,CAAAA,CAAwB,EAAC,CACjB,CACR,GAAM,CAAE,MAAA,CAAAC,EAAS,IAAK,CAAA,CAAID,EAE1B,OAAOF,CAAAA,CAAS,QAAQF,CAAAA,CAAa,CAACM,EAAOC,CAAAA,GAAmB,CAC9D,IAAMC,CAAAA,CAAMD,CAAAA,CAAO,MAAK,CACxB,GAAIC,KAAOL,CAAAA,CACT,OAAO,OAAOA,CAAAA,CAAKK,CAAG,CA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,EAAyC,CAC5E,IAAMC,EAAMC,YAAAA,CAAQF,CAAQ,EACxBR,CAAAA,CAEJ,GAAI,CACFA,CAAAA,CAAS,MAAMW,kBAASF,CAAAA,CAAK,OAAO,EACtC,CAAA,KAAQ,CACN,MAAM,IAAI,KAAA,CAAM,CAAA,gCAAA,EAAmCD,CAAQ,CAAA,CAAA,CAAG,CAChE,CAEA,OAAOT,CAAAA,CAAiBC,CAAM,CAChC,CAEA,eAAsBY,CAAAA,CACpBJ,CAAAA,CACA7B,EAAa,EAAC,CACdC,EAAwB,EAAC,CACR,CACjB,GAAM,CAAE,KAAAiC,CAAK,CAAA,CAAI,MAAMN,CAAAA,CAAeC,CAAQ,CAAA,CAC9C,OAAOvB,CAAAA,CAAM4B,CAAAA,CAAMlC,EAAMC,CAAO,CAClC,CCzBA,IAAMkC,CAAAA,CAAgB,8BAGhBC,CAAAA,CAAkB,SAAA,CAEjB,SAASC,CAAAA,CAAOC,CAAAA,CAAuB,CAC5C,OAAOA,CAAAA,CACJ,QAAQH,CAAAA,CAAe,EAAE,CAAA,CACzB,OAAA,CAAQC,CAAAA,CAAiB;;AAAA,CAAM,CAAA,CAC/B,MACL","file":"index.js","sourcesContent":["import type { Vars, BuildOptions } from \"../types/index.js\";\r\n\r\nconst VARIABLE_RE = /\\{\\{(\\s*[\\w.]+\\s*)\\}\\}/g;\r\n\r\nexport function inject(\r\n template: string,\r\n vars: Vars,\r\n options: BuildOptions = {},\r\n): string {\r\n const { strict = true } = options;\r\n\r\n return template.replace(VARIABLE_RE, (match, rawKey: string) => {\r\n const key = rawKey.trim();\r\n if (key in vars) {\r\n return String(vars[key]);\r\n }\r\n if (strict) {\r\n throw new Error(`[prompt-kit] Undefined variable: \"{{${key}}}\"`);\r\n }\r\n return match; // passthrough — leave {{var}} intact\r\n });\r\n}\r\n","import { inject } from \"./injector.js\";\r\nimport type { Vars, BuildOptions } from \"../types/index.js\";\r\n\r\nexport function build(\r\n template: string,\r\n vars: Vars = {},\r\n options: BuildOptions = {},\r\n): string {\r\n const { onSuccess, onError } = options;\r\n\r\n try {\r\n const result = inject(template, vars, options);\r\n onSuccess?.(result);\r\n return result;\r\n } catch (err) {\r\n const error = err instanceof Error ? err : new Error(String(err));\r\n onError?.(error);\r\n throw error;\r\n }\r\n}\r\n","import type { ParsedPrompt, FrontMatter } from \"../types/index.js\";\r\n\r\nconst FRONTMATTER_RE = /^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n?([\\s\\S]*)$/;\r\n\r\n/** Parse a single YAML-like line: key: value */\r\nfunction parseLine(line: string): [string, FrontMatter[string]] | null {\r\n const colonIdx = line.indexOf(\":\");\r\n if (colonIdx === -1) return null;\r\n\r\n const key = line.slice(0, colonIdx).trim();\r\n const raw = line.slice(colonIdx + 1).trim();\r\n\r\n if (!key) return null;\r\n\r\n // Boolean\r\n if (raw === \"true\") return [key, true];\r\n if (raw === \"false\") return [key, false];\r\n\r\n // Number\r\n const num = Number(raw);\r\n if (raw !== \"\" && !isNaN(num)) return [key, num];\r\n\r\n // Inline array: [a, b, c]\r\n if (raw.startsWith(\"[\") && raw.endsWith(\"]\")) {\r\n const items = raw\r\n .slice(1, -1)\r\n .split(\",\")\r\n .map((s) => s.trim().replace(/^['\"]|['\"]$/g, \"\"))\r\n .filter(Boolean);\r\n return [key, items];\r\n }\r\n\r\n // String — strip optional surrounding quotes\r\n return [key, raw.replace(/^['\"]|['\"]$/g, \"\")];\r\n}\r\n\r\nexport function parseFrontmatter(source: string): ParsedPrompt {\r\n const match = source.match(FRONTMATTER_RE);\r\n\r\n if (!match) {\r\n return { frontmatter: {}, body: source.trim() };\r\n }\r\n\r\n const [, rawFm, rawBody] = match;\r\n const frontmatter: FrontMatter = {};\r\n\r\n for (const line of rawFm!.split(/\\r?\\n/)) {\r\n const trimmed = line.trim();\r\n if (!trimmed || trimmed.startsWith(\"#\")) continue;\r\n const parsed = parseLine(trimmed);\r\n if (parsed) {\r\n const [key, value] = parsed;\r\n frontmatter[key] = value;\r\n }\r\n }\r\n\r\n return { frontmatter, body: rawBody!.trim() };\r\n}\r\n","import { readFile } from \"node:fs/promises\";\r\nimport { resolve } from \"node:path\";\r\nimport { parseFrontmatter } from \"../parser/frontmatter.js\";\r\nimport { build } from \"../core/builder.js\";\r\nimport type { Vars, BuildOptions, ParsedPrompt } from \"../types/index.js\";\r\n\r\nexport async function loadPromptFile(filePath: string): Promise<ParsedPrompt> {\r\n const abs = resolve(filePath);\r\n let source: string;\r\n\r\n try {\r\n source = await readFile(abs, \"utf-8\");\r\n } catch {\r\n throw new Error(`[prompt-kit] Cannot read file: \"${filePath}\"`);\r\n }\r\n\r\n return parseFrontmatter(source);\r\n}\r\n\r\nexport async function buildFromFile(\r\n filePath: string,\r\n vars: Vars = {},\r\n options: BuildOptions = {},\r\n): Promise<string> {\r\n const { body } = await loadPromptFile(filePath);\r\n return build(body, vars, options);\r\n}\r\n","/** Strip [//]: # (comment) style Markdown comments */\r\nconst MD_COMMENT_RE = /\\[\\/\\/\\]:\\s*#\\s*\\(.*?\\)\\n?/g;\r\n\r\n/** Collapse 3+ blank lines down to a single blank line */\r\nconst EXCESS_BLANK_RE = /\\n{3,}/g;\r\n\r\nexport function minify(input: string): string {\r\n return input\r\n .replace(MD_COMMENT_RE, \"\")\r\n .replace(EXCESS_BLANK_RE, \"\\n\\n\")\r\n .trim();\r\n}\r\n"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {readFile}from'fs/promises';import {resolve}from'path';var d=/\{\{(\s*[\w.]+\s*)\}\}/g;function m(t,o,r={}){let{strict:n=true}=r;return t.replace(d,(s,e)=>{let i=e.trim();if(i in o)return String(o[i]);if(n)throw new Error(`[prompt-kit] Undefined variable: "{{${i}}}"`);return s})}function p(t,o={},r={}){let{onSuccess:n,onError:s}=r;try{let e=m(t,o,r);return n?.(e),e}catch(e){let i=e instanceof Error?e:new Error(String(e));throw s?.(i),i}}var y=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;function g(t){let o=t.indexOf(":");if(o===-1)return null;let r=t.slice(0,o).trim(),n=t.slice(o+1).trim();if(!r)return null;if(n==="true")return [r,true];if(n==="false")return [r,false];let s=Number(n);if(n!==""&&!isNaN(s))return [r,s];if(n.startsWith("[")&&n.endsWith("]")){let e=n.slice(1,-1).split(",").map(i=>i.trim().replace(/^['"]|['"]$/g,"")).filter(Boolean);return [r,e]}return [r,n.replace(/^['"]|['"]$/g,"")]}function a(t){let o=t.match(y);if(!o)return {frontmatter:{},body:t.trim()};let[,r,n]=o,s={};for(let e of r.split(/\r?\n/)){let i=e.trim();if(!i||i.startsWith("#"))continue;let c=g(i);if(c){let[f,l]=c;s[f]=l;}}return {frontmatter:s,body:n.trim()}}async function u(t){let o=resolve(t),r;try{r=await readFile(o,"utf-8");}catch{throw new Error(`[prompt-kit] Cannot read file: "${t}"`)}return a(r)}async function E(t,o={},r={}){let{body:n}=await u(t);return p(n,o,r)}var P=/\[\/\/\]:\s*#\s*\(.*?\)\n?/g,w=/\n{3,}/g;function b(t){return t.replace(P,"").replace(w,`
|
|
2
|
+
|
|
3
|
+
`).trim()}/**
|
|
4
|
+
* @file index.ts
|
|
5
|
+
* @description Core entry point for @ekaone/prompt-kit
|
|
6
|
+
* @author Eka Prasetia
|
|
7
|
+
* @website https://prasetia.me
|
|
8
|
+
* @license MIT
|
|
9
|
+
*/export{p as build,E as buildFromFile,m as inject,u as loadPromptFile,b as minify,a as parseFrontmatter};//# sourceMappingURL=index.mjs.map
|
|
10
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/injector.ts","../src/core/builder.ts","../src/parser/frontmatter.ts","../src/loader/file.ts","../src/utils/minify.ts"],"names":["VARIABLE_RE","inject","template","vars","options","strict","match","rawKey","key","build","onSuccess","onError","result","err","error","FRONTMATTER_RE","parseLine","line","colonIdx","raw","num","items","s","parseFrontmatter","source","rawFm","rawBody","frontmatter","trimmed","parsed","value","loadPromptFile","filePath","abs","resolve","readFile","buildFromFile","body","MD_COMMENT_RE","EXCESS_BLANK_RE","minify","input"],"mappings":"8DAEA,IAAMA,CAAAA,CAAc,0BAEb,SAASC,CAAAA,CACdC,EACAC,CAAAA,CACAC,CAAAA,CAAwB,EAAC,CACjB,CACR,GAAM,CAAE,MAAA,CAAAC,EAAS,IAAK,CAAA,CAAID,EAE1B,OAAOF,CAAAA,CAAS,QAAQF,CAAAA,CAAa,CAACM,EAAOC,CAAAA,GAAmB,CAC9D,IAAMC,CAAAA,CAAMD,CAAAA,CAAO,MAAK,CACxB,GAAIC,KAAOL,CAAAA,CACT,OAAO,OAAOA,CAAAA,CAAKK,CAAG,CAAC,CAAA,CAEzB,GAAIH,EACF,MAAM,IAAI,KAAA,CAAM,CAAA,oCAAA,EAAuCG,CAAG,CAAA,GAAA,CAAK,EAEjE,OAAOF,CACT,CAAC,CACH,CClBO,SAASG,CAAAA,CACdP,CAAAA,CACAC,EAAa,EAAC,CACdC,EAAwB,EAAC,CACjB,CACR,GAAM,CAAE,UAAAM,CAAAA,CAAW,OAAA,CAAAC,CAAQ,CAAA,CAAIP,CAAAA,CAE/B,GAAI,CACF,IAAMQ,CAAAA,CAASX,EAAOC,CAAAA,CAAUC,CAAAA,CAAMC,CAAO,CAAA,CAC7C,OAAAM,IAAYE,CAAM,CAAA,CACXA,CACT,CAAA,MAASC,CAAAA,CAAK,CACZ,IAAMC,CAAAA,CAAQD,aAAe,KAAA,CAAQA,CAAAA,CAAM,IAAI,KAAA,CAAM,MAAA,CAAOA,CAAG,CAAC,CAAA,CAChE,MAAAF,IAAUG,CAAK,CAAA,CACTA,CACR,CACF,CCjBA,IAAMC,EAAiB,6CAAA,CAGvB,SAASC,CAAAA,CAAUC,CAAAA,CAAoD,CACrE,IAAMC,EAAWD,CAAAA,CAAK,OAAA,CAAQ,GAAG,CAAA,CACjC,GAAIC,IAAa,EAAA,CAAI,OAAO,KAE5B,IAAMV,C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n\r\nconst VARIABLE_RE = /\\{\\{(\\s*[\\w.]+\\s*)\\}\\}/g;\r\n\r\nexport function inject(\r\n template: string,\r\n vars: Vars,\r\n options: BuildOptions = {},\r\n): string {\r\n const { strict = true } = options;\r\n\r\n return template.replace(VARIABLE_RE, (match, rawKey: string) => {\r\n const key = rawKey.trim();\r\n if (key in vars) {\r\n return String(vars[key]);\r\n }\r\n if (strict) {\r\n throw new Error(`[prompt-kit] Undefined variable: \"{{${key}}}\"`);\r\n }\r\n return match; // passthrough — leave {{var}} intact\r\n });\r\n}\r\n","import { inject } from \"./injector.js\";\r\nimport type { Vars, BuildOptions } from \"../types/index.js\";\r\n\r\nexport function build(\r\n template: string,\r\n vars: Vars = {},\r\n options: BuildOptions = {},\r\n): string {\r\n const { onSuccess, onError } = options;\r\n\r\n try {\r\n const result = inject(template, vars, options);\r\n onSuccess?.(result);\r\n return result;\r\n } catch (err) {\r\n const error = err instanceof Error ? err : new Error(String(err));\r\n onError?.(error);\r\n throw error;\r\n }\r\n}\r\n","import type { ParsedPrompt, FrontMatter } from \"../types/index.js\";\r\n\r\nconst FRONTMATTER_RE = /^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n?([\\s\\S]*)$/;\r\n\r\n/** Parse a single YAML-like line: key: value */\r\nfunction parseLine(line: string): [string, FrontMatter[string]] | null {\r\n const colonIdx = line.indexOf(\":\");\r\n if (colonIdx === -1) return null;\r\n\r\n const key = line.slice(0, colonIdx).trim();\r\n const raw = line.slice(colonIdx + 1).trim();\r\n\r\n if (!key) return null;\r\n\r\n // Boolean\r\n if (raw === \"true\") return [key, true];\r\n if (raw === \"false\") return [key, false];\r\n\r\n // Number\r\n const num = Number(raw);\r\n if (raw !== \"\" && !isNaN(num)) return [key, num];\r\n\r\n // Inline array: [a, b, c]\r\n if (raw.startsWith(\"[\") && raw.endsWith(\"]\")) {\r\n const items = raw\r\n .slice(1, -1)\r\n .split(\",\")\r\n .map((s) => s.trim().replace(/^['\"]|['\"]$/g, \"\"))\r\n .filter(Boolean);\r\n return [key, items];\r\n }\r\n\r\n // String — strip optional surrounding quotes\r\n return [key, raw.replace(/^['\"]|['\"]$/g, \"\")];\r\n}\r\n\r\nexport function parseFrontmatter(source: string): ParsedPrompt {\r\n const match = source.match(FRONTMATTER_RE);\r\n\r\n if (!match) {\r\n return { frontmatter: {}, body: source.trim() };\r\n }\r\n\r\n const [, rawFm, rawBody] = match;\r\n const frontmatter: FrontMatter = {};\r\n\r\n for (const line of rawFm!.split(/\\r?\\n/)) {\r\n const trimmed = line.trim();\r\n if (!trimmed || trimmed.startsWith(\"#\")) continue;\r\n const parsed = parseLine(trimmed);\r\n if (parsed) {\r\n const [key, value] = parsed;\r\n frontmatter[key] = value;\r\n }\r\n }\r\n\r\n return { frontmatter, body: rawBody!.trim() };\r\n}\r\n","import { readFile } from \"node:fs/promises\";\r\nimport { resolve } from \"node:path\";\r\nimport { parseFrontmatter } from \"../parser/frontmatter.js\";\r\nimport { build } from \"../core/builder.js\";\r\nimport type { Vars, BuildOptions, ParsedPrompt } from \"../types/index.js\";\r\n\r\nexport async function loadPromptFile(filePath: string): Promise<ParsedPrompt> {\r\n const abs = resolve(filePath);\r\n let source: string;\r\n\r\n try {\r\n source = await readFile(abs, \"utf-8\");\r\n } catch {\r\n throw new Error(`[prompt-kit] Cannot read file: \"${filePath}\"`);\r\n }\r\n\r\n return parseFrontmatter(source);\r\n}\r\n\r\nexport async function buildFromFile(\r\n filePath: string,\r\n vars: Vars = {},\r\n options: BuildOptions = {},\r\n): Promise<string> {\r\n const { body } = await loadPromptFile(filePath);\r\n return build(body, vars, options);\r\n}\r\n","/** Strip [//]: # (comment) style Markdown comments */\r\nconst MD_COMMENT_RE = /\\[\\/\\/\\]:\\s*#\\s*\\(.*?\\)\\n?/g;\r\n\r\n/** Collapse 3+ blank lines down to a single blank line */\r\nconst EXCESS_BLANK_RE = /\\n{3,}/g;\r\n\r\nexport function minify(input: string): string {\r\n return input\r\n .replace(MD_COMMENT_RE, \"\")\r\n .replace(EXCESS_BLANK_RE, \"\\n\\n\")\r\n .trim();\r\n}\r\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ekaone/prompt-kit",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "TypeScript library for building prompts",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"prompt",
|
|
7
|
+
"kit",
|
|
8
|
+
"typescript",
|
|
9
|
+
"library",
|
|
10
|
+
"prompt-builder"
|
|
11
|
+
],
|
|
12
|
+
"author": {
|
|
13
|
+
"name": "Eka Prasetia",
|
|
14
|
+
"email": "ekaone3033@gmail.com",
|
|
15
|
+
"url": "https://prasetia.me"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=18"
|
|
21
|
+
},
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"module": "./dist/index.mjs",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.mjs",
|
|
29
|
+
"require": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"README.md",
|
|
38
|
+
"LICENSE"
|
|
39
|
+
],
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/ekaone/prompt-kit.git"
|
|
43
|
+
},
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/ekaone/prompt-kit/issues"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://github.com/ekaone/prompt-kit#readme",
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/node": "^25.5.0",
|
|
50
|
+
"@vitest/coverage-v8": "^4.1.0",
|
|
51
|
+
"@vitest/ui": "^4.1.0",
|
|
52
|
+
"rimraf": "^6.1.3",
|
|
53
|
+
"tsup": "^8.5.1",
|
|
54
|
+
"typescript": "^5.9.3",
|
|
55
|
+
"vitest": "^4.1.0"
|
|
56
|
+
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "pnpm typecheck && pnpm run test && pnpm run clean && tsup",
|
|
59
|
+
"dev": "tsup --watch",
|
|
60
|
+
"clean": "rimraf dist",
|
|
61
|
+
"typecheck": "tsc --noEmit",
|
|
62
|
+
"test": "vitest run",
|
|
63
|
+
"test:watch": "vitest",
|
|
64
|
+
"test:ui": "vitest --ui",
|
|
65
|
+
"test:coverage": "vitest run --coverage"
|
|
66
|
+
}
|
|
67
|
+
}
|