promptlike 0.11.0 → 0.12.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.12.0 — 2026-10-30
4
+
5
+ - **New: `ple visibility <prompt> public|private`** and **`ple visibility --all --project <repo> public|private`.**
6
+ Make one prompt, or every prompt of a repo, public or private from the terminal (before, only the web editor could).
7
+ A prompt page is public only when its repo is public too; the command says when the repo is still private. Going
8
+ public asks first (`--yes` in a script); only the owner can change it. There is no MCP tool for this on purpose.
9
+ - **New: `ple import ple:<user>/<repo>[/<prompt>]`.** Copy the public prompts of another PromptLikeEngineer user into
10
+ your library, the whole repo or one prompt by title or id. It works signed out and reads only the public
11
+ endpoints. Each copy keeps its source, the version it was read at and the repo's license (in the description, and as
12
+ provenance when signed in); a repo without a declared license is copied with a notice. A re-run skips what you
13
+ have; a newer upstream version is reported, not applied.
14
+ - **New: `ple repo license <repo> CC-BY-4.0|CC-BY-SA-4.0|CC0-1.0|MIT|Apache-2.0|none`.** Declare how a repo's prompts
15
+ may be reused (owner only). `ple repo show` and `--json` carry it as `license`; the public repo page shows it.
16
+
3
17
  ## 0.11.0 — 2026-10-30
4
18
 
