promptlike 0.12.4 → 0.13.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,32 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.13.0 — 2026-10-31
4
+
5
+ - **New: `ple move <name> [--to <repo>] [--folder <path>] [--project <repo>] [--yes] [--json]`** moves a prompt to another
6
+ repo and/or into a folder. The prompt keeps its id (`/p/<id>` still opens), versions, deploy labels, stars and usage;
7
+ its tags are matched by name in the target repo. Needs write access to both repos; a title already used in the target
8
+ stops the move; a move between a public and a private repo asks first (`--yes` for scripts). Nothing is deleted.
9
+ - **Folders inside a repo.** A folder is a path like `reviews/backend` (up to 3 levels, 64 characters each). `ple save
10
+ <title> --project <repo> --folder <path>` creates the prompt in that folder, or moves an existing one there;
11
+ `ple list --folder <path>` lists a folder and what is under it (`--folder ""` = the repo root only) and shows a
12
+ FOLDER column when a listed prompt is in one; `ple export --project <repo> --folder <path> --format skill` exports one
13
+ folder as its own skill.
14
+ - **`ple list --json`** prints one JSON array (`id`, `title`, `description`, `repo`, `project_id`, `folder`,
15
+ `visibility`, `tags` with every tag name, `updated_at`, `use_count`, `version`) instead of the table, signed in or out.
16
+
17
+ ## 0.12.5 — 2026-10-31
18
+
19
+ - **Fix: a passing outage no longer ends a login.** If refreshing an expired session met a server error or rate limit
20
+ (HTTP 5xx / 429), `ple feedback` filed the report as "login refused" and told a signed-in user to run `ple login`.
21
+ Now only a definitive rejection counts as refused; an outage is treated like being offline (the report is queued,
22
+ the saved login is kept and the text says so).
23
+ - **`ple feedback` names the reason also when it sends at once without an account** (`"anonymous_reason"` in `--json`,
24
+ a line in the text output), not only when it queues.
25
+ - **`--help` numbers come from the code** (queue size, retry interval, `list` default and maximum rows), and
26
+ `ple feedback list --help` / `close --help` now print their own exit-code table.
27
+ - **`ple feedback close` no longer says "Nothing was changed" after a timeout or a server error**: the request may
28
+ have been applied. It says so and points to `ple feedback list`; `list` still says nothing was changed.
29
+
3
30
  ## 0.12.4 — 2026-10-31
4
31
 
