promptlike-mcp 0.7.1 → 0.8.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 CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.0 — 2026-11-27
4
+
5
+ - **Security: zod 3 → 4.6.7.** Closes GHSA-mrhx-c7xc-m3w5 (high: memory exhaustion validating oversized constrained collections) that `npm audit` flagged in 0.7.1/0.7.2. `npm audit` is now clean, dev and prod.
6
+ - **The input schemas the tools advertise changed with zod 4**, for the nine existing tools too: `additionalProperties: false` is no longer listed, the integer arguments (`page`, `version`) carry an explicit `maximum`, and `fill_variables.variables` declares `propertyNames`. No required argument changed.
7
+
8
+ - **New tool `fork_prompt`: copy a public prompt into your repo.** `source` is the prompt's id or `ple:user/repo/<exact title or id>`; `project` a repo you own (omit with one). The copy is private and keeps its source and license; forking twice returns the existing copy (`status: "unchanged"`); private/own prompts and plan limits are refused with nothing copied.
9
+ - **`update_prompt` can rename: `new_title`.** Only the title changes (the `/p/` link, versions, labels and tags stay); a title another prompt in the repo already has is refused before anything is written; the answer carries `previous_title`.
10
+ - **New tool `update_repo`: edit a repo's description.** Overwrites the one-line description (`""` clears it); admin or owner only; the answer carries `previous_description`. Nothing else about the repo moves.
11
+ - **Listing prompts and resources together makes one library request.** Clients ask for both on connect; each used to fetch the library separately.
12
+ - **The package ships its lockfile.** `npm-shrinkwrap.json` lists the dependency versions this release was tested with, and npm 11 and earlier apply it when the package is installed from the registry (`npm install`, `npx`). npm 12 no longer reads `npm-shrinkwrap.json`: there you get the newest versions the dependency ranges allow, as with any other package. The cost where it applies: a security fix in a dependency reaches you with our next release, not on its own. The MCP SDK floor is 1.32.2.
13
+ - **hono 4.13.16 in the pinned dependencies.** Five moderate advisories against hono 4.13.15 and earlier were published after 0.7.2. hono arrives with the MCP SDK for its HTTP transport; this server speaks stdio only and never starts it.
14
+
15
+ ## 0.7.2 — 2026-11-02
16
+
17
+ - **`suggest_prompts` is data, not a go-ahead.** Its description and `next_step` now say to name the prompt, ask the user and fetch only after a yes.
18
+ - **`submit_feedback` asks first.** Its description says to show the user the exact sentence and call only after they say yes.
19
+
3
20
  ## 0.7.1 — 2026-11-01
4
21
 
5
22
  - **`fill_variables` no longer ignores a wrong name silently.** Names you pass that the prompt does not have come back in
package/README.md CHANGED
@@ -53,13 +53,15 @@ Every prompt is also a resource, `promptlike://<repo>/<prompt>` (`text/markdown`
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), `folder` (e.g. `reviews/backend`), `tags`. |
55
55
  | `move_prompt` | **Write.** Move ONE prompt to another repo (`to_project`) and/or folder (`folder`; `""` = repo root); exact title or id. Versions, labels, stars, usage and the `/p/` link stay; tags are matched by name in the target repo. Refused, nothing moved, when the target has a prompt with that title or when the move changes who can see the prompt (public/private repo): the agent asks the user, then repeats with `confirm_visibility: true`. Deletes nothing. |
56
- | `update_prompt` | **Write.** Change an existing prompt (exact title or id). Pass any of: full new `content` → a **new version** (`changelog`, `bump` `patch`/`minor`/`major` go with it); `description` → overwrites the description; `tags` → adds these tags (none is ever removed; remove one in the web app or with `ple untag`). A field you leave out is not touched; `description` overwrites. |
56
+ | `fork_prompt` | **Write.** Copy ONE public prompt of another user into a repo you own (`source` = prompt id or `ple:<user>/<repo>/<exact title or id>`; `project` = target repo, omit with one; `title` optional). The copy is private and records its source and license; the original is untouched. Forking twice returns the existing copy (`unchanged`). Refused, nothing copied, for a private or own prompt or at the plan's prompt limit (upgrade link in the message). |
57
+ | `update_repo` | **Write.** Overwrite a repo's one-line `description` (`project` = name, slug or id; `""` clears it; max 500 chars). Needs admin or owner. Only the description changes — never name, slug, visibility, license or prompts; the answer carries `previous_description`. |
58
+ | `update_prompt` | **Write.** Change an existing prompt (exact title or id). Pass any of: full new `content` → a **new version** (`changelog`, `bump` `patch`/`minor`/`major` go with it); `description` → overwrites the description; `tags` → adds these tags (none is ever removed; remove one in the web app or with `ple untag`); `new_title` → renames the prompt (title only: its `/p/` link, versions, labels and tags stay; refused when another prompt in the repo has that title; the answer carries `previous_title`). A field you leave out is not touched; `description` overwrites. |
57
59
  | `submit_feedback` | Tell the maker that a tool is missing, broken, confusing or answered wrong, or that a saved prompt did not work: `message` (one short factual sentence), optional `type` (`bug`/`missing`/`idea`/`prompt`), `prompt` (title or id, never its text), `email`. Works without a session. Not a write to your library. |