5
19
  - **New: `ple whoami` (alias `ple account`).** Shows the signed-in account: your email, the plan (Free / Pro /
package/README.md CHANGED
@@ -239,6 +239,7 @@ $ ple repo visibility team-prompts public # asks first; --yes in scripts
239
239
  | `ple repo list [--json]` | Every repo you own or belong to: visibility, your role, prompt count. |
240
240
  | `ple repo show <repo> [--json]` | One repo. `<repo>` = name, slug, id, or the 8-character id from `ple repo list`. |
241
241
  | `ple repo visibility <repo> private\|public [--yes] [--json]` | Owner only. Going public asks for confirmation (a script must pass `--yes`); going private never asks. |
242
+ | `ple repo license <repo> CC-BY-4.0\|CC-BY-SA-4.0\|CC0-1.0\|MIT\|Apache-2.0\|none [--json]` | Owner only. Declares how the repo's prompts may be reused; shown on the public repo page. `none` clears it. A repo with no license is shown as "none declared", never as free to use. |
242
243
 
243
244
  The server enforces the rules, not just the CLI: you must be signed in, Free
244
245
  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
@@ -251,7 +252,7 @@ a repo cannot be undone, so it is only possible on the web.
251
252
 
252
253
  ```json
253
254
  { "ok": true, "repo": { "id": "…", "name": "team-prompts", "slug": "team-prompts",
254
- "description": null, "visibility": "private", "role": "owner",
255
+ "description": null, "visibility": "private", "license": null, "role": "owner",
255
256
  "prompt_count": 0, "member_count": 1,
256
257
  "created_at": "2026-10-17T09:00:00Z", "updated_at": "2026-10-17T09:00:00Z" } }
257
258
  ```
@@ -260,6 +261,28 @@ a repo cannot be undone, so it is only possible on the web.
260
261
  `{ "repo": { … } }`; `visibility` prints `{ "ok": true, "changed": true|false, "repo": { … } }`.
261
262
  Keys are only ever added, never renamed or removed, within 0.x minor releases.
262
263
 
264
+ ### `ple visibility` — make single prompts public or private
265
+
266
+ A prompt page is public only when its repo **and** the prompt are public. `ple repo visibility` is the repo half; this
267
+ is the prompt half. Needs an account.
268
+
269
+ ```bash
270
+ $ ple visibility "code review" public --yes
271
+ ✓ 'Code Review' is now public.
272
+ Its repo 'ortak-web' is private, so the page stays hidden: ple repo visibility ortak-web public
273
+
274
+ $ ple visibility --all --project ortak-web public --yes
275
+ ✓ 5 prompts in 'ortak-web' are now public.
276
+ ```
277
+
278
+ | Command | What it does |
279
+ |---|---|
280
+ | `ple visibility <prompt> private\|public [--project <repo>] [--yes] [--json]` | One prompt, by title or id. Going public asks for confirmation (a script must pass `--yes`); going private never asks. A prompt that already has the value is left alone. |
281
+ | `ple visibility --all --project <repo> private\|public [--yes] [--json]` | Every prompt of the repo that differs, with one confirmation. A prompt that fails is reported and the exit code is `1`; the rest are still changed. |
282
+
283
+ Only the owner can change visibility (the server enforces it). There is no MCP tool for this on purpose: an agent
284
+ should not be able to publish your prompts.
285
+
263
286
  ### `ple copy <name>`
264
287
 
265
288
  Looks up a prompt by title substring (case-insensitive) or short ID, joins
@@ -558,6 +581,28 @@ followed by the real import costs nothing extra: files and file lists are
558
581
  stored by commit and never change, while a repo's info and what a branch points
559
582
  to are reused for 10 minutes.
560
583
 
584
+ ### Import from another PromptLikeEngineer user
585
+
586
+ ```bash
587
+ ple import ple:<user>/<repo> --dry-run # what is there, and under which license
588
+ ple import ple:<user>/<repo> --all # every public prompt of the repo
589
+ ple import ple:<user>/<repo>/<title or id> # one prompt (an 8-character id prefix works)
590
+ ```
591
+
592
+ Copies the **public** prompts of a public repo into your library. It works signed out: it reads only the public
593
+ endpoints (`/api/public/...`), and no session or token is read or sent. Signed out the copies go to
594
+ `~/.promptlike/prompts`, signed in to your account (`--project <repo>` picks the repo; the plan limit is said before
595
+ uploading).
596
+
597
+ - **Source and license are kept.** The description ends with
598
+ `Source: ple:<user>/<repo>/<id> · v<version> · <license> · promptlikeengineer.com/<user>/<repo>`. Signed in, the same
599
+ facts (source, owner, repo, prompt id, version, license) are stored as provenance.
600
+ - **A repo without a declared license** is copied with a notice, never silently: the author has not said how its
601
+ prompts may be reused.
602
+ - **Safe to run again.** A body you already have is skipped. If upstream has a newer version of a prompt you imported
603
+ earlier, it is reported (`you have v1, upstream is v2`) and not applied: updates are not followed yet.
604
+ - Text that looks like a secret is never copied. Several prompts with the same title in one repo: use the id.
605
+
561
606
  ### Check for upstream changes
562
607
 
563
608
  `ple import --check` looks at every prompt you imported from GitHub and shows
@@ -4,6 +4,7 @@
4
4
  *
5
5
  * ple import --scan # your agent folders (W1-2 — strategy F15, "activation = investment")
6
6
  * ple import github:owner/repo # a public GitHub repo, per-file license gate (importGithub.ts)
7
+ * ple import ple:user/repo # public prompts of another PromptLikeEngineer user (importPle.ts)
7
8
  * ple import --check [--apply] # follow upstream changes of what came from GitHub (importCheck.ts)
8
9
  *
9
10
  * `--scan`:
@@ -64,6 +65,8 @@ Object.defineProperty(exports, "parseSelection", { enumerable: true, get: functi
64
65
  const local_1 = require("./local");
65
66
  const format_1 = require("../lib/format");
66
67
  const importGithub_1 = require("./importGithub");
68
+ const importPle_1 = require("./importPle");
69
+ const pleSpec_1 = require("../lib/pleSpec");
67
70
  const importCheck_1 = require("./importCheck");
68
71
  function toImportable(cand) {
69
72
  return {
@@ -88,13 +91,15 @@ async function importCommand(options = {}, deps = {}) {
88
91
  if (options.apply && !options.check) {
89
92
  throw new Error('--apply only works together with --check.');
90
93
  }
94
+ if (options.source && (0, pleSpec_1.isPleSource)(options.source))
95
+ return (0, importPle_1.importPleCommand)(options.source, options, deps);
91
96
  if (options.source)
92
97
  return (0, importGithub_1.importGithubCommand)(options.source, options, deps);
93
98
  if (options.check)
94
99
  return (0, importCheck_1.importCheckCommand)({ apply: options.apply, dryRun: options.dryRun });
95
100
  if (!options.scan) {
96
101
  throw new Error('Nothing to import. Use `ple import --scan` to find prompts in your agent folders, ' +
97
- '`ple import github:<owner>/<repo>` to bring in a public GitHub repo, or `ple import --check` to look for upstream changes.');
102
+ '`ple import github:<owner>/<repo>` to bring in a public GitHub repo, `ple import ple:<user>/<repo>` for public prompts on PromptLikeEngineer, or `ple import --check` to look for upstream changes.');
98
103
  }
99
104
  const signedOut = (0, local_1.isSignedOut)();
100
105
  const destination = signedOut ? 'your local store' : 'your account';
@@ -0,0 +1,237 @@
1
+ "use strict";
2
+ /**
3
+ * `ple import ple:<user>/<repo>[/<prompt>]` — copy PUBLIC prompts of another PromptLikeEngineer user into your library.
4
+ *
5
+ * ple import ple:zeynepaslierhan/ortak-web --dry-run # what is there, and under which license
6
+ * ple import ple:zeynepaslierhan/ortak-web --all # every prompt of the repo, no questions
7
+ * ple import ple:zeynepaslierhan/ortak-web/Code Review # one prompt (title or id)
8
+ *
9
+ * Works signed out (it reads the public pages' API; no token is read or sent). Signed out → the local store,
10
+ * signed in → the account (`--project <repo>` picks the repo). Each copy keeps its source: user, repo, prompt id,
11
+ * the version it was read at and the repo's license, in the description and (signed in) as provenance, so a re-run
12
+ * skips what is already there. A prompt of a repo without a declared license is copied with a notice, never
13
+ * silently. Updates are not followed yet: a newer version upstream is reported, not applied.
14
+ */
15
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ var desc = Object.getOwnPropertyDescriptor(m, k);
18
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
19
+ desc = { enumerable: true, get: function() { return m[k]; } };
20
+ }
21
+ Object.defineProperty(o, k2, desc);
22
+ }) : (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ o[k2] = m[k];
25
+ }));
26
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
27
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
28
+ }) : function(o, v) {
29
+ o["default"] = v;
30
+ });
31
+ var __importStar = (this && this.__importStar) || (function () {
32
+ var ownKeys = function(o) {
33
+ ownKeys = Object.getOwnPropertyNames || function (o) {
34
+ var ar = [];
35
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
36
+ return ar;
37
+ };
38
+ return ownKeys(o);
39
+ };
40
+ return function (mod) {
41
+ if (mod && mod.__esModule) return mod;
42
+ var result = {};
43
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
44
+ __setModuleDefault(result, mod);
45
+ return result;
46
+ };
47
+ })();
48
+ Object.defineProperty(exports, "__esModule", { value: true });
49
+ exports.pickByRef = pickByRef;
50
+ exports.attributionLine = attributionLine;
51
+ exports.importPleCommand = importPleCommand;
52
+ const history = __importStar(require("../lib/localHistory"));
53
+ const store = __importStar(require("../lib/localStore"));
54
+ const api_client_1 = require("../lib/api-client");
55
+ const constants_1 = require("../lib/constants");
56
+ const format_1 = require("../lib/format");
57
+ const githubImport_1 = require("../lib/githubImport");
58
+ const importOrigins_1 = require("../lib/importOrigins");
59
+ const importShared_1 = require("../lib/importShared");
60
+ const pleSpec_1 = require("../lib/pleSpec");
61
+ const promptResolver_1 = require("../lib/promptResolver");
62
+ const publicApi_1 = require("../lib/publicApi");
63
+ const scanners_1 = require("../lib/scanners");
64
+ const secretGuard_1 = require("../lib/secretGuard");
65
+ const titleMatch_1 = require("../lib/titleMatch");
66
+ const local_1 = require("./local");
67
+ const LICENSE_NAMES = {
68
+ 'CC-BY-4.0': 'CC BY 4.0',
69
+ 'CC-BY-SA-4.0': 'CC BY-SA 4.0',
70
+ 'CC0-1.0': 'CC0 1.0',
71
+ MIT: 'MIT',
72
+ 'Apache-2.0': 'Apache 2.0',
73
+ };
74
+ const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
75
+ const SHORT_ID_RE = /^[0-9a-f]{8,}$/i;
76
+ /** The prompts a `<prompt>` argument names: an id (full or 8+ hex prefix), else exact title, else part of a title. */
77
+ function pickByRef(cards, ref) {
78
+ const r = ref.trim();
79
+ if (UUID_RE.test(r))
80
+ return cards.filter((k) => k.id.toLowerCase() === r.toLowerCase());
81
+ if (SHORT_ID_RE.test(r)) {
82
+ const byId = cards.filter((k) => k.id.toLowerCase().startsWith(r.toLowerCase()));
83
+ if (byId.length > 0)
84
+ return byId;
85
+ }
86
+ const exact = cards.filter((k) => (0, titleMatch_1.foldedEquals)(k.title, r));
87
+ return exact.length > 0 ? exact : cards.filter((k) => (0, titleMatch_1.foldedIncludes)(k.title, r));
88
+ }
89
+ /** `Source: ple:user/repo/ab12cd34 · v3 · CC BY 4.0 · promptlikeengineer.com/user/repo` */
90
+ function attributionLine(owner, d) {
91
+ const license = d.license ? LICENSE_NAMES[d.license] ?? d.license : 'no license declared';
92
+ const v = d.version ? ` · v${d.version}` : '';
93
+ return `Source: ple:${owner}/${d.repoSlug}/${d.id.slice(0, 8)}${v} · ${license} · promptlikeengineer.com/${owner}/${d.repoSlug}`;
94
+ }
95
+ async function importPleCommand(source, options = {}, deps = {}) {
96
+ const spec = (0, pleSpec_1.parsePleSpec)(source);
97
+ const signedOut = (0, local_1.isSignedOut)();
98
+ if (!signedOut)
99
+ await (0, api_client_1.ensureAuthed)();
100
+ const destination = signedOut ? 'your local store' : 'your account';
101
+ const where = `ple:${spec.owner}/${spec.repo}`;
102
+ const cards = await (0, publicApi_1.listPublicRepoPrompts)(spec.owner, spec.repo);
103
+ if (cards.length === 0) {
104
+ console.log(format_1.c.muted(`No public prompts found in ${where}. The repo and its prompts must both be public.`));
105
+ process.exitCode = 1;
106
+ return;
107
+ }
108
+ let rows = cards;
109
+ if (spec.prompt) {
110
+ rows = pickByRef(cards, spec.prompt);
111
+ if (rows.length === 0) {
112
+ console.error(format_1.c.error(`No prompt matched '${(0, format_1.safeText)(spec.prompt)}' in ${where}.`));
113
+ for (const k of cards.slice(0, 10))
114
+ console.error(format_1.c.muted(` ${k.id.slice(0, 8)} ${(0, format_1.truncate)(k.title, 60)}`));
115
+ process.exitCode = 1;
116
+ return;
117
+ }
118
+ if (rows.length > 1) {
119
+ console.error(format_1.c.error(`'${(0, format_1.safeText)(spec.prompt)}' matched ${rows.length} prompts in ${where}. Use the id:`));
120
+ for (const k of rows)
121
+ console.error(format_1.c.muted(` ${k.id.slice(0, 8)} ${(0, format_1.truncate)(k.title, 60)}`));
122
+ process.exitCode = 1;
123
+ return;
124
+ }
125
+ }
126
+ // What is already there: body hashes, and (signed in) which public prompt came in at which version.
127
+ let hashes = new Set();
128
+ const cameIn = new Map();
129
+ if (signedOut) {
130
+ hashes = new Set(store.list().map((p) => (0, scanners_1.hashBody)(p.body)));
131
+ }
132
+ else {
133
+ try {
134
+ const state = await (0, importOrigins_1.fetchImportOrigins)();
135
+ hashes = state.knownHashes;
136
+ for (const o of state.origins ?? []) {
137
+ if (o.meta?.source === 'ple' && o.meta.prompt_id)
138
+ cameIn.set(o.meta.prompt_id, Number(o.meta.version) || 0);
139
+ }
140
+ }
141
+ catch {
142
+ /* best effort: the server drops a duplicate hash itself */
143
+ }
144
+ }
145
+ const license = rows[0].license;
146
+ console.log(format_1.c.title(`Found ${rows.length} public prompt${rows.length === 1 ? '' : 's'} in ${where}`) +
147
+ format_1.c.muted(` → ${destination}`) +
148
+ format_1.c.muted(` · license: ${license ? LICENSE_NAMES[license] ?? license : 'none declared'}`));
149
+ if (!license) {
150
+ console.log(format_1.c.warn(' ⚠ This repo declares no license: the author has not said how its prompts may be reused. Ask before sharing them further.'));
151
+ }
152
+ rows.forEach((k, i) => console.log(` ${format_1.c.accent(String(i + 1).padStart(3))} ${(0, format_1.truncate)(k.title, 50).padEnd(50)} ${format_1.c.muted(k.id.slice(0, 8))}`));
153
+ if (options.dryRun) {
154
+ console.log(format_1.c.muted(`\nDry run — nothing imported. Run \`ple import ${(0, format_1.safeText)(source)}\` to pick, or add --all.`));
155
+ return;
156
+ }
157
+ // One named prompt is an explicit choice; a whole repo needs --all or a pick.
158
+ const selected = spec.prompt ? rows : await (0, importShared_1.chooseRows)(rows, options.all, deps);
159
+ if (!selected)
160
+ return;
161
+ const details = [];
162
+ let skipped = 0;
163
+ for (const k of selected) {
164
+ const d = await (0, publicApi_1.getPublicPrompt)(spec.owner, k);
165
+ const body = (0, format_1.joinPromptParts)(d);
166
+ if (!body) {
167
+ console.log(format_1.c.warn(` ⚠ ${(0, format_1.truncate)(d.title, 50)}: no text in its current version — skipped`));
168
+ skipped++;
169
+ continue;
170
+ }
171
+ const secret = (0, secretGuard_1.findSecret)(body);
172
+ if (secret) {
173
+ console.log(format_1.c.warn(` ⚠ ${(0, format_1.truncate)(d.title, 50)}: looks like it contains a ${secret} — not imported`));
174
+ skipped++;
175
+ continue;
176
+ }
177
+ const have = cameIn.get(d.id);
178
+ if (have !== undefined && d.version !== null && d.version > have && !hashes.has((0, scanners_1.hashBody)(body))) {
179
+ console.log(format_1.c.muted(` … ${(0, format_1.truncate)(d.title, 50)}: you have v${have}, upstream is v${d.version} — updates are not followed yet; skipped`));
180
+ skipped++;
181
+ continue;
182
+ }
183
+ if (hashes.has((0, scanners_1.hashBody)(body))) {
184
+ console.log(format_1.c.muted(` … ${(0, format_1.truncate)(d.title, 50)}: already in ${destination} — skipped`));
185
+ skipped++;
186
+ continue;
187
+ }
188
+ details.push(d);
189
+ }
190
+ if (details.length === 0) {
191
+ console.log(format_1.c.success(skipped > 0 ? '\nNothing new to import.' : '\nNothing to import.'));
192
+ return;
193
+ }
194
+ if (signedOut) {
195
+ for (const d of details) {
196
+ const body = (0, format_1.joinPromptParts)(d);
197
+ const slug = (0, importShared_1.freeSlug)(d.title);
198
+ const attribution = attributionLine(spec.owner, d);
199
+ const saved = store.save({
200
+ slug,
201
+ title: d.title,
202
+ description: (0, githubImport_1.buildDescription)(d.description ?? '', attribution),
203
+ tags: [],
204
+ body,
205
+ });
206
+ history.recordIfChanged(slug, { title: saved.title, description: saved.description, tags: saved.tags, body: saved.body }, { note: `Imported from ple:${spec.owner}/${d.repoSlug}/${d.id.slice(0, 8)}${d.version ? ` v${d.version}` : ''}` });
207
+ }
208
+ console.log(format_1.c.success(`✓ Imported ${details.length} prompt${details.length === 1 ? '' : 's'} into ${store.promptsDir()}`));
209
+ console.log(format_1.c.muted('Sign in and run `ple sync` to carry them to your account (history, web, agents).'));
210
+ return;
211
+ }
212
+ const projectId = options.project ? await (0, promptResolver_1.resolveProjectId)(options.project) : undefined;
213
+ const payload = details.map((d) => {
214
+ const body = (0, format_1.joinPromptParts)(d);
215
+ return {
216
+ title: d.title,
217
+ description: (0, githubImport_1.buildDescription)(d.description ?? '', attributionLine(spec.owner, d)),
218
+ content: body,
219
+ origin: {
220
+ tool: 'other',
221
+ kind: 'prompt',
222
+ path: `ple:${spec.owner}/${d.repoSlug}/${d.id}`,
223
+ sha256: (0, scanners_1.hashBody)(body),
224
+ meta: {
225
+ source: 'ple',
226
+ owner: spec.owner,
227
+ repo: d.repoSlug,
228
+ prompt_id: d.id,
229
+ ...(d.version ? { version: String(d.version) } : {}),
230
+ ...(d.license ? { license: d.license } : {}),
231
+ url: `${constants_1.WEB_APP_URL}/${spec.owner}/${d.repoSlug}`,
232
+ },
233
+ },
234
+ };
235
+ });
236
+ await (0, importShared_1.uploadPrompts)(payload, { projectId, retryCommand: `ple import ${(0, format_1.safeText)(source)}` });
237
+ }
@@ -6,6 +6,7 @@
6
6
  * ple repo list
