promptlike-mcp 0.1.1 → 0.2.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/dist/index.js +9 -5
- package/dist/lib/api-client.js +9 -0
- package/dist/lib/resolver.js +37 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -52,7 +52,7 @@ function versionText(v) {
|
|
|
52
52
|
function resolveFailure(name, result) {
|
|
53
53
|
if (result.status === 'ambiguous') {
|
|
54
54
|
return ok({
|
|
55
|
-
error: `'${name}' matched multiple prompts. Call again with a more specific name or an id from the candidates.`,
|
|
55
|
+
error: `'${name}' matched multiple prompts. Call again with the 'project' arg (each candidate lists its repo), a more specific name, or an id from the candidates.`,
|
|
56
56
|
candidates: result.candidates,
|
|
57
57
|
});
|
|
58
58
|
}
|
|
@@ -120,9 +120,11 @@ server.registerTool('get_prompt', {
|
|
|
120
120
|
inputSchema: {
|
|
121
121
|
name: zod_1.z.string().min(1).describe('Prompt title, id, or unique title fragment'),
|
|
122
122
|
version: zod_1.z.number().int().min(1).optional().describe('Exact version number to fetch (default: current)'),
|
|
123
|
+
project: zod_1.z.string().min(1).optional().describe('Repo name, slug, or id to scope resolution when titles collide'),
|
|
123
124
|
},
|
|
124
|
-
}, async ({ name, version }) => guarded(async () => {
|
|
125
|
-
const
|
|
125
|
+
}, async ({ name, version, project }) => guarded(async () => {
|
|
126
|
+
const projectId = project ? await (0, resolver_1.resolveProjectId)(project) : undefined;
|
|
127
|
+
const result = await (0, resolver_1.resolvePromptByName)(name, { projectId });
|
|
126
128
|
if (result.status !== 'found')
|
|
127
129
|
return resolveFailure(name, result);
|
|
128
130
|
const prompt = result.prompt;
|
|
@@ -152,9 +154,11 @@ server.registerTool('fill_variables', {
|
|
|
152
154
|
name: zod_1.z.string().min(1).describe('Prompt title, id, or unique title fragment'),
|
|
153
155
|
variables: zod_1.z.record(zod_1.z.string()).describe('Variable name → value map'),
|
|
154
156
|
version: zod_1.z.number().int().min(1).optional().describe('Exact version number (default: current)'),
|
|
157
|
+
project: zod_1.z.string().min(1).optional().describe('Repo name, slug, or id to scope resolution when titles collide'),
|
|
155
158
|
},
|
|
156
|
-
}, async ({ name, variables, version }) => guarded(async () => {
|
|
157
|
-
const
|
|
159
|
+
}, async ({ name, variables, version, project }) => guarded(async () => {
|
|
160
|
+
const projectId = project ? await (0, resolver_1.resolveProjectId)(project) : undefined;
|
|
161
|
+
const result = await (0, resolver_1.resolvePromptByName)(name, { projectId });
|
|
158
162
|
if (result.status !== 'found')
|
|
159
163
|
return resolveFailure(name, result);
|
|
160
164
|
const prompt = result.prompt;
|
package/dist/lib/api-client.js
CHANGED
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.NOT_LOGGED_IN = void 0;
|
|
16
16
|
exports.ensureAuthed = ensureAuthed;
|
|
17
17
|
exports.listPrompts = listPrompts;
|
|
18
|
+
exports.listProjects = listProjects;
|
|
18
19
|
exports.getPromptDetail = getPromptDetail;
|
|
19
20
|
exports.recordPromptUse = recordPromptUse;
|
|
20
21
|
const constants_1 = require("./constants");
|
|
@@ -138,10 +139,18 @@ async function listPrompts(params = {}) {
|
|
|
138
139
|
search: params.search,
|
|
139
140
|
limit: params.limit,
|
|
140
141
|
page: params.page,
|
|
142
|
+
projectId: params.projectId,
|
|
141
143
|
},
|
|
142
144
|
});
|
|
143
145
|
return res.prompts ?? [];
|
|
144
146
|
}
|
|
147
|
+
/** GET /api/projects — accessible repos, for resolving a `project` argument. */
|
|
148
|
+
async function listProjects() {
|
|
149
|
+
const res = await apiFetch('/api/projects', {
|
|
150
|
+
query: { limit: 100 },
|
|
151
|
+
});
|
|
152
|
+
return res.projects ?? [];
|
|
153
|
+
}
|
|
145
154
|
/** GET /api/prompts/{id} — full detail incl. versions; null when 404. */
|
|
146
155
|
async function getPromptDetail(id) {
|
|
147
156
|
try {
|
package/dist/lib/resolver.js
CHANGED
|
@@ -7,12 +7,39 @@
|
|
|
7
7
|
* agent kendisi seçip daha spesifik bir adla tekrar çağırır.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.resolveProjectId = resolveProjectId;
|
|
10
11
|
exports.resolvePromptByName = resolvePromptByName;
|
|
11
12
|
const api_client_1 = require("./api-client");
|
|
12
13
|
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
13
14
|
const SHORT_ID_RE = /^[0-9a-f]{8,}$/i;
|
|
14
15
|
function toCandidates(rows) {
|
|
15
|
-
|
|
16
|
+
// Aday listesinde repo adını da ver (F-analiz): agent aynı başlıklı iki
|
|
17
|
+
// prompt'u ayırt edip project ile daraltabilsin.
|
|
18
|
+
return rows.slice(0, 10).map((r) => ({
|
|
19
|
+
id: r.id,
|
|
20
|
+
title: r.title,
|
|
21
|
+
project_name: r.project_name ?? null,
|
|
22
|
+
updated_at: r.updated_at,
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Resolve a `project` argument (UUID, exact name, or slug) to a project id.
|
|
27
|
+
* Throws a descriptive error on zero/multiple matches so the agent can retry.
|
|
28
|
+
*/
|
|
29
|
+
async function resolveProjectId(value) {
|
|
30
|
+
const trimmed = value.trim();
|
|
31
|
+
if (UUID_RE.test(trimmed))
|
|
32
|
+
return trimmed;
|
|
33
|
+
const projects = await (0, api_client_1.listProjects)();
|
|
34
|
+
const lower = trimmed.toLowerCase();
|
|
35
|
+
const matches = projects.filter((p) => p.name.toLowerCase() === lower || (p.slug ?? '').toLowerCase() === lower);
|
|
36
|
+
if (matches.length === 1)
|
|
37
|
+
return matches[0].id;
|
|
38
|
+
if (matches.length === 0) {
|
|
39
|
+
throw new Error(`No repo matched '${trimmed}'. Use the repo's exact name, slug, or id.`);
|
|
40
|
+
}
|
|
41
|
+
const hint = matches.map((p) => `${p.id} (${p.name})`).join(', ');
|
|
42
|
+
throw new Error(`'${trimmed}' matched multiple repos: ${hint}. Use the repo id.`);
|
|
16
43
|
}
|
|
17
44
|
/** Bulunan liste öğesini detail'e (versiyonlar dahil) yükselt. */
|
|
18
45
|
async function hydrate(row) {
|
|
@@ -21,21 +48,26 @@ async function hydrate(row) {
|
|
|
21
48
|
return { status: 'not_found' };
|
|
22
49
|
return { status: 'found', prompt: detail };
|
|
23
50
|
}
|
|
24
|
-
async function resolvePromptByName(name) {
|
|
51
|
+
async function resolvePromptByName(name, scope = {}) {
|
|
25
52
|
const trimmed = name.trim();
|
|
26
53
|
if (!trimmed) {
|
|
27
54
|
throw new Error('Cannot resolve an empty name.');
|
|
28
55
|
}
|
|
56
|
+
const projectId = scope.projectId;
|
|
29
57
|
// 1) Full UUID → detail endpoint.
|
|
30
58
|
if (UUID_RE.test(trimmed)) {
|
|
31
59
|
const found = await (0, api_client_1.getPromptDetail)(trimmed);
|
|
32
|
-
if (found)
|
|
60
|
+
if (found) {
|
|
61
|
+
if (projectId && found.project_id && found.project_id !== projectId) {
|
|
62
|
+
return { status: 'not_found' };
|
|
63
|
+
}
|
|
33
64
|
return { status: 'found', prompt: found };
|
|
65
|
+
}
|
|
34
66
|
// Not found by id — fall through to a title search.
|
|
35
67
|
}
|
|
36
68
|
// 2) Short-id prefix (hex, 8+ chars, not a full UUID) → match a page.
|
|
37
69
|
if (!UUID_RE.test(trimmed) && SHORT_ID_RE.test(trimmed)) {
|
|
38
|
-
const page = await (0, api_client_1.listPrompts)({ limit: 100 });
|
|
70
|
+
const page = await (0, api_client_1.listPrompts)({ limit: 100, projectId });
|
|
39
71
|
const lower = trimmed.toLowerCase();
|
|
40
72
|
const matches = page.filter((p) => p.id.toLowerCase().startsWith(lower));
|
|
41
73
|
if (matches.length === 1)
|
|
@@ -45,7 +77,7 @@ async function resolvePromptByName(name) {
|
|
|
45
77
|
// No id match — fall through to a title search.
|
|
46
78
|
}
|
|
47
79
|
// 3) Title / description search.
|
|
48
|
-
const results = await (0, api_client_1.listPrompts)({ search: trimmed, limit: 100 });
|
|
80
|
+
const results = await (0, api_client_1.listPrompts)({ search: trimmed, limit: 100, projectId });
|
|
49
81
|
const lower = trimmed.toLowerCase();
|
|
50
82
|
const titleMatches = results.filter((p) => p.title.toLowerCase().includes(lower));
|
|
51
83
|
const pool = titleMatches.length > 0 ? titleMatches : results;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "promptlike-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "MCP server for PromptLikeEngineer - gives AI agents read-only access to your prompt library (list, search, get, fill variables).",
|
|
5
5
|
"bin": {
|
|
6
6
|
"promptlike-mcp": "dist/index.js",
|