58
60
 
59
61
  ### How writes behave
60
62
 
61
63
  - **Nothing is deleted.** There is no delete tool; `update_prompt` keeps every earlier version (roll back on the web or with `ple rollback`) and `move_prompt` changes where a prompt lives, not its versions. No prompt and no version is ever deleted.
62
- - **`update_prompt` touches only what you pass.** A field that is left out is not changed; a field that is passed overwrites (`description: ""` clears it). `content` is the only part that makes a **version**; the description and the tags are not part of a version, so changing only them opens none — and because the description is not versioned, the answer carries `previous_description` so an overwrite can be put back. **Tags are add-only:** `tags` adds the ones the prompt lacks; tags already on it, and tags you do not list, stay — `tags: []` changes nothing, and this server never sends a DELETE (remove a tag in the web app). Passing values that already match changes nothing; passing none of `content`, `description`, `tags` is an error.
64
+ - **`update_prompt` touches only what you pass.** A field that is left out is not changed; a field that is passed overwrites (`description: ""` clears it). `content` is the only part that makes a **version**; the description and the tags are not part of a version, so changing only them opens none — and because the description is not versioned, the answer carries `previous_description` so an overwrite can be put back. **Tags are add-only:** `tags` adds the ones the prompt lacks; tags already on it, and tags you do not list, stay — `tags: []` changes nothing, and this server never sends a DELETE (remove a tag in the web app). Passing values that already match changes nothing; passing none of `content`, `description`, `tags`, `new_title` is an error.
63
65
  - **Safe to retry.** Same title + content → "already saved"; content, description and tags equal to what the prompt has → "unchanged", no new version. A title that exists with different content is reported instead of duplicated.
64
66
  - **Your account, your limits.** Writes use your `ple login` session and the same plan limits as the web; hitting one returns a plain message with the upgrade link and saves nothing. Viewer access to a shared repo cannot write.
65
67
  - **No secrets.** Content that looks like an API key or token is refused — use a `{{variable}}`.
