promptlike 0.13.0 → 0.13.1

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,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.13.1 — 2026-11-01
4
+
5
+ - **New: `ple untag <name> <tag...> [--project <repo>] [--json]`** takes tags off a prompt in your account (signed in,
6
+ editor access; names ignore case). The prompt, its versions and the tag itself stay. A name the prompt does not have is
7
+ reported and exits 1. CLI only: the MCP tools still never remove a tag.
8
+ - **The Claude Code hook speaks far less.** `ple suggest --hook` now needs at least two words of your message in a prompt's
9
+ title, tags or description, one of them in the title or tags (a very short message can match on one). The body no longer
10
+ counts. It also stays silent on messages that are not yours: harness events and messages from another session, and it
11
+ ignores injected `<system-reminder>` context. `ple suggest` itself and the MCP `suggest_prompts` tool are unchanged.
12
+ - **`ple get --var` warns about a name the prompt does not have** (usually a typo) and lists the names it does have. The
13
+ warning goes to stderr; stdout stays the prompt, unchanged.
14
+
3
15
  ## 0.13.0 — 2026-10-31
4
16
 
5
17
  - **New: `ple move <name> [--to <repo>] [--folder <path>] [--project <repo>] [--yes] [--json]`** moves a prompt to another
package/README.md CHANGED
@@ -655,6 +655,17 @@ ple rollback "code review" v2 # asks first; --yes for scripts
655
655
  Rollback is non-destructive: the old version is copied forward as a new one,
656
656
  nothing is deleted — so a rollback can itself be undone.
657
657
 
658
+ ### `ple untag <name> <tag...>` — take tags off a prompt
659
+
660
+ ```bash
661
+ ple untag "code review" draft
662
+ ple untag "code review" draft needs-review --project my-prompts --json
663
+ ```
664
+
665
+ CLI 0.13.1+, signed in, editor access. Names ignore case. The prompt, its versions and the tag itself stay, and no new
666
+ version is made (tags are not part of a version). A name the prompt does not have is reported and exits 1. Deploy labels
667
+ are a different thing: `ple tag --remove`. The MCP tools cannot remove a tag, so an agent connected over MCP cannot either.
668
+
658
669
  ### `ple move <name>` — to another repo, or into a folder
659
670
 
