promptlike 0.5.0 → 0.6.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,40 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.0 — unreleased (2026-09-27)
4
+
5
+ Your library, where you already work.
6
+
7
+ - **New: `ple suggest "<task>"`** — which saved prompt fits this task?
8
+ Matching is local (a cached copy of your library, or `~/.promptlike` when
9
+ signed out); the text never leaves your machine. `--json`, `--limit`.
10
+ `--hook` is the Claude Code `UserPromptSubmit` mode used by the
11
+ promptlike plugin 0.3.0: silent for slash commands, short messages, weak
12
+ matches and repeats within a session; never waits on the network (a stale
13
+ cache refreshes in the background). Turn it off with
14
+ `ple config set suggest off` or `PLE_SUGGEST=off`.
15
+ - **New: `ple config get|set`** — CLI preferences (today: `suggest on|off`),
16
+ kept in `~/.config/promptlike/settings.json` so logging out does not reset them.
17
+ - **New: `ple import --scan`** — bring in the prompts you already keep for your
18
+ agents: `.claude/commands`, `.claude/skills/*/SKILL.md`, `.cursor/commands`,
19
+ `~/.codex/prompts`, `.github/prompts/*.prompt.md`, `AGENTS.md`, `CLAUDE.md`.
20
+ `--dry-run`, pick `1,3-5`, `--all`, `--project`. Re-running never imports
21
+ the same content twice; secrets (`.env*`, keys, files with live tokens) are
22
+ never read or uploaded.
23
+ - **New: `ple log` · `ple diff` · `ple rollback`** — the web's version history in
24
+ the terminal. Unified diff between any two versions (`3`, `v3` or `1.0.2`);
25
+ rollback is non-destructive (the old version is copied forward) and asks
26
+ first (`--yes` for scripts).
27
+ - **New: `ple stats`** — how your library is used: uses by surface (web / CLI /
28
+ agents), most used, not touched in 30 days (Free: 7-day view), plus how many
29
+ suggestions were shown on this machine and picked up.
30
+ - `copy` / `get` / `show` report the surface (`cli`) with each use;
31
+ `PLE_SURFACE` / `PLE_VIA` let a wrapper attribute uses (e.g. the hook).
32
+ - `ple list` / `ple sync` keep the suggestion cache fresh in the background.
33
+ - **Fixed:** `{{constructor}}`, `{{toString}}` and similar names no longer fill
34
+ from JavaScript built-ins when left empty.
35
+
36
+ `ple export` (AGENTS.md / Agent Skills) shipped in 0.5.0.
37
+
3
38
  ## 0.5.0 — 2026-09-27
4
39
 
5
40
  - **New: `ple export`.** Turn a prompt, or a whole repo with `--project`, into
package/README.md CHANGED
@@ -269,6 +269,99 @@ characters. The words "claude" and "anthropic" are removed because Anthropic
269
269
  rejects them in skill names. `{{variables}}` are listed under an **Inputs**
270
270
  heading so the agent knows what to ask for. Existing files are never
271
271
  overwritten without `--force`.
