promptlike 0.12.5 → 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,31 @@
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
+
15
+ ## 0.13.0 — 2026-10-31
16
+
17
+ - **New: `ple move <name> [--to <repo>] [--folder <path>] [--project <repo>] [--yes] [--json]`** moves a prompt to another
18
+ repo and/or into a folder. The prompt keeps its id (`/p/<id>` still opens), versions, deploy labels, stars and usage;
19
+ its tags are matched by name in the target repo. Needs write access to both repos; a title already used in the target
20
+ stops the move; a move between a public and a private repo asks first (`--yes` for scripts). Nothing is deleted.
21
+ - **Folders inside a repo.** A folder is a path like `reviews/backend` (up to 3 levels, 64 characters each). `ple save
22
+ <title> --project <repo> --folder <path>` creates the prompt in that folder, or moves an existing one there;
23
+ `ple list --folder <path>` lists a folder and what is under it (`--folder ""` = the repo root only) and shows a
24
+ FOLDER column when a listed prompt is in one; `ple export --project <repo> --folder <path> --format skill` exports one
25
+ folder as its own skill.
26
+ - **`ple list --json`** prints one JSON array (`id`, `title`, `description`, `repo`, `project_id`, `folder`,
27
+ `visibility`, `tags` with every tag name, `updated_at`, `use_count`, `version`) instead of the table, signed in or out.
28
+
3
29
  ## 0.12.5 — 2026-10-31
4
30
 
5
31
  - **Fix: a passing outage no longer ends a login.** If refreshing an expired session met a server error or rate limit
package/README.md CHANGED
@@ -122,7 +122,9 @@ A new title creates the prompt; the same title with different text adds a new ve
122
122
  overwritten, labels stay where they are); the same text sends nothing. `-d` changes the description only
123
123
  when it differs (no new version); `-t` only ever adds tags. If two prompts in the repo share the title and
124
124
  neither has this text, nothing is changed and both are listed (exit code 1). A wrong repo name stops before
125
- anything is sent. Signed out, `--project` still saves locally and prints a warning that the account was
125
+ anything is sent. `--folder reviews/backend` (with `--project`; up to 3 levels) creates a new prompt inside that
126
+ folder, and moves an existing one there (versions, labels, stars and usage stay); without `--folder` an
127
+ existing prompt stays where it is, and `--folder ""` brings it back to the repo root. Signed out, `--project` still saves locally and prints a warning that the account was
126
128
  not written; run the same command after `ple login` and it will not duplicate anything. Unlike `ple sync`
127
129
  (which uploads whatever text the local files hold, so an edited file becomes a second prompt), this
128
130
  command updates the prompt you named.