660
671
  ```bash
@@ -751,9 +762,12 @@ and other Latin accents). This applies to the hook note as well.
751
762
 
752
763
  `--hook` is what the Claude Code plugin runs on every message
753
764
  (`UserPromptSubmit`). It reads the hook's JSON from stdin and prints one short
754
- note — or nothing: slash commands, messages under 20 characters, weak
755
- matches and prompts already suggested in the session stay silent. It never
756
- waits on the network and gives up after 0.8 s.
765
+ note — or nothing: slash commands, messages under 20 characters, harness events
766
+ and messages from another session, weak matches and prompts already suggested in
767
+ the session stay silent. It is stricter than `ple suggest`: at least two words of
768
+ your message must be in a prompt's title, tags or description, one of them in the
769
+ title or tags (the body does not count). It never waits on the network and gives
770
+ up after 0.8 s.
757
771
 
758
772
  Turn suggestions off with `ple config set suggest off`, `PLE_SUGGEST=off`, or
759
773
  the plugin option in Claude Code's `/config`. How many were shown is counted
@@ -61,6 +61,7 @@ async function getCommand(name, options = {}) {
61
61
  }
62
62
  const values = options.var ?? {};
63
63
  const filled = (0, promptVariables_1.fillVariables)(raw, values);
64
+ (0, local_1.warnUnknownVars)(raw, values);
64
65
  // Warn about any variables left unfilled — to stderr (keep stdout clean).
65
66
  const remaining = (0, promptVariables_1.extractVariables)(filled);
66
67
  if (remaining.length > 0) {
@@ -47,6 +47,7 @@ exports.localList = localList;
47
47
  exports.localShow = localShow;
48
48
  exports.showLocalPrompt = showLocalPrompt;
49
49
  exports.localGet = localGet;
50
+ exports.warnUnknownVars = warnUnknownVars;
50
51
  exports.getLocalPrompt = getLocalPrompt;
51
52
  exports.localCopy = localCopy;
52
53
  exports.copyLocalPrompt = copyLocalPrompt;
@@ -168,6 +169,15 @@ async function localGet(name, values, copy) {
168
169
  return;
169
170
  await getLocalPrompt(p, values, copy);
170
171
  }
172
+ /** A --var the prompt does not have is usually a typo: say so on stderr instead of ignoring it (stdout stays clean). */
173
+ function warnUnknownVars(raw, values) {
174
+ const known = new Set((0, promptVariables_1.extractVariables)(raw));
175
+ const unknown = Object.keys(values).filter((k) => !known.has(k));
176
+ if (unknown.length === 0)
177
+ return;
178
+ console.error(format_1.c.warn(`⚠ Not in this prompt, ignored: ${unknown.map((v) => `--var ${v}`).join(', ')}`));
179
+ console.error(format_1.c.muted(` Its variables: ${[...known].join(', ') || 'none'}`));
180
+ }
171
181
  /** Print one local prompt raw to stdout (shared by the signed-out `get` and the signed-in local fallback). */
172
182
  async function getLocalPrompt(p, values, copy) {
173
183
  if (!p.body.trim()) {
@@ -176,6 +186,7 @@ async function getLocalPrompt(p, values, copy) {
176
186
  return;
177
187
  }
178
188
  const { text } = store.fillVariables(p.body, values);
189
+ warnUnknownVars(p.body, values);
179
190
  // stdout stays machine-clean; warnings go to stderr (same contract as the
180
191
  // signed-in `ple get`, so piping behaves identically either way).
181
192
  const remaining = (0, promptVariables_1.extractVariables)(text);
@@ -11,6 +11,7 @@
11
11
  * prints NOTHING. It is silent when:
12
12
  * - suggestions are off (`PLE_SUGGEST=off`, plugin option, `ple config set suggest off`)
13
13
  * - the message is a slash command or shorter than 20 characters
14
+ * - the message is not the user's: a harness event or another session's message (see {@link hookMessageText})
14
15
  * - nothing scores above the noise gate
15
16
  * - every match was already suggested in this session
16
17
  * - anything at all goes wrong (the hook must never get in the way)
@@ -54,6 +55,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
54
55
  exports.NOTE_TITLE_MAX = exports.HOOK_BUDGET_MS = exports.HOOK_MIN_CHARS = void 0;
55
56
  exports.filterEntries = filterEntries;
56
57
  exports.stripPasted = stripPasted;
58
+ exports.hookMessageText = hookMessageText;
57
59
  exports.hookShouldSkip = hookShouldSkip;
58
60
  exports.noteLabel = noteLabel;
59
61
  exports.isShellSafeSlug = isShellSafeSlug;
@@ -109,6 +111,16 @@ function parseLimit(raw) {
109
111
  function stripPasted(text) {
110
112
  return text.replace(/<pasted_content\b[^>]*>[\s\S]*?<\/pasted_content\b[^>]*>/g, ' ');
111
113
  }
114
+ /** Events the harness or another session sends as a "message": nobody asked for a prompt, so the hook stays silent. */
115
+ const NOT_THE_USER = /<(task-notification|cross-session-message|side-sessions-event|ci-monitor-event)\b/;
116
+ /** Context the harness wraps around a real message: dropped before matching, the message itself still counts. */
117
+ const HARNESS_CONTEXT = /<(system-reminder)\b[^>]*>[\s\S]*?<\/\1\b[^>]*>/g;
118
+ /** The user's own words in a hook message, or '' when the message is not from the user. */
119
+ function hookMessageText(prompt) {
120
+ if (NOT_THE_USER.test(prompt))
121
+ return '';
122
+ return stripPasted(prompt).replace(HARNESS_CONTEXT, ' ').trim();
123
+ }
112
124
  /** The hook's silence rules for the message itself. */
113
125
  function hookShouldSkip(prompt) {
114
126
  const t = prompt.trim();
@@ -260,17 +272,18 @@ async function runHook(raw, now = Date.now()) {
260
272
  }
261
273
  const prompt = typeof input.prompt === 'string' ? input.prompt : '';
262
274
  const sessionId = typeof input.session_id === 'string' ? input.session_id : undefined;
263
- if (hookShouldSkip(prompt))
275
+ const own = hookMessageText(prompt);
276
+ if (hookShouldSkip(own))
264
277
  return '';
265
278
  const { entries, signedIn, stale } = localLibrary(now);
266
279
  if (signedIn && stale)
267
280
  (0, libraryCache_1.startBackgroundRefresh)({ now });
268
281
  if (entries.length === 0)
269
282
  return '';
270
- const text = stripPasted(prompt).slice(0, MAX_TASK_CHARS);
283
+ const text = own.slice(0, MAX_TASK_CHARS);
271
284
  const state = (0, libraryCache_1.readState)();
272
285
  const already = (0, libraryCache_1.shownIn)(state, sessionId);
273
- const fresh = (0, rank_1.rankLibrary)(entries, text, 3 + already.size).filter((r) => !already.has(r.item.id)).slice(0, 3);
286
+ const fresh = (0, rank_1.rankLibrary)(entries, text, 3 + already.size, { strict: true }).filter((r) => !already.has(r.item.id)).slice(0, 3);
274
287
  if (fresh.length === 0)
275
288
  return '';
276
289
  (0, libraryCache_1.recordShown)(state, sessionId, fresh.map((r) => r.item.id), now);
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ /**
3
+ * `ple untag <name|id> <tag...> [--project <repo>] [--json]` — take tags off a prompt in your account.
4
+ *
5
+ * CLI only, on purpose: the MCP `update_prompt` tool stays add-only, so an agent cannot remove a tag through it
6
+ * (Zeynep's decision, 1 Nov 2026). The prompt, its versions and the tag itself stay; only the link goes. Not a version:
7
+ * tags are not part of a version. A name the prompt does not have is reported and changes nothing.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.untagCommand = untagCommand;
11
+ const api_client_1 = require("../lib/api-client");
12
+ const format_1 = require("../lib/format");
13
+ const loopApi_1 = require("../lib/loopApi");
14
+ const promptResolver_1 = require("../lib/promptResolver");
15
+ const local_1 = require("./local");
16
+ async function untagCommand(name, tags, options = {}) {
17
+ const wanted = [...new Set(tags.map((t) => t.trim()).filter(Boolean))];
18
+ if (wanted.length === 0)
19
+ throw new Error('Name at least one tag: ple untag "code review" draft');
20
+ if ((0, local_1.isSignedOut)()) {
21
+ throw new Error('Removing a tag needs an account. Signed out, a prompt is a Markdown file: edit its tags there. Sign in with: ple login');
22
+ }
23
+ await (0, api_client_1.ensureAuthed)();
24
+ const projectId = options.project ? await (0, promptResolver_1.resolveProjectId)(options.project) : undefined;
25
+ const found = await (0, promptResolver_1.resolvePromptByName)(name, { projectId });
26
+ if (!found) {
27
+ process.exitCode = 1;
28
+ return;
29
+ }
30
+ // The detail answer always carries the tags with their ids, however the prompt was found.
31
+ const prompt = (await (0, api_client_1.getPromptById)(found.id)) ?? found;
32
+ const onPrompt = prompt.tags ?? [];
33
+ const removed = [];
34
+ const notOnPrompt = [];
35
+ for (const tag of wanted) {
36
+ const match = onPrompt.find((t) => t.name.toLowerCase() === tag.toLowerCase());
37
+ if (!match) {
38
+ notOnPrompt.push(tag);
39
+ continue;
40
+ }
41
+ await (0, loopApi_1.removePromptTag)(prompt.id, match.id);
42
+ removed.push(match.name);
43
+ }
44
+ if (notOnPrompt.length > 0)
45
+ process.exitCode = 1;
46
+ if (options.json) {
47
+ console.log(JSON.stringify({ ok: notOnPrompt.length === 0, id: prompt.id, title: prompt.title, removed, not_on_prompt: notOnPrompt }));
48
+ return;
49
+ }
50
+ if (removed.length > 0)
51
+ console.log(format_1.c.success(`✓ Removed from '${prompt.title}': ${removed.join(', ')}`));
52
+ if (notOnPrompt.length > 0) {
53
+ const left = onPrompt.map((t) => t.name).filter((t) => !removed.includes(t));
54
+ console.error(format_1.c.error(`Not on this prompt: ${notOnPrompt.join(', ')}. Its tags: ${left.join(', ') || 'none'}.`));
55
+ }
56
+ }
package/dist/help.js CHANGED
@@ -10,7 +10,7 @@ exports.COMMAND_GROUPS = void 0;
10
10
  exports.formatRootHelp = formatRootHelp;
11
11
  const commander_1 = require("commander");
12
12
  exports.COMMAND_GROUPS = [
13
- { title: 'Prompts', commands: ['save', 'get', 'show', 'copy', 'list', 'search', 'log', 'diff', 'rollback', 'move', 'tag', 'improve', 'loop'] },
13
+ { title: 'Prompts', commands: ['save', 'get', 'show', 'copy', 'list', 'search', 'log', 'diff', 'rollback', 'move', 'tag', 'untag', 'improve', 'loop'] },
14
14
  { title: 'Repos', commands: ['repo', 'visibility'] },
15
15
  { title: 'Account', commands: ['login', 'logout', 'whoami'] },
16
16
  { title: 'Import / export / sync', commands: ['import', 'export', 'sync'] },
@@ -19,6 +19,7 @@ exports.createPrompt = createPrompt;
19
19
  exports.patchDescription = patchDescription;
20
20
  exports.addTagByName = addTagByName;
21
21
  exports.movePrompt = movePrompt;
22
+ exports.removePromptTag = removePromptTag;
22
23
  const crypto_1 = require("crypto");
23
24
  const constants_1 = require("./constants");
24
25
  const config_1 = require("./config");
@@ -71,10 +72,10 @@ async function bearerRequest(method, path, body, timeoutMs, forbidden) {
71
72
  res = await fetch(constants_1.API_BASE_URL + path, {
72
73
  method,
73
74
  headers: {
74
- ...(method !== 'GET' ? { 'Content-Type': 'application/json' } : {}),
75
+ ...(body !== undefined ? { 'Content-Type': 'application/json' } : {}),
75
76
  Authorization: `Bearer ${config.access_token}`,
76
77
  },
77
- body: method !== 'GET' ? JSON.stringify(body) : undefined,
78
+ body: body !== undefined ? JSON.stringify(body) : undefined,
78
79
  // Süre başlıkla sınırlı değil: gövde okuması da aynı sinyalle kesilir.
79
80
  signal,
80
81
  redirect: 'manual',
@@ -239,3 +240,8 @@ async function movePrompt(promptId, input) {
239
240
  }, exports.SAVE_TIMEOUT_MS, moveForbidden);
240
241
  return res;
241
242
  }
243
+ const untagForbidden = (serverError) => new Error(serverError?.trim() || 'You need editor access to this repo to remove a tag.');
244
+ /** DELETE /api/prompts/{id}/tags/{tagId} — takes one tag off a prompt. The tag itself stays in the repo. */
245
+ async function removePromptTag(promptId, tagId) {
246
+ await bearerRequest('DELETE', `/api/prompts/${encodeURIComponent(promptId)}/tags/${encodeURIComponent(tagId)}`, undefined, exports.SAVE_TIMEOUT_MS, untagForbidden);
247
+ }
package/dist/lib/rank.js CHANGED
@@ -29,6 +29,7 @@ exports.foldText = foldText;
29
29
  exports.tokenize = tokenize;
30
30
  exports.taskTerms = taskTerms;
31
31
  exports.requiredMatches = requiredMatches;
32
+ exports.requiredStrongMatches = requiredStrongMatches;
32
33
  exports.rankLibrary = rankLibrary;
33
34
  // <fold-text:begin> — copy of the same block in src/lib/suggest.ts (byte-identical; src/lib/suggest.test.ts locks it)
34
35
  /**
@@ -102,13 +103,23 @@ function fieldsOf(item) {
102
103
  body: new Set(tokenize((item.body ?? '').slice(0, exports.BODY_HEAD))),
103
104
  };
104
105
  }
106
+ /**
107
+ * Terms a prompt needs in its title, tag or description in the HOOK's strict mode (a title or tag hit is required
108
+ * anyway): 1 for a task of up to 2 terms, otherwise 2; the body does not count. The hook speaks unasked on every
109
+ * message, so one shared word is not evidence: `ple stats` measured 2360 suggestions and 0 fetched in 30 days
110
+ * (31 Oct 2026). An explicit `ple suggest` or MCP `suggest_prompts` stays loose: there somebody asked.
111
+ */
112
+ function requiredStrongMatches(termCount) {
113
+ return termCount <= 2 ? 1 : 2;
114
+ }
105
115
  /** Rank `items` for `task`; returns at most `limit` items above the noise gate. */
106
- function rankLibrary(items, task, limit = 3) {
116
+ function rankLibrary(items, task, limit = 3, options = {}) {
107
117
  const terms = taskTerms(task);
108
118
  if (terms.length === 0 || items.length === 0)
109
119
  return [];
110
120
  const fields = items.map(fieldsOf);
111
121
  const needed = requiredMatches(terms.length);
122
+ const neededSolid = options.strict ? requiredStrongMatches(terms.length) : 0;
112
123
  // Document frequency per term over the whole library → idf.
113
124
  const n = items.length;
114
125
  const idf = new Map();
@@ -127,6 +138,7 @@ function rankLibrary(items, task, limit = 3) {
127
138
  const f = fields[i];
128
139
  let score = 0;
129
140
  let strongHit = false;
141
+ let solid = 0;
130
142
  let matched = 0;
131
143
  for (const term of terms) {
132
144
  let w = 0;
@@ -143,10 +155,14 @@ function rankLibrary(items, task, limit = 3) {
143
155
  matched++;
144
156
  if (w >= WEIGHTS.tag)
145
157
  strongHit = true;
158
+ if (w >= WEIGHTS.description)
159
+ solid++;
146
160
  score += (idf.get(term) ?? 0) * w;
147
161
  }
148
162
  if (matched < needed || (!strongHit && matched < 2))
149
163
  return;
164
+ if (options.strict && (!strongHit || solid < neededSolid))
165
+ return;
150
166
  score += Math.log1p(Math.max(0, item.uses ?? 0)) * 0.3;
151
167
  if (score < exports.MIN_SCORE)
152
168
  return;
package/dist/program.js CHANGED
@@ -32,6 +32,7 @@ const log_1 = require("./commands/log");
32
32
  const diff_1 = require("./commands/diff");
33
33
  const rollback_1 = require("./commands/rollback");
34
34
  const move_1 = require("./commands/move");
35
+ const untag_1 = require("./commands/untag");
35
36
  const tag_1 = require("./commands/tag");
36
37
  const suggest_1 = require("./commands/suggest");
37
38
  const config_1 = require("./commands/config");
@@ -196,6 +197,19 @@ function buildProgram() {
196
197
  .option('--list', 'Show labels and recent moves')
197
198
  .option('-r, --remove <label>', 'Remove a label')
198
199
  .addHelpText('after', '\nExamples:\n ple tag "code review" 3 production\n ple tag "code review" --list\n ple get "code review" --label production')).action(runWithErrorHandler((name, version, label, opts) => (0, tag_1.tagCommand)(name, version, label, opts)));
200
+ scope(program
201
+ .command('untag <name> <tags...>')
202
+ .description('Take tags off a prompt in your account — the prompt and its versions stay')
203
+ .option('--json', 'Print the outcome as one JSON line')
204
+ .addHelpText('after', [
205
+ '',
206
+ 'Examples:',
207
+ ' ple untag "code review" draft',
208
+ ' ple untag "code review" draft needs-review --project my-prompts --json',
209
+ '',
210
+ 'Signed in, editor access. Names ignore case. Not a new version: tags are not part of one. A name the',
211
+ 'prompt does not have is reported and exits 1. Deploy labels are `ple tag --remove`.',
212
+ ].join('\n'))).action(runWithErrorHandler((name, tags, opts) => (0, untag_1.untagCommand)(name, tags, opts)));
199
213
  scope(program
200
214
  .command('move <name>')
201
215
  .description('Move a prompt to another repo and/or into a folder — versions, labels, stars and usage come along')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptlike",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "description": "Terminal access to your PromptLikeEngineer prompt library - search, read, and copy your saved prompts without leaving the shell.",
5
5
  "bin": {
6
6
  "ple": "dist/index.js"