promptlike 0.12.5 → 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,19 @@
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
+
3
17
  ## 0.12.5 — 2026-10-31
4
18
 
5
19
  - **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,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
@@ -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);
@@ -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,6 +31,7 @@ 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");
@@ -139,10 +140,12 @@ function buildProgram() {
139
140
  .option('-t, --tag <name>', 'Tag (repeatable)', save_1.collectTag, [])
140
141
  .option('-f, --force', 'Overwrite an existing local prompt')
141
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')
142
144
  .addHelpText('after', [
143
145
  '',
144
146
  'Examples:',
145
147
  ' ple save "code review" -m "Review this diff: {{diff}}"',
148
+ ' ple save "review diff" -m "..." --project my-prompts --folder reviews/backend',
146
149
  ' pbpaste | ple save "bug triage" --tag triage',
147
150
  ' ple save "code review" -m "..." --project my-prompts # into your account; run again to update',
148
151
  '',
@@ -169,8 +172,10 @@ function buildProgram() {
169
172
  .command('list')
170
173
  .description('List your prompts with their tags')
171
174
  .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')
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)\'')
174
179
  .action(runWithErrorHandler(list_1.listCommand));
175
180
  program
176
181
  .command('search <keyword>')
@@ -191,6 +196,28 @@ function buildProgram() {
191
196
  .option('--list', 'Show labels and recent moves')
192
197
  .option('-r, --remove <label>', 'Remove a label')
193
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)));
194
221
  scope(program
195
222
  .command('rollback <name> <version>')
196
223
  .description('Restore an old version as a new one — nothing is deleted (signed out: local history)')
@@ -303,6 +330,7 @@ function buildProgram() {
303
330
  .description('Export a prompt (or a whole repo with --project) as an AGENTS.md section or an Agent Skill (SKILL.md)')
304
331
  .requiredOption('--format <format>', 'agents-md | skill')
305
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)')
306
334
  .option('--zip', 'skill: write <name>.zip (upload in Claude) instead of a folder')
307
335
  .option('-f, --force', 'Overwrite an existing file or folder (never through a symbolic link)')).action(runWithErrorHandler(export_1.exportCommand));
308
336
  // ---- feedback -----------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptlike",
3
- "version": "0.12.5",
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"