5
32
  - **Fix: `ple improve` and `ple loop` crashed on Node 18** (`crypto is not defined`): the attempt id used the global
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,23 @@ 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 move <name>` — to another repo, or into a folder
659
+
660
+ ```bash
661
+ ple move "code review" --to team-prompts # another repo
662
+ ple move "code review" --to team-prompts --folder reviews/backend
663
+ ple move "code review" --folder reviews # same repo, into a folder
664
+ ple move "code review" --project old-repo --to new-repo --json # --project picks the source when titles collide
665
+ ```
666
+
667
+ Signed in only; needs write access to both repos. The prompt keeps its id (so its `/p/<id>` link still opens), every
668
+ version, its deploy labels, stars and usage counts; its tags are matched by name in the target repo (created there when
669
+ missing), and `ple stats --project` follows it to the new repo. A prompt with the same title in the target repo stops
670
+ the move. A move that changes who can see the prompt (public repo ↔ private repo) asks first on a terminal; scripts pass
671
+ `--yes`. Nothing is deleted: move it back to undo. `--folder` takes `a/b` (3 levels at most, 64 characters each); leave
672
+ `--folder` out and the prompt stays in its folder within the same repo, or lands at the root of another repo; `--folder ""`
673
+ means the root. Its public page address changes with the repo (`/<user>/<repo>/<prompt>`), the short link does not.
674
+
650
675
  #### Local version history (signed out)
651
676
 
652
677
  Without an account the same three commands work on a history kept on your
@@ -769,7 +794,7 @@ anonymous. Who wrote it is decided from `--agent`, else from `PLE_AGENT=<name>`,
769
794
  | `1` | Something unexpected |
770
795
  | `2` | Usage or validation error — nothing was sent (bad flag, empty or too long message, secret found, rejected by the server) |
771
796
  | `3` | Rate limited — try again after the delay shown |
772
- | `4` | Server or network problem — the report was saved to the local queue (with `PLE_FEEDBACK_QUEUE=off`: nothing was saved); `list` / `close`: nothing was changed |
797
+ | `4` | Server or network problem — the report was saved to the local queue (with `PLE_FEEDBACK_QUEUE=off`: nothing was saved); `list`: nothing was changed; `close`: it may have been applied, check with `ple feedback list` |
773
798
 
774
799
  **Offline queue.** A report that could not be delivered is saved to `~/.promptlike/feedback/queue.json` (at most 50;
775
800
  the oldest is dropped when it is full; mode `0600`). After any other `ple` command it is sent silently, with a
@@ -777,7 +802,7 @@ the oldest is dropped when it is full; mode `0600`). After any other `ple` comma
777
802
  `suggest`, `import`) and never when the command failed. A report written while you are signed in is sent with that
778
803
  same account only, and only while that account is still signed in with a session that is not about to expire and
779
804
  that the server accepts. In every other case it goes out anonymously: written signed out (or while the saved login
780
- could not be checked, e.g. offline with an expired session), signed out by the time it is sent, another account
805
+ could not be checked, e.g. offline, or the server busy, with an expired session), signed out by the time it is sent, another account
781
806
  signed in at sending time, or the session refused. Signing in later never attaches an older report to the new account. Turn it off with `PLE_FEEDBACK_QUEUE=off`: then nothing is written to disk and a report that cannot be
782
807
  delivered is simply not sent (exit code 4, run `ple feedback` again when you are online).
783
808
 
@@ -794,7 +819,9 @@ ple feedback close <id> --commit <sha> [--status done|wontfix] [--json]
794
819
  `list` prints what the server returns (with `--json`: `{"ok":true,"exit_code":0,"items":[…]}` exactly as sent, e-mail
795
820
  addresses included). `close` marks an item `done` (default) or `wontfix` and records the commit that resolved it
796
821
  (`--commit` is required for `done`). They use `0` ok · `1` not signed in or not allowed · `2` bad input · `3` rate limit ·
797
- `4` server or network problem (nothing is queued for these two).
822
+ `4` server or network problem (nothing is queued for these two; after a `close` that got no clean answer the change may
823
+ have been applied: check with `ple feedback list` before closing it again). `ple feedback list --help` and
824
+ `ple feedback close --help` print their own table.
798
825
 
799
826
  ### `ple config get [key]` · `ple config set <key> <value>`
800
827
 
@@ -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);
@@ -20,7 +20,7 @@
20
20
  * one it is anonymous.
21
21
  */
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.FEEDBACK_EXIT_CODES_HELP = exports.EXIT_QUEUED = exports.EXIT_RATE_LIMITED = exports.EXIT_USAGE = exports.EXIT_UNEXPECTED = exports.EXIT_SENT = void 0;
23
+ exports.MAX_LIST_LIMIT = exports.DEFAULT_LIST_LIMIT = exports.FEEDBACK_CLOSE_EXIT_CODES_HELP = exports.FEEDBACK_LIST_EXIT_CODES_HELP = exports.FEEDBACK_EXIT_CODES_HELP = exports.EXIT_QUEUED = exports.EXIT_RATE_LIMITED = exports.EXIT_USAGE = exports.EXIT_UNEXPECTED = exports.EXIT_SENT = void 0;
24
24
  exports.feedbackCommand = feedbackCommand;
25
25
  exports.feedbackListCommand = feedbackListCommand;
26
26
  exports.feedbackCloseCommand = feedbackCloseCommand;
@@ -43,7 +43,23 @@ exports.FEEDBACK_EXIT_CODES_HELP = [
43
43
  '1 unexpected problem (list / close: also not signed in, or not allowed)',
44
44
  '2 usage or validation error — nothing was sent',
45
45
  '3 rate limited — try again after the delay shown',
46
- '4 server or network problem — a report is saved to the local queue and sent by a later `ple` command (PLE_FEEDBACK_QUEUE=off: not saved); list / close: nothing was changed',
46
+ '4 server or network problem — a report is saved to the local queue and sent by a later `ple` command (PLE_FEEDBACK_QUEUE=off: not saved); list: nothing was changed; close: it may have been applied, check with `ple feedback list`',
47
+ ];
48
+ /** `list --help`: the same codes, in the words that fit a read. */
49
+ exports.FEEDBACK_LIST_EXIT_CODES_HELP = [
50
+ '0 listed',
51
+ '1 not signed in, not the owner account, session not accepted, or an unexpected answer',
52
+ '2 bad --status / --limit',
53
+ '3 rate limited — try again after the delay shown',
54
+ '4 server or network problem — nothing was changed',
55
+ ];
56
+ /** `close --help`: the same codes, in the words that fit a write. */
57
+ exports.FEEDBACK_CLOSE_EXIT_CODES_HELP = [
58
+ '0 closed',
59
+ '1 not signed in, not the owner account, session not accepted, or an unexpected answer',
60
+ '2 bad id, --commit or --status, or no feedback with that id',
61
+ '3 rate limited — try again after the delay shown',
62
+ '4 server or network problem — if the request was already sent the change may have been applied: check with `ple feedback list`, do not assume it failed',
47
63
  ];
48
64
  // ---------------------------------------------------------------------------
49
65
  // Output
@@ -78,7 +94,11 @@ async function defaultToken() {
78
94
  // The server could not be reached to refresh the session: it cannot take the report either.
79
95
  if (err instanceof api_client_1.NetworkError || err instanceof api_client_1.RequestTimeoutError)
80
96
  return { unreachable: err.message };
81
- return { dead: true }; // a dead session must not block a report: it goes out anonymously
97
+ // A passing outage of the refresh (503 / 429 / 5xx) says nothing about the login: it stays valid, and the
98
+ // report waits like an offline one instead of being filed as "refused".
99
+ if (err instanceof api_client_1.ApiError && (err.status === 429 || err.status >= 500))
100
+ return { unreachable: err.message };
101
+ return { dead: true }; // a definitively rejected session must not block a report: it goes out anonymously
82
102
  }
83
103
  }
84
104
  async function feedbackCommand(messageParts, opts = {}, deps = {}) {
@@ -138,10 +158,10 @@ async function submit(message, opts, deps, json) {
138
158
  case 'sent':
139
159
  setExit(exports.EXIT_SENT);
140
160
  if (json)
141
- emitJson({ ok: true, ...(result.id ? { id: result.id } : {}), exit_code: exports.EXIT_SENT, ...base, account: attachedAccount });
161
+ emitJson({ ok: true, ...(result.id ? { id: result.id } : {}), exit_code: exports.EXIT_SENT, ...base, account: attachedAccount, ...(attachedAccount ? {} : { anonymous_reason: anonReason }) });
142
162
  else {
143
163
  console.log(format_1.c.success('✓ Feedback sent — thank you.') + (result.id ? format_1.c.muted(` (id ${result.id})`) : ''));
144
- console.log(format_1.c.muted(attachedAccount ? ' Tied to your account.' : ' Sent anonymously (sign in with `ple login` to attach it to your account).'));
164
+ console.log(format_1.c.muted(attachedAccount ? ' Tied to your account.' : ` Sent anonymously (${ANON_REASON_TEXT[anonReason]}).${anonReason === 'signed_out' ? ' Sign in with `ple login` to attach reports to your account.' : ''}`));
145
165
  }
146
166
  return;
147
167
  case 'invalid':
@@ -162,7 +182,7 @@ async function submit(message, opts, deps, json) {
162
182
  }
163
183
  const ANON_REASON_TEXT = {
164
184
  signed_out: 'no account was signed in',
165
- unchecked: 'the saved login could not be checked while offline',
185
+ unchecked: 'the saved login could not be checked right now (offline or the server is busy); it is kept',
166
186
  refused: 'the saved login is no longer valid or the server did not accept it',
167
187
  };
168
188
  function queueIt(payload, reason, json, env, deps, base, userId, anonReason) {
@@ -223,11 +243,13 @@ async function ownerAuth() {
223
243
  return token ? { token } : { error: 'This command needs a session. Sign in first: ple login', code: exports.EXIT_UNEXPECTED };
224
244
  }
225
245
  /** The same status → exit code mapping for both owner commands. Returns null when the response is a success (2xx). */
226
- function ownerFailure(out) {
246
+ function ownerFailure(out, writes = false) {
247
+ // A read changes nothing. A write that got no clean answer (timeout, 5xx) may or may not have been applied.
248
+ const unsure = 'It may have been applied: check with `ple feedback list` before closing it again.';
227
249
  if (out.kind === 'config')
228
250
  return { code: exports.EXIT_USAGE, error: out.message };
229
251
  if (out.kind === 'unreachable')
230
- return { code: exports.EXIT_QUEUED, error: `${out.message} Nothing was changed.` };
252
+ return { code: exports.EXIT_QUEUED, error: `${out.message} ${writes ? unsure : 'Nothing was changed.'}` };
231
253
  const { status, body } = out;
232
254
  if (status >= 200 && status < 300)
233
255
  return null;
@@ -248,10 +270,11 @@ function ownerFailure(out) {
248
270
  return { code: exports.EXIT_USAGE, error: (0, feedbackApi_1.serverMessage)(body, fallback) + (details ? ` (${details})` : '') };
249
271
  }
250
272
  if (status >= 500 || status === 408)
251
- return { code: exports.EXIT_QUEUED, error: `The server answered HTTP ${status}. Nothing was changed.` };
273
+ return { code: exports.EXIT_QUEUED, error: `The server answered HTTP ${status}. ${writes ? unsure : 'Nothing was changed.'}` };
252
274
  return { code: exports.EXIT_UNEXPECTED, error: (0, feedbackApi_1.serverMessage)(body, `The server answered HTTP ${status}.`) };
253
275
  }
254
- const MAX_LIST_LIMIT = 200;
276
+ exports.DEFAULT_LIST_LIMIT = 50;
277
+ exports.MAX_LIST_LIMIT = 200;
255
278
  async function feedbackListCommand(opts = {}, deps = {}) {
256
279
  const json = opts.json === true;
257
280
  try {
@@ -259,10 +282,10 @@ async function feedbackListCommand(opts = {}, deps = {}) {
259
282
  if (status !== undefined && !feedbackApi_1.FEEDBACK_STATUSES.includes(status)) {
260
283
  return fail(json, exports.EXIT_USAGE, `--status must be one of: ${feedbackApi_1.FEEDBACK_STATUSES.join(', ')}.`);
261
284
  }
262
- let limit = 50;
285
+ let limit = exports.DEFAULT_LIST_LIMIT;
263
286
  if (opts.limit !== undefined) {
264
- if (!/^\d{1,4}$/.test(opts.limit.trim()) || Number(opts.limit) < 1 || Number(opts.limit) > MAX_LIST_LIMIT) {
265
- return fail(json, exports.EXIT_USAGE, `--limit must be a whole number from 1 to ${MAX_LIST_LIMIT}.`);
287
+ if (!/^\d{1,4}$/.test(opts.limit.trim()) || Number(opts.limit) < 1 || Number(opts.limit) > exports.MAX_LIST_LIMIT) {
288
+ return fail(json, exports.EXIT_USAGE, `--limit must be a whole number from 1 to ${exports.MAX_LIST_LIMIT}.`);
266
289
  }
267
290
  limit = Number(opts.limit);
268
291
  }
@@ -361,7 +384,7 @@ async function feedbackCloseCommand(id, opts = {}, deps = {}) {
361
384
  timeoutMs: feedbackApi_1.OWNER_TIMEOUT_MS,
362
385
  fetchImpl: deps.fetchImpl,
363
386
  });
364
- const failure = ownerFailure(out);
387
+ const failure = ownerFailure(out, true);
365
388
  if (failure)
366
389
  return fail(json, failure.code, failure.error, failure.extra);
367
390
  setExit(exports.EXIT_SENT);
@@ -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);
@@ -115,6 +115,10 @@ function localList(options) {
115
115
  if (wanted.length > 0) {
116
116
  rows = rows.filter((p) => (0, tagFilter_1.hasAllLocalTags)(p.tags, wanted));
117
117
  }
118
+ if (options.json) {
119
+ 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 }))));
120
+ return;
121
+ }
118
122
  if (rows.length === 0) {
119
123
  if (wanted.length > 0)
120
124
  console.log(format_1.c.muted(`No local prompts tagged ${wanted.map((t) => `'${t}'`).join(' + ')}${wanted.length > 1 ? ' (all must match)' : ''}.`));
@@ -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)
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', '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,7 @@ exports.saveWinner = saveWinner;
18
18
  exports.createPrompt = createPrompt;
19
19
  exports.patchDescription = patchDescription;
20
20
  exports.addTagByName = addTagByName;
21
+ exports.movePrompt = movePrompt;
21
22
  const crypto_1 = require("crypto");
22
23
  const constants_1 = require("./constants");
23
24
  const config_1 = require("./config");
@@ -113,7 +114,8 @@ async function bearerRequest(method, path, body, timeoutMs, forbidden) {
113
114
  throw new Error(`Rate limited. Try again${retryAfter ? ` in ${retryAfter}s` : ' in a moment'}.`);
114
115
  }
115
116
  if (!res.ok) {
116
- throw new Error(parsed.error || `Request failed (${res.status}).`);
117
+ // The message is unchanged; `code` / `status` let a caller act on a specific refusal (e.g. ask to confirm).
118
+ throw Object.assign(new Error(parsed.error || `Request failed (${res.status}).`), { code: parsed.code, status: res.status });
117
119
  }
118
120
  return parsed;
119
121
  }
@@ -209,6 +211,7 @@ async function createPrompt(input) {
209
211
  contextText: input.body,
210
212
  changelog: input.changelog,
211
213
  source: 'cli',
214
+ ...(input.folder ? { folder: input.folder } : {}),
212
215
  }, exports.SAVE_TIMEOUT_MS, createForbidden);
213
216
  }
214
217
  /**
@@ -222,3 +225,17 @@ async function patchDescription(promptId, description) {
222
225
  async function addTagByName(promptId, tagName) {
223
226
  await bearerRequest('POST', `/api/prompts/${encodeURIComponent(promptId)}/tags`, { tagName }, exports.SAVE_TIMEOUT_MS, metaForbidden);
224
227
  }
228
+ const moveForbidden = (serverError) => new Error(serverError?.trim() || 'The target repo\'s owner has reached the prompt limit of their plan.');
229
+ /**
230
+ * POST /api/prompts/{id}/move — to another repo and/or folder. `folder` omitted: kept in the same repo, root in
231
+ * another; '' = root. A move that changes who can see the prompt is refused (code VISIBILITY_CONFIRM_REQUIRED)
232
+ * until `confirmVisibility` is true.
233
+ */
234
+ async function movePrompt(promptId, input) {
235
+ const res = await bearerRequest('POST', `/api/prompts/${encodeURIComponent(promptId)}/move`, {
236
+ project_id: input.projectId,
237
+ ...(input.folder !== undefined ? { folder: input.folder } : {}),
238
+ ...(input.confirmVisibility ? { confirm_visibility: true } : {}),
239
+ }, exports.SAVE_TIMEOUT_MS, moveForbidden);
240
+ return res;
241
+ }
@@ -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/program.js CHANGED
@@ -31,11 +31,13 @@ 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");
34
35
  const tag_1 = require("./commands/tag");
35
36
  const suggest_1 = require("./commands/suggest");
36
37
  const config_1 = require("./commands/config");
37
38
  const repo_1 = require("./commands/repo");
38
39
  const feedback_1 = require("./commands/feedback");
40
+ const feedbackQueue_1 = require("./lib/feedbackQueue");
39
41
  const feedbackApi_1 = require("./lib/feedbackApi");
40
42
  const feedbackInput_1 = require("./lib/feedbackInput");
41
43
  const feedbackHint_1 = require("./lib/feedbackHint");
@@ -138,10 +140,12 @@ function buildProgram() {
138
140
  .option('-t, --tag <name>', 'Tag (repeatable)', save_1.collectTag, [])
139
141
  .option('-f, --force', 'Overwrite an existing local prompt')
140
142
  .option('--project <repo>', 'Save into this repo of your account (name, slug or id) — needs `ple login`; safe to run again')
143
+ .option('--folder <path>', 'Folder inside that repo (a/b, up to 3 levels) — needs --project; an existing prompt is moved there')
141
144
  .addHelpText('after', [
142
145
  '',
143
146
  'Examples:',
144
147
  ' ple save "code review" -m "Review this diff: {{diff}}"',
148
+ ' ple save "review diff" -m "..." --project my-prompts --folder reviews/backend',
145
149
  ' pbpaste | ple save "bug triage" --tag triage',
146
150
  ' ple save "code review" -m "..." --project my-prompts # into your account; run again to update',
147
151
  '',
@@ -168,8 +172,10 @@ function buildProgram() {
168
172
  .command('list')
169
173
  .description('List your prompts with their tags')
170
174
  .option('-t, --tag <name>', 'Filter by tag; repeat to require several (all must match)', save_1.collectTag, [])
171
- .option('-l, --limit <n>', 'Max number of rows (default 30)', '30'))
172
- .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')
175
+ .option('-l, --limit <n>', 'Max number of rows (default 30)', '30')
176
+ .option('--folder <path>', 'Only this folder and what is under it (a/b); "" = the repo root only')
177
+ .option('--json', 'Print the rows as one JSON array: id, title, description, repo, folder, every tag, …'))
178
+ .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)\'')
173
179
  .action(runWithErrorHandler(list_1.listCommand));
174
180
  program
175
181
  .command('search <keyword>')
@@ -190,6 +196,28 @@ function buildProgram() {
190
196
  .option('--list', 'Show labels and recent moves')
191
197
  .option('-r, --remove <label>', 'Remove a label')
192
198
  .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)));
199
+ scope(program
200
+ .command('move <name>')
201
+ .description('Move a prompt to another repo and/or into a folder — versions, labels, stars and usage come along')
202
+ .option('--to <repo>', 'Target repo (name, slug or id); omit to stay in the same repo')
203
+ .option('--folder <path>', 'Folder inside the repo, like a/b (3 levels at most); "" = the repo root')
204
+ .option('-y, --yes', 'Confirm a move that changes who can see the prompt (public repo <-> private repo)')
205
+ .option('--json', 'Print the outcome as one JSON line')
206
+ .addHelpText('after', [
207
+ '',
208
+ 'Examples:',
209
+ ' ple move "code review" --to team-prompts',
210
+ ' ple move "code review" --to team-prompts --folder reviews/backend',
211
+ ' ple move "code review" --folder reviews # same repo, into a folder',
212
+ ' ple move "code review" --project old-repo --to new-repo --json',
213
+ '',
214
+ 'The prompt keeps its id, versions, deploy labels, stars and usage; tags are matched by name in the',
215
+ 'target repo (created there when missing). Needs write access to both repos. A prompt with the same',
216
+ 'title in the target repo stops the move. Nothing is deleted: move it back to undo.',
217
+ '',
218
+ 'Exit codes: 0 moved · 1 fix it yourself (bad input, not found, not allowed, title taken, plan limit) ·',
219
+ '2 try again later (network, timeout, rate limit, server error)',
220
+ ].join('\n'))).action(runWithErrorHandler((name, opts) => (0, move_1.moveCommand)(name, opts)));
193
221
  scope(program
194
222
  .command('rollback <name> <version>')
195
223
  .description('Restore an old version as a new one — nothing is deleted (signed out: local history)')
@@ -302,6 +330,7 @@ function buildProgram() {
302
330
  .description('Export a prompt (or a whole repo with --project) as an AGENTS.md section or an Agent Skill (SKILL.md)')
303
331
  .requiredOption('--format <format>', 'agents-md | skill')
304
332
  .option('-o, --out <path>', 'agents-md: file to write (default stdout) · skill: parent folder (default .)')
333
+ .option('--folder <path>', 'With --project: export only this folder of the repo (and what is under it)')
305
334
  .option('--zip', 'skill: write <name>.zip (upload in Claude) instead of a folder')
306
335
  .option('-f, --force', 'Overwrite an existing file or folder (never through a symbolic link)')).action(runWithErrorHandler(export_1.exportCommand));
307
336
  // ---- feedback -----------------------------------------------------------
@@ -332,10 +361,11 @@ function buildProgram() {
332
361
  'account; signed out it is anonymous. Do not put secrets or personal data in the message: a message that',
333
362
  'looks like a key or token is refused.',
334
363
  '',
335
- 'If the server cannot be reached the report is saved to ~/.promptlike/feedback/queue.json (max 50) and',
336
- 'sent by a later `ple` command (at most every 15 minutes). A report written while you are signed in goes',
364
+ `If the server cannot be reached the report is saved to ~/.promptlike/feedback/queue.json (max ${feedbackQueue_1.QUEUE_MAX}) and`,
365
+ `sent by a later \`ple\` command (at most every ${feedbackQueue_1.RETRY_INTERVAL_MS / 60000} minutes). A report written while you are signed in goes`,
337
366
  'out with that same account only; otherwise (signed out by then, another account, a session about to expire',