7
7
  * ple repo show <repo>
8
8
  * ple repo visibility <repo> private|public
9
+ * ple repo license <repo> <spdx|none>
9
10
  *
10
11
  * Everything is enforced on the SERVER (session, plan limit, name rules, slug
11
12
  * uniqueness, owner-only visibility); the checks here only give a faster, clearer
@@ -13,12 +14,15 @@
13
14
  * the web app.
14
15
  */
15
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.REPO_LICENSES = void 0;
16
18
  exports.toRepoJson = toRepoJson;
17
19
  exports.explainRepoError = explainRepoError;
18
20
  exports.repoCreateCommand = repoCreateCommand;
19
21
  exports.repoListCommand = repoListCommand;
20
22
  exports.repoShowCommand = repoShowCommand;
21
23
  exports.repoVisibilityCommand = repoVisibilityCommand;
24
+ exports.parseLicense = parseLicense;
25
+ exports.repoLicenseCommand = repoLicenseCommand;
22
26
  const api_client_1 = require("../lib/api-client");
23
27
  const confirm_1 = require("../lib/confirm");
24
28
  const format_1 = require("../lib/format");
@@ -33,6 +37,7 @@ function toRepoJson(r) {
33
37
  slug: r.slug ?? null,
34
38
  description: r.description,
35
39
  visibility: r.visibility,
40
+ license: r.license,
36
41
  role: r.role,
37
42
  prompt_count: r.prompt_count,
38
43
  member_count: r.member_count,
@@ -122,6 +127,7 @@ async function repoShowCommand(ref, options = {}) {
122
127
  row('id', repo.id);
123
128
  row('slug', repo.slug ?? '-');
124
129
  row('visibility', repo.visibility);
130
+ row('license', repo.license ?? 'none declared');
125
131
  row('your role', repo.role);
126
132
  row('prompts', String(repo.prompt_count));
127
133
  row('members', String(repo.member_count));
@@ -169,3 +175,46 @@ async function repoVisibilityCommand(ref, value, options = {}, deps = {}) {
169
175
  }
170
176
  console.log(format_1.c.success(`✓ '${repo.name}' is now ${target}.`));
171
177
  }
178
+ // ---------------------------------------------------------------------------
179
+ /** Same list as the server (src/lib/repo-license.ts) and its database CHECK; the server stays the authority. */
180
+ exports.REPO_LICENSES = ['CC-BY-4.0', 'CC-BY-SA-4.0', 'CC0-1.0', 'MIT', 'Apache-2.0'];
181
+ /** `cc by 4.0`-style spellings are not guessed: the SPDX id, any case, or `none`. Returns null for "clear it". */
182
+ function parseLicense(value) {
183
+ const v = value.trim();
184
+ if (/^(none|null|-|clear)$/i.test(v))
185
+ return null;
186
+ const hit = exports.REPO_LICENSES.find((l) => l.toLowerCase() === v.toLowerCase());
187
+ if (!hit)
188
+ throw new Error(`Unknown license '${v.slice(0, 40)}'. Use one of: ${exports.REPO_LICENSES.join(', ')} — or none to clear it.`);
189
+ return hit;
190
+ }
191
+ async function repoLicenseCommand(ref, value, options = {}) {
192
+ const target = parseLicense(value);
193
+ requireAccount();
194
+ await (0, api_client_1.ensureAuthed)();
195
+ const repo = (0, repoRef_1.resolveRepoRef)(ref, await (0, api_client_1.listProjectsDetailed)());
196
+ if (repo.role !== 'owner') {
197
+ throw new Error(`Only the owner can change a repo's license (your role in '${repo.name}': ${repo.role}).`);
198
+ }
199
+ if ((repo.license ?? null) === target) {
200
+ if (options.json)
201
+ console.log(JSON.stringify({ ok: true, changed: false, repo: toRepoJson(repo) }, null, 2));
202
+ else
203
+ console.log(format_1.c.muted(`'${repo.name}' already has ${target ?? 'no license declared'}. Nothing changed.`));
204
+ return;
205
+ }
206
+ try {
207
+ await (0, api_client_1.setProjectLicense)(repo.id, target);
208
+ }
209
+ catch (err) {
210
+ explainRepoError(err);
211
+ }
212
+ if (options.json) {
213
+ console.log(JSON.stringify({ ok: true, changed: true, repo: toRepoJson({ ...repo, license: target }) }, null, 2));
214
+ return;
215
+ }
216
+ console.log(format_1.c.success(target ? `✓ '${repo.name}' is now licensed ${target}.` : `✓ '${repo.name}' has no license declared now.`));
217
+ if (target && repo.visibility !== 'public') {
218
+ console.log(format_1.c.muted(` The repo is private; the license is shown once it is public: ple repo visibility ${repo.slug ?? (0, format_1.shortId)(repo.id)} public`));
219
+ }
220
+ }
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ /**
3
+ * `ple visibility` — make single prompts public or private.
4
+ *
5
+ * ple visibility <prompt> public|private [--project <repo>] [--yes] [--json]
6
+ * ple visibility --all --project <repo> public|private [--yes] [--json]
7
+ *
8
+ * A prompt page is public only when BOTH the repo and the prompt are public
9
+ * (`ple repo visibility` is the repo half). The server enforces who may change
10
+ * what (owner only); the checks here only give a faster, clearer message.
11
+ * Going private never asks; going public needs a yes (a person, or --yes).
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.visibilityCommand = visibilityCommand;
15
+ const api_client_1 = require("../lib/api-client");
16
+ const confirm_1 = require("../lib/confirm");
17
+ const format_1 = require("../lib/format");
18
+ const promptResolver_1 = require("../lib/promptResolver");
19
+ const repoRef_1 = require("../lib/repoRef");
20
+ const local_1 = require("./local");
21
+ const repo_1 = require("./repo");
22
+ const PAGE = 50;
23
+ const MAX_PAGES = 40;
24
+ function explain(err) {
25
+ if (err instanceof api_client_1.ApiError && err.status === 403)
26
+ throw new Error(`Only the owner can change a prompt's visibility. (${err.message})`);
27
+ return (0, repo_1.explainRepoError)(err);
28
+ }
29
+ async function allPromptsOf(projectId) {
30
+ const out = [];
31
+ for (let page = 1; page <= MAX_PAGES; page++) {
32
+ const batch = await (0, api_client_1.listPrompts)({ projectId, limit: PAGE, page });
33
+ out.push(...batch);
34
+ if (batch.length < PAGE)
35
+ break;
36
+ }
37
+ return out;
38
+ }
39
+ async function approvePublic(question, options, deps) {
40
+ if (options.yes)
41
+ return true;
42
+ const interactive = deps.isTTY ?? Boolean(process.stdin.isTTY && process.stdout.isTTY);
43
+ if (!interactive)
44
+ throw new Error('Making prompts public needs confirmation: re-run with --yes.');
45
+ const ok = await (deps.confirm ?? confirm_1.confirm)(question);
46
+ if (!ok)
47
+ console.log(format_1.c.muted('Cancelled — nothing changed.'));
48
+ return ok;
49
+ }
50
+ async function visibilityCommand(args = [], options = {}, deps = {}) {
51
+ const usage = 'Usage: ple visibility <prompt> public|private or ple visibility --all --project <repo> public|private';
52
+ const expected = options.all ? 1 : 2;
53
+ if (args.length !== expected)
54
+ throw new Error(usage);
55
+ const target = (0, repoRef_1.parseVisibility)(args[args.length - 1]);
56
+ if (options.all && !options.project)
57
+ throw new Error('--all needs --project <repo>. ' + usage);
58
+ if ((0, local_1.isSignedOut)())
59
+ throw new Error('Visibility lives in your account. Sign in first: ple login');
60
+ await (0, api_client_1.ensureAuthed)();
61
+ const repos = await (0, api_client_1.listProjectsDetailed)();
62
+ const repoOf = (projectId) => repos.find((r) => r.id === projectId);
63
+ if (options.all) {
64
+ const repo = (0, repoRef_1.resolveRepoRef)(options.project, repos);
65
+ const prompts = await allPromptsOf(repo.id);
66
+ const todo = prompts.filter((p) => (p.visibility ?? 'private') !== target);
67
+ if (todo.length === 0) {
68
+ if (options.json)
69
+ console.log(JSON.stringify({ ok: true, repo: repo.name, target, changed: 0, unchanged: prompts.length }, null, 2));
70
+ else
71
+ console.log(format_1.c.muted(`All ${prompts.length} prompt${prompts.length === 1 ? '' : 's'} in '${repo.name}' are already ${target}. Nothing changed.`));
72
+ return;
73
+ }
74
+ if (target === 'public') {
75
+ const ok = await approvePublic(`Make ${todo.length} prompt${todo.length === 1 ? '' : 's'} in '${repo.name}' public? Their text becomes readable by anyone once the repo is public too. [y/N] `, options, deps);
76
+ if (!ok)
77
+ return;
78
+ }
79
+ let changed = 0;
80
+ const failed = [];
81
+ for (const p of todo) {
82
+ try {
83
+ await (0, api_client_1.setPromptVisibility)(p.id, target);
84
+ changed++;
85
+ }
86
+ catch (err) {
87
+ failed.push({ id: p.id, title: p.title, error: err instanceof Error ? err.message : String(err) });
88
+ }
89
+ }
90
+ if (options.json) {
91
+ console.log(JSON.stringify({ ok: failed.length === 0, repo: repo.name, target, changed, unchanged: prompts.length - todo.length, failed }, null, 2));
92
+ }
93
+ else {
94
+ console.log(format_1.c.success(`✓ ${changed} prompt${changed === 1 ? '' : 's'} in '${repo.name}' ${changed === 1 ? 'is' : 'are'} now ${target}.`));
95
+ for (const f of failed)
96
+ console.log(format_1.c.warn(` ⚠ ${(0, format_1.shortId)(f.id)} ${f.title}: ${f.error}`));
97
+ if (target === 'public' && repo.visibility !== 'public') {
98
+ console.log(format_1.c.warn(` The repo is still private, so none of this is visible yet: ple repo visibility ${repo.slug ?? (0, format_1.shortId)(repo.id)} public`));
99
+ }
100
+ }
101
+ if (failed.length > 0)
102
+ process.exitCode = 1;
103
+ return;
104
+ }
105
+ const projectId = options.project ? await (0, promptResolver_1.resolveProjectId)(options.project) : undefined;
106
+ const prompt = await (0, promptResolver_1.resolvePromptByName)(args[0], { projectId });
107
+ if (!prompt) {
108
+ process.exitCode = 1;
109
+ return;
110
+ }
111
+ const repo = repoOf(prompt.project_id);
112
+ if ((prompt.visibility ?? 'private') === target) {
113
+ if (options.json)
114
+ console.log(JSON.stringify({ ok: true, changed: false, id: prompt.id, visibility: target }, null, 2));
115
+ else
116
+ console.log(format_1.c.muted(`'${prompt.title}' is already ${target}. Nothing changed.`));
117
+ return;
118
+ }
119
+ if (target === 'public') {
120
+ const ok = await approvePublic(`Make '${prompt.title}' public? Its text becomes readable by anyone once its repo is public too. [y/N] `, options, deps);
121
+ if (!ok)
122
+ return;
123
+ }
124
+ try {
125
+ await (0, api_client_1.setPromptVisibility)(prompt.id, target);
126
+ }
127
+ catch (err) {
128
+ explain(err);
129
+ }
130
+ if (options.json) {
131
+ console.log(JSON.stringify({ ok: true, changed: true, id: prompt.id, title: prompt.title, visibility: target, repo_visibility: repo?.visibility ?? null }, null, 2));
132
+ return;
133
+ }
134
+ console.log(format_1.c.success(`✓ '${prompt.title}' is now ${target}.`));
135
+ if (target === 'public' && repo && repo.visibility !== 'public') {
136
+ console.log(format_1.c.warn(` Its repo '${repo.name}' is private, so the page stays hidden: ple repo visibility ${repo.slug ?? (0, format_1.shortId)(repo.id)} public`));
137
+ }
138
+ }
package/dist/help.js CHANGED
@@ -11,7 +11,7 @@ exports.formatRootHelp = formatRootHelp;
11
11
  const commander_1 = require("commander");
12
12
  exports.COMMAND_GROUPS = [
13
13
  { title: 'Prompts', commands: ['save', 'get', 'show', 'copy', 'list', 'search', 'log', 'diff', 'rollback', 'tag', 'improve', 'loop'] },
14
- { title: 'Repos', commands: ['repo'] },
14
+ { title: 'Repos', commands: ['repo', 'visibility'] },
15
15
  { title: 'Account', commands: ['login', 'logout', 'whoami'] },
16
16
  { title: 'Import / export / sync', commands: ['import', 'export', 'sync'] },
17
17
  { title: 'Insights & settings', commands: ['stats', 'suggest', 'config', 'feedback'] },
@@ -32,6 +32,8 @@ exports.toRepoDetail = toRepoDetail;
32
32
  exports.listProjectsDetailed = listProjectsDetailed;
33
33
  exports.createProject = createProject;
34
34
  exports.setProjectVisibility = setProjectVisibility;
35
+ exports.setProjectLicense = setProjectLicense;
36
+ exports.setPromptVisibility = setPromptVisibility;
35
37
  exports.getPromptById = getPromptById;
36
38
  exports.getPromptHistory = getPromptHistory;
37
39
  exports.rollbackPrompt = rollbackPrompt;
@@ -496,6 +498,7 @@ function toRepoDetail(raw) {
496
498
  slug: typeof r.slug === 'string' ? (0, format_1.safeText)(r.slug) : null,
497
499
  description: typeof r.description === 'string' ? (0, format_1.safeText)(r.description) : null,
498
500
  visibility: r.visibility === 'public' ? 'public' : 'private',
501
+ license: typeof r.license === 'string' ? (0, format_1.safeText)(r.license) : null,
499
502
  role,
500
503
  prompt_count: typeof r.prompt_count === 'number' ? r.prompt_count : 0,
501
504
  member_count: typeof r.member_count === 'number' ? r.member_count : 0,
@@ -532,6 +535,20 @@ async function setProjectVisibility(id, visibility) {
532
535
  body: { visibility },
533
536
  });
534
537
  }
538
+ /** PATCH /api/projects/{id} — declare (or clear, with null) the repo's license; the server allows the owner only. */
539
+ async function setProjectLicense(id, license) {
540
+ await apiFetch(`/api/projects/${encodeURIComponent(id)}`, {
541
+ method: 'PATCH',
542
+ body: { license },
543
+ });
544
+ }
545
+ /** PATCH /api/prompts/{id} — change one prompt's visibility (the server allows the owner only). */
546
+ async function setPromptVisibility(id, visibility) {
547
+ await apiFetch(`/api/prompts/${encodeURIComponent(id)}`, {
548
+ method: 'PATCH',
549
+ body: { visibility },
550
+ });
551
+ }
535
552
  /** GET /api/prompts/{id} — full detail; returns null when not found (404). */
536
553
  async function getPromptById(id) {
537
554
  try {
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ /**
3
+ * `ple import ple:<user>/<repo>[/<prompt>]` — what the argument may look like.
4
+ *
5
+ * ple:zeynepaslierhan/ortak-web every public prompt of the repo
6
+ * ple:zeynepaslierhan/ortak-web/Code Review one prompt: its title, or its id (8+ hex characters)
7
+ *
8
+ * <user> is the handle on promptlikeengineer.com, <repo> its URL slug. Every part is validated before it can
9
+ * reach a URL; anything else is refused with {@link PLE_SPEC_HELP}.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PLE_SPEC_HELP = void 0;
13
+ exports.isPleSource = isPleSource;
14
+ exports.parsePleSpec = parsePleSpec;
15
+ exports.PLE_SPEC_HELP = 'Use ple:<user>/<repo>[/<prompt>], e.g. ple:zeynepaslierhan/ortak-web';
16
+ const USER_RE = /^[A-Za-z0-9_-]{3,40}$/;
17
+ const SLUG_RE = /^[A-Za-z0-9._-]{1,100}$/;
18
+ const CONTROL_RE = /[\u0000-\u001f\u007f-\u009f\\]/;
19
+ function isPleSource(value) {
20
+ return /^ple:/i.test(value.trim());
21
+ }
22
+ function parsePleSpec(raw) {
23
+ const value = raw.trim().replace(/^ple:/i, '');
24
+ const parts = value.split('/');
25
+ const [owner, repo] = parts;
26
+ if (!owner || !repo || !USER_RE.test(owner) || !SLUG_RE.test(repo) || repo === '.' || repo === '..') {
27
+ throw new Error(exports.PLE_SPEC_HELP);
28
+ }
29
+ const prompt = parts.slice(2).join('/').trim();
30
+ if (prompt && (prompt.length > 200 || CONTROL_RE.test(prompt)))
31
+ throw new Error(exports.PLE_SPEC_HELP);
32
+ return { owner, repo, prompt: prompt || null };
33
+ }
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ /**
3
+ * Read-only calls to the PUBLIC endpoints of promptlikeengineer.com (no session, no token is read or sent).
4
+ * Used by `ple import ple:…`, which works signed out. Same rules as the rest of the client: https only (see
5
+ * constants.ts), timeouts, redirects are never followed.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.listPublicRepoPrompts = listPublicRepoPrompts;
9
+ exports.getPublicPrompt = getPublicPrompt;
10
+ const constants_1 = require("./constants");
11
+ const api_client_1 = require("./api-client");
12
+ const format_1 = require("./format");
13
+ async function getJson(path, query = {}) {
14
+ const url = new URL(constants_1.API_BASE_URL + path);
15
+ for (const [k, v] of Object.entries(query))
16
+ url.searchParams.set(k, String(v));
17
+ const signal = AbortSignal.timeout(api_client_1.READ_TIMEOUT_MS);
18
+ let res;
19
+ try {
20
+ res = await fetch(url, { headers: { Accept: 'application/json', 'X-CLI-Version': constants_1.CLI_VERSION }, signal, redirect: 'manual' });
21
+ }
22
+ catch (err) {
23
+ if (signal.aborted)
24
+ throw new api_client_1.RequestTimeoutError(api_client_1.READ_TIMEOUT_MS, 'GET');
25
+ throw new api_client_1.NetworkError(err instanceof Error ? err.message : String(err));
26
+ }
27
+ if (res.status >= 300 && res.status < 400) {
28
+ throw new api_client_1.ApiError(`The server answered with a redirect (HTTP ${res.status}); the CLI does not follow redirects.`, res.status);
29
+ }
30
+ if (res.status === 429)
31
+ throw new api_client_1.ApiError('Rate limited. Try again in a moment.', 429, 'RATE_LIMITED');
32
+ if (!res.ok) {
33
+ let code;
34
+ try {
35
+ code = (await res.json()).code;
36
+ }
37
+ catch {
38
+ /* no JSON body */
39
+ }
40
+ throw new api_client_1.ApiError(`Request failed (${res.status}).`, res.status, code);
41
+ }
42
+ return (await res.json());
43
+ }
44
+ const str = (v) => (typeof v === 'string' ? v : null);
45
+ const clean = (v) => (0, format_1.safeText)(typeof v === 'string' ? v : '');
46
+ /** Every public prompt of `owner` that sits in the public repo whose slug is `repoSlug` (case-insensitive). */
47
+ async function listPublicRepoPrompts(owner, repoSlug) {
48
+ const out = [];
49
+ const PAGE = 50;
50
+ for (let offset = 0; offset < 2000; offset += PAGE) {
51
+ let res;
52
+ try {
53
+ res = await getJson(`/api/public/users/${encodeURIComponent(owner)}/prompts`, { limit: PAGE, offset });
54
+ }
55
+ catch (err) {
56
+ if (err instanceof api_client_1.ApiError && err.status === 404)
57
+ throw new Error(`No public user '${(0, format_1.safeText)(owner)}' on PromptLikeEngineer.`);
58
+ throw err;
59
+ }
60
+ const rows = Array.isArray(res.prompts) ? res.prompts : [];
61
+ for (const r of rows) {
62
+ if (typeof r.prompt_id !== 'string' || str(r.project_slug)?.toLowerCase() !== repoSlug.toLowerCase())
63
+ continue;
64
+ out.push({
65
+ id: r.prompt_id,
66
+ title: clean(r.prompt_title),
67
+ description: str(r.prompt_description) === null ? null : clean(r.prompt_description),
68
+ repoSlug: clean(r.project_slug),
69
+ repoName: clean(r.project_name),
70
+ license: str(r.project_license),
71
+ });
72
+ }
73
+ if (rows.length < PAGE)
74
+ break;
75
+ }
76
+ return out;
77
+ }
78
+ /** One public prompt with the text of its current version. */
79
+ async function getPublicPrompt(owner, card) {
80
+ const res = await getJson(`/api/public/prompts/${encodeURIComponent(owner)}/${encodeURIComponent(card.repoSlug)}/${encodeURIComponent(card.id)}`);
81
+ const p = res.prompt;
82
+ if (!p)
83
+ throw new Error(`The server sent no prompt for '${card.title}'.`);
84
+ return {
85
+ ...card,
86
+ license: str(p.project_license) ?? card.license,
87
+ version: typeof p.version_number === 'number' ? p.version_number : null,
88
+ role_text: str(p.role_text),
89
+ description_text: str(p.description_text),
90
+ context_text: str(p.context_text),
91
+ };
92
+ }
package/dist/program.js CHANGED
@@ -27,6 +27,7 @@ const sync_1 = require("./commands/sync");
27
27
  const export_1 = require("./commands/export");
