promptlike-mcp 0.5.1 → 0.6.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,28 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.0 — 2026-10-30
4
+
5
+ - **`update_prompt` can now change a prompt's description and tags** (before, only its text). New optional
6
+ arguments: `description` (overwrites; `""` clears it) and `tags` (add-only: adds the tags the prompt lacks, never removes one; `[]` changes nothing);
7
+ `content` is now optional too. Add-only is kept this way: a field you do not pass is not touched, a field you
8
+ pass overwrites, no prompt or version is deleted. Only `content` creates a **version** (the old one is
9
+ kept; same text → none). The description and the tags are not part of a version, so a call that changes only
10
+ them opens no version; the answer returns `previous_description` so an overwrite can be restored.
11
+ Tags are add-only (decision of 30 Oct): missing ones are added; tags already on the prompt, and tags you do
12
+ not list, are left as they are, so the answer has no `tags_removed` and the client sends no DELETE. When some
13
+ existing tags were not listed the answer carries a `tags_note` saying so. Values that already match change nothing (`status: "unchanged"`);
14
+ `status` is `updated` (a version was added), `metadata_updated` or `unchanged`. A call with none of
15
+ `content`, `description`, `tags` is an error. The same length limits and the secret check as `save_prompt`
16
+ apply. If a step fails after another succeeded, the answer is an error that says what was applied.
17
+ - **New tool: `submit_feedback`** (the eighth). An agent calls it when a PromptLikeEngineer tool is missing,
18
+ broken, confusing or returned a wrong result, or when a saved prompt did not work: `message` (one short
19
+ factual sentence), optional `type` (`bug`, `missing`, `idea`, `prompt`; default `idea`), `prompt` (a title or
20
+ id, never its text) and `email`. It works without a session and ties the report to your account when you are
21
+ signed in. Sent: those fields, `source: "agent"`, the agent name (the MCP client's name, or `mcp-client`),
22
+ `client: "mcp"` and four short values (version, OS and CPU, Node version, tool name). A message that looks
23
+ like an API key or token is refused, as in `save_prompt`. A rate limit, a network problem or a server error
24
+ returns a tool error with `code`, `retryable` and, for a rate limit, `retry_after`; nothing is queued.
25
+
3
26
  ## 0.5.1 — 2026-10-25
4
27
 
5
28
  - **Security:** `PROMPTLIKE_API_URL` must now use https (plain http is accepted only for
package/README.md CHANGED
@@ -52,16 +52,28 @@ Every prompt is also a resource, `promptlike://<repo>/<prompt>` (`text/markdown`
52
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
- | `update_prompt` | **Write.** New version of an existing prompt: exact title or id, full new `content`, optional `changelog`, `bump` (`patch`/`minor`/`major`). |
55
+ | `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` → replaces the tag list. A field you leave out is not touched; one you pass overwrites. |
56
+ | `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. |
56
57
 
57
58
  ### How writes behave
58
59
 
59
- - **Add-only.** There is no delete tool; `update_prompt` keeps every earlier version (roll back on the web or with `ple rollback`).
60
- - **Safe to retry.** Same title + content → "already saved"; content equal to the current version → no new version. A title that exists with different content is reported instead of duplicated.
60
+ - **Add-only.** There is no delete tool; `update_prompt` keeps every earlier version (roll back on the web or with `ple rollback`). No prompt and no version is ever deleted.
61
+ - **`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.
62
+ - **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.
61
63
  - **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.
62
64
  - **No secrets.** Content that looks like an API key or token is refused — use a `{{variable}}`.
63
65
  - **Exact names only for updates.** A fuzzy match is answered with "did you mean…", never written to.
64
66
 
67
+ ### `submit_feedback`
68
+
69
+ The one tool that does not touch your library. The agent calls it when a PromptLikeEngineer tool is missing, broken,
70
+ confusing or returned a wrong result, or when a saved prompt did not work. What is sent: the type, the message, the
71
+ prompt title or id and email if given, `source: "agent"`, the agent name (your MCP client's name, or `mcp-client`),
72
+ `client: "mcp"` and four short values (server version, OS and CPU, Node version, the tool name). Never prompt bodies,
73
+ and a message that looks like an API key or token is refused. It works signed out; with a `ple login` session the
74
+ report is tied to your account. A rate limit, a network problem or a server error comes back as a tool error with
75
+ `code` and `retryable` (nothing is queued, nothing is thrown). The `ple feedback` command is the same thing from a terminal.
76
+
65
77
  The server never spends your AI tokens (no improve), and it does not use MCP sampling.
66
78
 
67
79
  ## Notes
@@ -29,6 +29,7 @@ exports.recordPromptUse = recordPromptUse;
29
29
  exports.createPrompt = createPrompt;
30
30
  exports.savePromptVersion = savePromptVersion;
31
31
  exports.addPromptTag = addPromptTag;
32
+ exports.updatePromptDescription = updatePromptDescription;
32
33
  exports.suggestPrompts = suggestPrompts;
33
34
  const constants_1 = require("./constants");
34
35
  const config_1 = require("./config");
@@ -428,6 +429,13 @@ async function savePromptVersion(input) {
428
429
  async function addPromptTag(promptId, tagName) {
429
430
  await apiFetch(`/api/prompts/${promptId}/tags`, { method: 'POST', body: { tagName } });
430
431
  }
432
+ /**
433
+ * Overwrite the prompt-level description (PATCH /api/prompts/{id}). The description is not part of a
434
+ * version: no version is created and nothing else about the prompt changes. `''` clears it.
435
+ */
436
+ async function updatePromptDescription(promptId, description) {
437
+ await apiFetch(`/api/prompts/${promptId}`, { method: 'PATCH', body: { description } });
438
+ }
431
439
  /** Best matches for a task from the user's OWN library (server-side full text). */
432
440
  async function suggestPrompts(task, limit = 3) {
433
441
  const res = await apiFetch('/api/prompts/suggest', {
@@ -0,0 +1,225 @@
1
+ "use strict";
2
+ /**
3
+ * submit_feedback — an agent tells the maker that a tool is missing, broken, confusing or gave a wrong
4
+ * result, or that a saved prompt did not work (POST /api/feedback).
5
+ *
6
+ * Guarantees (each has a test):
7
+ * - No secret, no prompt body: the same secret patterns as save_prompt (writeGuard.ts) REFUSE the call and
8
+ * name the kind, never the value; `prompt` is a title or an id on one line (≤200), never prompt text.
9
+ * - What is sent is the type, the message, the prompt title/id and email if given, who wrote it
10
+ * (`source: "agent"`, `agent_name`: the MCP client's name or "mcp-client", `client: "mcp"`) and four short
11
+ * context values (version, OS + CPU, Node version, the tool name). Nothing else.
12
+ * - The session is optional: signed in, the report is tied to the account (bearer token of `ple login`);
13
+ * signed out, or when the server does not accept the session, it goes out anonymously.
14
+ * - Never throws. Rate limits, network problems and server errors come back as a structured error
15
+ * (`{ error, code, retryable, retry_after? }`) the agent can act on. Nothing is queued (the CLI queues; a
16
+ * stdio server that just failed to reach the API is not a place to keep state).
17
+ * - Retried tool calls do not duplicate: an identical report that already went through in this session
18
+ * returns the earlier id.
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.FEEDBACK_TIMEOUT_MS = exports.DEFAULT_AGENT_NAME = exports.MAX_AGENT_NAME = exports.MAX_FEEDBACK_PROMPT_REF = exports.MAX_FEEDBACK_MESSAGE = exports.FEEDBACK_TYPES = void 0;
22
+ exports.agentNameFor = agentNameFor;
23
+ exports.buildFeedbackPayload = buildFeedbackPayload;
24
+ exports.resetFeedbackSession = resetFeedbackSession;
25
+ exports.submitFeedbackFlow = submitFeedbackFlow;
26
+ const constants_1 = require("./constants");
27
+ const api_client_1 = require("./api-client");
28
+ const config_1 = require("./config");
29
+ const writeGuard_1 = require("./writeGuard");
30
+ exports.FEEDBACK_TYPES = ['bug', 'missing', 'idea', 'prompt'];
31
+ exports.MAX_FEEDBACK_MESSAGE = 2000;
32
+ exports.MAX_FEEDBACK_PROMPT_REF = 200;
33
+ exports.MAX_AGENT_NAME = 64;
34
+ exports.DEFAULT_AGENT_NAME = 'mcp-client';
35
+ exports.FEEDBACK_TIMEOUT_MS = 15000;
36
+ const MAX_CONTEXT_VALUE = 64;
37
+ const EMAIL_RE = /^[^\s@<>()[\],;:"\\]{1,64}@[^\s@<>()[\],;:"\\]+\.[^\s@<>()[\],;:"\\]{2,}$/;
38
+ /** MCP client name (from `initialize`) as an agent label: lowercase `a-z 0-9 . _ -`, ≤64; "mcp-client" when unknown. */
39
+ function agentNameFor(clientName) {
40
+ const cleaned = (clientName ?? '')
41
+ .normalize('NFKC')
42
+ .toLowerCase()
43
+ .replace(/[^a-z0-9._-]+/g, '-')
44
+ .replace(/-{2,}/g, '-')
45
+ .replace(/^[-._]+|[-._]+$/g, '')
46
+ .slice(0, exports.MAX_AGENT_NAME);
47
+ return cleaned || exports.DEFAULT_AGENT_NAME;
48
+ }
49
+ function fail(code, message, extra = {}) {
50
+ return { ok: false, message, payload: { error: message, code, ...extra } };
51
+ }
52
+ /** Validate input and build the body. The error never echoes a secret. */
53
+ function buildFeedbackPayload(args, clientName) {
54
+ const type = args.type ?? 'idea';
55
+ if (!exports.FEEDBACK_TYPES.includes(type)) {
56
+ return { ok: false, error: `type must be one of: ${exports.FEEDBACK_TYPES.join(', ')}.` };
57
+ }
58
+ const message = (0, writeGuard_1.cleanContent)(args.message ?? '');
59
+ if (!message)
60
+ return { ok: false, error: 'message is empty.' };
61
+ if (message.length > exports.MAX_FEEDBACK_MESSAGE) {
62
+ return { ok: false, error: `message is too long (${message.length} chars, max ${exports.MAX_FEEDBACK_MESSAGE}). One short, factual sentence is enough.` };
63
+ }
64
+ // Scan the RAW text too: cleaning turns a control character into nothing/space, which can split a key.
65
+ const secret = (0, writeGuard_1.findSecret)(args.message) ?? (0, writeGuard_1.findSecret)(message);
66
+ if (secret) {
67
+ return { ok: false, error: `message looks like it contains a ${secret}. Nothing was sent. Remove it and try again — feedback never needs secrets.` };
68
+ }
69
+ const value = {
70
+ type: type,
71
+ message,
72
+ source: 'agent',
73
+ agent_name: agentNameFor(clientName),
74
+ client: 'mcp',
75
+ context: {
76
+ cli_version: constants_1.MCP_VERSION.slice(0, MAX_CONTEXT_VALUE),
77
+ os: `${process.platform}-${process.arch}`.slice(0, MAX_CONTEXT_VALUE),
78
+ node: process.versions.node.slice(0, MAX_CONTEXT_VALUE),
79
+ command: 'submit_feedback',
80
+ },
81
+ };
82
+ if (args.prompt !== undefined) {
83
+ if (/[\r\n\u2028\u2029]/.test(args.prompt)) {
84
+ return { ok: false, error: 'prompt must be a prompt title or id on one line, not prompt text. Prompt bodies are never sent.' };
85
+ }
86
+ const ref = (0, writeGuard_1.cleanTitle)(args.prompt);
87
+ if (ref.length > exports.MAX_FEEDBACK_PROMPT_REF) {
88
+ return { ok: false, error: `prompt is too long (max ${exports.MAX_FEEDBACK_PROMPT_REF} chars). Give the title or id, never the text.` };
89
+ }
90
+ const refSecret = (0, writeGuard_1.findSecret)(args.prompt);
91
+ if (refSecret)
92
+ return { ok: false, error: `prompt looks like it contains a ${refSecret}. Nothing was sent.` };
93
+ if (ref)
94
+ value.prompt_ref = ref;
95
+ }
96
+ if (args.email !== undefined) {
97
+ const email = args.email.trim();
98
+ if (email.length > 254 || !EMAIL_RE.test(email))
99
+ return { ok: false, error: 'email is not a valid address.' };
100
+ value.email = email;
101
+ }
102
+ return { ok: true, value };
103
+ }
104
+ function retryAfterOf(...values) {
105
+ for (const v of values) {
106
+ const n = typeof v === 'number' ? v : typeof v === 'string' && /^\d{1,6}$/.test(v.trim()) ? Number(v) : NaN;
107
+ if (Number.isFinite(n) && n >= 0)
108
+ return Math.min(Math.floor(n), 86400);
109
+ }
110
+ return undefined;
111
+ }
112
+ async function post(payload, token, fetchImpl) {
113
+ const signal = AbortSignal.timeout(exports.FEEDBACK_TIMEOUT_MS);
114
+ let res;
115
+ try {
116
+ res = await fetchImpl(`${constants_1.API_BASE_URL}/api/feedback`, {
117
+ method: 'POST',
118
+ headers: {
119
+ 'Content-Type': 'application/json',
120
+ Accept: 'application/json',
121
+ 'X-Client-Version': `mcp/${constants_1.MCP_VERSION}`,
122
+ ...(token ? { Authorization: `Bearer ${token}` } : {}),
123
+ },
124
+ body: JSON.stringify(payload),
125
+ signal,
126
+ // Never follow a redirect: the body (and a token) must not be replayed at an address the server chose.
127
+ redirect: 'manual',
128
+ });
129
+ }
130
+ catch (err) {
131
+ const timedOut = signal.aborted || err?.name === 'TimeoutError' || err?.name === 'AbortError';
132
+ return {
133
+ kind: 'unreachable',
134
+ message: timedOut
135
+ ? `No response from ${constants_1.API_BASE_URL} within ${exports.FEEDBACK_TIMEOUT_MS / 1000}s.`
136
+ : `Cannot reach ${constants_1.API_BASE_URL}. Check the connection.`,
137
+ };
138
+ }
139
+ if (res.status >= 300 && res.status < 400) {
140
+ return { kind: 'unreachable', message: `The server answered with a redirect (HTTP ${res.status}); it is not followed. Check PROMPTLIKE_API_URL.` };
141
+ }
142
+ let body = {};
143
+ try {
144
+ const parsed = await res.json();
145
+ if (typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed))
146
+ body = parsed;
147
+ }
148
+ catch {
149
+ /* status decides */
150
+ }
151
+ return { kind: 'response', status: res.status, body, retryAfter: retryAfterOf(body.retry_after, res.headers.get('retry-after')) };
152
+ }
153
+ /** Short, single-line text from the server (it is data, not instructions: length-capped, control characters removed). */
154
+ function serverText(body, fallback) {
155
+ const e = body.error;
156
+ if (typeof e !== 'string' || !e.trim())
157
+ return fallback;
158
+ return (0, writeGuard_1.cleanTitle)(e).slice(0, 300) || fallback;
159
+ }
160
+ const sentInThisSession = new Map();
161
+ const MAX_REMEMBERED = 100;
162
+ /** For tests. */
163
+ function resetFeedbackSession() {
164
+ sentInThisSession.clear();
165
+ }
166
+ async function submitFeedbackFlow(args, opts = {}) {
167
+ try {
168
+ const built = buildFeedbackPayload(args, opts.clientName);
169
+ if (!built.ok)
170
+ return fail('invalid_input', built.error, { retryable: false });
171
+ const payload = built.value;
172
+ if (constants_1.API_BASE_URL_ERROR)
173
+ return fail('config', constants_1.API_BASE_URL_ERROR, { retryable: false });
174
+ const key = JSON.stringify([payload.type, payload.message, payload.prompt_ref ?? '', payload.email ?? '']);
175
+ const earlier = sentInThisSession.get(key);
176
+ if (earlier !== undefined) {
177
+ return { ok: true, payload: { status: 'already_sent', ...(earlier ? { id: earlier } : {}), note: 'This exact report was already sent in this session.' } };
178
+ }
179
+ const fetchImpl = opts.fetchImpl ?? fetch;
180
+ // The session is optional. A refresh that fails only means: send without it.
181
+ let token;
182
+ if ((0, config_1.readConfig)()) {
183
+ try {
184
+ await (0, api_client_1.ensureAuthed)();
185
+ token = (0, config_1.readConfig)()?.access_token;
186
+ }
187
+ catch {
188
+ token = undefined;
189
+ }
190
+ }
191
+ let raw = await post(payload, token, fetchImpl);
192
+ if (raw.kind === 'response' && (raw.status === 401 || raw.status === 403) && token) {
193
+ raw = await post(payload, undefined, fetchImpl); // the server did not accept the session: send anonymously
194
+ token = undefined;
195
+ }
196
+ if (raw.kind === 'unreachable') {
197
+ return fail('unavailable', `${raw.message} The feedback was not sent; do not retry in a loop — mention it to the user instead.`, { retryable: true });
198
+ }
199
+ const { status, body } = raw;
200
+ if (status === 200 || status === 201) {
201
+ const id = typeof body.id === 'string' || typeof body.id === 'number' ? (0, writeGuard_1.cleanTitle)(String(body.id)).slice(0, 64) : '';
202
+ if (sentInThisSession.size >= MAX_REMEMBERED)
203
+ sentInThisSession.clear();
204
+ sentInThisSession.set(key, id);
205
+ return { ok: true, payload: { status: 'sent', ...(id ? { id } : {}), account: token !== undefined, note: 'Thank you — this reaches the maker of PromptLikeEngineer.' } };
206
+ }
207
+ if (status === 429) {
208
+ const wait = raw.retryAfter;
209
+ return fail('rate_limited', `Rate limited${wait !== undefined ? `; retry in ${wait}s` : ''}. The feedback was not sent.`, {
210
+ retryable: true,
211
+ ...(wait !== undefined ? { retry_after: wait } : {}),
212
+ });
213
+ }
214
+ if (status === 400 || status === 413 || status === 422) {
215
+ return fail('rejected', `The server rejected the feedback: ${serverText(body, status === 413 ? 'too large' : 'invalid')}`, { retryable: false });
216
+ }
217
+ if (status >= 500 || status === 404 || status === 408) {
218
+ return fail('unavailable', `The server answered HTTP ${status}. The feedback was not sent.`, { retryable: true });
219
+ }
220
+ return fail('unexpected', `The server answered HTTP ${status}: ${serverText(body, 'unexpected answer')}`, { retryable: false });
221
+ }
222
+ catch (err) {
223
+ return fail('unexpected', err instanceof Error ? (0, writeGuard_1.cleanTitle)(err.message).slice(0, 200) : 'Unexpected error.', { retryable: false });
224
+ }
225
+ }
@@ -109,35 +109,37 @@ function checkContent(raw) {
109
109
  }
110
110
  return { ok: true, value: content };
111
111
  }
112
- /** Validate + normalise save_prompt input. */
113
- function checkSaveInput(input) {
114
- const title = cleanTitle(input.title);
115
- if (!title)
116
- return { ok: false, error: 'title is empty.' };
117
- if (title.length > exports.MAX_TITLE) {
118
- return { ok: false, error: `title is too long (${title.length} chars, max ${exports.MAX_TITLE}).` };
119
- }
120
- const content = checkContent(input.content);
121
- if (!content.ok)
122
- return content;
123
- const description = cleanTitle(input.description ?? '');
112
+ /**
113
+ * Description text (one line): control characters collapse, length-capped, secret-scanned. `alsoScan` is text
114
+ * that travels with it (the title) and is scanned in the same pass, as `save_prompt` always did.
115
+ * `undefined` → `''`.
116
+ */
117
+ function checkDescription(raw, alsoScan = '') {
118
+ const description = cleanTitle(raw ?? '');
124
119
  if (description.length > exports.MAX_DESCRIPTION) {
125
120
  return { ok: false, error: `description is too long (max ${exports.MAX_DESCRIPTION} chars).` };
126
121
  }
127
122
  // Scan the RAW text: cleanTitle turns a control character into a space, which would split a key.
128
- const textSecret = findSecret(`${input.title}\n${input.description ?? ''}`);
123
+ const textSecret = findSecret(`${alsoScan}\n${raw ?? ''}`);
129
124
  if (textSecret) {
130
- return { ok: false, error: `title/description looks like it contains a ${textSecret}. Remove it and try again.` };
125
+ return {
126
+ ok: false,
127
+ error: `${alsoScan ? 'title/description' : 'description'} looks like it contains a ${textSecret}. Remove it and try again.`,
128
+ };
131
129
  }
130
+ return { ok: true, value: description };
131
+ }
132
+ /** Tag names: cleaned, length-capped, secret-scanned, de-duplicated ignoring case, at most {@link MAX_TAGS}. */
133
+ function checkTags(raw) {
132
134
  const tags = [];
133
- for (const raw of input.tags ?? []) {
134
- const tag = cleanTitle(raw);
135
+ for (const rawTag of raw ?? []) {
136
+ const tag = cleanTitle(rawTag);
135
137
  if (!tag)
136
138
  continue;
137
139
  if (tag.length > exports.MAX_TAG_LENGTH) {
138
140
  return { ok: false, error: `tag '${tag.slice(0, 20)}…' is too long (max ${exports.MAX_TAG_LENGTH} chars).` };
139
141
  }
140
- const tagSecret = findSecret(raw);
142
+ const tagSecret = findSecret(rawTag);
141
143
  if (tagSecret) {
142
144
  return { ok: false, error: `a tag looks like it contains a ${tagSecret}. Remove it and try again.` };
143
145
  }
@@ -146,13 +148,43 @@ function checkSaveInput(input) {
146
148
  }
147
149
  if (tags.length > exports.MAX_TAGS)
148
150
  return { ok: false, error: `too many tags (max ${exports.MAX_TAGS}).` };
149
- return { ok: true, value: { title, content: content.value, description, tags } };
151
+ return { ok: true, value: tags };
150
152
  }
151
- /** Validate + normalise update_prompt input. */
152
- function checkUpdateInput(input) {
153
+ /** Validate + normalise save_prompt input. */
154
+ function checkSaveInput(input) {
155
+ const title = cleanTitle(input.title);
156
+ if (!title)
157
+ return { ok: false, error: 'title is empty.' };
158
+ if (title.length > exports.MAX_TITLE) {
159
+ return { ok: false, error: `title is too long (${title.length} chars, max ${exports.MAX_TITLE}).` };
160
+ }
153
161
  const content = checkContent(input.content);
154
162
  if (!content.ok)
155
163
  return content;
164
+ const description = checkDescription(input.description, input.title);
165
+ if (!description.ok)
166
+ return description;
167
+ const tags = checkTags(input.tags);
168
+ if (!tags.ok)
169
+ return tags;
170
+ return { ok: true, value: { title, content: content.value, description: description.value, tags: tags.value } };
171
+ }
172
+ /**
173
+ * Validate + normalise update_prompt input. A field that was not given stays absent from the result, and a
174
+ * call that gives none of `content`, `description`, `tags` is refused — "update nothing" is a mistake, not a no-op.
175
+ * The same limits and secret scan as `save_prompt` apply to each field that IS given.
176
+ */
177
+ 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.' };
180
+ }
181
+ const value = {};
182
+ if (input.content !== undefined) {
183
+ const content = checkContent(input.content);
184
+ if (!content.ok)
185
+ return content;
186
+ value.content = content.value;
187
+ }
156
188
  const changelog = input.changelog === undefined ? undefined : cleanTitle(input.changelog);
157
189
  if (changelog !== undefined && changelog.length > exports.MAX_CHANGELOG) {
158
190
  return { ok: false, error: `changelog is too long (max ${exports.MAX_CHANGELOG} chars).` };
@@ -161,7 +193,21 @@ function checkUpdateInput(input) {
161
193
  if (changelogSecret) {
162
194
  return { ok: false, error: `changelog looks like it contains a ${changelogSecret}. Remove it and try again.` };
163
195
  }
164
- return { ok: true, value: { content: content.value, changelog: changelog || undefined } };
196
+ if (changelog)
197
+ value.changelog = changelog;
198
+ if (input.description !== undefined) {
199
+ const description = checkDescription(input.description);
200
+ if (!description.ok)
201
+ return description;
202
+ value.description = description.value;
203
+ }
204
+ if (input.tags !== undefined) {
205
+ const tags = checkTags(input.tags);
206
+ if (!tags.ok)
207
+ return tags;
208
+ value.tags = tags.value;
209
+ }
210
+ return { ok: true, value };
165
211
  }
166
212
  /**
167
213
  * Idempotency key for "same content": whitespace-insensitive at the ends and
@@ -12,7 +12,8 @@
12
12
  * prompt; updating with the current content creates no version. A retried
13
13
  * tool call therefore never duplicates anything.
14
14
  * - Safety: update_prompt needs an exact title / id — a fuzzy match could
15
- * add a version to the wrong prompt. Old versions are never deleted.
15
+ * change the wrong prompt. Old versions are never deleted. Its `description` overwrites only when given and
16
+ * its `tags` are add-only (see updatePromptFlow); this client sends no DELETE at all.
16
17
  */
17
18
  Object.defineProperty(exports, "__esModule", { value: true });
18
19
  exports.describeWriteError = describeWriteError;
@@ -125,11 +126,22 @@ function isExactReference(name, prompt) {
125
126
  return true;
126
127
  return prompt.title.trim().toLowerCase() === n;
127
128
  }
129
+ /**
130
+ * update_prompt. Three independent parts, each acting ONLY when its argument was given:
131
+ * - `content` → a NEW version (old ones kept, labels stay); equal to the current text → no version.
132
+ * - `description` → overwritten on the prompt; equal to the current one → nothing is sent. No version.
133
+ * - `tags` → ADD-ONLY: the ones the prompt lacks are added; ones already on it (any case) are left,
134
+ * and tags not listed are never removed (`[]` changes nothing). No version.
135
+ * The description and the tags are not part of a version, so a metadata-only call never opens one. What the
136
+ * description was before is returned (`previous_description`) because it is overwritten and not versioned.
137
+ * Nothing here deletes a prompt or a version. The text goes first: a plan-limit refusal there stops the call
138
+ * before any metadata changes; a metadata step that fails after it is reported, never silent.
139
+ */
128
140
  async function updatePromptFlow(args) {
129
141
  const checked = (0, writeGuard_1.checkUpdateInput)(args);
130
142
  if (!checked.ok)
131
143
  return { ok: false, message: checked.error };
132
- const { content, changelog } = checked.value;
144
+ const { content, changelog, description, tags } = checked.value;
133
145
  try {
134
146
  const projectId = args.project ? await (0, resolver_1.resolveProjectId)(args.project) : undefined;
135
147
  const result = await (0, resolver_1.resolvePromptByName)(args.name, { projectId });
@@ -152,30 +164,94 @@ async function updatePromptFlow(args) {
152
164
  };
153
165
  }
154
166
  const current = (0, promptText_1.pickVersion)(prompt);
155
- if ((0, writeGuard_1.sameContent)((0, promptText_1.versionText)(current), content)) {
167
+ const payload = { id: prompt.id, title: prompt.title };
168
+ let versionAdded = false;
169
+ let metaChanged = false;
170
+ // 1) Text → new version.
171
+ if (content !== undefined) {
172
+ if ((0, writeGuard_1.sameContent)((0, promptText_1.versionText)(current), content)) {
173
+ payload.content = 'unchanged';
174
+ payload.version = current?.version_number ?? null;
175
+ }
176
+ else {
177
+ const saved = await (0, api_client_1.savePromptVersion)({ promptId: prompt.id, content, changelog, bump: args.bump });
178
+ versionAdded = true;
179
+ payload.content = 'updated';
180
+ payload.version = saved.versionNumber ?? null;
181
+ payload.previous_version = current?.version_number ?? null;
182
+ payload.note = 'The previous version is kept; roll back any time from the web or `ple rollback`.';
183
+ }
184
+ }
185
+ const failures = [];
186
+ // 2) Description → overwrite (no version).
187
+ if (description !== undefined) {
188
+ const before = prompt.description ?? '';
189
+ if (before === description) {
190
+ payload.description = 'unchanged';
191
+ }
192
+ else {
193
+ try {
194
+ await (0, api_client_1.updatePromptDescription)(prompt.id, description);
195
+ metaChanged = true;
196
+ payload.description = 'updated';
197
+ // The description is not versioned: hand back what was overwritten so it can be restored.
198
+ payload.previous_description = before;
199
+ }
200
+ catch (err) {
201
+ payload.description = 'failed';
202
+ failures.push(`description: ${describeWriteError(err)}`);
203
+ }
204
+ }
205
+ }
206
+ // 3) Tags → add-only (no version). Nothing is ever detached.
207
+ if (tags !== undefined) {
208
+ const have = prompt.tags ?? [];
209
+ const haveNames = new Set(have.map((t) => t.name.toLowerCase()));
210
+ const toAdd = tags.filter((t) => !haveNames.has(t.toLowerCase()));
211
+ const added = [];
212
+ const tagsFailed = [];
213
+ for (const tag of toAdd) {
214
+ try {
215
+ await (0, api_client_1.addPromptTag)(prompt.id, tag);
216
+ added.push(tag);
217
+ }
218
+ catch {
219
+ tagsFailed.push(tag);
220
+ }
221
+ }
222
+ metaChanged = metaChanged || added.length > 0;
223
+ payload.tags = toAdd.length === 0 ? 'unchanged' : tagsFailed.length > 0 ? 'partly updated' : 'updated';
224
+ if (added.length > 0)
225
+ payload.tags_added = added;
226
+ if (tagsFailed.length > 0) {
227
+ payload.tags_failed = tagsFailed;
228
+ failures.push(`tags: could not add ${tagsFailed.join(', ')}`);
229
+ }
230
+ const wanted = new Set(tags.map((t) => t.toLowerCase()));
231
+ if (have.some((t) => !wanted.has(t.name.toLowerCase()))) {
232
+ payload.tags_note = 'Tags are add-only: the tags you did not list were left on the prompt. Remove a tag in the web app.';
233
+ }
234
+ }
235
+ payload.status = versionAdded ? 'updated' : metaChanged ? 'metadata_updated' : 'unchanged';
236
+ if (payload.status === 'unchanged') {
237
+ // Text only: the wording the docs quote (src/config/iddia-kilidi.test.ts binds the page to this line).
238
+ payload.message =
239
+ description === undefined && tags === undefined
240
+ ? 'Content matches the current version — no new version created.'
241
+ : 'Everything you sent already matches — nothing changed, no version created.';
242
+ }
243
+ else if (!versionAdded) {
244
+ payload.note = 'Only the description / tags changed: no new version was created (they are not part of a version).';
245
+ }
246
+ if (failures.length > 0) {
247
+ // The text (if any) is already saved: say so, and what is still to do.
156
248
  return {
157
- ok: true,
158
- payload: {
159
- status: 'unchanged',
160
- message: 'Content matches the current version — no new version created.',
161
- id: prompt.id,
162
- title: prompt.title,
163
- version: current?.version_number ?? null,
164
- },
249
+ ok: false,
250
+ message: `${versionAdded ? 'The new version was saved, but ' : ''}some changes were not applied — ${failures.join('; ')}. Call update_prompt again to retry them.`,
251
+ payload,
165
252
  };
166
253
  }
167
- const saved = await (0, api_client_1.savePromptVersion)({ promptId: prompt.id, content, changelog, bump: args.bump });
168
- return {
169
- ok: true,
170
- payload: {
171
- status: 'updated',
172
- id: prompt.id,
173
- title: prompt.title,
174
- version: saved.versionNumber ?? null,
175
- previous_version: current?.version_number ?? null,
176
- note: 'The previous version is kept; roll back any time from the web or `ple rollback`.',
177
- },
178
- };
254
+ return { ok: true, payload };
179
255
  }
180
256
  catch (err) {
181
257
  return { ok: false, message: describeWriteError(err) };
package/dist/server.js CHANGED
@@ -5,7 +5,8 @@
5
5
  *
6
6
  * Üç yüzey:
7
7
  * - tools: okuma (list_prompts / search_prompts / get_prompt / fill_variables
8
- * / suggest_prompts) + yazma (v0.4+, W1-3: save_prompt / update_prompt)
8
+ * / suggest_prompts) + yazma (v0.4+, W1-3: save_prompt / update_prompt) +
9
+ * geri bildirim (submit_feedback: yapımcıya kısa not, oturumsuz da çalışır)
9
10
  * - prompts (v0.3+): kullanıcının kütüphanesi MCP prompt'u olarak — istemcinin
10
11
  * `/` menüsünde görünür, {{değişkenler}} prompt argümanı olur. Yerleşik
11
12
  * `save-this` prompt'u (v0.4+) konuşmadaki talimatı kaydettirir.
@@ -30,6 +31,7 @@ const promptText_1 = require("./lib/promptText");
30
31
  const mcpPrompts_1 = require("./lib/mcpPrompts");
31
32
  const resources_1 = require("./lib/resources");
32
33
  const writeTools_1 = require("./lib/writeTools");
34
+ const feedback_1 = require("./lib/feedback");
33
35
  const writeGuard_1 = require("./lib/writeGuard");
34
36
  function ok(payload) {
35
37
  return { content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }] };
@@ -37,6 +39,12 @@ function ok(payload) {
37
39
  function fail(message) {
38
40
  return { content: [{ type: 'text', text: message }], isError: true };
39
41
  }
42
+ /** submit_feedback sonucu: başarıda JSON; hatada yapılandırılmış JSON (`error`, `code`, `retryable`, `retry_after?`) + isError. */
43
+ function fromFeedback(outcome) {
44
+ if (outcome.ok)
45
+ return ok(outcome.payload);
46
+ return { content: [{ type: 'text', text: JSON.stringify(outcome.payload, null, 2) }], isError: true };
47
+ }
40
48
  function fromOutcome(outcome) {
41
49
  if (outcome.ok)
42
50
  return ok(outcome.payload);
@@ -504,24 +512,79 @@ function createServer(options = {}) {
504
512
  return fromOutcome(outcome);
505
513
  }));
506
514
  server.registerTool('update_prompt', {
507
- title: 'Save a new version of a prompt',
508
- description: 'Save new content for an existing prompt as a NEW version (the old version is kept; nothing is ' +
509
- 'deleted). `name` must be the exact title or the id. Content equal to the current version creates ' +
510
- "no version. bump: 'patch' (default), 'minor' or 'major'.",
515
+ title: 'Update a prompt (new version, description, tags)',
516
+ description: 'Change an existing prompt. `name` must be the exact title or the id. Only the fields you pass are ' +
517
+ 'touched; a field you leave out is NOT changed, a field you pass OVERWRITES. ' +
518
+ '`content` (the full new text) is saved as a NEW version: the old version is kept and nothing is ' +
519
+ 'deleted; content equal to the current version creates no version. bump: patch (default), minor or major. ' +
520
+ "`description` (one line; '' clears it) overwrites the prompt's description. `tags` ADDS tags: the ones " +
521
+ 'the prompt lacks are added; tags already on it, and tags you do not list, are left as they are. ' +
522
+ 'It never removes a tag ([] changes nothing; remove a tag in the web app). Description and tags are not ' +
523
+ 'part of a version: changing only them never creates one, and the previous description is returned so ' +
524
+ 'it can be restored. ' +
525
+ 'Pass at least one of content, description, tags; passing values that already match changes nothing. ' +
526
+ 'This tool never deletes a prompt, a version or a tag.',
511
527
  inputSchema: {
512
528
  name: zod_1.z.string().min(1).describe('Exact prompt title, or its id / short id'),
513
- content: zod_1.z.string().min(1).max(writeGuard_1.MAX_CONTENT).describe('The full new prompt text'),
514
- changelog: zod_1.z.string().max(500).optional().describe('What changed, one line'),
515
- bump: zod_1.z.enum(['patch', 'minor', 'major']).optional().describe('Semver bump (default patch)'),
529
+ content: zod_1.z
530
+ .string()
531
+ .min(1)
532
+ .max(writeGuard_1.MAX_CONTENT)
533
+ .optional()
534
+ .describe('The full new prompt text (a new version). Omit to leave the text and versions untouched'),
535
+ description: zod_1.z
536
+ .string()
537
+ .max(writeGuard_1.MAX_DESCRIPTION)
538
+ .optional()
539
+ .describe("One-line description. Omit to leave it unchanged; given (even '') it overwrites"),
540
+ tags: zod_1.z
541
+ .array(zod_1.z.string().min(1).max(writeGuard_1.MAX_TAG_LENGTH))
542
+ .max(writeGuard_1.MAX_TAGS)
543
+ .optional()
544
+ .describe('Tags to ADD (add-only: tags already on the prompt, or not listed, are never removed; [] changes nothing). Omit to leave tags unchanged'),
545
+ changelog: zod_1.z.string().max(500).optional().describe('What changed in the new version, one line (only with content)'),
546
+ bump: zod_1.z.enum(['patch', 'minor', 'major']).optional().describe('Semver bump of the new version (default patch; only with content)'),
516
547
  project: zod_1.z.string().min(1).optional().describe('Repo name, slug, or id when titles collide'),
517
548
  },
518
549
  annotations: WRITE,
519
550
  }, async (args) => guarded(async () => {
520
551
  const outcome = await (0, writeTools_1.updatePromptFlow)(args);
521
- if (outcome.ok && outcome.payload.status === 'updated')
552
+ // A partly failed call can still have saved a version or changed metadata: refresh the catalog then too.
553
+ const status = outcome.ok ? outcome.payload.status : outcome.payload?.status;
554
+ if (status === 'updated' || status === 'metadata_updated')
522
555
  afterWrite(server, catalog);
523
556
  return fromOutcome(outcome);
524
557
  }));
558
+ server.registerTool('submit_feedback', {
559
+ title: 'Send feedback to the PromptLikeEngineer maker',
560
+ description: 'Call this when a PromptLikeEngineer tool is missing, broken, confusing or returned a wrong result, ' +
561
+ 'or when a saved prompt did not work. One short factual sentence is enough. ' +
562
+ 'Never include prompt bodies, secrets or personal data. ' +
563
+ 'Works without a signed-in session. A call with a key or token in the message is refused. ' +
564
+ 'Errors come back as JSON with `code` and `retryable`; do not retry in a loop.',
565
+ inputSchema: {
566
+ type: zod_1.z
567
+ .enum(feedback_1.FEEDBACK_TYPES)
568
+ .optional()
569
+ .describe("bug = something broke or answered wrong, missing = a tool or option is absent, idea = a suggestion, prompt = a saved prompt did not work (default 'idea')"),
570
+ message: zod_1.z.string().min(1).max(feedback_1.MAX_FEEDBACK_MESSAGE).describe('What happened or what is missing, as one short factual sentence'),
571
+ prompt: zod_1.z
572
+ .string()
573
+ .min(1)
574
+ .max(feedback_1.MAX_FEEDBACK_PROMPT_REF)
575
+ .optional()
576
+ .describe('Title or id of the prompt this is about (never its text)'),
577
+ email: zod_1.z.string().max(254).optional().describe('Where the maker can answer, only if the user wants a reply'),
578
+ },
579
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
580
+ }, async (args) => {
581
+ try {
582
+ return fromFeedback(await (0, feedback_1.submitFeedbackFlow)(args, { clientName: server.server.getClientVersion()?.name }));
583
+ }
584
+ catch {
585
+ return fail('Unexpected error.'); // submitFeedbackFlow does not throw; this is only a backstop
586
+ }
587
+ });
525
588
  registerPromptLibrary(server, catalog);
526
589
  registerResources(server, catalog);
527
590
  return server;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptlike-mcp",
3
- "version": "0.5.1",
3
+ "version": "0.6.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": {