promptlike-mcp 0.4.3 → 0.5.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/CHANGELOG.md +17 -0
- package/LICENSE +21 -0
- package/README.md +5 -15
- package/dist/index.js +4 -2
- package/dist/lib/api-client.js +16 -0
- package/dist/lib/promptTemplate.js +189 -0
- package/dist/lib/promptVariables.js +7 -40
- package/dist/server.js +38 -13
- package/package.json +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.0 — 2026-10-19
|
|
4
|
+
|
|
5
|
+
- **New: `label` parameter** on `get_prompt` and `fill_variables` reads the version a deployment
|
|
6
|
+
label (e.g. `production`, `staging`) points at instead of the current one. `version` and `label`
|
|
7
|
+
together are rejected.
|
|
8
|
+
- **New: conditional blocks.** `fill_variables` now understands `{{#if var}}…{{else}}…{{/if}}` and
|
|
9
|
+
`{{#unless var}}…{{/unless}}` (text only; nesting limited to 5 levels).
|
|
10
|
+
|
|
11
|
+
## 0.4.4 — 2026-10-13
|
|
12
|
+
|
|
13
|
+
- **Package metadata:** `repository` and `bugs` now point to the public plugin repository
|
|
14
|
+
(github.com/zeynepaslierhann/promptlike-plugin), which is where issues can be filed. No code change.
|
|
15
|
+
- **Docs (npm page):** the README no longer says MCP prompts show up in Cursor and Claude
|
|
16
|
+
Desktop: it says support varies by client and that the server was tested in Claude Code.
|
|
17
|
+
"Self-hosters" became a plain note about `PROMPTLIKE_API_URL`. Maintainer notes moved out
|
|
18
|
+
of the README into `DEVELOPMENT.md`, which is not part of the package.
|
|
19
|
+
|
|
3
20
|
## 0.4.3 — 2026-10-12
|
|
4
21
|
|
|
5
22
|
- **Fix:** a network problem while the session is being refreshed (no DNS,
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Zeynep Aslı Erhan
|
|
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
CHANGED
|
@@ -26,7 +26,7 @@ Any other MCP client: run `npx -y promptlike-mcp` over stdio.
|
|
|
26
26
|
The server also implements the MCP **prompts** primitive (`prompts/list`, `prompts/get`), so clients that support it show your library as slash commands:
|
|
27
27
|
|
|
28
28
|
- **Claude Code:** type `/` → `/mcp__promptlike__code-review`
|
|
29
|
-
- **
|
|
29
|
+
- **Other MCP clients:** support for MCP prompts varies by client. Tested in Claude Code; not yet tested in Cursor or Claude Desktop.
|
|
30
30
|
|
|
31
31
|
| Your prompt | MCP prompt |
|
|
32
32
|
|---|---|
|
|
@@ -48,8 +48,8 @@ Every prompt is also a resource, `promptlike://<repo>/<prompt>` (`text/markdown`
|
|
|
48
48
|
|---|---|
|
|
49
49
|
| `list_prompts` | List your prompts (optional `tag` filter). Includes each prompt's `{{variable}}` names. Paged: `limit` + `page`; the reply carries the real `total`, `total_pages` and `has_more`. |
|
|
50
50
|
| `search_prompts` | Search by title/description. Same paging as `list_prompts`. |
|
|
51
|
-
| `get_prompt` | Full content by name/id/short-id, optional `version` pin. `via: "suggestion"` when fetching a suggested prompt. |
|
|
52
|
-
| `fill_variables` | Fetch + substitute `{{variables}}
|
|
51
|
+
| `get_prompt` | Full content by name/id/short-id, optional `version` pin or deployment `label` (e.g. `production`). `via: "suggestion"` when fetching a suggested prompt. |
|
|
52
|
+
| `fill_variables` | Fetch + substitute `{{variables}}` (and `{{#if var}}…{{/if}}` blocks; optional `version`/`label`), returns ready-to-use text (unfilled ones reported in `missing_variables`). |
|
|
53
53
|
| `suggest_prompts` | Up to 3 prompts from your own library that fit a task (call once at the start of a non-trivial task). |
|
|
54
54
|
| `save_prompt` | **Write.** New prompt: `title`, `content`, optional `description`, `project` (repo; default: your most recent repo you can edit), `tags`. |
|
|
55
55
|
| `update_prompt` | **Write.** New version of an existing prompt: exact title or id, full new `content`, optional `changelog`, `bump` (`patch`/`minor`/`major`). |
|
|
@@ -68,17 +68,7 @@ The server never spends your AI tokens (no improve), and it does not use MCP sam
|
|
|
68
68
|
|
|
69
69
|
- Ambiguous names return a candidate list (id + title) — call again with a more specific name or the id.
|
|
70
70
|
- Rate limits surface as `Retry in Ns` messages so agents can back off.
|
|
71
|
-
-
|
|
71
|
+
- To point at another deployment of the web app (for example a local dev server), set `PROMPTLIKE_API_URL` (same env var the CLI honors).
|
|
72
72
|
- Session store: `~/.config/promptlike/config.json` (written by `ple login`, file mode 0600).
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
Same OIDC Trusted Publishing flow as the CLI — no npm token:
|
|
77
|
-
|
|
78
|
-
```bash
|
|
79
|
-
npm --prefix mcp version patch --no-git-tag-version
|
|
80
|
-
git add mcp/package.json mcp/package-lock.json && git commit -m "mcp: vX.Y.Z"
|
|
81
|
-
git tag mcp-vX.Y.Z && git push origin main mcp-vX.Y.Z
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
`.github/workflows/mcp-publish.yml` runs typecheck + tests + build, then publishes.
|
|
74
|
+
Website: <https://promptlikeengineer.com/?utm_source=npm&utm_medium=readme&utm_campaign=ple_dist>
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* promptlike-mcp — PromptLikeEngineer MCP server (stdio).
|
|
5
5
|
*
|
|
6
|
-
* AI agent'lara prompt kütüphanesine
|
|
7
|
-
*
|
|
6
|
+
* AI agent'lara prompt kütüphanesine erişim verir: okuma araçları + yalnız-ekleme
|
|
7
|
+
* yazma araçları (save_prompt, update_prompt; silme aracı YOK, improve/AI harcaması
|
|
8
|
+
* YOK → agent'ın token yakma / veri silme riski yok). v0.1–0.3 salt-okunurdu; 0.4'ten
|
|
9
|
+
* beri yazabilir, "read-only" denmez.
|
|
8
10
|
* Auth sıfır kurulum: CLI'ın `ple login` ile yazdığı
|
|
9
11
|
* ~/.config/promptlike/config.json paylaşılır.
|
|
10
12
|
*
|
package/dist/lib/api-client.js
CHANGED
|
@@ -22,6 +22,7 @@ exports.listPromptsPage = listPromptsPage;
|
|
|
22
22
|
exports.listPrompts = listPrompts;
|
|
23
23
|
exports.listProjects = listProjects;
|
|
24
24
|
exports.getPromptDetail = getPromptDetail;
|
|
25
|
+
exports.getLabeledVersion = getLabeledVersion;
|
|
25
26
|
exports.buildUseEventBody = buildUseEventBody;
|
|
26
27
|
exports.sanitizeClientName = sanitizeClientName;
|
|
27
28
|
exports.recordPromptUse = recordPromptUse;
|
|
@@ -328,6 +329,21 @@ async function getPromptDetail(id) {
|
|
|
328
329
|
throw err;
|
|
329
330
|
}
|
|
330
331
|
}
|
|
332
|
+
/**
|
|
333
|
+
* GET /api/prompts/{id}?label=… — the version a deployment label (`production`, …) points at.
|
|
334
|
+
* Returns null when the prompt or the label does not exist.
|
|
335
|
+
*/
|
|
336
|
+
async function getLabeledVersion(id, label) {
|
|
337
|
+
try {
|
|
338
|
+
const res = await apiFetch(`/api/prompts/${id}?label=${encodeURIComponent(label)}`);
|
|
339
|
+
return res.prompt?.labeled_version ?? null;
|
|
340
|
+
}
|
|
341
|
+
catch (err) {
|
|
342
|
+
if (err instanceof Error && /not found/i.test(err.message))
|
|
343
|
+
return null;
|
|
344
|
+
throw err;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
331
347
|
/** POST /use body. Client is trimmed to the server's charset/length. */
|
|
332
348
|
function buildUseEventBody(opts) {
|
|
333
349
|
const body = {
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Prompt şablon motoru - TEK KAYNAK (değişkenler + basit koşul).
|
|
4
|
+
*
|
|
5
|
+
* Bu dosya web (`src/lib/prompt-template.ts`), CLI (`cli/src/lib/promptTemplate.ts`)
|
|
6
|
+
* ve MCP (`mcp/src/lib/promptTemplate.ts`) içinde BAYT BAYT aynı durur; kayma
|
|
7
|
+
* `src/lib/prompt-template-drift.test.ts` ile yakalanır. Değiştirirsen üçünü de güncelle.
|
|
8
|
+
* Bağımlılıksız, saf fonksiyonlar. Kod ÇALIŞTIRMAZ: yalnız metin ağacı kurar ve yazdırır.
|
|
9
|
+
*
|
|
10
|
+
* Sözdizimi:
|
|
11
|
+
* {{ad}} değişken (boşluk tolere, Unicode ad)
|
|
12
|
+
* {{#if ad}} ... {{else}} ... {{/if}} ad doluysa ilk dal, değilse else dalı
|
|
13
|
+
* {{#unless ad}} ... {{/unless}} ad boş/yoksa
|
|
14
|
+
* Doluluk: değer verilmiş, kırpınca boş değil ve "false" / "0" değil (büyük/küçük harf farksız).
|
|
15
|
+
* Koşulda verilmeyen değişken = yanlış (sessizce); filler arayüzü bu adı yine de sorar.
|
|
16
|
+
* Sınırlar: iç içe en çok MAX_DEPTH. Dengesiz / fazla derin / sahipsiz {{else}} {{/if}} durumunda
|
|
17
|
+
* koşul etiketleri yorumlanmaz, metin olduğu gibi kalır (değişkenler yine doldurulur).
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.MAX_DEPTH = void 0;
|
|
21
|
+
exports.extractVariables = extractVariables;
|
|
22
|
+
exports.fillVariables = fillVariables;
|
|
23
|
+
exports.hasVariables = hasVariables;
|
|
24
|
+
exports.MAX_DEPTH = 5;
|
|
25
|
+
const NAME = '[\\p{L}\\p{N}_.-]+';
|
|
26
|
+
// 1: if|unless (açılış) 2: açılış adı 3: else 4: kapanış tipi 5: düz değişken adı
|
|
27
|
+
const TAG = new RegExp(`\\{\\{\\s*(?:#(if|unless)\\s+(${NAME})|(else)|\\/(if|unless)|(${NAME}))\\s*\\}\\}`, 'gu');
|
|
28
|
+
function tokenize(text) {
|
|
29
|
+
const tokens = [];
|
|
30
|
+
let cursor = 0;
|
|
31
|
+
for (const m of text.matchAll(TAG)) {
|
|
32
|
+
const start = m.index ?? 0;
|
|
33
|
+
const end = start + m[0].length;
|
|
34
|
+
const isControl = m[5] === undefined;
|
|
35
|
+
let from = start;
|
|
36
|
+
let to = end;
|
|
37
|
+
if (isControl) {
|
|
38
|
+
// Etiket kendi satırındaysa satırı (boşluk + satır sonu) tümden tüket.
|
|
39
|
+
// Yalnız boşluk karakterleri taranır (satır başına/sonuna kadar), O(1) amortize.
|
|
40
|
+
let ls = start;
|
|
41
|
+
while (ls > 0 && text[ls - 1] !== '\n' && /[ \t\r]/.test(text[ls - 1]))
|
|
42
|
+
ls--;
|
|
43
|
+
let le = end;
|
|
44
|
+
while (le < text.length && text[le] !== '\n' && /[ \t\r]/.test(text[le]))
|
|
45
|
+
le++;
|
|
46
|
+
const startsLine = ls === 0 || text[ls - 1] === '\n';
|
|
47
|
+
const endsLine = le === text.length || text[le] === '\n';
|
|
48
|
+
if (startsLine && endsLine) {
|
|
49
|
+
from = Math.max(ls, cursor);
|
|
50
|
+
to = Math.min(le + 1, text.length);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (from > cursor)
|
|
54
|
+
tokens.push({ t: 'text', v: text.slice(cursor, from) });
|
|
55
|
+
cursor = to;
|
|
56
|
+
if (m[1])
|
|
57
|
+
tokens.push({ t: 'open', kind: m[1], name: m[2], raw: m[0] });
|
|
58
|
+
else if (m[3])
|
|
59
|
+
tokens.push({ t: 'else', raw: m[0] });
|
|
60
|
+
else if (m[4])
|
|
61
|
+
tokens.push({ t: 'close', kind: m[4], raw: m[0] });
|
|
62
|
+
else
|
|
63
|
+
tokens.push({ t: 'var', name: m[5], raw: m[0] });
|
|
64
|
+
}
|
|
65
|
+
if (cursor < text.length)
|
|
66
|
+
tokens.push({ t: 'text', v: text.slice(cursor) });
|
|
67
|
+
return tokens;
|
|
68
|
+
}
|
|
69
|
+
/** Dengeli ağaç kurar; hata olursa null (çağıran düz moda düşer). */
|
|
70
|
+
function parse(tokens) {
|
|
71
|
+
const root = [];
|
|
72
|
+
const stack = [];
|
|
73
|
+
const current = () => {
|
|
74
|
+
const top = stack[stack.length - 1];
|
|
75
|
+
return top ? (top.inElse ? top.node.no : top.node.yes) : root;
|
|
76
|
+
};
|
|
77
|
+
for (const tok of tokens) {
|
|
78
|
+
if (tok.t === 'text')
|
|
79
|
+
current().push(tok);
|
|
80
|
+
else if (tok.t === 'var')
|
|
81
|
+
current().push(tok);
|
|
82
|
+
else if (tok.t === 'open') {
|
|
83
|
+
if (stack.length >= exports.MAX_DEPTH)
|
|
84
|
+
return null;
|
|
85
|
+
const node = {
|
|
86
|
+
t: 'cond',
|
|
87
|
+
negate: tok.kind === 'unless',
|
|
88
|
+
name: tok.name,
|
|
89
|
+
yes: [],
|
|
90
|
+
no: [],
|
|
91
|
+
};
|
|
92
|
+
current().push(node);
|
|
93
|
+
stack.push({ kind: tok.kind, node, inElse: false });
|
|
94
|
+
}
|
|
95
|
+
else if (tok.t === 'else') {
|
|
96
|
+
const top = stack[stack.length - 1];
|
|
97
|
+
if (!top || top.inElse)
|
|
98
|
+
return null;
|
|
99
|
+
top.inElse = true;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
const top = stack.pop();
|
|
103
|
+
if (!top || top.kind !== tok.kind)
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return stack.length === 0 ? root : null;
|
|
108
|
+
}
|
|
109
|
+
/** Düz mod: koşul etiketleri metin kalır, yalnız değişkenler var sayılır. */
|
|
110
|
+
function flatten(tokens) {
|
|
111
|
+
return tokens.map((tok) => {
|
|
112
|
+
if (tok.t === 'var')
|
|
113
|
+
return tok;
|
|
114
|
+
if (tok.t === 'text')
|
|
115
|
+
return tok;
|
|
116
|
+
return { t: 'text', v: tok.raw };
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function isTruthy(values, name) {
|
|
120
|
+
if (!Object.prototype.hasOwnProperty.call(values, name))
|
|
121
|
+
return false;
|
|
122
|
+
const v = values[name];
|
|
123
|
+
if (typeof v !== 'string')
|
|
124
|
+
return false;
|
|
125
|
+
const s = v.trim().toLowerCase();
|
|
126
|
+
return s !== '' && s !== 'false' && s !== '0';
|
|
127
|
+
}
|
|
128
|
+
function build(text) {
|
|
129
|
+
const tokens = tokenize(text);
|
|
130
|
+
const tree = parse(tokens);
|
|
131
|
+
return tree ? { tree, balanced: true } : { tree: flatten(tokens), balanced: false };
|
|
132
|
+
}
|
|
133
|
+
function render(nodes, values) {
|
|
134
|
+
let out = '';
|
|
135
|
+
for (const n of nodes) {
|
|
136
|
+
if (n.t === 'text')
|
|
137
|
+
out += n.v;
|
|
138
|
+
else if (n.t === 'var') {
|
|
139
|
+
// Yalnız kendi anahtarları: {{constructor}} gibi adlar prototipten bir şey çekmesin.
|
|
140
|
+
const value = Object.prototype.hasOwnProperty.call(values, n.name)
|
|
141
|
+
? values[n.name]
|
|
142
|
+
: undefined;
|
|
143
|
+
out += typeof value === 'string' && value !== '' ? value : n.raw;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
const on = isTruthy(values, n.name) !== n.negate;
|
|
147
|
+
out += render(on ? n.yes : n.no, values);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return out;
|
|
151
|
+
}
|
|
152
|
+
function collect(nodes, seen, result) {
|
|
153
|
+
const add = (name) => {
|
|
154
|
+
if (!seen.has(name)) {
|
|
155
|
+
seen.add(name);
|
|
156
|
+
result.push(name);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
for (const n of nodes) {
|
|
160
|
+
if (n.t === 'var')
|
|
161
|
+
add(n.name);
|
|
162
|
+
else if (n.t === 'cond') {
|
|
163
|
+
add(n.name);
|
|
164
|
+
collect(n.yes, seen, result);
|
|
165
|
+
collect(n.no, seen, result);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/** Metindeki benzersiz değişken adları (koşul adları dahil), ilk görülme sırasıyla. */
|
|
170
|
+
function extractVariables(text) {
|
|
171
|
+
if (!text)
|
|
172
|
+
return [];
|
|
173
|
+
const result = [];
|
|
174
|
+
collect(build(text).tree, new Set(), result);
|
|
175
|
+
return result;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Koşulları çözer, `{{ad}}` yer tutucularını doldurur. Bulunmayan/boş değişken
|
|
179
|
+
* olduğu gibi kalır (sessizce silinmez); koşulda yanlış sayılır.
|
|
180
|
+
*/
|
|
181
|
+
function fillVariables(text, values) {
|
|
182
|
+
if (!text)
|
|
183
|
+
return '';
|
|
184
|
+
return render(build(text).tree, values);
|
|
185
|
+
}
|
|
186
|
+
/** Metinde en az bir değişken ya da koşul var mı. */
|
|
187
|
+
function hasVariables(text) {
|
|
188
|
+
return extractVariables(text).length > 0;
|
|
189
|
+
}
|
|
@@ -1,44 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Prompt değişkenleri (`{{ad}}`) — CLI yerel kopyası.
|
|
4
|
-
*
|
|
5
|
-
* Web tarafındaki `src/lib/prompt-variables.ts` ile BİREBİR aynı mantık. CLI
|
|
6
|
-
* ayrı bir npm paketi olduğu için web'den import edemiyor; bu yüzden küçük,
|
|
7
|
-
* bağımlılıksız util burada tekrarlanıyor. Birini değiştirirken diğerini de
|
|
8
|
-
* güncelle (ya da ileride shared/ altına taşıyıp sync-types ile senkronla).
|
|
9
|
-
*
|
|
10
|
-
* Syntax: `{{ad}}`, içeride whitespace tolere, Unicode adlar (Türkçe dahil).
|
|
11
|
-
*/
|
|
12
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.extractVariables =
|
|
14
|
-
exports.fillVariables = fillVariables;
|
|
15
|
-
const VARIABLE_PATTERN = /\{\{\s*([\p{L}\p{N}_.-]+)\s*\}\}/gu;
|
|
16
|
-
/** Metindeki benzersiz değişken adları, ilk görülme sırasıyla. */
|
|
17
|
-
function extractVariables(text) {
|
|
18
|
-
if (!text)
|
|
19
|
-
return [];
|
|
20
|
-
const seen = new Set();
|
|
21
|
-
const result = [];
|
|
22
|
-
for (const match of text.matchAll(VARIABLE_PATTERN)) {
|
|
23
|
-
const name = match[1];
|
|
24
|
-
if (!seen.has(name)) {
|
|
25
|
-
seen.add(name);
|
|
26
|
-
result.push(name);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
3
|
+
exports.hasVariables = exports.fillVariables = exports.extractVariables = void 0;
|
|
31
4
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
5
|
+
* Prompt değişkenleri + koşullar — motor `promptTemplate.ts` içinde (web ile aynı dosya,
|
|
6
|
+
* kayma `src/lib/prompt-template-drift.test.ts` ile yakalanır).
|
|
34
7
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// Yalnız kendi anahtarları: {{constructor}} / {{toString}} gibi adlar
|
|
40
|
-
// Object.prototype'tan fonksiyon çekip metne "function Object()…" basmasın.
|
|
41
|
-
const value = Object.prototype.hasOwnProperty.call(values, name) ? values[name] : undefined;
|
|
42
|
-
return typeof value === 'string' && value !== '' ? value : whole;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
8
|
+
var promptTemplate_1 = require("./promptTemplate");
|
|
9
|
+
Object.defineProperty(exports, "extractVariables", { enumerable: true, get: function () { return promptTemplate_1.extractVariables; } });
|
|
10
|
+
Object.defineProperty(exports, "fillVariables", { enumerable: true, get: function () { return promptTemplate_1.fillVariables; } });
|
|
11
|
+
Object.defineProperty(exports, "hasVariables", { enumerable: true, get: function () { return promptTemplate_1.hasVariables; } });
|
package/dist/server.js
CHANGED
|
@@ -330,6 +330,31 @@ function afterWrite(server, catalog) {
|
|
|
330
330
|
const READ_ONLY = { readOnlyHint: true, openWorldHint: false };
|
|
331
331
|
/** Yazma: yeni prompt/versiyon ekler, hiçbir şeyi silmez; aynı içerikle tekrar = no-op. */
|
|
332
332
|
const WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
333
|
+
/** Deployment label (`production`, …) shape accepted by the server (a-z 0-9 . _ -; max 32). */
|
|
334
|
+
const LABEL_RE = /^[a-z0-9][a-z0-9._-]{0,31}$/;
|
|
335
|
+
/**
|
|
336
|
+
* Pick the version for get_prompt / fill_variables: a pinned `version`, a deployment `label`, or the
|
|
337
|
+
* current version. `version` and `label` together are rejected so the caller never guesses which wins.
|
|
338
|
+
*/
|
|
339
|
+
async function pickByVersionOrLabel(prompt, version, label) {
|
|
340
|
+
if (label !== undefined) {
|
|
341
|
+
if (version !== undefined)
|
|
342
|
+
return { error: 'Pass either `version` or `label`, not both.' };
|
|
343
|
+
const wanted = label.trim().toLowerCase();
|
|
344
|
+
if (!LABEL_RE.test(wanted))
|
|
345
|
+
return { error: `Invalid label '${label}'. Use a-z, 0-9, '.', '_' or '-' (max 32).` };
|
|
346
|
+
const labeled = await (0, api_client_1.getLabeledVersion)(prompt.id, wanted);
|
|
347
|
+
if (!labeled)
|
|
348
|
+
return { error: `No label '${wanted}' on '${prompt.title}'.` };
|
|
349
|
+
return { picked: labeled };
|
|
350
|
+
}
|
|
351
|
+
const picked = (0, promptText_1.pickVersion)(prompt, version);
|
|
352
|
+
if (!picked) {
|
|
353
|
+
const available = (prompt.versions ?? []).map((v) => v.version_number);
|
|
354
|
+
return { error: `Version ${version} not found for '${prompt.title}'. Available: ${available.join(', ') || 'none'}.` };
|
|
355
|
+
}
|
|
356
|
+
return { picked };
|
|
357
|
+
}
|
|
333
358
|
function createServer(options = {}) {
|
|
334
359
|
const server = new mcp_js_1.McpServer({ name: constants_1.MCP_SERVER_NAME, version: constants_1.MCP_VERSION });
|
|
335
360
|
const catalog = createCatalogCache(options.now ?? Date.now);
|
|
@@ -360,12 +385,13 @@ function createServer(options = {}) {
|
|
|
360
385
|
server.registerTool('get_prompt', {
|
|
361
386
|
title: 'Get prompt content',
|
|
362
387
|
description: 'Fetch the full content of one prompt by name, title, id or short-id. ' +
|
|
363
|
-
'Optionally pin an exact version number. Returns the prompt text plus the ' +
|
|
388
|
+
'Optionally pin an exact version number or a deployment label (e.g. production). Returns the prompt text plus the ' +
|
|
364
389
|
'{{variable}} names it expects — if there are variables, either fill them ' +
|
|
365
390
|
'yourself or call fill_variables.',
|
|
366
391
|
inputSchema: {
|
|
367
392
|
name: zod_1.z.string().min(1).describe('Prompt title, id, or unique title fragment'),
|
|
368
393
|
version: zod_1.z.number().int().min(1).optional().describe('Exact version number to fetch (default: current)'),
|
|
394
|
+
label: zod_1.z.string().min(1).max(32).optional().describe("Deployment label to fetch instead of the current version, e.g. 'production' or 'staging' (not with version)"),
|
|
369
395
|
project: zod_1.z.string().min(1).optional().describe('Repo name, slug, or id to scope resolution when titles collide'),
|
|
370
396
|
via: zod_1.z
|
|
371
397
|
.enum(['direct', 'suggestion'])
|
|
@@ -373,17 +399,16 @@ function createServer(options = {}) {
|
|
|
373
399
|
.describe("Set 'suggestion' when fetching a prompt that suggest_prompts or a PromptLikeEngineer hint offered"),
|
|
374
400
|
},
|
|
375
401
|
annotations: READ_ONLY,
|
|
376
|
-
}, async ({ name, version, project, via }) => guarded(async () => {
|
|
402
|
+
}, async ({ name, version, label, project, via }) => guarded(async () => {
|
|
377
403
|
const projectId = project ? await (0, resolver_1.resolveProjectId)(project) : undefined;
|
|
378
404
|
const result = await (0, resolver_1.resolvePromptByName)(name, { projectId });
|
|
379
405
|
if (result.status !== 'found')
|
|
380
406
|
return resolveFailure(name, result);
|
|
381
407
|
const prompt = result.prompt;
|
|
382
|
-
const
|
|
383
|
-
if (
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
}
|
|
408
|
+
const choice = await pickByVersionOrLabel(prompt, version, label);
|
|
409
|
+
if ('error' in choice)
|
|
410
|
+
return fail(choice.error);
|
|
411
|
+
const picked = choice.picked;
|
|
387
412
|
const text = (0, promptText_1.versionText)(picked);
|
|
388
413
|
(0, api_client_1.recordPromptUse)(prompt.id, useOptions(server, 'mcp_tool', { via, version: picked.version_number }));
|
|
389
414
|
return ok({
|
|
@@ -405,20 +430,20 @@ function createServer(options = {}) {
|
|
|
405
430
|
name: zod_1.z.string().min(1).describe('Prompt title, id, or unique title fragment'),
|
|
406
431
|
variables: zod_1.z.record(zod_1.z.string()).describe('Variable name → value map'),
|
|
407
432
|
version: zod_1.z.number().int().min(1).optional().describe('Exact version number (default: current)'),
|
|
433
|
+
label: zod_1.z.string().min(1).max(32).optional().describe("Deployment label to use instead of the current version, e.g. 'production' (not with version)"),
|
|
408
434
|
project: zod_1.z.string().min(1).optional().describe('Repo name, slug, or id to scope resolution when titles collide'),
|
|
409
435
|
},
|
|
410
436
|
annotations: READ_ONLY,
|
|
411
|
-
}, async ({ name, variables, version, project }) => guarded(async () => {
|
|
437
|
+
}, async ({ name, variables, version, label, project }) => guarded(async () => {
|
|
412
438
|
const projectId = project ? await (0, resolver_1.resolveProjectId)(project) : undefined;
|
|
413
439
|
const result = await (0, resolver_1.resolvePromptByName)(name, { projectId });
|
|
414
440
|
if (result.status !== 'found')
|
|
415
441
|
return resolveFailure(name, result);
|
|
416
442
|
const prompt = result.prompt;
|
|
417
|
-
const
|
|
418
|
-
if (
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
}
|
|
443
|
+
const choice = await pickByVersionOrLabel(prompt, version, label);
|
|
444
|
+
if ('error' in choice)
|
|
445
|
+
return fail(choice.error);
|
|
446
|
+
const picked = choice.picked;
|
|
422
447
|
const raw = (0, promptText_1.versionText)(picked);
|
|
423
448
|
const filled = (0, promptVariables_1.fillVariables)(raw, variables);
|
|
424
449
|
const missing = (0, promptVariables_1.extractVariables)(filled);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "promptlike-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"mcpName": "io.github.zeynepaslierhan/promptlike-mcp",
|
|
5
5
|
"description": "MCP server for PromptLikeEngineer - your prompt library as MCP tools, slash-command prompts and @-resources: list, search, get, fill {{variables}}, suggest, and save new prompts/versions (add-only).",
|
|
6
6
|
"bin": {
|
|
@@ -41,6 +41,13 @@
|
|
|
41
41
|
},
|
|
42
42
|
"license": "MIT",
|
|
43
43
|
"homepage": "https://promptlikeengineer.com",
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/zeynepaslierhann/promptlike-plugin.git"
|
|
47
|
+
},
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/zeynepaslierhann/promptlike-plugin/issues"
|
|
50
|
+
},
|
|
44
51
|
"publishConfig": {
|
|
45
52
|
"access": "public"
|
|
46
53
|
},
|