@@ -181,7 +183,7 @@ prints `Not signed in. Run `ple login`.` on stderr (`{"signed_in":false}` with `
181
183
  The data comes from `GET /api/account/limits`; that endpoint does not report a trial end or how many versions
182
184
  each prompt has, so those two are shown only when it does.
183
185
 
184
- ### `ple list [--tag <name>]… [--limit <n>] [--project <repo>]`
186
+ ### `ple list [--tag <name>]… [--limit <n>] [--project <repo>] [--folder <path>] [--json]`
185
187
 
186
188
  Lists every prompt your account has access to. The server scopes results to
187
189
  you automatically. The last column shows each prompt's tags (signed in and signed
@@ -198,8 +200,13 @@ $ ple list --tag debug # filter by tag
198
200
  $ ple list --tag debug --tag review # repeat --tag: a prompt must carry all of them
199
201
  $ ple list --limit 50 # default 30, max 100
200
202
  $ ple list --project my-prompts # only one repo (name, slug or id)
203
+ $ ple list --folder reviews # that folder and what is under it (`--folder ""` = repo root only)
204
+ $ ple list --json # one JSON array: id, title, description, repo, folder, tags, ...
201
205
  ```
202
206
 
207
+ A FOLDER column appears when a listed prompt is in a folder. `--folder` needs an account (folders live inside
208
+ repos); `--json` works signed in and signed out and lists every tag name, nothing cut to `+2`.
209
+
203
210
  `--tag` can be repeated and every tag has to match. In your account a tag
204
211
  matches exactly as saved (`Debug` is not `debug`); local prompts match tags
205
212
  ignoring case. The server filters by one tag, so with several `--tag` flags `ple`
@@ -465,6 +472,7 @@ ple export "code review" --format agents-md >> AGENTS.md
465
472
  ple export "code review" --format skill --out ~/.claude/skills # Claude Code picks it up
466
473
  ple export --project backend --format skill --zip # upload the zip in Claude
467
474
  ple export --project backend --format agents-md --out AGENTS.md
475
+ ple export --project backend --folder reviews --format skill # only one folder of the repo (a skill named backend-reviews)
468
476
  ```
469
477
 
470
478
  Skill names follow the spec: lowercase, digits and single hyphens, at most 64
@@ -647,6 +655,34 @@ ple rollback "code review" v2 # asks first; --yes for scripts
647
655
  Rollback is non-destructive: the old version is copied forward as a new one,
648
656
  nothing is deleted — so a rollback can itself be undone.
649
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
+
669
+ ### `ple move <name>` — to another repo, or into a folder
670
+
671
+ ```bash
672
+ ple move "code review" --to team-prompts # another repo
673
+ ple move "code review" --to team-prompts --folder reviews/backend
674
+ ple move "code review" --folder reviews # same repo, into a folder
675
+ ple move "code review" --project old-repo --to new-repo --json # --project picks the source when titles collide
676
+ ```
677
+
678
+ Signed in only; needs write access to both repos. The prompt keeps its id (so its `/p/<id>` link still opens), every
679
+ version, its deploy labels, stars and usage counts; its tags are matched by name in the target repo (created there when
680
+ missing), and `ple stats --project` follows it to the new repo. A prompt with the same title in the target repo stops
681
+ the move. A move that changes who can see the prompt (public repo ↔ private repo) asks first on a terminal; scripts pass
682
+ `--yes`. Nothing is deleted: move it back to undo. `--folder` takes `a/b` (3 levels at most, 64 characters each); leave
683
+ `--folder` out and the prompt stays in its folder within the same repo, or lands at the root of another repo; `--folder ""`
684
+ means the root. Its public page address changes with the repo (`/<user>/<repo>/<prompt>`), the short link does not.
685
+
650
686
  #### Local version history (signed out)
651
687
 
652
688
  Without an account the same three commands work on a history kept on your
@@ -726,9 +762,12 @@ and other Latin accents). This applies to the hook note as well.
726
762
 
727
763
  `--hook` is what the Claude Code plugin runs on every message
728
764
  (`UserPromptSubmit`). It reads the hook's JSON from stdin and prints one short
729
- note — or nothing: slash commands, messages under 20 characters, weak
730
- matches and prompts already suggested in the session stay silent. It never
731
- 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.
732
771
 
733
772
  Turn suggestions off with `ple config set suggest off`, `PLE_SUGGEST=off`, or
734
773
  the plugin option in Claude Code's `/config`. How many were shown is counted
@@ -41,6 +41,8 @@ const local_1 = require("./local");
41
41
  const store = __importStar(require("../lib/localStore"));
42
42
  const promptResolver_1 = require("../lib/promptResolver");
43
43
  const format_1 = require("../lib/format");
44
+ const folder_1 = require("../lib/folder");
45
+ const promptList_1 = require("../lib/promptList");
44
46
  const fsSafe_1 = require("../lib/fsSafe");
45
47
  const agentExport_1 = require("../lib/agentExport");
46
48
  /** Hard cap for a repo export — 10 pages × 100. */
@@ -66,10 +68,12 @@ function fromLocal(p) {
66
68
  return null;
67
69
  return { title: p.title, description: p.description || null, body: p.body.trim() };
68
70
  }
69
- async function collectRemoteRepo(projectId) {
71
+ async function collectRemoteRepo(projectId, folder) {
70
72
  const out = [];
71
73
  for (let page = 1; page <= MAX_PAGES; page++) {
72
- const rows = await (0, api_client_1.listPrompts)({ projectId, limit: PAGE_SIZE, page });
74
+ const rows = folder === undefined
75
+ ? await (0, api_client_1.listPrompts)({ projectId, limit: PAGE_SIZE, page })
76
+ : await (0, promptList_1.listPromptsInFolder)({ projectId, limit: PAGE_SIZE, page, folder });
73
77
  for (const r of rows) {
74
78
  const e = fromRemote(r);
75
79
  if (e)
@@ -133,6 +137,7 @@ function writeAgentsMd(text, options) {
133
137
  * ple export "code review" --format agents-md >> AGENTS.md
134
138
  * ple export "code review" --format skill --out ~/.claude/skills
135
139
  * ple export --project ai-os --format skill --zip # upload in Claude
140
+ * ple export --project ai-os --folder reviews --format skill # only that folder of the repo
136
141
  *
137
142
  * Signed out, it exports from the local store (no name → every local prompt).
138
143
  */
@@ -141,6 +146,17 @@ async function exportCommand(name, options = {}) {
141
146
  if (options.zip && format !== 'skill')
142
147
  throw new Error('--zip only applies to --format skill.');
143
148
  const exportedAt = new Date().toISOString();
149
+ let folder;
150
+ if (options.folder !== undefined) {
151
+ const parsed = (0, folder_1.normalizeFolder)(options.folder);
152
+ if ('error' in parsed)
153
+ throw new Error(parsed.error);
154
+ if (!options.project || name)
155
+ throw new Error('--folder exports part of a repo: use it with --project <repo> and no prompt name.');
156
+ if ((0, local_1.isSignedOut)())
157
+ throw new Error('Folders belong to repos in your account. Sign in first: ple login');
158
+ folder = parsed.value ?? '';
159
+ }
144
160
  let single = null;
145
161
  let repo = null;
146
162
  if ((0, local_1.isSignedOut)()) {
@@ -177,8 +193,10 @@ async function exportCommand(name, options = {}) {
177
193
  throw new Error(`'${prompt.title}' has empty content.`);
178
194
  }
179
195
  else if (projectId) {
180
- const prompts = await collectRemoteRepo(projectId);
181
- repo = { name: prompts[0]?.projectName ?? options.project ?? 'prompts', prompts };
196
+ const prompts = await collectRemoteRepo(projectId, folder);
197
+ const repoName = prompts[0]?.projectName ?? options.project ?? 'prompts';
198
+ // A folder export is its own skill: the folder is part of the name, so it never overwrites the whole-repo skill.
199
+ repo = { name: folder ? `${repoName}-${folder.replace(/\//g, '-')}` : repoName, prompts };
182
200
  }
183
201
  else {
184
202
  throw new Error('Give a prompt name, or --project <repo> to export a whole repo.');
@@ -194,8 +212,9 @@ async function exportCommand(name, options = {}) {
194
212
  skill = (0, agentExport_1.buildPromptSkill)(single, exportedAt);
195
213
  }
196
214
  else if (repo) {
197
- if (repo.prompts.length === 0)
198
- throw new Error('Nothing to export — no prompts with content.');
215
+ if (repo.prompts.length === 0) {
216
+ throw new Error(folder !== undefined ? `Nothing to export — no prompts with content in folder '${folder || '(root)'}'.` : 'Nothing to export — no prompts with content.');
217
+ }
199
218
  count = repo.prompts.length;
200
219
  if (format === 'agents-md')
201
220
  text = (0, agentExport_1.buildAgentsMdDocument)(repo.name, null, repo.prompts, exportedAt);
@@ -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) {
@@ -10,10 +10,31 @@ const libraryCache_1 = require("../lib/libraryCache");
10
10
  const promptSource_1 = require("../lib/promptSource");
11
11
  const localStore_1 = require("../lib/localStore");
12
12
  const tagFilter_1 = require("../lib/tagFilter");
13
+ const promptList_1 = require("../lib/promptList");
14
+ const folder_1 = require("../lib/folder");
13
15
  /** The API returns at most 100 rows per page. */
14
16
  const TAG_PAGE_SIZE = 100;
15
17
  /** Multi-tag lookups read at most this many pages (10 × 100 prompts carrying the first tag). */
16
18
  const MAX_TAG_PAGES = 10;
19
+ /** Width of the FOLDER cell. */
20
+ const FOLDER_WIDTH = 18;
21
+ /** One prompt as `ple list --json` prints it: every field a script needs, no truncation. */
22
+ function toJsonRow(p) {
23
+ const listed = p;
24
+ return {
25
+ id: p.id,
26
+ title: p.title,
27
+ description: p.description ?? null,
28
+ repo: p.project_name ?? null,
29
+ project_id: p.project_id ?? null,
30
+ folder: listed.folder ?? null,
31
+ visibility: p.visibility ?? null,
32
+ tags: (p.tags ?? []).map((t) => t.name),
33
+ updated_at: p.updated_at,
34
+ use_count: p.use_count ?? 0,
35
+ version: p.current_version?.version_number ?? null,
36
+ };
37
+ }
17
38
  /** Width of the TAGS cell. It is the last column, so rows without tags carry no padding. */
18
39
  const TAGS_WIDTH = 24;
19
40
  /**
@@ -31,15 +52,30 @@ const TAGS_WIDTH = 24;
31
52
  async function listCommand(options) {
32
53
  const limit = Math.max(1, Math.min(100, parseInt(options.limit ?? '30', 10) || 30));
33
54
  const tags = (0, tagFilter_1.parseTagFilter)(options.tag);
55
+ let folder;
56
+ if (options.folder !== undefined) {
57
+ const parsed = (0, folder_1.normalizeFolder)(options.folder);
58
+ if ('error' in parsed)
59
+ throw new Error(parsed.error);
60
+ folder = parsed.value ?? ''; // --folder "" = the repo root only
61
+ }
34
62
  // Signed out → the local store. The install has to be useful on its own.
35
63
  if ((0, local_1.isSignedOut)()) {
64
+ if (folder !== undefined)
65
+ throw new Error('Folders belong to repos in your account. Sign in first: ple login');
36
66
  (0, local_1.noteIgnoredProject)(options.project);
37
- (0, local_1.localList)({ tags, limit });
67
+ (0, local_1.localList)({ tags, limit, json: options.json });
38
68
  return;
39
69
  }
40
70
  await (0, api_client_1.ensureAuthed)();
41
71
  const projectId = options.project ? await (0, promptResolver_1.resolveProjectId)(options.project) : undefined;
42
- const { rows: prompts, capped } = await fetchPrompts(tags, limit, projectId);
72
+ const lister = folder !== undefined ? (p) => (0, promptList_1.listPromptsInFolder)({ ...p, folder }) : api_client_1.listPrompts;
73
+ const { rows: prompts, capped } = await fetchPrompts(tags, limit, projectId, lister);
74
+ if (options.json) {
75
+ console.log(JSON.stringify(prompts.map(toJsonRow)));
76
+ (0, libraryCache_1.startBackgroundRefresh)();
77
+ return;
78
+ }
43
79
  // Keep the suggestion cache (W1-5) in step with the account — detached,
44
80
  // at most once a minute, never slows this command down.
45
81
  (0, libraryCache_1.startBackgroundRefresh)();
@@ -52,16 +88,19 @@ async function listCommand(options) {
52
88
  }
53
89
  }
54
90
  else {
55
- console.log(format_1.c.label('ID TITLE UPDATED TAGS'));
56
- console.log(format_1.c.label(`──────── ──────────────────────────────────────── ────────── ${'─'.repeat(TAGS_WIDTH)}`));
91
+ // A FOLDER column appears only when a listed prompt is in a folder: a library without folders looks as before.
92
+ const withFolders = prompts.some((p) => typeof p.folder === 'string');
93
+ console.log(format_1.c.label(`ID TITLE ${withFolders ? `${'FOLDER'.padEnd(FOLDER_WIDTH)} ` : ''}UPDATED TAGS`));
94
+ console.log(format_1.c.label(`──────── ──────────────────────────────────────── ${withFolders ? `${'─'.repeat(FOLDER_WIDTH)} ` : ''}────────── ${'─'.repeat(TAGS_WIDTH)}`));
57
95
  for (const p of prompts) {
58
96
  const id = format_1.c.muted((0, format_1.shortId)(p.id));
59
97
  const title = (0, format_1.truncate)(p.title, 40).padEnd(40);
98
+ const folderCell = withFolders ? `${format_1.c.muted((0, format_1.truncate)(p.folder ?? '', FOLDER_WIDTH).padEnd(FOLDER_WIDTH))} ` : '';
60
99
  const tagCell = (0, format_1.formatTags)((p.tags ?? []).map((t) => t.name), TAGS_WIDTH);
61
100
  // UPDATED is padded only when a TAGS cell follows — no trailing spaces on untagged rows.
62
101
  const ago = (0, format_1.timeAgo)(p.updated_at);
63
102
  const updated = format_1.c.muted(tagCell ? ago.padEnd(10) : ago);
64
- console.log(`${id} ${title} ${updated}${tagCell ? ` ${format_1.c.muted(tagCell)}` : ''}`);
103
+ console.log(`${id} ${title} ${folderCell}${updated}${tagCell ? ` ${format_1.c.muted(tagCell)}` : ''}`);
65
104
  }
66
105
  console.log(format_1.c.muted(`\n${prompts.length} prompt${prompts.length === 1 ? '' : 's'} listed.`));
67
106
  }
@@ -70,7 +109,7 @@ async function listCommand(options) {
70
109
  'add --project to narrow it down.'));
71
110
  }
72
111
  // A tag or repo filter asks a narrower question; the hint belongs to the plain "what do I have" list.
73
- if (tags.length === 0 && !options.project)
112
+ if (tags.length === 0 && !options.project && folder === undefined)
74
113
  printLocalOnlyHint(prompts, limit);
75
114
  }
76
115
  /**
@@ -78,13 +117,13 @@ async function listCommand(options) {
78
117
  * several: the server filters by the first, and a page-by-page walk keeps the prompts that carry
79
118
  * every tag until `limit` are found, the pages run out, or {@link MAX_TAG_PAGES} is reached.
80
119
  */
81
- async function fetchPrompts(tags, limit, projectId) {
120
+ async function fetchPrompts(tags, limit, projectId, list = api_client_1.listPrompts) {
82
121
  if (tags.length <= 1) {
83
- return { rows: await (0, api_client_1.listPrompts)({ tag: tags[0], limit, projectId }), capped: false };
122
+ return { rows: await list({ tag: tags[0], limit, projectId }), capped: false };
84
123
  }
85
124
  const rows = [];
86
125
  for (let page = 1; page <= MAX_TAG_PAGES; page++) {
87
- const batch = await (0, api_client_1.listPrompts)({ tag: tags[0], limit: TAG_PAGE_SIZE, page, projectId });
126
+ const batch = await list({ tag: tags[0], limit: TAG_PAGE_SIZE, page, projectId });
88
127
  for (const p of batch)
89
128
  if ((0, tagFilter_1.hasAllTags)(p.tags, tags))
90
129
  rows.push(p);
@@ -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;
@@ -115,6 +116,10 @@ function localList(options) {
115
116
  if (wanted.length > 0) {
116
117
  rows = rows.filter((p) => (0, tagFilter_1.hasAllLocalTags)(p.tags, wanted));
117
118
  }
119
+ if (options.json) {
120
+ console.log(JSON.stringify(rows.slice(0, options.limit).map((p) => ({ name: p.slug, title: p.title, tags: p.tags, updated_at: p.updated ?? null }))));
121
+ return;
122
+ }
118
123
  if (rows.length === 0) {
119
124
  if (wanted.length > 0)
120
125
  console.log(format_1.c.muted(`No local prompts tagged ${wanted.map((t) => `'${t}'`).join(' + ')}${wanted.length > 1 ? ' (all must match)' : ''}.`));
@@ -164,6 +169,15 @@ async function localGet(name, values, copy) {
164
169
  return;
165
170
  await getLocalPrompt(p, values, copy);
166
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
+ }
167
181
  /** Print one local prompt raw to stdout (shared by the signed-out `get` and the signed-in local fallback). */
168
182
  async function getLocalPrompt(p, values, copy) {
169
183
  if (!p.body.trim()) {
@@ -172,6 +186,7 @@ async function getLocalPrompt(p, values, copy) {
172
186
  return;
173
187
  }
174
188
  const { text } = store.fillVariables(p.body, values);
189
+ warnUnknownVars(p.body, values);
175
190
  // stdout stays machine-clean; warnings go to stderr (same contract as the
176
191
  // signed-in `ple get`, so piping behaves identically either way).
177
192
  const remaining = (0, promptVariables_1.extractVariables)(text);
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ /**
3
+ * `ple move <name|id> [--to <repo>] [--folder <path>] [--project <source repo>] [--yes] [--json]` — move a prompt
4
+ * to another repo and/or into a folder of its repo.
5
+ *
6
+ * The prompt keeps its id (so `/p/<id>` still opens), every version, its deploy labels, stars and usage; its tags
7
+ * are matched by name in the target repo (created there when missing). Needs write access to both repos. Nothing
8
+ * is deleted: undo by moving it back. A move that changes who can see the prompt (public repo <-> private repo)
9
+ * asks first; scripts pass `--yes`.
10
+ */
11
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ var desc = Object.getOwnPropertyDescriptor(m, k);
14
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
+ desc = { enumerable: true, get: function() { return m[k]; } };
16
+ }
17
+ Object.defineProperty(o, k2, desc);
18
+ }) : (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ }));
22
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
23
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
24
+ }) : function(o, v) {
25
+ o["default"] = v;
26
+ });
27
+ var __importStar = (this && this.__importStar) || (function () {
28
+ var ownKeys = function(o) {
29
+ ownKeys = Object.getOwnPropertyNames || function (o) {
30
+ var ar = [];
31
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
32
+ return ar;
33
+ };
34
+ return ownKeys(o);
35
+ };
36
+ return function (mod) {
37
+ if (mod && mod.__esModule) return mod;
38
+ var result = {};
39
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
40
+ __setModuleDefault(result, mod);
41
+ return result;
42
+ };
43
+ })();
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.moveCommand = moveCommand;
46
+ const readline = __importStar(require("readline"));
47
+ const api_client_1 = require("../lib/api-client");
48
+ const format_1 = require("../lib/format");
49
+ const loopApi_1 = require("../lib/loopApi");
50
+ const folder_1 = require("../lib/folder");
51
+ const promptResolver_1 = require("../lib/promptResolver");
52
+ const local_1 = require("./local");
53
+ function defaultConfirm(question) {
54
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
55
+ return new Promise((resolve) => {
56
+ rl.question(question, (answer) => {
57
+ rl.close();
58
+ resolve(/^y(es)?$/i.test(answer.trim()));
59
+ });
60
+ });
61
+ }
62
+ async function moveCommand(name, options = {}, deps = {}) {
63
+ if (options.to === undefined && options.folder === undefined) {
64
+ throw new Error('Nothing to move to. Pass --to <repo>, --folder <path>, or both.');
65
+ }
66
+ if ((0, local_1.isSignedOut)()) {
67
+ throw new Error('Moving needs an account (it changes the repo of a saved prompt). Sign in first: ple login');
68
+ }
69
+ let folder;
70
+ if (options.folder !== undefined) {
71
+ const parsed = (0, folder_1.normalizeFolder)(options.folder);
72
+ if ('error' in parsed)
73
+ throw new Error(parsed.error);
74
+ folder = parsed.value ?? ''; // --folder "" / "/" = the repo root
75
+ }
76
+ await (0, api_client_1.ensureAuthed)();
77
+ const sourceProjectId = options.project ? await (0, promptResolver_1.resolveProjectId)(options.project) : undefined;
78
+ const prompt = await (0, promptResolver_1.resolvePromptByName)(name, { projectId: sourceProjectId });
79
+ if (!prompt) {
80
+ process.exitCode = 1;
81
+ return;
82
+ }
83
+ const target = options.to !== undefined ? await (0, promptResolver_1.resolveProject)(options.to) : prompt.project_id ? { id: prompt.project_id } : null;
84
+ if (!target)
85
+ throw new Error('Could not tell which repo the prompt is in. Pass --to <repo>.');
86
+ let result;
87
+ try {
88
+ result = await (0, loopApi_1.movePrompt)(prompt.id, { projectId: target.id, folder, confirmVisibility: options.yes === true });
89
+ }
90
+ catch (err) {
91
+ const code = err?.code;
92
+ if (code !== 'VISIBILITY_CONFIRM_REQUIRED')
93
+ throw err;
94
+ const interactive = deps.isTTY ?? Boolean(process.stdin.isTTY && process.stdout.isTTY);
95
+ if (!interactive) {
96
+ throw new Error('This move changes who can see the prompt (public repo <-> private repo). Re-run with --yes to confirm.');
97
+ }
98
+ const ok = await (deps.confirm ?? defaultConfirm)(`Moving '${prompt.title}' changes who can see it (public repo <-> private repo). Move it anyway? [y/N] `);
99
+ if (!ok) {
100
+ console.log(format_1.c.muted('Cancelled.'));
101
+ return;
102
+ }
103
+ result = await (0, loopApi_1.movePrompt)(prompt.id, { projectId: target.id, folder, confirmVisibility: true });
104
+ }
105
+ if (options.json) {
106
+ console.log(JSON.stringify({ ok: true, ...result }));
107
+ return;
108
+ }
109
+ const where = `${options.to ?? 'its repo'}${result.folder ? ` / ${result.folder}` : ''}`;
110
+ console.log(format_1.c.success(`✓ Moved '${prompt.title}' to ${where}`) + format_1.c.muted(` (${(0, format_1.shortId)(prompt.id)})`));
111
+ if (result.moved_between_repos) {
112
+ console.log(format_1.c.muted(` Versions, labels, stars and usage came along; ${result.tags_moved} tag${result.tags_moved === 1 ? '' : 's'} matched by name in the new repo.`));
113
+ console.log(format_1.c.muted(` The short link /p/${prompt.id} still opens it. Undo: ple move "${prompt.title}" --to <the old repo>`));
114
+ }
115
+ }
@@ -53,6 +53,7 @@ const history = __importStar(require("../lib/localHistory"));
53
53
  const format_1 = require("../lib/format");
54
54
  const promptVariables_1 = require("../lib/promptVariables");
55
55
  const api_client_1 = require("../lib/api-client");
56
+ const folder_1 = require("../lib/folder");
56
57
  const accountSave_1 = require("../lib/accountSave");
57
58
  const promptResolver_1 = require("../lib/promptResolver");
58
59
  const libraryCache_1 = require("../lib/libraryCache");
@@ -126,6 +127,22 @@ async function saveCommand(title, options = {}) {
126
127
  process.exitCode = 1;
127
128
  return;
128
129
  }
130
+ let folder;
131
+ if (options.folder !== undefined) {
132
+ const parsed = (0, folder_1.normalizeFolder)(options.folder);
133
+ if ('error' in parsed) {
134
+ console.error(format_1.c.error(parsed.error));
135
+ process.exitCode = 1;
136
+ return;
137
+ }
138
+ if (options.project === undefined) {
139
+ console.error(format_1.c.error('--folder needs --project <repo>: folders live inside a repo of your account.'));
140
+ console.error(format_1.c.muted(' ple save "code review" -m "..." --project my-prompts --folder reviews/backend'));
141
+ process.exitCode = 1;
142
+ return;
143
+ }
144
+ folder = parsed.value ?? '';
145
+ }
129
146
  if (options.project !== undefined) {
130
147
  const project = options.project.trim();
131
148
  if (!project) {
@@ -134,7 +151,7 @@ async function saveCommand(title, options = {}) {
134
151
  return;
135
152
  }
136
153
  if (!(0, local_1.isSignedOut)()) {
137
- await saveIntoAccount(cleanTitle, body, project, options);
154
+ await saveIntoAccount(cleanTitle, body, project, options, folder);
138
155
  return;
139
156
  }
140
157
  // No session: do what `ple save` always did, but say that the account was NOT written —
@@ -176,7 +193,7 @@ async function saveCommand(title, options = {}) {
176
193
  }
177
194
  }
178
195
  /** `--project` with a session: write to the account; the local store is not touched. */
179
- async function saveIntoAccount(title, body, projectRef, options) {
196
+ async function saveIntoAccount(title, body, projectRef, options, folder) {
180
197
  const tags = (0, accountSave_1.cleanTags)(options.tag ?? []);
181
198
  (0, accountSave_1.assertTagLengths)(tags);
182
199
  const description = options.description === undefined ? undefined : options.description.trim();
@@ -184,7 +201,7 @@ async function saveIntoAccount(title, body, projectRef, options) {
184
201
  // A wrong repo name stops here, before anything is sent.
185
202
  const projectId = await (0, promptResolver_1.resolveProjectId)(projectRef);
186
203
  const projectName = (await (0, api_client_1.listProjects)()).find((p) => p.id === projectId)?.name ?? projectRef;
187
- const out = await (0, accountSave_1.saveToAccount)({ title, body, description, tags, projectId, projectName });
204
+ const out = await (0, accountSave_1.saveToAccount)({ title, body, description, tags, projectId, projectName, folder });
188
205
  printAccountOutcome(out, title, projectName, projectRef);
189
206
  if (out.status === 'created' || out.status === 'updated')
190
207
  (0, libraryCache_1.startBackgroundRefresh)({ force: true });
@@ -211,6 +228,10 @@ function printAccountOutcome(out, title, repo, projectRef) {
211
228
  else {
212
229
  console.log(`= Unchanged: "${shown}" in ${repoName} already has this text${out.version ? ` (v${out.version})` : ''} — no new version.` + format_1.c.muted(` (${id})`));
213
230
  }
231
+ if (out.folderNote) {
232
+ const where = out.folderNote.folder ? `folder ${(0, format_1.safeText)(out.folderNote.folder)}` : 'the repo root';
233
+ console.log(format_1.c.muted(out.folderNote.moved ? ` moved to ${where}` : ` in ${where}`));
234
+ }
214
235
  if (out.status !== 'created' && out.descriptionUpdated)
215
236
  console.log(format_1.c.muted(' description updated (no new version)'));
216
237
  if (out.tagsAdded.length > 0)
@@ -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', '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'] },
@@ -114,11 +114,19 @@ async function saveToAccount(input) {
114
114
  description: input.description,
115
115
  body: input.body,
116
116
  changelog: 'Saved with ple save',
117
+ folder: input.folder,
117
118
  });
118
119
  if (!saved.promptId)
119
120
  throw new Error('The server saved the prompt but sent an unexpected response. Run `ple list --project` to check.');
120
121
  const tags = await addTags(saved.promptId, input.tags);
121
- return { status: 'created', id: saved.promptId, version: saved.versionNumber ?? 1, tagsAdded: tags.added, tagsFailed: tags.failed };
122
+ return {
123
+ status: 'created',
124
+ id: saved.promptId,
125
+ version: saved.versionNumber ?? 1,
126
+ tagsAdded: tags.added,
127
+ tagsFailed: tags.failed,
128
+ ...(input.folder !== undefined ? { folderNote: { folder: input.folder || null, moved: false } } : {}),
129
+ };
122
130
  }
123
131
  // The one that already holds this text wins; otherwise a single match is the one to version.
124
132
  const identical = sameTitle.find((p) => sameText((0, format_1.joinPromptParts)(p.current_version ?? {}), input.body));
@@ -131,6 +139,7 @@ async function saveToAccount(input) {
131
139
  await (0, loopApi_1.patchDescription)(target.id, input.description);
132
140
  descriptionUpdated = true;
133
141
  }
142
+ const folderNote = await placeInFolder(target, input);
134
143
  const tags = await addTags(target.id, missingTags(input.tags, target));
135
144
  if (identical) {
136
145
  return {
@@ -140,6 +149,7 @@ async function saveToAccount(input) {
140
149
  descriptionUpdated,
141
150
  tagsAdded: tags.added,
142
151
  tagsFailed: tags.failed,
152
+ ...(folderNote ? { folderNote } : {}),
143
153
  };
144
154
  }
145
155
  const saved = await (0, loopApi_1.saveVersion)(target.id, { roleText: '', descriptionText: '', contextText: input.body }, 'Updated with ple save', 'cli');
@@ -151,8 +161,22 @@ async function saveToAccount(input) {
151
161
  descriptionUpdated,
152
162
  tagsAdded: tags.added,
153
163
  tagsFailed: tags.failed,
164
+ ...(folderNote ? { folderNote } : {}),
154
165
  };
155
166
  }
167
+ /**
168
+ * `--folder` on a prompt that already exists: move it inside its repo when it is elsewhere (the move keeps
169
+ * versions, labels, stars and usage); already there is a no-op. Nothing is done when `--folder` was not given.
170
+ */
171
+ async function placeInFolder(target, input) {
172
+ if (input.folder === undefined)
173
+ return undefined;
174
+ const current = target.folder ?? '';
175
+ if (current === input.folder)
176
+ return { folder: input.folder || null, moved: false };
177
+ const res = await (0, loopApi_1.movePrompt)(target.id, { projectId: input.projectId, folder: input.folder });
178
+ return { folder: res.folder ?? null, moved: true };
179
+ }
156
180
  /** One candidate line for the "several prompts share this title" stop. */
157
181
  function candidateLine(p) {
158
182
  return `${(0, format_1.shortId)(p.id)} ${(0, format_1.safeText)(p.title)}`;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FOLDER_SEGMENT_MAX = exports.FOLDER_MAX_DEPTH = void 0;
4
+ exports.normalizeFolder = normalizeFolder;
5
+ /**
6
+ * A folder path inside a repo: `a/b`, at most 3 levels, 64 characters per level, empty = the repo root.
7
+ * The same rule as the database (prompts_folder_format) and the web API (src/lib/prompt-folder.ts, kept identical by a test).
8
+ */
9
+ exports.FOLDER_MAX_DEPTH = 3;
10
+ exports.FOLDER_SEGMENT_MAX = 64;
11
+ // A level neither starts nor ends with a space and has no '/' or control character.
12
+ const SEGMENT = /^[^/\s\p{Cc}](?:[^/\p{Cc}]{0,62}[^/\s\p{Cc}])?$/u;
13
+ /** Trims spaces and slashes; null when empty (root). `{ error }` when invalid. */
14
+ function normalizeFolder(input) {
15
+ if (input === null || input === undefined)
16
+ return { value: null };
17
+ if (typeof input !== 'string')
18
+ return { error: 'folder must be text like "a/b"' };
19
+ const cleaned = input.trim().replace(/^\/+|\/+$/g, '').trim();
20
+ if (cleaned === '')
21
+ return { value: null };
22
+ const parts = cleaned.split('/');
23
+ if (parts.length > exports.FOLDER_MAX_DEPTH)
24
+ return { error: `A folder path has at most ${exports.FOLDER_MAX_DEPTH} levels (a/b/c).` };
25
+ for (const part of parts) {
26
+ if (part.length > exports.FOLDER_SEGMENT_MAX)
27
+ return { error: `Each folder name is at most ${exports.FOLDER_SEGMENT_MAX} characters.` };
28
+ if (!SEGMENT.test(part))
29
+ return { error: 'Folder names cannot be empty, start or end with a space, or contain control characters.' };
30
+ }
31
+ return { value: parts.join('/') };
32
+ }
@@ -18,6 +18,8 @@ exports.saveWinner = saveWinner;
18
18
  exports.createPrompt = createPrompt;
19
19
  exports.patchDescription = patchDescription;
20
20
  exports.addTagByName = addTagByName;
21
+ exports.movePrompt = movePrompt;
22
+ exports.removePromptTag = removePromptTag;
21
23
  const crypto_1 = require("crypto");
22
24
  const constants_1 = require("./constants");
23
25
  const config_1 = require("./config");
@@ -70,10 +72,10 @@ async function bearerRequest(method, path, body, timeoutMs, forbidden) {
70
72
  res = await fetch(constants_1.API_BASE_URL + path, {
71
73
  method,
72
74
  headers: {
73
- ...(method !== 'GET' ? { 'Content-Type': 'application/json' } : {}),
75
+ ...(body !== undefined ? { 'Content-Type': 'application/json' } : {}),
74
76
  Authorization: `Bearer ${config.access_token}`,
75
77
  },
76
- body: method !== 'GET' ? JSON.stringify(body) : undefined,
78
+ body: body !== undefined ? JSON.stringify(body) : undefined,
77
79
  // Süre başlıkla sınırlı değil: gövde okuması da aynı sinyalle kesilir.
78
80
  signal,
79
81
  redirect: 'manual',
@@ -113,7 +115,8 @@ async function bearerRequest(method, path, body, timeoutMs, forbidden) {
113
115
  throw new Error(`Rate limited. Try again${retryAfter ? ` in ${retryAfter}s` : ' in a moment'}.`);
114
116
  }
115
117
  if (!res.ok) {
116
- throw new Error(parsed.error || `Request failed (${res.status}).`);
118
+ // The message is unchanged; `code` / `status` let a caller act on a specific refusal (e.g. ask to confirm).
119
+ throw Object.assign(new Error(parsed.error || `Request failed (${res.status}).`), { code: parsed.code, status: res.status });
117
120
  }
118
121
  return parsed;
119
122
  }
@@ -209,6 +212,7 @@ async function createPrompt(input) {
209
212
  contextText: input.body,
210
213
  changelog: input.changelog,
211
214
  source: 'cli',
215
+ ...(input.folder ? { folder: input.folder } : {}),
212
216
  }, exports.SAVE_TIMEOUT_MS, createForbidden);
213
217
  }
214
218
  /**
@@ -222,3 +226,22 @@ async function patchDescription(promptId, description) {
222
226
  async function addTagByName(promptId, tagName) {
223
227
  await bearerRequest('POST', `/api/prompts/${encodeURIComponent(promptId)}/tags`, { tagName }, exports.SAVE_TIMEOUT_MS, metaForbidden);
224
228
  }
229
+ const moveForbidden = (serverError) => new Error(serverError?.trim() || 'The target repo\'s owner has reached the prompt limit of their plan.');
230
+ /**
231
+ * POST /api/prompts/{id}/move — to another repo and/or folder. `folder` omitted: kept in the same repo, root in
232
+ * another; '' = root. A move that changes who can see the prompt is refused (code VISIBILITY_CONFIRM_REQUIRED)
233
+ * until `confirmVisibility` is true.
234
+ */
235
+ async function movePrompt(promptId, input) {
236
+ const res = await bearerRequest('POST', `/api/prompts/${encodeURIComponent(promptId)}/move`, {
237
+ project_id: input.projectId,
238
+ ...(input.folder !== undefined ? { folder: input.folder } : {}),
239
+ ...(input.confirmVisibility ? { confirm_visibility: true } : {}),
240
+ }, exports.SAVE_TIMEOUT_MS, moveForbidden);
241
+ return res;
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
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listPromptsInFolder = listPromptsInFolder;
4
+ const format_1 = require("./format");
5
+ const loopApi_1 = require("./loopApi");
6
+ async function listPromptsInFolder(params) {
7
+ const q = new URLSearchParams();
8
+ if (params.tag)
9
+ q.set('tag', params.tag);
10
+ if (params.limit !== undefined)
11
+ q.set('limit', String(params.limit));
12
+ if (params.page !== undefined)
13
+ q.set('page', String(params.page));
14
+ if (params.projectId)
15
+ q.set('projectId', params.projectId);
16
+ if (params.folder !== undefined)
17
+ q.set('folder', params.folder);
18
+ const res = await (0, loopApi_1.bearerGet)(`/api/prompts?${q.toString()}`);
19
+ return (Array.isArray(res.prompts) ? res.prompts : []).map((p) => ({
20
+ ...p,
21
+ title: typeof p.title === 'string' ? (0, format_1.safeText)(p.title) : '',
22
+ description: typeof p.description === 'string' ? (0, format_1.safeText)(p.description) : p.description,
23
+ project_name: typeof p.project_name === 'string' ? (0, format_1.safeText)(p.project_name) : p.project_name,
24
+ folder: typeof p.folder === 'string' ? (0, format_1.safeText)(p.folder) : null,
25
+ }));
26
+ }
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
@@ -31,6 +31,8 @@ const visibility_1 = require("./commands/visibility");
31
31
  const log_1 = require("./commands/log");
32
32
  const diff_1 = require("./commands/diff");
33
33
  const rollback_1 = require("./commands/rollback");
34
+ const move_1 = require("./commands/move");
35
+ const untag_1 = require("./commands/untag");
34
36
  const tag_1 = require("./commands/tag");
35
37
  const suggest_1 = require("./commands/suggest");
36
38
  const config_1 = require("./commands/config");
@@ -139,10 +141,12 @@ function buildProgram() {
139
141
  .option('-t, --tag <name>', 'Tag (repeatable)', save_1.collectTag, [])
140
142
  .option('-f, --force', 'Overwrite an existing local prompt')
141
143
  .option('--project <repo>', 'Save into this repo of your account (name, slug or id) — needs `ple login`; safe to run again')
144
+ .option('--folder <path>', 'Folder inside that repo (a/b, up to 3 levels) — needs --project; an existing prompt is moved there')
142
145
  .addHelpText('after', [
143
146
  '',
144
147
  'Examples:',
145
148
  ' ple save "code review" -m "Review this diff: {{diff}}"',
149
+ ' ple save "review diff" -m "..." --project my-prompts --folder reviews/backend',
146
150
  ' pbpaste | ple save "bug triage" --tag triage',
147
151
  ' ple save "code review" -m "..." --project my-prompts # into your account; run again to update',
148
152
  '',
@@ -169,8 +173,10 @@ function buildProgram() {
169
173
  .command('list')
170
174
  .description('List your prompts with their tags')
171
175
  .option('-t, --tag <name>', 'Filter by tag; repeat to require several (all must match)', save_1.collectTag, [])
172
- .option('-l, --limit <n>', 'Max number of rows (default 30)', '30'))
173
- .addHelpText('after', '\nExamples:\n ple list --tag debug\n ple list --tag debug --tag review # only prompts that have both\n ple list --project my-prompts')
176
+ .option('-l, --limit <n>', 'Max number of rows (default 30)', '30')
177
+ .option('--folder <path>', 'Only this folder and what is under it (a/b); "" = the repo root only')
178
+ .option('--json', 'Print the rows as one JSON array: id, title, description, repo, folder, every tag, …'))
179
+ .addHelpText('after', '\nExamples:\n ple list --tag debug\n ple list --tag debug --tag review # only prompts that have both\n ple list --project my-prompts\n ple list --project my-prompts --folder reviews\n ple list --json | jq \'.[] | select(.folder == null)\'')
174
180
  .action(runWithErrorHandler(list_1.listCommand));
175
181
  program
176
182
  .command('search <keyword>')
@@ -191,6 +197,41 @@ function buildProgram() {
191
197
  .option('--list', 'Show labels and recent moves')
192
198
  .option('-r, --remove <label>', 'Remove a label')
193
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)));
213
+ scope(program
214
+ .command('move <name>')
215
+ .description('Move a prompt to another repo and/or into a folder — versions, labels, stars and usage come along')
216
+ .option('--to <repo>', 'Target repo (name, slug or id); omit to stay in the same repo')
217
+ .option('--folder <path>', 'Folder inside the repo, like a/b (3 levels at most); "" = the repo root')
218
+ .option('-y, --yes', 'Confirm a move that changes who can see the prompt (public repo <-> private repo)')
219
+ .option('--json', 'Print the outcome as one JSON line')
220
+ .addHelpText('after', [
221
+ '',
222
+ 'Examples:',
223
+ ' ple move "code review" --to team-prompts',
224
+ ' ple move "code review" --to team-prompts --folder reviews/backend',
225
+ ' ple move "code review" --folder reviews # same repo, into a folder',
226
+ ' ple move "code review" --project old-repo --to new-repo --json',
227
+ '',
228
+ 'The prompt keeps its id, versions, deploy labels, stars and usage; tags are matched by name in the',
229
+ 'target repo (created there when missing). Needs write access to both repos. A prompt with the same',
230
+ 'title in the target repo stops the move. Nothing is deleted: move it back to undo.',
231
+ '',
232
+ 'Exit codes: 0 moved · 1 fix it yourself (bad input, not found, not allowed, title taken, plan limit) ·',
233
+ '2 try again later (network, timeout, rate limit, server error)',
234
+ ].join('\n'))).action(runWithErrorHandler((name, opts) => (0, move_1.moveCommand)(name, opts)));
194
235
  scope(program
195
236
  .command('rollback <name> <version>')
196
237
  .description('Restore an old version as a new one — nothing is deleted (signed out: local history)')
@@ -303,6 +344,7 @@ function buildProgram() {
303
344
  .description('Export a prompt (or a whole repo with --project) as an AGENTS.md section or an Agent Skill (SKILL.md)')
304
345
  .requiredOption('--format <format>', 'agents-md | skill')
305
346
  .option('-o, --out <path>', 'agents-md: file to write (default stdout) · skill: parent folder (default .)')
347
+ .option('--folder <path>', 'With --project: export only this folder of the repo (and what is under it)')
306
348
  .option('--zip', 'skill: write <name>.zip (upload in Claude) instead of a folder')
307
349
  .option('-f, --force', 'Overwrite an existing file or folder (never through a symbolic link)')).action(runWithErrorHandler(export_1.exportCommand));
308
350
  // ---- feedback -----------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptlike",
3
- "version": "0.12.5",
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"