28
28
  const stats_1 = require("./commands/stats");
29
29
  const import_1 = require("./commands/import");
30
+ const visibility_1 = require("./commands/visibility");
30
31
  const log_1 = require("./commands/log");
31
32
  const diff_1 = require("./commands/diff");
32
33
  const rollback_1 = require("./commands/rollback");
@@ -231,6 +232,20 @@ function buildProgram() {
231
232
  .option('-y, --yes', 'Confirm without asking (required when making a repo public in a script)')
232
233
  .option('--json', 'Print the result as JSON')
233
234
  .action(runWithErrorHandler((ref, value, opts) => (0, repo_1.repoVisibilityCommand)(ref, value, opts)));
235
+ repo.command('license <repo> <value>')
236
+ .description('Declare the license of a repo\'s prompts (owner only): CC-BY-4.0 | CC-BY-SA-4.0 | CC0-1.0 | MIT | Apache-2.0 | none')
237
+ .option('--json', 'Print the result as JSON')
238
+ .action(runWithErrorHandler(repo_1.repoLicenseCommand));
239
+ // ---- visibility of single prompts ---------------------------------------
240
+ program
241
+ .command('visibility [args...]')
242
+ .description('Make one prompt public or private: ple visibility <prompt> public|private (or --all in a repo)')
243
+ .option('--project <repo>', 'Scope the prompt name to this repo; required with --all')
244
+ .option('--all', 'Every prompt in --project: ple visibility --all --project <repo> public')
245
+ .option('-y, --yes', 'Confirm without asking (required when making prompts public in a script)')
246
+ .option('--json', 'Print the result as JSON')
247
+ .addHelpText('after', '\nExamples:\n ple visibility "code review" public --yes\n ple visibility --all --project ortak-web public --yes\n\nA prompt page is public only when the repo AND the prompt are public: see ple repo visibility.')
248
+ .action(runWithErrorHandler(visibility_1.visibilityCommand));
234
249
  // ---- account ------------------------------------------------------------
235
250
  program
236
251
  .command('login')
@@ -256,7 +271,7 @@ function buildProgram() {
256
271
  .action(runWithErrorHandler(sync_1.syncCommand));
257
272
  program
258
273
  .command('import [source]')
259
- .description('Bring in prompts from a public GitHub repo (github:owner/repo) or your agent folders (--scan)')
274
+ .description('Bring in prompts from a public GitHub repo (github:owner/repo), a public PromptLikeEngineer repo (ple:user/repo) or your agent folders (--scan)')
260
275
  .option('--scan', 'Scan this repo and your home folder for agent prompt files')
261
276
  .option('--check', 'Check prompts imported from GitHub for upstream changes')
262
277
  .option('--apply', 'With --check: add the upstream changes as new versions (nothing is overwritten)')
@@ -269,6 +284,8 @@ function buildProgram() {
269
284
  ' ple import github:anthropics/skills --dry-run # what is there, and under which license',
270
285
  ' ple import github:anthropics/skills/skills/pdf # one folder; pick 1,3-5 / all',
271
286
  ' ple import github:owner/repo@v1.2 --all # a tag, branch or commit; no questions',
287
+ ' ple import ple:zeynepaslierhan/ortak-web --dry-run # public prompts of another user, works signed out',
288
+ ' ple import ple:zeynepaslierhan/ortak-web/"Code Review" # one prompt by title or id',
272
289
  ' ple import --check # did anything change on GitHub since?',
273
290
  ' ple import --check --apply # add the changes as new versions',
274
291
  ' ple import --scan --dry-run # prompts already on this machine',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptlike",
3
- "version": "0.11.0",
3
+ "version": "0.12.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"