promptlike 0.7.0 → 0.8.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,55 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.0 — 2026-10-17
4
+
5
+ - **New: `ple repo`.** Create and manage repos from the terminal.
6
+ `ple repo create <name> [--private|--public] [-d <text>]` (private unless you
7
+ say `--public`), `ple repo list` (visibility, your role, prompt count),
8
+ `ple repo show <repo>`, `ple repo visibility <repo> private|public` (owner
9
+ only; making a repo public asks first, `--yes` in scripts). `<repo>` is a name,
10
+ slug, id or the 8-character id that `ple repo list` prints. All four take
11
+ `--json` (stable shape, see the README). There is no delete command: deleting a
12
+ repo cannot be undone, so it stays on the web. The server enforces the plan's
13
+ repo limit (Free: 1), the name rules, slug uniqueness and owner-only visibility;
14
+ the CLI only checks first so mistakes fail faster.
15
+ - **New: `ple list --project <repo>`** (the README listed it as missing). The short
16
+ repo id from `ple repo list` now also works for every `--project` option.
17
+ - **`ple --help` is grouped** (Prompts, Repos, Account, Import / export / sync,
18
+ Insights & settings) with examples and the exit codes. Every old command and
19
+ option still works unchanged.
20
+ - **Exit codes are consistent:** 0 success; 1 you can fix it (bad input, not
21
+ signed in, not found, not allowed, plan limit, conflict); 2 try again later (no
22
+ network, timeout, rate limit, server error). Before, every failure exited 1.
23
+ A script that tested for exactly `1` should test for non-zero.
24
+ - **Security: the API URL must be https.** `PROMPTLIKE_API_URL` now has to be https
25
+ (plain http only for localhost / 127.0.0.1 / [::1]), without a username, password,
26
+ query or fragment. A bad value stops the command before any request, so the
27
+ token and your password can never be sent to an insecure or mistyped address.
28
+ - **Security: no redirects.** The CLI no longer follows HTTP redirects (a redirect
29
+ could replay your login or token at another address); it stops with a message.
30
+ - **Security: session and local files.** The session file is written atomically,
31
+ `0600` in a `0700` folder; a looser existing file or folder is tightened. A
32
+ symbolic link at `config.json`, a prompt file, a history file or an export target
33
+ is never written through (the link is replaced or the export refused); a link at
34
+ `config.json` is not trusted as a session. `ple logout` now also removes a corrupt
35
+ or unreadable session file instead of reporting "Not logged in" and leaving it.
36
+ Settings, the suggestion cache and `~/.promptlike` files get the same treatment.
37
+ - **Security: `ple export`** refuses to write through a symbolic link (even with
38
+ `--force`) and treats a dangling link as existing; skill files must stay inside the
39
+ chosen folder.
40
+ - **Security: server text on your terminal.** Titles, descriptions and repo names
41
+ from the server (including shared repos) have terminal escape sequences and
42
+ control characters removed before they are printed; `ple show` does the same for
43
+ the body. `ple get` and `ple copy` still output the prompt byte for byte.
44
+ - **Security: responses are checked.** A sign-in response without proper tokens is
45
+ rejected before anything is written to disk; repo rows from the server are
46
+ validated and fall back to the most restrictive reading (private, viewer). A
47
+ `Retry-After` header is only echoed when it is a plain number.
48
+ - No environment variable can hold the token: the only place a session lives is
49
+ `config.json`. Tokens are never printed or put on a command line.
50
+ - **Docs:** README documents `ple repo`, the `--json` shapes, exit codes and the
51
+ security behavior above.
52
+
3
53
  ## 0.7.0 — 2026-10-15
4
54
 
5
55
  - **Local version history (no account needed):** `ple save` now keeps an