272
+ ### `ple import --scan [--dry-run] [--all] [--project <repo>]`
273
+
274
+ Bring in the prompts you already keep for your agents — no copy-pasting.
275
+ Scans this repo and your home folder:
276
+
277
+ | Tool | Where |
278
+ |---|---|
279
+ | Claude Code | `.claude/commands/**/*.md`, `~/.claude/commands/**/*.md`, `.claude/skills/*/SKILL.md`, `~/.claude/skills/*/SKILL.md` |
280
+ | Cursor | `.cursor/commands/*.md`, `~/.cursor/commands/*.md` |
281
+ | Codex | `~/.codex/prompts/*.md` |
282
+ | Copilot | `.github/prompts/*.prompt.md` |
283
+ | Context | `AGENTS.md`, `CLAUDE.md` (repo root) |
284
+
285
+ ```bash
286
+ ple import --scan --dry-run # what was found: tool, title, size, path
287
+ ple import --scan # pick: 1,3-5 / all / Enter to cancel
288
+ ple import --scan --all # everything new, no questions
289
+ ```
290
+
291
+ - Frontmatter `description` / `tags` / `name` become the prompt's fields; the
292
+ body is what gets imported.
293
+ - Re-running is safe: the same content (sha256) is never imported twice.
294
+ - Signed out → your local store (`~/.promptlike`); signed in → your account.
295
+ - Never read: `.env*`, `*.key`, `*.pem`, `credentials*`, SSH keys, files over
296
+ 64 KB. A file that looks like it contains a live token (`sk-…`, `AKIA…`,
297
+ `ghp_…`, private keys …) is skipped and named so you can clean it up.
298
+
299
+ ### `ple log <name>` · `ple diff <name> [a] [b]` · `ple rollback <name> <version>`
300
+
301
+ The version history you have on the web, in the terminal (signed in).
302
+
303
+ ```bash
304
+ ple log "code review" # v5 1.0.4 rollback 2h ago … (* = current)
305
+ ple diff "code review" # previous ↔ current, unified diff
306
+ ple diff "code review" 2 5 # any two: 3, v3 or 1.0.2
307
+ ple diff "code review" 2 | delta # plain when piped (or --no-color)
308
+ ple rollback "code review" v2 # asks first; --yes for scripts
309
+ ```
310
+
311
+ Rollback is non-destructive: the old version is copied forward as a new one,
312
+ nothing is deleted — so a rollback can itself be undone.
313
+
314
+ ### `ple stats [--range 7|30|365] [--json]`
315
+
316
+ How your library is actually used — the same numbers as the web Insights
317
+ page: uses in the window, where they came from (web / CLI / agents), the most
318
+ used prompts and the ones not touched in 30 days. Free shows a 7-day view;
319
+ asking for more says so instead of silently shrinking the window.
320
+
321
+ ```bash
322
+ $ ple stats --range 30
323
+ ```
324
+
325
+ Every `ple copy/get/show` records one use with `surface: cli`. A wrapper can
326
+ attribute uses differently with `PLE_SURFACE` (e.g. `hook`) and
327
+ `PLE_VIA=suggestion`; unknown values fall back to `cli`.
328
+
329
+ ### `ple suggest "<task>" [--json] [--limit <n>] [--hook]`
330
+
331
+ Which of your saved prompts fits what you are about to do? Matching is
332
+ **local**: a cached copy of your library (`~/.config/promptlike/cache/`,
333
+ refreshed by `ple list` / `ple sync` and in the background every 10 minutes),
334
+ or `~/.promptlike` when you are signed out. The text you type never leaves
335
+ your machine.
336
+
337
+ ```bash
338
+ $ ple suggest "review this pull request for security issues"
339
+ Code Review ai-os · used 12× · score 7.4
340
+ Review a diff for bugs, style and security
341
+
342
+ Use one: ple get "Code Review"
343
+ ```
344
+
345
+ Ranking: title ×3, tag ×2, description ×1, the first 600 characters of the
346
+ body ×0.5, weighted by how rare each word is in your library, plus a small
347
+ bonus for prompts you use a lot. Weak single-word matches are not suggested.
348
+
349
+ `--hook` is what the Claude Code plugin runs on every message
350
+ (`UserPromptSubmit`). It reads the hook's JSON from stdin and prints one short
351
+ note — or nothing: slash commands, messages under 20 characters, weak
352
+ matches and prompts already suggested in the session stay silent. It never
353
+ waits on the network and gives up after 0.8 s.
354
+
355
+ Turn suggestions off with `ple config set suggest off`, `PLE_SUGGEST=off`, or
356
+ the plugin option in Claude Code's `/config`. How many were shown is counted
357
+ on this machine only (`ple stats`); the server only learns about a suggestion
358
+ when one is actually used.
359
+
360
+ ### `ple config get [key]` · `ple config set <key> <value>`
361
+
362
+ CLI preferences, stored in `~/.config/promptlike/settings.json` (separate from
363
+ the session file, so logging out keeps them). Today there is one key:
364
+ `suggest` (`on` | `off`).
272
365
 
273
366
  ### `ple --help` / `ple <cmd> --help`
274
367
 
@@ -282,6 +375,8 @@ sub-command.
282
375
  | Path | Purpose | Permissions |
283
376
  |---|---|---|
284
377
  | `~/.config/promptlike/config.json` | Local session token storage | `0600` |