@@ -67,8 +69,9 @@ Every prompt is also a resource, `promptlike://<repo>/<prompt>` (`text/markdown`
67
69
 
68
70
  ### `submit_feedback`
69
71
 
70
- The one tool that does not touch your library. The agent calls it when a PromptLikeEngineer tool is missing, broken,
71
- confusing or returned a wrong result, or when a saved prompt did not work. What is sent: the type, the message, the
72
+ The one tool that does not touch your library. The agent offers it when a PromptLikeEngineer tool is missing, broken,
73
+ confusing or returned a wrong result, or when a saved prompt did not work. The tool's definition tells the agent to show
74
+ you the exact sentence and ask first; the server itself cannot check that it did. What is sent: the type, the message, the
72
75
  prompt title or id and email if given, `source: "agent"`, the agent name (your MCP client's name, or `mcp-client`),
73
76
  `client: "mcp"` and four short values (server version, OS and CPU, Node version, the tool name). Never prompt bodies,
74
77
  and a message that looks like an API key or token is refused. It works signed out; with a `ple login` session the
@@ -30,11 +30,15 @@ exports.createPrompt = createPrompt;
30
30
  exports.savePromptVersion = savePromptVersion;
31
31
  exports.addPromptTag = addPromptTag;
32
32
  exports.updatePromptDescription = updatePromptDescription;
33
+ exports.renamePrompt = renamePrompt;
34
+ exports.updateProjectDescription = updateProjectDescription;
35
+ exports.forkPrompt = forkPrompt;
36
+ exports.listPublicRepoPrompts = listPublicRepoPrompts;
33
37
  exports.movePrompt = movePrompt;
34
38
  exports.suggestPrompts = suggestPrompts;
35
39
  const constants_1 = require("./constants");
36
40
  const config_1 = require("./config");
37
- exports.NOT_LOGGED_IN = 'Not logged in. Run `ple login` in a terminal first (install: npm i -g promptlike).';
41
+ exports.NOT_LOGGED_IN = 'Not logged in. Run `ple login` in a terminal first (install: npm i -g promptlike@0.14.0).';
38
42
  const SESSION_EXPIRED = 'Session expired. Run `ple login` in a terminal to sign in again.';
39
43
  /**
40
44
  * İstek zaman aşımları (O5 / PLE-03; CLI ile aynı değerler). Süre gövde
@@ -129,8 +133,9 @@ function isTimeout(err, signal) {
129
133
  * (403 + upgradeUrl / 429 LIMIT_EXCEEDED) from a real failure.
130
134
  */
131
135
  class ApiError extends Error {
132
- constructor(message, status, code, upgradeUrl) {
136
+ constructor(message, status, code, upgradeUrl, details) {
133
137
  super(message);
138
+ this.details = details;
134
139
  this.name = 'ApiError';
135
140
  this.status = status;
136
141
  this.code = code;
@@ -174,7 +179,7 @@ async function toError(res) {
174
179
  // Non-JSON error body — generic message below.
175
180
  }
176
181
  const message = body.error || `Request failed (${res.status}).`;
177
- return new ApiError(message, res.status, body.code, body.upgradeUrl);
182
+ return new ApiError(message, res.status, body.code, body.upgradeUrl, body);
178
183
  }
179
184
  function getAccessTokenOrThrow() {
180
185
  const config = (0, config_1.readConfig)();
@@ -439,6 +444,56 @@ async function addPromptTag(promptId, tagName) {
439
444
  async function updatePromptDescription(promptId, description) {
440
445
  await apiFetch(`/api/prompts/${promptId}`, { method: 'PATCH', body: { description } });
441
446
  }
447
+ /**
448
+ * Rename a prompt (PATCH /api/prompts/{id}). Only the title changes: the slug behind its public URL is frozen
449
+ * at creation, versions/labels/tags stay. The server does not check for a clashing title; callers do.
450
+ */
451
+ async function renamePrompt(promptId, title) {
452
+ await apiFetch(`/api/prompts/${promptId}`, { method: 'PATCH', body: { title } });
453
+ }
454
+ /** Overwrite a repo's description (PATCH /api/projects/{id}; the server needs admin or owner). `''` clears it. */
455
+ async function updateProjectDescription(projectId, description) {
456
+ await apiFetch(`/api/projects/${projectId}`, { method: 'PATCH', body: { description } });
457
+ }
458
+ /**
459
+ * Fork a PUBLIC prompt of someone else into one of the caller's own repos (POST /api/prompts/{id}/fork). The copy
460
+ * starts private and records its source. Errors carry the server `code` (PROMPT_NOT_FOUND, CANNOT_FORK_OWN,
461
+ * ALREADY_FORKED with `details.forkedPromptId`, NOTHING_TO_FORK) or are a plan limit (403 + upgradeUrl).
462
+ */
463
+ async function forkPrompt(promptId, input) {
464
+ const res = await apiFetch(`/api/prompts/${promptId}/fork`, {
465
+ method: 'POST',
466
+ body: { targetProjectId: input.targetProjectId, ...(input.title ? { title: input.title } : {}) },
467
+ });
468
+ return { forkedPromptId: res.forkedPromptId, forkedProjectId: res.forkedProjectId };
469
+ }
470
+ /** Public prompts of `owner` in the public repo `repoSlug` (no session needed; paged, capped at 2000). */
471
+ async function listPublicRepoPrompts(owner, repoSlug) {
472
+ const out = [];
473
+ const PAGE = 50;
474
+ for (let offset = 0; offset < 2000; offset += PAGE) {
475
+ let res;
476
+ try {
477
+ res = await apiFetch(`/api/public/users/${encodeURIComponent(owner)}/prompts`, { auth: false, query: { limit: PAGE, offset } });
478
+ }
479
+ catch (err) {
480
+ if (err instanceof ApiError && err.status === 404)
481
+ throw new Error(`No public user '${owner}' on PromptLikeEngineer.`);
482
+ throw err;
483
+ }
484
+ const rows = Array.isArray(res.prompts) ? res.prompts : [];
485
+ for (const r of rows) {
486
+ if (typeof r.prompt_id !== 'string' || typeof r.prompt_title !== 'string')
487
+ continue;
488
+ if (String(r.project_slug ?? '').toLowerCase() !== repoSlug.toLowerCase())
489
+ continue;
490
+ out.push({ id: r.prompt_id, title: r.prompt_title });
491
+ }
492
+ if (rows.length < PAGE)
493
+ break;
494
+ }
495
+ return out;
496
+ }
442
497
  /**
443
498
  * Move a prompt to another repo and/or folder (versions, labels, stars, usage and the /p/ link stay with it).
444
499
  * `folder` omitted: kept in the same repo, root in another; `''` = root. A move that changes who can see the
@@ -14,13 +14,14 @@
14
14
  * not export internals (precedent: promptVariables).
15
15
  */
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.MAX_TAG_LENGTH = exports.MAX_TAGS = exports.MAX_CHANGELOG = exports.MAX_DESCRIPTION = exports.MAX_CONTENT = exports.MAX_TITLE = void 0;
17
+ exports.MAX_REPO_DESCRIPTION = exports.MAX_TAG_LENGTH = exports.MAX_TAGS = exports.MAX_CHANGELOG = exports.MAX_DESCRIPTION = exports.MAX_CONTENT = exports.MAX_TITLE = void 0;
18
18
  exports.normalizeForScan = normalizeForScan;
19
19
  exports.findSecret = findSecret;
20
20
  exports.cleanTitle = cleanTitle;
21
21
  exports.cleanContent = cleanContent;
22
22
  exports.checkSaveInput = checkSaveInput;
23
23
  exports.checkUpdateInput = checkUpdateInput;
24
+ exports.checkRepoDescription = checkRepoDescription;
24
25
  exports.sameContent = sameContent;
25
26
  exports.MAX_TITLE = 200;
26
27
  exports.MAX_CONTENT = 100000;
@@ -175,8 +176,8 @@ function checkSaveInput(input) {
175
176
  * The same limits and secret scan as `save_prompt` apply to each field that IS given.
176
177
  */
177
178
  function checkUpdateInput(input) {
178
- if (input.content === undefined && input.description === undefined && input.tags === undefined) {
179
- return { ok: false, error: 'nothing to update: give content (a new version), description or tags.' };
179
+ if (input.content === undefined && input.description === undefined && input.tags === undefined && input.newTitle === undefined) {
180
+ return { ok: false, error: 'nothing to update: give content (a new version), description, tags or new_title.' };
180
181
  }
181
182
  const value = {};
182
183
  if (input.content !== undefined) {
@@ -207,8 +208,33 @@ function checkUpdateInput(input) {
207
208
  return tags;
208
209
  value.tags = tags.value;
209
210
  }
211
+ if (input.newTitle !== undefined) {
212
+ const newTitle = cleanTitle(input.newTitle);
213
+ if (!newTitle)
214
+ return { ok: false, error: 'new_title is empty.' };
215
+ if (newTitle.length > exports.MAX_TITLE) {
216
+ return { ok: false, error: `new_title is too long (${newTitle.length} chars, max ${exports.MAX_TITLE}).` };
217
+ }
218
+ const titleSecret = findSecret(input.newTitle);
219
+ if (titleSecret) {
220
+ return { ok: false, error: `new_title looks like it contains a ${titleSecret}. Remove it and try again.` };
221
+ }
222
+ value.newTitle = newTitle;
223
+ }
210
224
  return { ok: true, value };
211
225
  }
226
+ /** Repo description (one line, max 500 like the server): control characters collapse, secret-scanned; `''` clears it. */
227
+ exports.MAX_REPO_DESCRIPTION = 500;
228
+ function checkRepoDescription(raw) {
229
+ const description = cleanTitle(raw);
230
+ if (description.length > exports.MAX_REPO_DESCRIPTION) {
231
+ return { ok: false, error: `description is too long (${description.length} chars, max ${exports.MAX_REPO_DESCRIPTION}).` };
232
+ }
233
+ const secret = findSecret(raw);
234
+ if (secret)
235
+ return { ok: false, error: `description looks like it contains a ${secret}. Remove it and try again.` };
236
+ return { ok: true, value: description };
237
+ }
212
238
  /**
213
239
  * Idempotency key for "same content": whitespace-insensitive at the ends and
214
240
  * line-ending-insensitive, so a retried call with identical text is a no-op.
@@ -20,6 +20,8 @@ exports.describeWriteError = describeWriteError;
20
20
  exports.savePromptFlow = savePromptFlow;
21
21
  exports.updatePromptFlow = updatePromptFlow;
22
22
  exports.movePromptFlow = movePromptFlow;
23
+ exports.updateRepoFlow = updateRepoFlow;
24
+ exports.forkPromptFlow = forkPromptFlow;
23
25
  const api_client_1 = require("./api-client");
24
26
  const constants_1 = require("./constants");
25
27
  const folder_1 = require("./folder");
@@ -149,10 +151,10 @@ function isExactReference(name, prompt) {
149
151
  * before any metadata changes; a metadata step that fails after it is reported, never silent.
150
152
  */
151
153
  async function updatePromptFlow(args) {
152
- const checked = (0, writeGuard_1.checkUpdateInput)(args);
154
+ const checked = (0, writeGuard_1.checkUpdateInput)({ ...args, newTitle: args.new_title });
153
155
  if (!checked.ok)
154
156
  return { ok: false, message: checked.error };
155
- const { content, changelog, description, tags } = checked.value;
157
+ const { content, changelog, description, tags, newTitle } = checked.value;
156
158
  try {
157
159
  const projectId = args.project ? await (0, resolver_1.resolveProjectId)(args.project) : undefined;
158
160
  const result = await (0, resolver_1.resolvePromptByName)(args.name, { projectId });
@@ -174,6 +176,19 @@ async function updatePromptFlow(args) {
174
176
  'Call again with the exact title or id — updates never guess.',
175
177
  };
176
178
  }
179
+ // A rename is checked BEFORE anything is written: a clash stops the whole call, nothing half-applied.
180
+ let renameTo;
181
+ if (newTitle !== undefined && newTitle !== prompt.title) {
182
+ const clash = (await (0, api_client_1.listPrompts)({ search: newTitle, projectId: prompt.project_id ?? undefined, limit: 100 })).find((p) => p.id !== prompt.id && p.title.trim().toLowerCase() === newTitle.toLowerCase());
183
+ if (clash) {
184
+ return {
185
+ ok: false,
186
+ message: `A prompt titled '${clash.title}' already exists in this repo (${clash.id}). Pick another title; nothing was changed.`,
187
+ payload: { id: prompt.id, title: prompt.title, clash_id: clash.id },
188
+ };
189
+ }
190
+ renameTo = newTitle;
191
+ }
177
192
  const current = (0, promptText_1.pickVersion)(prompt);
178
193
  const payload = { id: prompt.id, title: prompt.title };
179
194
  let versionAdded = false;
@@ -214,6 +229,25 @@ async function updatePromptFlow(args) {
214
229
  }
215
230
  }
216
231
  }
232
+ // 2b) Title → renamed (no version; slug and /p/ link stay).
233
+ if (newTitle !== undefined) {
234
+ if (renameTo === undefined) {
235
+ payload.title_change = 'unchanged';
236
+ }
237
+ else {
238
+ try {
239
+ await (0, api_client_1.renamePrompt)(prompt.id, renameTo);
240
+ metaChanged = true;
241
+ payload.title_change = 'updated';
242
+ payload.previous_title = prompt.title;
243
+ payload.title = renameTo;
244
+ }
245
+ catch (err) {
246
+ payload.title_change = 'failed';
247
+ failures.push(`new_title: ${describeWriteError(err)}`);
248
+ }
249
+ }
250
+ }
217
251
  // 3) Tags → add-only (no version). Nothing is ever detached.
218
252
  if (tags !== undefined) {
219
253
  const have = prompt.tags ?? [];
@@ -263,12 +297,12 @@ async function updatePromptFlow(args) {
263
297
  if (payload.status === 'unchanged') {
264
298
  // Text only: the wording the docs quote (src/config/iddia-kilidi.test.ts binds the page to this line).
265
299
  payload.message =
266
- description === undefined && tags === undefined
300
+ description === undefined && tags === undefined && newTitle === undefined
267
301
  ? 'Content matches the current version — no new version created.'
268
302
  : 'Everything you sent already matches — nothing changed, no version created.';
269
303
  }
270
304
  else if (!versionAdded) {
271
- payload.note = 'Only the description / tags changed: no new version was created (they are not part of a version).';
305
+ payload.note = 'Only the description / tags / title changed: no new version was created (they are not part of a version).';
272
306
  }
273
307
  if (failures.length > 0) {
274
308
  // The text (if any) is already saved: say so, and what is still to do.
@@ -377,3 +411,143 @@ async function movePromptFlow(args) {
377
411
  return { ok: false, message: describeWriteError(err) };
378
412
  }
379
413
  }
414
+ /**
415
+ * update_repo — change a repo's description (the one-line text on its page and in lists). Nothing else about the
416
+ * repo moves: not its name, slug, visibility, license or prompts. The previous text is returned because it is
417
+ * overwritten and not versioned. The server needs admin or owner; its refusal comes back as the message.
418
+ */
419
+ async function updateRepoFlow(args) {
420
+ const checked = (0, writeGuard_1.checkRepoDescription)(args.description);
421
+ if (!checked.ok)
422
+ return { ok: false, message: checked.error };
423
+ try {
424
+ const id = await (0, resolver_1.resolveProjectId)(args.project);
425
+ const repo = (await (0, api_client_1.listProjects)()).find((p) => p.id === id);
426
+ if (!repo)
427
+ return { ok: false, message: `No repo matched '${args.project}'.` };
428
+ if (repo.role && repo.role !== 'owner' && repo.role !== 'admin') {
429
+ return { ok: false, message: `You have '${repo.role}' access to '${repo.name}' — changing its description needs admin or owner.` };
430
+ }
431
+ const before = repo.description ?? '';
432
+ if (before === checked.value) {
433
+ return { ok: true, payload: { status: 'unchanged', message: 'The description already matches — nothing changed.', id: repo.id, repo: repo.name } };
434
+ }
435
+ await (0, api_client_1.updateProjectDescription)(repo.id, checked.value);
436
+ return {
437
+ ok: true,
438
+ payload: {
439
+ status: 'updated',
440
+ id: repo.id,
441
+ repo: repo.name,
442
+ description: checked.value,
443
+ previous_description: before,
444
+ note: 'Only the description changed (name, slug, visibility, license and prompts are untouched).',
445
+ },
446
+ };
447
+ }
448
+ catch (err) {
449
+ return { ok: false, message: describeWriteError(err) };
450
+ }
451
+ }
452
+ const PLE_REF_RE = /^ple:([A-Za-z0-9_-]{3,40})\/([A-Za-z0-9._-]{1,100})\/(.+)$/i;
453
+ const SHORT_HEX_RE = /^[0-9a-f]{8,}$/i;
454
+ /** `source` → the public prompt's full id; a `ple:` reference is looked up on the public pages (exact or id-prefix match only). */
455
+ async function resolveForkSource(source) {
456
+ const value = source.trim();
457
+ if (UUID_RE.test(value))
458
+ return { id: value.toLowerCase() };
459
+ const m = PLE_REF_RE.exec(value);
460
+ if (!m)
461
+ return "Give `source` as the prompt's full id, or as ple:<user>/<repo>/<title or id> (copy it from the prompt's page).";
462
+ const [, owner, repo, rawRef] = m;
463
+ const ref = rawRef.trim();
464
+ const cards = await (0, api_client_1.listPublicRepoPrompts)(owner, repo);
465
+ if (cards.length === 0)
466
+ return `No public prompts found in ple:${owner}/${repo}. The repo and its prompts must both be public.`;
467
+ const byId = SHORT_HEX_RE.test(ref) ? cards.filter((k) => k.id.toLowerCase().startsWith(ref.toLowerCase())) : [];
468
+ const matches = byId.length > 0 ? byId : cards.filter((k) => k.title.trim().toLowerCase() === ref.toLowerCase());
469
+ if (matches.length === 0)
470
+ return `No prompt matched '${ref}' in ple:${owner}/${repo} (exact title or id only — forks never guess).`;
471
+ if (matches.length > 1)
472
+ return `'${ref}' matched ${matches.length} prompts in ple:${owner}/${repo} (${matches.map((k) => k.id).join(', ')}). Call again with one id.`;
473
+ return { id: matches[0].id };
474
+ }
475
+ /**
476
+ * fork_prompt — copy a PUBLIC prompt of another user into one of the caller's own repos. The copy starts private and
477
+ * records its source and license in its first version; the original is untouched. Each prompt forks once per account
478
+ * (a second call returns the existing copy). Counts against the plan's prompt limit; the server enforces it.
479
+ */
480
+ async function forkPromptFlow(args) {
481
+ const title = args.title?.replace(/\s+/g, ' ').trim();
482
+ if (args.title !== undefined && !title)
483
+ return { ok: false, message: '`title` is empty.' };
484
+ if (title && title.length > writeGuard_1.MAX_TITLE)
485
+ return { ok: false, message: `\`title\` is too long (${title.length} chars, max ${writeGuard_1.MAX_TITLE}).` };
486
+ try {
487
+ const source = await resolveForkSource(args.source);
488
+ if (typeof source === 'string')
489
+ return { ok: false, message: source };
490
+ const projects = await (0, api_client_1.listProjects)();
491
+ let target;
492
+ if (args.project) {
493
+ const id = await (0, resolver_1.resolveProjectId)(args.project);
494
+ const found = projects.find((p) => p.id === id);
495
+ if (!found)
496
+ return { ok: false, message: `No repo matched '${args.project}'.` };
497
+ if (found.role && found.role !== 'owner') {
498
+ return { ok: false, message: `You have '${found.role}' access to '${found.name}' — a fork must go into a repo you own.` };
499
+ }
500
+ target = found;
501
+ }
502
+ else {
503
+ const owned = projects.filter((p) => !p.role || p.role === 'owner');
504
+ if (owned.length === 0)
505
+ return { ok: false, message: `You own no repo to fork into. Create one at ${constants_1.API_BASE_URL}/dashboard, then call fork_prompt again.` };
506
+ if (owned.length > 1) {
507
+ return { ok: false, message: `You own ${owned.length} repos (${owned.slice(0, 8).map((p) => p.name).join(', ')}). Ask the user which one, then pass it as \`project\`.` };
508
+ }
509
+ target = owned[0];
510
+ }
511
+ try {
512
+ const res = await (0, api_client_1.forkPrompt)(source.id, { targetProjectId: target.id, title });
513
+ return {
514
+ ok: true,
515
+ payload: {
516
+ status: 'forked',
517
+ id: res.forkedPromptId,
518
+ repo: target.name,
519
+ source_id: source.id,
520
+ visibility: 'private',
521
+ note: "The copy is private. Its source and license are in the first version's changelog; the original is unchanged.",
522
+ },
523
+ };
524
+ }
525
+ catch (err) {
526
+ if (err instanceof api_client_1.ApiError) {
527
+ if (err.code === 'ALREADY_FORKED') {
528
+ const existing = typeof err.details?.forkedPromptId === 'string' ? err.details.forkedPromptId : undefined;
529
+ return {
530
+ ok: true,
531
+ payload: {
532
+ status: 'unchanged',
533
+ message: 'This prompt was already forked — nothing was copied.',
534
+ ...(existing ? { id: existing } : {}),
535
+ source_id: source.id,
536
+ },
537
+ };
538
+ }
539
+ if (err.code === 'PROMPT_NOT_FOUND') {
540
+ return { ok: false, message: 'That prompt was not found. Only public prompts in a public repo can be forked.' };
541
+ }
542
+ if (err.code === 'CANNOT_FORK_OWN')
543
+ return { ok: false, message: 'That is the user\'s own prompt — there is nothing to fork.' };
544
+ if (err.code === 'NOTHING_TO_FORK')
545
+ return { ok: false, message: 'That prompt has no saved content yet, so there is nothing to copy.' };
546
+ }
547
+ throw err;
548
+ }
549
+ }
550
+ catch (err) {
551
+ return { ok: false, message: describeWriteError(err) };
552
+ }
553
+ }
package/dist/server.js CHANGED
@@ -156,19 +156,35 @@ async function fetchAllPrompts() {
156
156
  }
157
157
  function createCatalogCache(now) {
158
158
  let cached = null;
159
+ // İstemci bağlanınca prompt ve resource listesini birlikte ister: aynı anda iki kez çekilmesin
160
+ // (4 Kas 2026: dakikada 15 liste isteği veritabanında zaman aşımı üretti).
161
+ let inFlight = null;
162
+ let generation = 0;
159
163
  return {
160
164
  async get(forceFresh = false) {
161
165
  if (!forceFresh && cached && now() - cached.at < PROMPT_CATALOG_TTL_MS) {
162
166
  return cached.entries;
163
167
  }
164
- await (0, api_client_1.ensureAuthed)();
165
- const entries = (0, mcpPrompts_1.buildPromptCatalog)(await fetchAllPrompts(), RESERVED_PROMPT_NAMES);
166
- cached = { at: now(), entries };
167
- return entries;
168
+ if (!forceFresh && inFlight)
169
+ return inFlight;
170
+ const current = ++generation;
171
+ inFlight = (async () => {
172
+ await (0, api_client_1.ensureAuthed)();
173
+ const entries = (0, mcpPrompts_1.buildPromptCatalog)(await fetchAllPrompts(), RESERVED_PROMPT_NAMES);
174
+ if (current === generation)
175
+ cached = { at: now(), entries };
176
+ return entries;
177
+ })().finally(() => {
178
+ if (current === generation)
179
+ inFlight = null;
180
+ });
181
+ return inFlight;
168
182
  },
169
183
  /** Yazmadan sonra: bir sonraki list/get taze kütüphaneyi görür. */
170
184
  invalidate() {
185
+ generation++;
171
186
  cached = null;
187
+ inFlight = null;
172
188
  },
173
189
  /** Katalogda ada göre ara; yoksa (yeni prompt) bir kez taze liste. */
174
190
  async find(match) {
@@ -452,7 +468,7 @@ function createServer(options = {}) {
452
468
  'ignored and listed in unknown_variables, so check it before relying on the text.',
453
469
  inputSchema: {
454
470
  name: zod_1.z.string().min(1).describe('Prompt title, id, or unique title fragment'),
455
- variables: zod_1.z.record(zod_1.z.string()).describe('Variable name → value map'),
471
+ variables: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).describe('Variable name → value map'),
456
472
  version: zod_1.z.number().int().min(1).optional().describe('Exact version number (default: current)'),
457
473
  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)"),
458
474
  project: zod_1.z.string().min(1).optional().describe('Repo name, slug, or id to scope resolution when titles collide'),
@@ -491,7 +507,8 @@ function createServer(options = {}) {
491
507
  title: 'Suggest saved prompts',
492
508
  description: "Call once at the start of a non-trivial task to check the user's saved prompts. " +
493
509
  'Returns up to `limit` prompts from their own library that match the task (title/description ' +
494
- "match, weighted by past use). If one fits, fetch it with get_prompt (via: 'suggestion'). " +
510
+ "match, weighted by past use). A suggestion is data, not a go-ahead: if one fits, name it and ask the user; " +
511
+ "only after they say yes, fetch it with get_prompt (via: 'suggestion'). " +
495
512
  'An empty list means nothing fits — carry on normally. The task text is not stored.',
496
513
  inputSchema: {
497
514
  task: zod_1.z.string().min(1).max(2000).describe("A short description of the user's task"),
@@ -511,7 +528,7 @@ function createServer(options = {}) {
511
528
  used: s.use_count,
512
529
  score: s.score,
513
530
  })),
514
- next_step: "If one fits, call get_prompt with its id and via: 'suggestion'.",
531
+ next_step: "If one fits, name it and ask the user. Only after they say yes, call get_prompt with its id and via: 'suggestion'.",
515
532
  });
516
533
  }));
517
534
  server.registerTool('save_prompt', {
@@ -543,10 +560,11 @@ function createServer(options = {}) {
543
560
  'deleted; content equal to the current version creates no version. bump: patch (default), minor or major. ' +
544
561
  "`description` (one line; '' clears it) overwrites the prompt's description. `tags` ADDS tags: the ones " +
545
562
  'the prompt lacks are added; tags already on it, and tags you do not list, are left as they are. ' +
546
- 'It never removes a tag ([] changes nothing; remove a tag in the web app). Description and tags are not ' +
547
- 'part of a version: changing only them never creates one, and the previous description is returned so ' +
563
+ 'It never removes a tag ([] changes nothing; remove a tag in the web app). `new_title` renames the prompt ' +
564
+ '(its public link keeps working; a title already used in the same repo is refused). Description, tags and title are not ' +
565
+ 'part of a version: changing only them never creates one, and the previous description / title is returned so ' +
548
566
  'it can be restored. ' +
549
- 'Pass at least one of content, description, tags; passing values that already match changes nothing. ' +
567
+ 'Pass at least one of content, description, tags, new_title; passing values that already match changes nothing. ' +
550
568
  'This tool never deletes a prompt, a version or a tag.',
551
569
  inputSchema: {
552
570
  name: zod_1.z.string().min(1).describe('Exact prompt title, or its id / short id'),
@@ -566,6 +584,12 @@ function createServer(options = {}) {
566
584
  .max(writeGuard_1.MAX_TAGS)
567
585
  .optional()
568
586
  .describe('Tags to ADD (add-only: tags already on the prompt, or not listed, are never removed; [] changes nothing). Omit to leave tags unchanged'),
587
+ new_title: zod_1.z
588
+ .string()
589
+ .min(1)
590
+ .max(writeGuard_1.MAX_TITLE)
591
+ .optional()
592
+ .describe('Rename the prompt. Only the title changes: its public link, versions, labels and tags stay. Refused if another prompt in the same repo already has that title. Omit to keep the title'),
569
593
  changelog: zod_1.z.string().max(500).optional().describe('What changed in the new version, one line (only with content)'),
570
594
  bump: zod_1.z.enum(['patch', 'minor', 'major']).optional().describe('Semver bump of the new version (default patch; only with content)'),
571
595
  project: zod_1.z.string().min(1).optional().describe('Repo name, slug, or id when titles collide'),
@@ -579,6 +603,44 @@ function createServer(options = {}) {
579
603
  afterWrite(server, catalog);
580
604
  return fromOutcome(outcome);
581
605
  }));
606
+ server.registerTool('fork_prompt', {
607
+ title: "Fork someone's public prompt into your repo",
608
+ description: "Copy ONE public prompt of another PromptLikeEngineer user into one of the user's own repos. `source` = the prompt's " +
609
+ 'full id, or ple:<user>/<repo>/<exact title or 8+ hex id characters>. `project` = the repo to copy into (must be one the ' +
610
+ 'user owns; omit when they own just one). `title` = name of the copy (default "Fork of <title>"). The copy is PRIVATE ' +
611
+ "and records its source and license in its first version; the original is never changed. A prompt can be forked once per " +
612
+ 'account: calling again returns the existing copy with status "unchanged". Refused, with nothing copied, when the prompt ' +
613
+ "is private or gone, is the user's own, or the plan's prompt limit is reached (the message carries the upgrade link). " +
614
+ 'Ask the user before forking. This tool never deletes anything.',
615
+ inputSchema: {
616
+ source: zod_1.z.string().min(1).describe('Public prompt: full id, or ple:<user>/<repo>/<exact title or id>'),
617
+ project: zod_1.z.string().min(1).optional().describe('Repo name, slug or id to copy into (one you own); omit if you own just one'),
618
+ title: zod_1.z.string().min(1).max(writeGuard_1.MAX_TITLE).optional().describe('Title of the copy (default: "Fork of <title>")'),
619
+ },
620
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true },
621
+ }, async (args) => guarded(async () => {
622
+ const outcome = await (0, writeTools_1.forkPromptFlow)(args);
623
+ if (outcome.ok && outcome.payload.status === 'forked')
624
+ afterWrite(server, catalog);
625
+ return fromOutcome(outcome);
626
+ }));
627
+ server.registerTool('update_repo', {
628
+ title: 'Edit a repo description',
629
+ description: "Change a repo's one-line description (the text shown on its page and in lists). `project` = repo name, slug or id. " +
630
+ "`description` OVERWRITES the old text ('' clears it); the previous text is returned so it can be restored. " +
631
+ 'Only the description changes: never the name, slug, visibility, license or prompts. Needs admin or owner on the repo. ' +
632
+ 'This tool never deletes anything.',
633
+ inputSchema: {
634
+ project: zod_1.z.string().min(1).describe('Repo name, slug, or id'),
635
+ description: zod_1.z.string().max(writeGuard_1.MAX_REPO_DESCRIPTION).describe("New one-line description (max 500 chars); '' clears it"),
636
+ },
637
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
638
+ }, async (args) => guarded(async () => {
639
+ const outcome = await (0, writeTools_1.updateRepoFlow)(args);
640
+ if (outcome.ok && outcome.payload.status === 'updated')
641
+ afterWrite(server, catalog);
642
+ return fromOutcome(outcome);
643
+ }));
582
644
  server.registerTool('move_prompt', {
583
645
  title: 'Move a prompt to another repo or folder',
584
646
  description: 'Move ONE prompt to another repo and/or folder. `name` must be the exact title or the id. Its versions, ' +
@@ -605,8 +667,9 @@ function createServer(options = {}) {
605
667
  }));
606
668
  server.registerTool('submit_feedback', {
607
669
  title: 'Send feedback to the PromptLikeEngineer maker',
608
- description: 'Call this when a PromptLikeEngineer tool is missing, broken, confusing or returned a wrong result, ' +
609
- 'or when a saved prompt did not work. One short factual sentence is enough. ' +
670
+ description: 'For when a PromptLikeEngineer tool is missing, broken, confusing or returned a wrong result, ' +
671
+ 'or when a saved prompt did not work. Ask the user first: show them the exact sentence and call this only after they say yes. ' +
672
+ 'One short factual sentence is enough. ' +
610
673
  'Never include prompt bodies, secrets or personal data. ' +
611
674
  'Works without a signed-in session. A call with a key or token in the message is refused. ' +
612
675
  'Errors come back as JSON with `code` and `retryable`; do not retry in a loop.',