package/README.md CHANGED
@@ -37,11 +37,13 @@ ple sync # one-way, local → account; local files are kept
37
37
  1. [Install](#install)
38
38
  2. [Quick start](#quick-start)
39
39
  3. [Commands](#commands)
40
- 4. [Configuration](#configuration)
41
- 5. [How it works](#how-it-works)
42
- 6. [Troubleshooting](#troubleshooting)
43
- 7. [Feedback](#feedback)
44
- 8. [License](#license)
40
+ 4. [Exit codes](#exit-codes)
41
+ 5. [Security notes](#security-notes)
42
+ 6. [Configuration](#configuration)
43
+ 7. [How it works](#how-it-works)
44
+ 8. [Troubleshooting](#troubleshooting)
45
+ 9. [Feedback](#feedback)
46
+ 10. [License](#license)
45
47
 
46
48
  ---
47
49
 
@@ -126,7 +128,7 @@ Password: ********
126
128
  Removes the local session file. The session itself expires naturally on its
127
129
  own clock — this just clears the local copy.
128
130
 
129
- ### `ple list [--tag <name>] [--limit <n>]`
131
+ ### `ple list [--tag <name>] [--limit <n>] [--project <repo>]`
130
132
 
131
133
  Lists every prompt your account has access to. The server scopes results to
132
134
  you automatically.
@@ -140,8 +142,58 @@ ID TITLE UPDATED
140
142
 
141
143
  $ ple list --tag debug # filter by tag (server-side)
142
144
  $ ple list --limit 50 # default 30, max 100
145
+ $ ple list --project my-prompts # only one repo (name, slug or id)
143
146
  ```
144
147
 
148
+ ### `ple repo` — create and manage repos
149
+
150
+ A repo is a collection of prompts in your account. Needs an account
151
+ (`ple login`); signed out, the commands say so.
152
+
153
+ ```bash
154
+ $ ple repo create "team-prompts" --description "Shared review prompts"
155
+ ✓ Created private repo 'team-prompts' (team-prompts, 1a2b3c4d)
156
+ Private: only you and people you invite can see it.
157
+ Next: ple import --scan --project 1a2b3c4d (or ple sync, then move prompts on the web)
158
+
159
+ $ ple repo list
160
+ ID NAME VISIBILITY ROLE PROMPTS UPDATED
161
+ ──────── ────────────────────────────── ────────── ────── ─────── ──────────
162
+ 1a2b3c4d team-prompts private owner 0 now
163
+ 9f8e7d6c Open prompts public owner 12 3d ago
164
+
165
+ $ ple repo show team-prompts
166
+ $ ple repo visibility team-prompts public # asks first; --yes in scripts
167
+ ✓ 'team-prompts' is now public.
168
+ ```
169
+
170
+ | Command | What it does |
171
+ |---|---|
172
+ | `ple repo create <name> [--private\|--public] [-d <text>] [--json]` | Creates a repo. **Private unless you pass `--public`.** Name: 1–100 characters, plain text, at least one letter or digit (it becomes the URL slug). Description: up to 500 characters. |
173
+ | `ple repo list [--json]` | Every repo you own or belong to: visibility, your role, prompt count. |
174
+ | `ple repo show <repo> [--json]` | One repo. `<repo>` = name, slug, id, or the 8-character id from `ple repo list`. |
175
+ | `ple repo visibility <repo> private\|public [--yes] [--json]` | Owner only. Going public asks for confirmation (a script must pass `--yes`); going private never asks. |
176
+
177
+ The server enforces the rules, not just the CLI: you must be signed in, Free
178
+ includes 1 repo (hitting the limit says so and links the pricing page), names and URL slugs must be valid and unique among your repos
179
+ (a clash says "pick a different name"), and only the owner can change a repo's
180
+ visibility. Private repos are available on every plan. A repo you do not own or
181
+ belong to is reported as "not found". There is **no delete command**: deleting
182
+ a repo cannot be undone, so it is only possible on the web.
183
+
184
+ `--json` prints one stable object and nothing else:
185
+
186
+ ```json
187
+ { "ok": true, "repo": { "id": "…", "name": "team-prompts", "slug": "team-prompts",
188
+ "description": null, "visibility": "private", "role": "owner",
189
+ "prompt_count": 0, "member_count": 1,
190
+ "created_at": "2026-10-17T09:00:00Z", "updated_at": "2026-10-17T09:00:00Z" } }
191
+ ```
192
+
193
+ `list` prints `{ "repos": [ … ] }` with the same repo objects; `show` prints
194
+ `{ "repo": { … } }`; `visibility` prints `{ "ok": true, "changed": true|false, "repo": { … } }`.
195
+ Keys are only ever added, never renamed or removed, within 0.x minor releases.
196
+
145
197
  ### `ple copy <name>`
146
198
 
147
199
  Looks up a prompt by title substring (case-insensitive) or short ID, joins
@@ -399,6 +451,38 @@ sub-command.
399
451
 
400
452
  ---
401
453
 
454
+ ## Exit codes
455
+
456
+ | Code | Meaning | Examples |
457
+ |---|---|---|
458
+ | `0` | Success | |
459
+ | `1` | You can fix it | bad input, not signed in, not found, not allowed, plan limit, name already used |
460
+ | `2` | Try again later | no network, timeout, rate limited, server error (5xx) |
461
+
462
+ Scripts should treat any non-zero code as failure; `2` is the one worth retrying.
463
+
464
+ ## Security notes
465
+
466
+ - **Where your session lives:** `~/.config/promptlike/config.json`, mode `0600`
467
+ inside a `0700` folder (a looser existing file or folder is tightened). It is
468
+ written atomically and never through a symbolic link. There is no environment
469
+ variable for the token, the token is never printed or passed on a command line,
470
+ and `ple logout` deletes the file (also when it is corrupt).
471
+ - **HTTPS only.** `PROMPTLIKE_API_URL` must be https (plain http only for
472
+ `localhost`, `127.0.0.1`, `[::1]`), without credentials, query or fragment. An
473
+ invalid value stops the command before anything is sent. Redirects are never
474
+ followed. Requests time out (15 s reads, 30 s writes) and are never retried
475
+ automatically.
476
+ - **Files:** `ple export` refuses to overwrite without `--force` and never writes
477
+ through a symbolic link; local prompts, history and cache are `0600`.
478
+ - **Terminal safety:** titles and descriptions that come from the server have
479
+ escape sequences and control characters removed before they are printed.
480
+ - **No shell:** `ple copy` runs the clipboard tool directly and sends the text on
481
+ its standard input. The one deliberate exception is `ple loop --exec`, which runs
482
+ *your own* command through your shell (see the note there).
483
+
484
+ ---
485
+
402
486
  ## Configuration
403
487
 
404
488
  | Path | Purpose | Permissions |
@@ -426,7 +510,8 @@ you to run `ple login`.
426
510
  ### Optional environment variables
427
511
 
428
512
  The CLI ships with the production API URL baked in. You can point it at a
429
- different deployment (e.g. a local dev server) for testing:
513
+ different deployment (e.g. a local dev server) for testing. The URL must be
514
+ https, except for `localhost` / `127.0.0.1` / `[::1]`:
430
515
 
431
516
  ```bash
432
517
  export PROMPTLIKE_API_URL="http://localhost:3000"
@@ -441,6 +526,8 @@ to configure.
441
526
  | `PLE_SUGGEST=off` | `ple suggest --hook` stays silent |
442
527
  | `PLE_SURFACE`, `PLE_VIA` | How `copy/get/show` report a use (e.g. `hook`, `suggestion`) |
443
528
  | `PROMPTLIKE_HOME` | Local store location (default `~/.promptlike`) |
529
+ | `PROMPTLIKE_CONFIG_DIR` | Session / settings / cache folder (default `~/.config/promptlike`) |
530
+ | `PROMPTLIKE_API_URL` | API address (https only, see above) |
444
531
 
445
532
  ---
446
533
 
@@ -461,6 +548,7 @@ to configure.
461
548
  │ POST /api/auth/cli/login │
462
549
  │ GET /api/prompts?tag&search&limit │
463
550
  │ GET /api/prompts/{id} │
551
+ │ GET/POST /api/projects (repos) │
464
552
  │ rate limiting · validation · RLS │
465
553
  └──────────────────────────────────────┘
466
554
  ```
@@ -491,6 +579,11 @@ to configure.
491
579
  | `'X' matched multiple prompts.` | Substring matched several rows | Use a more specific name or the short ID |
492
580
  | `Rate limited. Try again in Ns.` | Too many requests in a short window | Wait the suggested seconds and retry |
493
581
  | `Cannot reach <url>. Check your connection.` | Network / wrong `PROMPTLIKE_API_URL` | Check connectivity or unset the override |
582
+ | `PROMPTLIKE_API_URL must use https …` | The override is plain http (or not a URL) | Use an https address, or unset it; http works only for localhost |
583
+ | `Your plan's repo limit is reached …` | Free includes 1 repo | Use your existing repo (`ple repo list`) or upgrade |
584
+ | `You already have a repo with that name …` | The name's URL slug is taken | Pick a different name |
585
+ | `Only the owner can change a repo's visibility` | You are an admin/editor/viewer there | Ask the owner |
586
+ | `Making '…' public needs confirmation` | Non-interactive run | Re-run with `--yes` |
494
587
 
495
588
  ---
496
589
 
@@ -500,7 +593,7 @@ What this CLI does **not** do yet:
500
593
 
501
594
  - Delete prompts (`ple save` creates and updates; deleting is done on the web)
502
595
  - `ple search` over version body (`content`); needs a server-side full-text index
503
- - `--project <name>` filter on `ple list`
596
+ - Delete a repo (`ple repo` creates, lists, shows and changes visibility; deleting is done on the web)
504
597
  - Interactive picker (think `fzf`-style)
505
598
  - Configurable color theme
506
599
 
@@ -41,6 +41,7 @@ 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 fsSafe_1 = require("../lib/fsSafe");
44
45
  const agentExport_1 = require("../lib/agentExport");
45
46
  /** Hard cap for a repo export — 10 pages × 100. */
46
47
  const MAX_PAGES = 10;
@@ -80,9 +81,19 @@ async function collectRemoteRepo(projectId) {
80
81
  return out;
81
82
  }
82
83
  function ensureWritable(target, force) {
83
- if (fs.existsSync(target) && !force) {
84
+ // lstat-based: a dangling symlink counts as "exists" (existsSync said no and
85
+ // the write then created the link's target), and a link is never written through.
86
+ if ((0, fsSafe_1.pathExists)(target) && !force) {
84
87
  throw new Error(`${target} already exists. Re-run with --force to overwrite.`);
85
88
  }
89
+ (0, fsSafe_1.assertNotSymlink)(target);
90
+ }
91
+ /** Every file of an export must land inside the chosen folder (no `..`, no absolute paths). */
92
+ function assertInside(parent, target) {
93
+ const rel = path.relative(parent, target);
94
+ if (rel === '' || rel.startsWith('..') || path.isAbsolute(rel)) {
95
+ throw new Error(`Refusing to write outside ${parent}: ${target}`);
96
+ }
86
97
  }
87
98
  function writeSkill(skill, options) {
88
99
  const parent = path.resolve(options.out ?? '.');
@@ -97,6 +108,8 @@ function writeSkill(skill, options) {
97
108
  ensureWritable(folder, options.force);
98
109
  for (const f of skill.files) {
99
110
  const target = path.join(parent, ...f.path.split('/'));
111
+ assertInside(parent, target);
112
+ (0, fsSafe_1.assertNotSymlink)(target);
100
113
  fs.mkdirSync(path.dirname(target), { recursive: true });
101
114
  fs.writeFileSync(target, f.content, 'utf-8');
102
115
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.listCommand = listCommand;
4
4
  const api_client_1 = require("../lib/api-client");
5
5
  const local_1 = require("./local");
6
+ const promptResolver_1 = require("../lib/promptResolver");
6
7
  const constants_1 = require("../lib/constants");
7
8
  const format_1 = require("../lib/format");
8
9
  const libraryCache_1 = require("../lib/libraryCache");
@@ -17,11 +18,13 @@ async function listCommand(options) {
17
18
  const limit = Math.max(1, Math.min(100, parseInt(options.limit ?? '30', 10) || 30));
18
19
  // Signed out → the local store. The install has to be useful on its own.
19
20
  if ((0, local_1.isSignedOut)()) {
21
+ (0, local_1.noteIgnoredProject)(options.project);
20
22
  (0, local_1.localList)({ tag: options.tag, limit });
21
23
  return;
22
24
  }
23
25
  await (0, api_client_1.ensureAuthed)();
24
- const prompts = await (0, api_client_1.listPrompts)({ tag: options.tag, limit });
26
+ const projectId = options.project ? await (0, promptResolver_1.resolveProjectId)(options.project) : undefined;
27
+ const prompts = await (0, api_client_1.listPrompts)({ tag: options.tag, limit, projectId });
25
28
  // Keep the suggestion cache (W1-5) in step with the account — detached,
26
29
  // at most once a minute, never slows this command down.
27
30
  (0, libraryCache_1.startBackgroundRefresh)();
@@ -30,7 +33,7 @@ async function listCommand(options) {
30
33
  console.log(format_1.c.muted(`No prompts matched tag '${options.tag}'.`));
31
34
  }
32
35
  else {
33
- console.log(format_1.c.muted(`No prompts yet. Create one at ${constants_1.WEB_APP_URL}`));
36
+ console.log(format_1.c.muted(options.project ? `No prompts in '${options.project}' yet.` : `No prompts yet. Create one at ${constants_1.WEB_APP_URL}`));
34
37
  }
35
38
  return;
36
39
  }
@@ -4,15 +4,20 @@ exports.logoutCommand = logoutCommand;
4
4
  const config_1 = require("../lib/config");
5
5
  const format_1 = require("../lib/format");
6
6
  /**
7
- * `ple logout` — delete the local config file. No server call is made (the
7
+ * `ple logout` — delete the local session file. No server call is made (the
8
8
  * session expires naturally); this only clears local state.
9
+ *
10
+ * A corrupt or unreadable session file is deleted too: logout is the documented
11
+ * fix for that state, so it must not answer "Not logged in" and leave the file.
9
12
  */
10
13
  async function logoutCommand() {
11
- const existing = (0, config_1.readConfig)();
12
- if (!existing) {
14
+ if ((0, config_1.configStatus)() === 'absent') {
13
15
  console.log(format_1.c.muted('Not logged in.'));
14
16
  return;
15
17
  }
18
+ const existing = (0, config_1.readConfig)();
16
19
  (0, config_1.clearConfig)();
17
- console.log(format_1.c.success(`✓ Logged out (${existing.email}).`));
20
+ console.log(existing
21
+ ? format_1.c.success(`✓ Logged out (${existing.email}).`)
22
+ : format_1.c.success('✓ Removed the unreadable session file. You are logged out.'));
18
23
  }
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+ /**
3
+ * `ple repo ...` — repos (projects) of your account.
4
+ *
5
+ * ple repo create <name> [--private|--public] [--description <text>]
6
+ * ple repo list
7
+ * ple repo show <repo>
8
+ * ple repo visibility <repo> private|public
9
+ *
10
+ * Everything is enforced on the SERVER (session, plan limit, name rules, slug
11
+ * uniqueness, owner-only visibility); the checks here only give a faster, clearer
12
+ * message. There is deliberately no `delete`: it cannot be undone, so it stays in
13
+ * the web app.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.toRepoJson = toRepoJson;
17
+ exports.explainRepoError = explainRepoError;
18
+ exports.repoCreateCommand = repoCreateCommand;
19
+ exports.repoListCommand = repoListCommand;
20
+ exports.repoShowCommand = repoShowCommand;
21
+ exports.repoVisibilityCommand = repoVisibilityCommand;
22
+ const api_client_1 = require("../lib/api-client");
23
+ const confirm_1 = require("../lib/confirm");
24
+ const format_1 = require("../lib/format");
25
+ const local_1 = require("./local");
26
+ const constants_1 = require("../lib/constants");
27
+ const repoRef_1 = require("../lib/repoRef");
28
+ const SIGN_IN_FIRST = 'Repos live in your account. Sign in first: ple login';
29
+ function toRepoJson(r) {
30
+ return {
31
+ id: r.id,
32
+ name: r.name,
33
+ slug: r.slug ?? null,
34
+ description: r.description,
35
+ visibility: r.visibility,
36
+ role: r.role,
37
+ prompt_count: r.prompt_count,
38
+ member_count: r.member_count,
39
+ created_at: r.created_at,
40
+ updated_at: r.updated_at,
41
+ };
42
+ }
43
+ function requireAccount() {
44
+ if ((0, local_1.isSignedOut)())
45
+ throw new Error(SIGN_IN_FIRST);
46
+ }
47
+ /** Turn the server's refusals into "what happened + what to do". */
48
+ function explainRepoError(err) {
49
+ if (err instanceof api_client_1.ApiError) {
50
+ if (err.status === 403 && err.code === 'LIMIT_EXCEEDED') {
51
+ throw new Error(`Your plan's repo limit is reached (Free includes 1 repo). Upgrade at ${constants_1.WEB_APP_URL}/pricing, or use the repo you already have: ple repo list`);
52
+ }
53
+ if (err.status === 403) {
54
+ throw new Error(err.message);
55
+ }
56
+ if (err.status === 409) {
57
+ throw new Error('You already have a repo with that name or URL slug. Pick a different name (see: ple repo list).');
58
+ }
59
+ if (err.status === 404) {
60
+ throw new Error('Repo not found, or you have no access to it. See: ple repo list');
61
+ }
62
+ }
63
+ throw err;
64
+ }
65
+ async function repoCreateCommand(name, options = {}) {
66
+ // Local checks first: no network, no session needed to learn the name is wrong.
67
+ const cleanName = (0, repoRef_1.validateRepoName)(name);
68
+ const description = (0, repoRef_1.validateRepoDescription)(options.description);
69
+ const visibility = (0, repoRef_1.pickVisibility)(options);
70
+ requireAccount();
71
+ await (0, api_client_1.ensureAuthed)();
72
+ let repo;
73
+ try {
74
+ repo = await (0, api_client_1.createProject)({ name: cleanName, description, visibility });
75
+ }
76
+ catch (err) {
77
+ explainRepoError(err);
78
+ }
79
+ if (options.json) {
80
+ console.log(JSON.stringify({ ok: true, repo: toRepoJson(repo) }, null, 2));
81
+ return;
82
+ }
83
+ console.log(format_1.c.success(`✓ Created ${visibility} repo '${repo.name}'`) + format_1.c.muted(` (${repo.slug ?? (0, repoRef_1.slugFromName)(repo.name)}, ${(0, format_1.shortId)(repo.id)})`));
84
+ if (visibility === 'public') {
85
+ console.log(format_1.c.warn(' Public: anyone can read its public prompts. Make it private again: ple repo visibility ' + (0, format_1.shortId)(repo.id) + ' private'));
86
+ }
87
+ else {
88
+ console.log(format_1.c.muted(' Private: only you and people you invite can see it.'));
89
+ }
90
+ console.log(format_1.c.muted(` Next: ple import --scan --project ${(0, format_1.shortId)(repo.id)} (or ple sync, then move prompts on the web)`));
91
+ }
92
+ async function repoListCommand(options = {}) {
93
+ requireAccount();
94
+ await (0, api_client_1.ensureAuthed)();
95
+ const repos = await (0, api_client_1.listProjectsDetailed)();
96
+ if (options.json) {
97
+ console.log(JSON.stringify({ repos: repos.map(toRepoJson) }, null, 2));
98
+ return;
99
+ }
100
+ if (repos.length === 0) {
101
+ console.log(format_1.c.muted('No repos yet. Create one: ple repo create "my-prompts"'));
102
+ return;
103
+ }
104
+ console.log(format_1.c.label('ID NAME VISIBILITY ROLE PROMPTS UPDATED'));
105
+ console.log(format_1.c.label('──────── ────────────────────────────── ────────── ────── ─────── ──────────'));
106
+ for (const r of repos) {
107
+ const vis = r.visibility === 'public' ? format_1.c.warn('public ') : format_1.c.muted('private ');
108
+ console.log(`${format_1.c.muted((0, format_1.shortId)(r.id))} ${(0, format_1.truncate)(r.name, 30).padEnd(30)} ${vis} ${r.role.padEnd(6)} ${String(r.prompt_count).padStart(7)} ${format_1.c.muted(r.updated_at ? (0, format_1.timeAgo)(r.updated_at) : '-')}`);
109
+ }
110
+ console.log(format_1.c.muted(`\n${repos.length} repo${repos.length === 1 ? '' : 's'} listed.`));
111
+ }
112
+ async function repoShowCommand(ref, options = {}) {
113
+ requireAccount();
114
+ await (0, api_client_1.ensureAuthed)();
115
+ const repo = (0, repoRef_1.resolveRepoRef)(ref, await (0, api_client_1.listProjectsDetailed)());
116
+ if (options.json) {
117
+ console.log(JSON.stringify({ repo: toRepoJson(repo) }, null, 2));
118
+ return;
119
+ }
120
+ console.log(format_1.c.title(repo.name));
121
+ const row = (k, v) => console.log(`${format_1.c.label(k.padEnd(12))}${v}`);
122
+ row('id', repo.id);
123
+ row('slug', repo.slug ?? '-');
124
+ row('visibility', repo.visibility);
125
+ row('your role', repo.role);
126
+ row('prompts', String(repo.prompt_count));
127
+ row('members', String(repo.member_count));
128
+ row('updated', repo.updated_at ? (0, format_1.timeAgo)(repo.updated_at) : '-');
129
+ if (repo.description)
130
+ row('description', repo.description);
131
+ }
132
+ async function repoVisibilityCommand(ref, value, options = {}, deps = {}) {
133
+ const target = (0, repoRef_1.parseVisibility)(value);
134
+ requireAccount();
135
+ await (0, api_client_1.ensureAuthed)();
136
+ const repo = (0, repoRef_1.resolveRepoRef)(ref, await (0, api_client_1.listProjectsDetailed)());
137
+ if (repo.role !== 'owner') {
138
+ throw new Error(`Only the owner can change a repo's visibility (your role in '${repo.name}': ${repo.role}).`);
139
+ }
140
+ if (repo.visibility === target) {
141
+ if (options.json)
142
+ console.log(JSON.stringify({ ok: true, changed: false, repo: toRepoJson(repo) }, null, 2));
143
+ else
144
+ console.log(format_1.c.muted(`'${repo.name}' is already ${target}. Nothing changed.`));
145
+ return;
146
+ }
147
+ // Making a repo public is the one step here that exposes data. It needs a
148
+ // person to say yes (or a script to say --yes); going private never asks.
149
+ if (target === 'public' && !options.yes) {
150
+ const interactive = deps.isTTY ?? Boolean(process.stdin.isTTY && process.stdout.isTTY);
151
+ if (!interactive) {
152
+ throw new Error(`Making '${repo.name}' public needs confirmation: re-run with --yes.`);
153
+ }
154
+ const ok = await (deps.confirm ?? confirm_1.confirm)(`Make '${repo.name}' public? Its public prompts become readable by anyone. [y/N] `);
155
+ if (!ok) {
156
+ console.log(format_1.c.muted('Cancelled — nothing changed.'));
157
+ return;
158
+ }
159
+ }
160
+ try {
161
+ await (0, api_client_1.setProjectVisibility)(repo.id, target);
162
+ }
163
+ catch (err) {
164
+ explainRepoError(err);
165
+ }
166
+ if (options.json) {
167
+ console.log(JSON.stringify({ ok: true, changed: true, repo: toRepoJson({ ...repo, visibility: target }) }, null, 2));
168
+ return;
169
+ }
170
+ console.log(format_1.c.success(`✓ '${repo.name}' is now ${target}.`));
171
+ }
@@ -46,7 +46,7 @@ async function showCommand(name, options = {}) {
46
46
  !version.description_text &&
47
47
  !version.context_text) {
48
48
  console.log();
49
- console.log(version.content);
49
+ console.log((0, format_1.safeText)(version.content, true));
50
50
  console.log();
51
51
  return;
52
52
  }
@@ -54,17 +54,17 @@ async function showCommand(name, options = {}) {
54
54
  if (version.role_text?.trim()) {
55
55
  console.log();
56
56
  console.log(format_1.c.accent('── ROLE ──'));
57
- console.log(version.role_text.trim());
57
+ console.log((0, format_1.safeText)(version.role_text.trim(), true));
58
58
  }
59
59
  if (version.description_text?.trim()) {
60
60
  console.log();
61
61
  console.log(format_1.c.accent('── DESCRIPTION ──'));
62
- console.log(version.description_text.trim());
62
+ console.log((0, format_1.safeText)(version.description_text.trim(), true));
63
63
  }
64
64
  if (version.context_text?.trim()) {
65
65
  console.log();
66
66
  console.log(format_1.c.accent('── CONTEXT ──'));
67
- console.log(version.context_text.trim());
67
+ console.log((0, format_1.safeText)(version.context_text.trim(), true));
68
68
  }
69
69
  console.log();
70
70
  }
package/dist/help.js ADDED
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ /**
3
+ * Grouped `ple --help`. commander lists commands in registration order with no
4
+ * headings; with ~20 commands that is a wall of text. This prints the same
5
+ * commands under task-based headings. A test (program.test.ts) fails when a
6
+ * command is registered but missing from GROUPS, so the help cannot drift.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.COMMAND_GROUPS = void 0;
10
+ exports.formatRootHelp = formatRootHelp;
11
+ const commander_1 = require("commander");
12
+ exports.COMMAND_GROUPS = [
13
+ { title: 'Prompts', commands: ['save', 'get', 'show', 'copy', 'list', 'search', 'log', 'diff', 'rollback', 'improve', 'loop'] },
14
+ { title: 'Repos', commands: ['repo'] },
15
+ { title: 'Account', commands: ['login', 'logout'] },
16
+ { title: 'Import / export / sync', commands: ['import', 'export', 'sync'] },
17
+ { title: 'Insights & settings', commands: ['stats', 'suggest', 'config'] },
18
+ ];
19
+ const EXAMPLES = [
20
+ 'ple save "code review" -m "Review this diff: {{diff}}" # no account needed',
21
+ 'ple get "code review" --var diff="$(git diff)" | claude',
22
+ 'ple repo create "team-prompts" # private by default',
23
+ 'ple login && ple sync --dry-run',
24
+ ];
25
+ const EXIT_CODES = [
26
+ '0 success',
27
+ '1 fix it yourself: bad input, not signed in, not found, not allowed, plan limit',
28
+ '2 try again later: no network, timeout, rate limit, server error',
29
+ ];
30
+ function formatRootHelp(cmd, helper) {
31
+ // configureHelp() is inherited by subcommands; only the root gets the grouped layout.
32
+ if (cmd.parent)
33
+ return commander_1.Help.prototype.formatHelp.call(helper, cmd, helper);
34
+ const lines = [];
35
+ lines.push(`Usage: ${helper.commandUsage(cmd)}`, '');
36
+ lines.push(helper.commandDescription(cmd), '');
37
+ const subs = helper.visibleCommands(cmd);
38
+ const byName = new Map(subs.map((s) => [s.name(), s]));
39
+ const width = Math.max(...subs.map((s) => helper.subcommandTerm(s).length)) + 2;
40
+ const seen = new Set();
41
+ const render = (title, names) => {
42
+ const rows = names.map((n) => byName.get(n)).filter((s) => s !== undefined);
43
+ if (rows.length === 0)
44
+ return;
45
+ lines.push(`${title}:`);
46
+ for (const s of rows) {
47
+ seen.add(s.name());
48
+ lines.push(` ${helper.subcommandTerm(s).padEnd(width)}${helper.subcommandDescription(s)}`);
49
+ }
50
+ lines.push('');
51
+ };
52
+ for (const g of exports.COMMAND_GROUPS)
53
+ render(g.title, g.commands);
54
+ // A command nobody grouped still shows up (and fails the test) instead of vanishing.
55
+ render('Other', subs.map((s) => s.name()).filter((n) => !seen.has(n) && n !== 'help'));
56
+ lines.push('Options:');
57
+ for (const o of helper.visibleOptions(cmd)) {
58
+ lines.push(` ${helper.optionTerm(o).padEnd(width)}${helper.optionDescription(o)}`);
59
+ }
60
+ lines.push('');
61
+ lines.push('Examples:', ...EXAMPLES.map((e) => ` ${e}`), '');
62
+ lines.push('Exit codes:', ...EXIT_CODES.map((e) => ` ${e}`), '');
63
+ lines.push('Run `ple <command> --help` for a command, or `ple repo --help` for the repo commands.');
64
+ return lines.join('\n') + '\n';
65
+ }