378
+ | `~/.config/promptlike/settings.json` | Preferences (`ple config`) | `0600` |
379
+ | `~/.config/promptlike/cache/library.json` | Library snapshot for `ple suggest` (titles, descriptions, tags, first 600 chars) | `0600` |
285
380
 
286
381
  Shape of the config file:
287
382
 
@@ -312,6 +407,12 @@ ple list
312
407
  That URL is the only backend detail the CLI knows — there is no Supabase key
313
408
  to configure.
314
409
 
410
+ | Variable | Effect |
411
+ |---|---|
412
+ | `PLE_SUGGEST=off` | `ple suggest --hook` stays silent |
413
+ | `PLE_SURFACE`, `PLE_VIA` | How `copy/get/show` report a use (e.g. `hook`, `suggestion`) |
414
+ | `PROMPTLIKE_HOME` | Local store location (default `~/.promptlike`) |
415
+
315
416
  ---
316
417
 
317
418
  ## How it works
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ /**
3
+ * `ple config get [key]` · `ple config set <key> <value>` — CLI preferences.
4
+ *
5
+ * Keys: `suggest` (on|off) — whether `ple suggest --hook` (the Claude Code
6
+ * plugin hook) may add a saved-prompt hint to your messages.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.configGetCommand = configGetCommand;
10
+ exports.configSetCommand = configSetCommand;
11
+ const format_1 = require("../lib/format");
12
+ const settings_1 = require("../lib/settings");
13
+ function assertKey(key) {
14
+ const k = key.trim().toLowerCase();
15
+ if (settings_1.SETTING_KEYS.includes(k))
16
+ return k;
17
+ throw new Error(`Unknown setting '${key}'. Available: ${settings_1.SETTING_KEYS.join(', ')}.`);
18
+ }
19
+ async function configGetCommand(key) {
20
+ const settings = (0, settings_1.readSettings)();
21
+ const keys = key ? [assertKey(key)] : [...settings_1.SETTING_KEYS];
22
+ for (const k of keys) {
23
+ if (k === 'suggest') {
24
+ const stored = settings.suggest ?? 'on';
25
+ const effective = (0, settings_1.suggestEnabled)() ? 'on' : 'off';
26
+ const note = stored !== effective ? format_1.c.muted(' (off via PLE_SUGGEST or the Claude Code plugin option)') : '';
27
+ console.log(`suggest ${effective}${note}`);
28
+ }
29
+ }
30
+ }
31
+ async function configSetCommand(key, value) {
32
+ const k = assertKey(key);
33
+ const settings = (0, settings_1.readSettings)();
34
+ if (k === 'suggest')
35
+ settings.suggest = (0, settings_1.parseOnOff)(value);
36
+ (0, settings_1.writeSettings)(settings);
37
+ console.log(format_1.c.success(`✓ ${k} = ${settings[k]}`));
38
+ if (k === 'suggest' && settings.suggest === 'off') {
39
+ console.log(format_1.c.muted(' The Claude Code hook stays silent now. Turn it back on: ple config set suggest on'));
40
+ }
41
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ /**
3
+ * `ple diff <name> [a] [b]` — unified diff between two versions (W1-4).
4
+ *
5
+ * Defaults: no refs → previous ↔ current; one ref → that ↔ current.
6
+ * Refs: `3`, `v3` (version number) or `1.0.2` (semver). Colored on a TTY,
7
+ * plain when piped or with `--no-color` (chalk honours both).
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.diffCommand = diffCommand;
11
+ const api_client_1 = require("../lib/api-client");
12
+ const format_1 = require("../lib/format");
13
+ const diff_1 = require("../lib/diff");
14
+ const history_1 = require("./history");
15
+ function label(title, v) {
16
+ return `${title} v${v.version_number} (${(0, history_1.semverOf)(v)})`;
17
+ }
18
+ async function diffCommand(name, a, b, options = {}) {
19
+ const prompt = await (0, history_1.resolveForHistory)(name, options.project);
20
+ if (!prompt) {
21
+ process.exitCode = 1;
22
+ return;
23
+ }
24
+ const history = await (0, api_client_1.getPromptHistory)(prompt.id);
25
+ const current = (0, history_1.currentVersion)(history);
26
+ if (!current)
27
+ throw new Error(`'${history.title}' has no versions yet.`);
28
+ let to;
29
+ let from;
30
+ if (a && b) {
31
+ from = (0, history_1.findVersion)(history.versions, a) ?? (() => { throw (0, history_1.versionNotFound)(a, history.versions); })();
32
+ to = (0, history_1.findVersion)(history.versions, b) ?? (() => { throw (0, history_1.versionNotFound)(b, history.versions); })();
33
+ }
34
+ else if (a) {
35
+ from = (0, history_1.findVersion)(history.versions, a) ?? (() => { throw (0, history_1.versionNotFound)(a, history.versions); })();
36
+ to = current;
37
+ }
38
+ else {
39
+ to = current;
40
+ const older = (0, history_1.sortNewestFirst)(history.versions).find((v) => v.version_number < current.version_number);
41
+ if (!older) {
42
+ console.log(format_1.c.muted(`'${history.title}' has a single version — nothing to compare yet.`));
43
+ return;
44
+ }
45
+ from = older;
46
+ }
47
+ const useColor = options.color !== false && format_1.c.success.level > 0;
48
+ const lines = (0, diff_1.unifiedDiff)((0, format_1.joinPromptParts)(from), (0, format_1.joinPromptParts)(to), {
49
+ fromLabel: label(history.title, from),
50
+ toLabel: label(history.title, to),
51
+ colors: useColor ? { header: format_1.c.title, hunk: format_1.c.accent, add: format_1.c.success, del: format_1.c.error } : undefined,
52
+ });
53
+ if (lines.length === 0) {
54
+ console.log(format_1.c.muted(`v${from.version_number} and v${to.version_number} have identical content.`));
55
+ return;
56
+ }
57
+ for (const line of lines)
58
+ console.log(line);
59
+ }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ /**
3
+ * Shared helpers for `ple log`, `ple diff`, `ple rollback` (W1-4).
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.HISTORY_NEEDS_ACCOUNT = void 0;
7
+ exports.semverOf = semverOf;
8
+ exports.sortNewestFirst = sortNewestFirst;
9
+ exports.findVersion = findVersion;
10
+ exports.currentVersion = currentVersion;
11
+ exports.resolveForHistory = resolveForHistory;
12
+ exports.versionNotFound = versionNotFound;
13
+ const api_client_1 = require("../lib/api-client");
14
+ const promptResolver_1 = require("../lib/promptResolver");
15
+ const local_1 = require("./local");
16
+ exports.HISTORY_NEEDS_ACCOUNT = 'Version history lives in your account — local prompts keep no versions. Run `ple login`, then `ple sync`.';
17
+ /** "1.2.3" from the semver columns, else release_tag, else "v<n>". */
18
+ function semverOf(v) {
19
+ if (v.major_version != null && v.minor_version != null && v.patch_version != null) {
20
+ return `${v.major_version}.${v.minor_version}.${v.patch_version}`;
21
+ }
22
+ return v.release_tag || `v${v.version_number}`;
23
+ }
24
+ /** Newest first, by version_number (the API already orders; do not trust it blindly). */
25
+ function sortNewestFirst(versions) {
26
+ return [...versions].sort((a, b) => b.version_number - a.version_number);
27
+ }
28
+ /**
29
+ * Find a version by a user-typed ref: `3`, `v3`, `#3` (version number) or
30
+ * `1.0.2` (semver). Returns null when nothing matches.
31
+ */
32
+ function findVersion(versions, ref) {
33
+ const r = ref.trim().toLowerCase();
34
+ const num = r.match(/^[v#]?(\d+)$/);
35
+ if (num) {
36
+ const n = Number(num[1]);
37
+ return versions.find((v) => v.version_number === n) ?? null;
38
+ }
39
+ const sem = r.replace(/^v/, '');
40
+ if (/^\d+\.\d+\.\d+$/.test(sem)) {
41
+ return versions.find((v) => semverOf(v) === sem) ?? null;
42
+ }
43
+ return null;
44
+ }
45
+ function currentVersion(history) {
46
+ const sorted = sortNewestFirst(history.versions);
47
+ return history.versions.find((v) => v.id === history.current_version_id) ?? sorted[0] ?? null;
48
+ }
49
+ /** Signed-in guard + name/--project resolution. Returns null when unresolved (message already printed). */
50
+ async function resolveForHistory(name, project) {
51
+ if ((0, local_1.isSignedOut)()) {
52
+ (0, local_1.noteIgnoredProject)(project);
53
+ throw new Error(exports.HISTORY_NEEDS_ACCOUNT);
54
+ }
55
+ await (0, api_client_1.ensureAuthed)();
56
+ const projectId = project ? await (0, promptResolver_1.resolveProjectId)(project) : undefined;
57
+ const prompt = await (0, promptResolver_1.resolvePromptByName)(name, { projectId });
58
+ return prompt ? { id: prompt.id, title: prompt.title } : null;
59
+ }
60
+ function versionNotFound(ref, versions) {
61
+ const known = sortNewestFirst(versions).slice(0, 8).map((v) => `v${v.version_number}`).join(', ');
62
+ return new Error(`No version '${ref}'. Known: ${known}${versions.length > 8 ? ', …' : ''} — see \`ple log\`.`);
63
+ }
@@ -0,0 +1,250 @@
1
+ "use strict";
2
+ /**
3
+ * `ple import --scan` — bring the prompts you already keep on disk into PLE
4
+ * (W1-2 — strategy F15, "activation = investment").
5
+ *
6
+ * ple import --scan --dry-run # preview: tool, path, title, size, status
7
+ * ple import --scan # preview + pick (1,3-5 / all)
8
+ * ple import --scan --all # no questions (scripts, agents)
9
+ * ple import --scan --project api # into one repo
10
+ *
11
+ * Signed out → the local store (local-first, same as `ple save`).
12
+ * Signed in → the account, with provenance so a re-run skips what already
13
+ * came in (sha256 of the body; the server double-checks).
14
+ *
15
+ * Nothing is read that the secret guard refuses (see lib/secretGuard.ts), and
16
+ * nothing is uploaded without either an explicit pick or `--all`.
17
+ */
18
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ var desc = Object.getOwnPropertyDescriptor(m, k);
21
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
22
+ desc = { enumerable: true, get: function() { return m[k]; } };
23
+ }
24
+ Object.defineProperty(o, k2, desc);
25
+ }) : (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ o[k2] = m[k];
28
+ }));
29
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
30
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
31
+ }) : function(o, v) {
32
+ o["default"] = v;
33
+ });
34
+ var __importStar = (this && this.__importStar) || (function () {
35
+ var ownKeys = function(o) {
36
+ ownKeys = Object.getOwnPropertyNames || function (o) {
37
+ var ar = [];
38
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
39
+ return ar;
40
+ };
41
+ return ownKeys(o);
42
+ };
43
+ return function (mod) {
44
+ if (mod && mod.__esModule) return mod;
45
+ var result = {};
46
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
47
+ __setModuleDefault(result, mod);
48
+ return result;
49
+ };
50
+ })();
51
+ Object.defineProperty(exports, "__esModule", { value: true });
52
+ exports.parseSelection = parseSelection;
53
+ exports.importCommand = importCommand;
54
+ const readline = __importStar(require("readline"));
55
+ const store = __importStar(require("../lib/localStore"));
56
+ const api_client_1 = require("../lib/api-client");
57
+ const promptResolver_1 = require("../lib/promptResolver");
58
+ const scanners_1 = require("../lib/scanners");
59
+ const local_1 = require("./local");
60
+ const format_1 = require("../lib/format");
61
+ const constants_1 = require("../lib/constants");
62
+ /** The import endpoint caps one request at 50 records. */
63
+ const BATCH = 50;
64
+ /**
65
+ * Parse a pick like `1,3-5`, `all`, or empty (cancel). Returns 0-based
66
+ * indices, `null` for cancel; throws on anything out of range or malformed.
67
+ */
68
+ function parseSelection(input, count) {
69
+ const v = input.trim().toLowerCase();
70
+ if (v === '' || v === 'q' || v === 'n' || v === 'none')
71
+ return null;
72
+ if (v === 'a' || v === 'all' || v === '*')
73
+ return Array.from({ length: count }, (_, i) => i);
74
+ const picked = new Set();
75
+ for (const part of v.split(/[\s,]+/).filter(Boolean)) {
76
+ const range = part.match(/^(\d+)-(\d+)$/);
77
+ const single = part.match(/^(\d+)$/);
78
+ if (range) {
79
+ const a = Number(range[1]);
80
+ const b = Number(range[2]);
81
+ if (a < 1 || b > count || a > b)
82
+ throw new Error(`'${part}' is out of range (1-${count}).`);
83
+ for (let i = a; i <= b; i++)
84
+ picked.add(i - 1);
85
+ }
86
+ else if (single) {
87
+ const n = Number(single[1]);
88
+ if (n < 1 || n > count)
89
+ throw new Error(`'${part}' is out of range (1-${count}).`);
90
+ picked.add(n - 1);
91
+ }
92
+ else {
93
+ throw new Error(`Could not read '${part}'. Use numbers like 1,3-5 or 'all'.`);
94
+ }
95
+ }
96
+ return [...picked].sort((x, y) => x - y);
97
+ }
98
+ function formatSize(bytes) {
99
+ return bytes < 1024 ? `${bytes} B` : `${(bytes / 1024).toFixed(1)} KB`;
100
+ }
101
+ function defaultAsk(question) {
102
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
103
+ return new Promise((resolve) => {
104
+ rl.question(question, (answer) => {
105
+ rl.close();
106
+ resolve(answer);
107
+ });
108
+ });
109
+ }
110
+ /** Local slug that does not overwrite a different existing prompt. */
111
+ function freeSlug(title) {
112
+ const base = store.slugify(title.replace(/[/\\:]+/g, '-'));
113
+ let slug = base;
114
+ for (let n = 2; store.exists(slug); n++)
115
+ slug = `${base}-${n}`;
116
+ return slug;
117
+ }
118
+ function toImportable(cand) {
119
+ return {
120
+ title: cand.title,
121
+ description: cand.description || undefined,
122
+ content: cand.body,
123
+ tags: cand.tags,
124
+ origin: {
125
+ tool: cand.tool,
126
+ kind: cand.kind,
127
+ path: cand.displayPath,
128
+ sha256: cand.sha256,
129
+ ...(Object.keys(cand.meta).length > 0 ? { meta: cand.meta } : {}),
130
+ },
131
+ };
132
+ }
133
+ async function importCommand(options = {}, deps = {}) {
134
+ if (!options.scan) {
135
+ throw new Error('Nothing to import. Use `ple import --scan` to find prompts in your agent folders.');
136
+ }
137
+ const signedOut = (0, local_1.isSignedOut)();
138
+ const destination = signedOut ? 'your local store' : 'your account';
139
+ const result = (0, scanners_1.scanAgentFiles)(deps.scan);
140
+ // What is already there: account → provenance hashes; local → body hashes.
141
+ let known;
142
+ if (signedOut) {
143
+ known = new Set(store.list().map((p) => (0, scanners_1.hashBody)(p.body)));
144
+ }
145
+ else {
146
+ await (0, api_client_1.ensureAuthed)();
147
+ known = await (0, api_client_1.getImportedHashes)();
148
+ }
149
+ const fresh = result.candidates.filter((cand) => !known.has(cand.sha256));
150
+ const already = result.candidates.length - fresh.length;
151
+ if (result.candidates.length === 0 && result.skipped.length === 0) {
152
+ console.log(format_1.c.muted('No agent prompt files found here or in your home folder.'));
153
+ console.log(format_1.c.muted('Looked in .claude/commands, .claude/skills, .cursor/commands, ~/.codex/prompts, .github/prompts, AGENTS.md, CLAUDE.md.'));
154
+ return;
155
+ }
156
+ console.log(format_1.c.title(`Found ${result.candidates.length} prompt file${result.candidates.length === 1 ? '' : 's'}`) +
157
+ format_1.c.muted(` → ${destination}`));
158
+ fresh.forEach((cand, i) => {
159
+ console.log(` ${format_1.c.accent(String(i + 1).padStart(3))} ${cand.tool.padEnd(11)} ${cand.kind.padEnd(7)} ` +
160
+ `${(0, format_1.truncate)(cand.title, 40).padEnd(40)} ${format_1.c.muted(formatSize(cand.bytes).padStart(8))} ${format_1.c.muted(cand.displayPath)}`);
161
+ });
162
+ if (already > 0) {
163
+ console.log(format_1.c.muted(` … and ${already} already imported (same content) — skipped`));
164
+ }
165
+ if (result.duplicates.length > 0) {
166
+ console.log(format_1.c.muted(` … ${result.duplicates.length} identical cop${result.duplicates.length === 1 ? 'y' : 'ies'} in another folder — counted once`));
167
+ }
168
+ for (const s of result.skipped) {
169
+ console.log(format_1.c.warn(` ⚠ ${s.displayPath}: ${s.reason}`));
170
+ }
171
+ if (fresh.length === 0) {
172
+ console.log(format_1.c.success('\nNothing new to import.'));
173
+ return;
174
+ }
175
+ if (options.dryRun) {
176
+ console.log(format_1.c.muted(`\nDry run — nothing imported. Run \`ple import --scan\` to pick, or add --all.`));
177
+ return;
178
+ }
179
+ let selected;
180
+ if (options.all) {
181
+ selected = fresh;
182
+ }
183
+ else {
184
+ const interactive = deps.isTTY ?? Boolean(process.stdin.isTTY && process.stdout.isTTY);
185
+ if (!interactive) {
186
+ console.log(format_1.c.muted(`\nNot a terminal — re-run with --all to import these ${fresh.length}, or --dry-run to only look.`));
187
+ return;
188
+ }
189
+ const answer = await (deps.ask ?? defaultAsk)(`\nImport which? [all | 1,3-5 | Enter to cancel]: `);
190
+ const picked = parseSelection(answer, fresh.length);
191
+ if (!picked || picked.length === 0) {
192
+ console.log(format_1.c.muted('Cancelled — nothing imported.'));
193
+ return;
194
+ }
195
+ selected = picked.map((i) => fresh[i]);
196
+ }
197
+ if (signedOut) {
198
+ for (const cand of selected) {
199
+ store.save({ slug: freeSlug(cand.title), title: cand.title, description: cand.description, tags: cand.tags, body: cand.body });
200
+ }
201
+ console.log(format_1.c.success(`✓ Imported ${selected.length} prompt${selected.length === 1 ? '' : 's'} into ${store.promptsDir()}`));
202
+ console.log(format_1.c.muted('Sign in and run `ple sync` to carry them to your account (history, web, agents).'));
203
+ return;
204
+ }
205
+ const projectId = options.project ? await (0, promptResolver_1.resolveProjectId)(options.project) : undefined;
206
+ // Say the plan limit out loud BEFORE uploading, not after a partial result.
207
+ const headroom = await (0, api_client_1.getAccountHeadroom)();
208
+ if (headroom.promptsRemaining !== null && selected.length > headroom.promptsRemaining) {
209
+ console.log(format_1.c.warn(`Your plan has room for ${headroom.promptsRemaining} more prompt${headroom.promptsRemaining === 1 ? '' : 's'}; ` +
210
+ `the first ${headroom.promptsRemaining} of ${selected.length} will be imported.`));
211
+ }
212
+ const payload = selected.map(toImportable);
213
+ let imported = 0;
214
+ let skippedDuplicate = 0;
215
+ let truncatedByQuota = 0;
216
+ let failed = 0;
217
+ let abortMessage = null;
218
+ for (let i = 0; i < payload.length; i += BATCH) {
219
+ try {
220
+ const res = await (0, api_client_1.importPrompts)(payload.slice(i, i + BATCH), {
221
+ source: 'import',
222
+ projectId,
223
+ fallbackToExistingProject: !projectId,
224
+ });
225
+ imported += res.imported;
226
+ skippedDuplicate += res.skippedDuplicate;
227
+ truncatedByQuota += res.truncatedByQuota;
228
+ failed += res.failed + res.skippedInvalid;
229
+ }
230
+ catch (err) {
231
+ abortMessage = err instanceof Error ? err.message : String(err);
232
+ truncatedByQuota += payload.length - i;
233
+ break;
234
+ }
235
+ }
236
+ console.log(format_1.c.success(`✓ Imported ${imported} prompt${imported === 1 ? '' : 's'} into your account`));
237
+ if (skippedDuplicate > 0)
238
+ console.log(format_1.c.muted(` ${skippedDuplicate} already there — skipped`));
239
+ if (abortMessage)
240
+ console.log(format_1.c.warn(`⚠ Stopped early: ${abortMessage}`));
241
+ if (truncatedByQuota > 0) {
242
+ console.log(format_1.c.warn(`⚠ ${truncatedByQuota} not imported — plan prompt limit reached.`));
243
+ console.log(format_1.c.muted(` Start the 14-day Pro trial to bring the rest: ${constants_1.WEB_APP_URL}/pricing`));
244
+ console.log(format_1.c.muted(' Then run `ple import --scan` again — what already came in is skipped.'));
245
+ }
246
+ if (failed > 0)
247
+ console.log(format_1.c.warn(`⚠ ${failed} failed. Re-run \`ple import --scan\` to retry those.`));
248
+ if (imported > 0)
249
+ console.log(format_1.c.muted(`Open them at ${constants_1.WEB_APP_URL}/dashboard or \`ple list\`.`));
250
+ }
@@ -5,6 +5,7 @@ const api_client_1 = require("../lib/api-client");
5
5
  const local_1 = require("./local");
