@chinawatdc/ai-prompt-manager 1.0.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.
- package/README.md +17 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +44 -0
- package/dist/index.mjs +20 -0
- package/package.json +27 -0
- package/src/index.ts +19 -0
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @chinawatdc/ai-prompt-manager
|
|
2
|
+
|
|
3
|
+
> ตัวช่วยจัดการ Prompt สำหรับ Node.js ใส่ตัวแปรและจัดการเวอร์ชันได้ง่ายๆ
|
|
4
|
+
|
|
5
|
+
## 📌 แผนการพัฒนา (Roadmap)
|
|
6
|
+
1. ออกแบบ API และโครงสร้างฟังก์ชันหลัก
|
|
7
|
+
2. เขียนโค้ดด้วย TypeScript
|
|
8
|
+
3. ทดสอบการทำงาน (Unit Tests)
|
|
9
|
+
4. อัปโหลดขึ้น npm
|
|
10
|
+
|
|
11
|
+
## 🚀 วิธีติดตั้ง (ในอนาคต)
|
|
12
|
+
```bash
|
|
13
|
+
npm install @chinawatdc/ai-prompt-manager
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## 📖 วิธีใช้งานเบื้องต้น
|
|
17
|
+
*รอการอัปเดตหลังจากพัฒนาเสร็จสิ้น...*
|
package/dist/index.d.mts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/index.ts
|
|
20
|
+
var index_exports = {};
|
|
21
|
+
__export(index_exports, {
|
|
22
|
+
PromptManager: () => PromptManager
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(index_exports);
|
|
25
|
+
var PromptManager = class {
|
|
26
|
+
prompts = /* @__PURE__ */ new Map();
|
|
27
|
+
register(name, template) {
|
|
28
|
+
this.prompts.set(name, template);
|
|
29
|
+
}
|
|
30
|
+
get(name, variables = {}) {
|
|
31
|
+
const template = this.prompts.get(name);
|
|
32
|
+
if (!template) {
|
|
33
|
+
throw new Error(`Prompt template '${name}' not found.`);
|
|
34
|
+
}
|
|
35
|
+
return Object.entries(variables).reduce(
|
|
36
|
+
(result, [key, value]) => result.replace(new RegExp(`{{${key}}}`, "g"), String(value)),
|
|
37
|
+
template
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
PromptManager
|
|
44
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var PromptManager = class {
|
|
3
|
+
prompts = /* @__PURE__ */ new Map();
|
|
4
|
+
register(name, template) {
|
|
5
|
+
this.prompts.set(name, template);
|
|
6
|
+
}
|
|
7
|
+
get(name, variables = {}) {
|
|
8
|
+
const template = this.prompts.get(name);
|
|
9
|
+
if (!template) {
|
|
10
|
+
throw new Error(`Prompt template '${name}' not found.`);
|
|
11
|
+
}
|
|
12
|
+
return Object.entries(variables).reduce(
|
|
13
|
+
(result, [key, value]) => result.replace(new RegExp(`{{${key}}}`, "g"), String(value)),
|
|
14
|
+
template
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
PromptManager
|
|
20
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chinawatdc/ai-prompt-manager",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
7
|
+
"dev": "tsup src/index.ts --format cjs,esm --watch",
|
|
8
|
+
"test": "echo \"No test yet\""
|
|
9
|
+
},
|
|
10
|
+
"keywords": [],
|
|
11
|
+
"author": "",
|
|
12
|
+
"license": "ISC",
|
|
13
|
+
"description": "ตัวช่วยจัดการ Prompt สำหรับ Node.js ใส่ตัวแปรและจัดการเวอร์ชันได้ง่ายๆ",
|
|
14
|
+
"module": "./dist/index.mjs",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.mjs",
|
|
20
|
+
"require": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"tsup": "^8.5.1",
|
|
25
|
+
"typescript": "^5.4.5"
|
|
26
|
+
}
|
|
27
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export class PromptManager {
|
|
2
|
+
private prompts: Map<string, string> = new Map();
|
|
3
|
+
|
|
4
|
+
register(name: string, template: string) {
|
|
5
|
+
this.prompts.set(name, template);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
get(name: string, variables: Record<string, string | number> = {}): string {
|
|
9
|
+
const template = this.prompts.get(name);
|
|
10
|
+
if (!template) {
|
|
11
|
+
throw new Error(`Prompt template '${name}' not found.`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return Object.entries(variables).reduce(
|
|
15
|
+
(result, [key, value]) => result.replace(new RegExp(`{{${key}}}`, 'g'), String(value)),
|
|
16
|
+
template
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
}
|