338
- 'or refused, or a login that could not be checked offline) it goes out anonymously. With',
367
+ 'or refused, or a login that could not be checked while offline or the server is busy) it goes out',
368
+ 'anonymously. With',
339
369
  'PLE_FEEDBACK_QUEUE=off nothing is saved or sent later.',
340
370
  '',
341
371
  'Exit codes:',
@@ -348,8 +378,9 @@ function buildProgram() {
348
378
  .command('list')
349
379
  .description('List the feedback people sent (owner)')
350
380
  .addOption(new commander_1.Option('--status <status>', `Only this status: ${feedbackApi_1.FEEDBACK_STATUSES.join(' | ')}`))
351
- .option('-l, --limit <n>', 'Max rows (default 50)')
381
+ .option('-l, --limit <n>', `Max rows (default ${feedback_1.DEFAULT_LIST_LIMIT}, at most ${feedback_1.MAX_LIST_LIMIT})`)
352
382
  .option('--json', 'Print the items as JSON, exactly as the server returned them')
383
+ .addHelpText('after', ['', 'Exit codes:', ...feedback_1.FEEDBACK_LIST_EXIT_CODES_HELP.map((l) => ` ${l}`), ''].join('\n'))
353
384
  .action(runWithErrorHandler(async (opts, cmd) => (0, feedback_1.feedbackListCommand)({ ...opts, json: opts.json ?? cmd.optsWithGlobals().json === true })));
354
385
  feedback
355
386
  .command('close <id>')
@@ -357,6 +388,7 @@ function buildProgram() {
357
388
  .option('--commit <sha>', 'The commit that resolved it (required for done)')
358
389
  .addOption(new commander_1.Option('--status <status>', 'done (default) or wontfix'))
359
390
  .option('--json', 'Print the result as one JSON line')
391
+ .addHelpText('after', ['', 'Exit codes:', ...feedback_1.FEEDBACK_CLOSE_EXIT_CODES_HELP.map((l) => ` ${l}`), ''].join('\n'))
360
392
  .action(runWithErrorHandler(async (id, opts, cmd) => (0, feedback_1.feedbackCloseCommand)(id, { ...opts, json: opts.json ?? cmd.optsWithGlobals().json === true })));
361
393
  // ---- insights & settings ------------------------------------------------
362
394
  program
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptlike",
3
- "version": "0.12.4",
3
+ "version": "0.13.0",
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"