6
6
  const constants_1 = require("../lib/constants");
7
7
  const format_1 = require("../lib/format");
8
+ const libraryCache_1 = require("../lib/libraryCache");
8
9
  /**
9
10
  * `ple list [--tag X] [--limit N]` — list the user's prompts.
10
11
  *
@@ -21,6 +22,9 @@ async function listCommand(options) {
21
22
  }
22
23
  await (0, api_client_1.ensureAuthed)();
23
24
  const prompts = await (0, api_client_1.listPrompts)({ tag: options.tag, limit });
25
+ // Keep the suggestion cache (W1-5) in step with the account — detached,
26
+ // at most once a minute, never slows this command down.
27
+ (0, libraryCache_1.startBackgroundRefresh)();
24
28
  if (prompts.length === 0) {
25
29
  if (options.tag) {
26
30
  console.log(format_1.c.muted(`No prompts matched tag '${options.tag}'.`));
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ /**
3
+ * `ple log <name>` — version history in the terminal (W1-4).
4
+ *
5
+ * v5 1.0.4 rollback 2h ago Rolled back to v2
6
+ * * marks the current version.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.logCommand = logCommand;
10
+ const api_client_1 = require("../lib/api-client");
11
+ const format_1 = require("../lib/format");
12
+ const history_1 = require("./history");
13
+ async function logCommand(name, options = {}) {
14
+ const prompt = await (0, history_1.resolveForHistory)(name, options.project);
15
+ if (!prompt) {
16
+ process.exitCode = 1;
17
+ return;
18
+ }
19
+ const history = await (0, api_client_1.getPromptHistory)(prompt.id);
20
+ const limit = Math.max(1, Math.min(Number.parseInt(options.limit ?? '20', 10) || 20, 100));
21
+ const versions = (0, history_1.sortNewestFirst)(history.versions).slice(0, limit);
22
+ if (options.json) {
23
+ console.log(JSON.stringify(versions.map((v) => ({
24
+ version: v.version_number,
25
+ semver: (0, history_1.semverOf)(v),
26
+ source: v.source ?? null,
27
+ created_at: v.created_at,
28
+ changelog: v.changelog ?? null,
29
+ current: v.id === history.current_version_id,
30
+ })), null, 2));
31
+ return;
32
+ }
33
+ console.log(format_1.c.title(history.title) + format_1.c.muted(` ${history.versions.length} version${history.versions.length === 1 ? '' : 's'}`));
34
+ if (versions.length === 0) {
35
+ console.log(format_1.c.muted(' No versions yet.'));
36
+ return;
37
+ }
38
+ for (const v of versions) {
39
+ const mark = v.id === history.current_version_id ? format_1.c.success('*') : ' ';
40
+ console.log(`${mark} ${format_1.c.accent(`v${v.version_number}`.padEnd(5))} ${(0, history_1.semverOf)(v).padEnd(9)} ` +
41
+ `${format_1.c.muted((v.source ?? '').padEnd(9))} ${format_1.c.muted((0, format_1.timeAgo)(v.created_at).padEnd(8))} ` +
42
+ (0, format_1.truncate)((v.changelog ?? '').replace(/\s+/g, ' '), 60));
43
+ }
44
+ if (history.versions.length > versions.length) {
45
+ console.log(format_1.c.muted(` … ${history.versions.length - versions.length} older (use --limit)`));
46
+ }
47
+ console.log(format_1.c.muted(`\nCompare: ple diff "${history.title}" <a> <b> · Restore: ple rollback "${history.title}" <version>`));
48
+ }