promptlike 0.6.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.0 — 2026-10-15
4
+
5
+ - **Local version history (no account needed):** `ple save` now keeps an
6
+ append-only history under `~/.promptlike/history/<name>/` (`v0001.md`, …). A
7
+ save adds a version only when the prompt text changed. Signed out, `ple log`,
8
+ `ple diff [a] [b]` and `ple rollback <name> <version>` work on it instead of
9
+ saying "local prompts keep no versions". Rollback adds the old text as a new
10
+ version ("Restored vX as a new version. Nothing was deleted."); the CLI never
11
+ overwrites or deletes a version and there is no limit. These commands make no
12
+ network requests (covered by a test). Signed in, the three commands are
13
+ unchanged and still use the account history. `ple sync` uploads each prompt's
14
+ current text only; the local history is not uploaded.
15
+ - **Docs:** README describes the local history; the claim that the local store
16
+ keeps no versions is removed.
17
+
18
+ ## 0.6.3 — 2026-10-13
19
+
20
+ - **Package metadata:** `repository` and `bugs` now point to the public plugin repository
21
+ (github.com/zeynepaslierhann/promptlike-plugin), which is where issues can be filed. No code change.
22
+ - **Docs (npm page):** the README no longer calls the CLI "open source" or invites pull
23
+ requests: the source is not public, the npm package is MIT-licensed. It no longer lists
24
+ the Chrome extension (not published) among what a free account adds, says that Free
25
+ holds up to 3 versions of each prompt (the 4th save asks you to upgrade), and gives feedback by email or on the plugin
26
+ repository. Maintainer notes (development, publishing) moved out of the README into
27
+ `DEVELOPMENT.md`, which is not part of the package. "Scope / V2" no longer says the CLI
28
+ cannot create prompts (`ple save` does).
29
+
3
30
  ## 0.6.2 — 2026-10-12
4
31
 
5
32
  - **Fix:** a network problem while your session is being refreshed (no DNS,
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # promptlike (ple)
2
2
 
3
- > Your personal prompt library in the terminal. Open source CLI for PromptLikeEngineer.
3
+ > Your personal prompt library in the terminal. The CLI for PromptLikeEngineer (MIT-licensed npm package).
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/promptlike.svg)](https://www.npmjs.com/package/promptlike)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
@@ -20,9 +20,9 @@ diffable, and yours. Nothing leaves your machine until you ask it to.
20
20
 
21
21
  **Signing in is the upgrade, not the door.** A free
22
22
  [promptlikeengineer.com](https://promptlikeengineer.com) account adds version
23
- history with diff and rollback, the web editor, the Chrome extension, and the
24
- same library inside any MCP client. Bring your local prompts up with one
25
- explicit command:
23
+ history with diff and rollback (Free holds up to 3 versions of each prompt; the 4th save asks you to upgrade),
24
+ the web editor, and the same library in Claude Code and other MCP clients.
25
+ Bring your local prompts up with one explicit command:
26
26
 
27
27
  ```bash
28
28
  ple login
@@ -39,11 +39,9 @@ ple sync # one-way, local → account; local files are kept
39
39
  3. [Commands](#commands)
40
40
  4. [Configuration](#configuration)
41
41
  5. [How it works](#how-it-works)
42
- 6. [Development](#development)
43
- 7. [Publishing a new version](#publishing-a-new-version)
44
- 8. [Troubleshooting](#troubleshooting)
45
- 9. [Contributing](#contributing)
46
- 10. [License](#license)
42
+ 6. [Troubleshooting](#troubleshooting)
43
+ 7. [Feedback](#feedback)
44
+ 8. [License](#license)
47
45
 
48
46
  ---
49
47
 
@@ -96,9 +94,10 @@ $ ple save "code review" -m "Review this diff: {{diff}}" -t review
96
94
  $ pbpaste | ple save "bug triage" # or pipe it in
97
95
  ```
98
96
 
99
- Saving over an existing prompt needs `--force`, because the local store keeps
100
- no version history. Tags and the description you do not repeat are carried
101
- over rather than wiped.
97
+ Saving over an existing prompt needs `--force`. Tags and the description you do
98
+ not repeat are carried over rather than wiped. Every save that changes the text
99
+ also adds a version to a local, append-only history (see
100
+ [Local version history](#local-version-history-signed-out)).
102
101
 
103
102
  ### `ple sync [--dry-run]`
104
103
 
@@ -311,6 +310,36 @@ ple rollback "code review" v2 # asks first; --yes for scripts
311
310
  Rollback is non-destructive: the old version is copied forward as a new one,
312
311
  nothing is deleted — so a rollback can itself be undone.
313
312
 
313
+ #### Local version history (signed out)
314
+
315
+ Without an account the same three commands work on a history kept on your
316
+ machine, in `~/.promptlike/history/<name>/v0001.md`, `v0002.md`, … (the same
317
+ Markdown format as your prompts, so you can read, grep and commit it).
318
+
319
+ ```bash
320
+ ple save "code review" -m "Review this diff: {{diff}}" # v1
321
+ ple save "code review" -m "Review this diff, be strict" --force # v2
322
+ ple log "code review" # newest first, * = current
323
+ ple diff "code review" # previous ↔ current (same unified format)
324
+ ple diff "code review" 1 2 # any two: 1, v1 or #1
325
+ ple rollback "code review" v1 # asks first; --yes for scripts
326
+ # ✓ Restored v1 as a new version. Nothing was deleted.
327
+ ```
328
+
329
+ - A save adds a version only when the prompt text changed. Title, description
330
+ and tags are stored with each version, but only a change to the text creates one.
331
+ - Append-only: version files are never overwritten or deleted by the CLI and
332
+ there is no limit on how many are kept. A rollback adds a new version, so it
333
+ can be undone with another rollback. Rollback restores the text; the current
334
+ title, description and tags stay.
335
+ - A prompt that existed before you updated has no history yet; the first
336
+ `ple save --force` over it records the text that was on disk as v1 first.
337
+ A file you edited by hand is recorded the same way before a rollback.
338
+ - No network access: these commands only read and write files under
339
+ `~/.promptlike` (`PROMPTLIKE_HOME` moves it). `--project` is ignored signed out.
340
+ - `ple sync` uploads the current text of each prompt. The version history is
341
+ not uploaded and stays local.
342
+
314
343
  ### `ple stats [--range 7|30|365] [--json]`
315
344
 
316
345
  How your library is actually used — the same numbers as the web Insights
@@ -448,134 +477,6 @@ to configure.
448
477
 
449
478
  ---
450
479
 
451
- ## Development
452
-
453
- The CLI lives in the `cli/` directory of the PromptLikeEngineer monorepo.
454
-
455
- ```bash
456
- cd PromptLikeEngineer/cli
457
- npm install
458
- npm run dev # tsc --watch
459
- node dist/index.js list # or `npm link` then `ple list`
460
-
461
- # point the CLI at a local API while developing
462
- PROMPTLIKE_API_URL=http://localhost:3000 node dist/index.js list
463
- ```
464
-
465
- ### Scripts
466
-
467
- | Script | What it does |
468
- |---|---|
469
- | `npm run build` | Compiles TS → `dist/`, marks `dist/index.js` executable |
470
- | `npm run dev` | `tsc --watch` for live rebuilds |
471
- | `npm run typecheck` | `tsc --noEmit` |
472
- | `npm run clean` | Removes `dist/` |
473
-
474
- ### Project layout
475
-
476
- ```
477
- cli/
478
- ├── src/
479
- │ ├── index.ts # commander dispatcher + global error handler
480
- │ ├── commands/ # one file per command, async default export
481
- │ │ ├── login.ts # masked password prompt + api login
482
- │ │ ├── logout.ts # delete config file
483
- │ │ ├── list.ts # list with --tag / --limit
484
- │ │ ├── copy.ts # resolve + fetch + clipboard
485
- │ │ ├── show.ts # resolve + 3-part colored render
486
- │ │ ├── search.ts # title + description search
487
- │ │ ├── save.ts # write to local store, no account needed
488
- │ │ ├── get.ts # resolve + fill {{vars}} + print/copy
489
- │ │ ├── sync.ts # one-way upload: local store → account
490
- │ │ ├── improve.ts # one-shot variants, pick a winner
491
- │ │ ├── loop.ts # multi-round improve judged by --exec
492
- │ │ └── local.ts # logged-out routing + local-store implementations
493
- │ └── lib/
494
- │ ├── constants.ts # API_BASE_URL + WEB_APP_URL
495
- │ ├── config.ts # read/write ~/.config/promptlike/config.json
496
- │ ├── api-client.ts # fetch wrapper: bearer auth, refresh, error mapping
497
- │ ├── clipboard.ts # spawn(pbcopy/xclip/clip) + Wayland fallback
498
- │ ├── format.ts # chalk palette, timeAgo, truncate, joinPromptParts
499
- │ ├── promptResolver.ts # name → prompt (id prefix or title search)
500
- │ ├── promptVariables.ts # {{variable}} extract + fill
501
- │ ├── localStore.ts # ~/.promptlike/prompts/ Markdown read/write
502
- │ └── loopApi.ts / loopUx.ts # loop + improve variant generation & prompts
503
- └── dist/ # tsc output, what gets published
504
- ```
505
-
506
- ### Adding a new command
507
-
508
- 1. Create `src/commands/<name>.ts`, `export async function`.
509
- 2. If it needs auth, call `await ensureAuthed()` from `../lib/api-client`
510
- (throws a clear "log in" message + refreshes a soon-to-expire token), then
511
- call the typed api-client helpers (`listPrompts`, `getPromptById`, …).
512
- 3. Wire it up in `src/index.ts` with `program.command('<name>')` + the
513
- `runWithErrorHandler` wrapper for consistent error output.
514
- 4. `npm run build` and try it locally.
515
-
516
- ### Self-contained
517
-
518
- The CLI defines its own minimal types (in `lib/api-client.ts`) and does not
519
- depend on the repo's `shared/types/` — it talks to the web API purely over
520
- HTTP, so there is no type-sync step for the CLI.
521
-
522
- ---
523
-
524
- ## Publishing a new version
525
-
526
- Publishing is automated: pushing a `cli-v*` git tag runs the
527
- `.github/workflows/cli-publish.yml` workflow, which typechecks, tests, builds,
528
- and runs `npm publish --access public`.
529
-
530
- Auth is **npm Trusted Publishing (OIDC)** — no token. npm verifies via OpenID
531
- Connect that this exact repo + workflow is the package's configured trusted
532
- publisher (npmjs.com/package/promptlike → Settings → Trusted Publisher:
533
- `zeynepaslierhann` / `PromptLikeEngineer` / `cli-publish.yml`). The workflow
534
- needs `permissions: id-token: write` and npm >= 11.5.1 (the runner upgrades npm
535
- on Node 22), which the current workflow already sets.
536
-
537
- This CLI lives in a monorepo, so bump the version **without** letting `npm`
538
- create its own tag/commit, then push a `cli-v<version>` tag whose number
539
- matches `package.json` exactly. Run everything from the repo root:
540
-
541
- ```bash
542
- # 1. Bump cli/package.json only (no auto tag, no auto commit)
543
- npm --prefix cli version patch --no-git-tag-version # or minor / major
544
-
545
- # 2. Commit the bump (grab the new number from cli/package.json)
546
- git add cli/package.json cli/package-lock.json
547
- git commit -m "chore(cli): v0.2.1"
548
- git push origin main
549
-
550
- # 3. Tag that commit — the tag push is what triggers publishing
551
- git tag cli-v0.2.1
552
- git push origin cli-v0.2.1
553
- ```
554
-
555
- Rules the automation relies on:
556
-
557
- - The tag number **must** equal `cli/package.json#version` (npm rejects a
558
- mismatch, and a version can never be published twice).
559
- - Push the tag on its own (`git push origin cli-v0.2.1`), **not**
560
- `git push --tags` — that would also push any stray local tags.
561
- - If the run fails on the test step, nothing is published (publish runs last);
562
- fix, move the tag to the new commit (`git tag -d` + delete remote + re-tag),
563
- and push again.
564
-
565
- To publish manually instead (only if CI is unavailable):
566
-
567
- ```bash
568
- cd cli
569
- npm run build
570
- npm publish --dry-run # verify only dist/, README.md, LICENSE ship
571
- npm publish --access public # requires npm login + 2FA OTP
572
- ```
573
-
574
- `package.json#files` and `.npmignore` keep `src/`, `tsconfig.json`, and tests
575
- out of the published tarball — only `dist/`, `LICENSE`, and `README.md` ship.
576
-
577
- ---
578
-
579
480
  ## Troubleshooting
580
481
 
581
482
  | Symptom | Cause | Fix |
@@ -595,9 +496,9 @@ out of the published tarball — only `dist/`, `LICENSE`, and `README.md` ship.
595
496
 
596
497
  ## Scope / V2
597
498
 
598
- What this CLI does **not** do yet (PRs welcome):
499
+ What this CLI does **not** do yet:
599
500
 
600
- - Create / edit / delete prompts (read + copy only — write paths live on the web)
501
+ - Delete prompts (`ple save` creates and updates; deleting is done on the web)
601
502
  - `ple search` over version body (`content`); needs a server-side full-text index
602
503
  - `--project <name>` filter on `ple list`
603
504
  - Interactive picker (think `fzf`-style)
@@ -605,21 +506,19 @@ What this CLI does **not** do yet (PRs welcome):
605
506
 
606
507
  ---
607
508
 
608
- ## Contributing
509
+ ## Feedback
609
510
 
610
- The CLI is open source — bug reports, feature requests, and pull requests are
611
- welcome.
511
+ Bug reports and feature requests: email
512
+ [zeynepaslierhan@gmail.com](mailto:zeynepaslierhan@gmail.com) or open an issue on
513
+ [github.com/zeynepaslierhann/promptlike-plugin](https://github.com/zeynepaslierhann/promptlike-plugin/issues).
514
+ For a bug, include the command you ran, the error, your OS, and your Node version.
515
+ Check [Scope / V2](#scope--v2) before asking for a feature.
612
516
 
613
- - **Bugs:** open an issue with the command you ran, the error, your OS, and
614
- Node version.
615
- - **Features:** check [Scope / V2](#scope--v2) first; if it's there, mention
616
- the issue you're picking up.
617
- - **Code style:** TypeScript strict, no `any`, no `@ts-ignore`. Keep new
618
- modules small and single-purpose (`src/lib/<thing>.ts`).
517
+ The `promptlike` and `promptlike-mcp` npm packages are MIT-licensed. The
518
+ PromptLikeEngineer web app they talk to is a hosted product owned by Zeynep Aslı
519
+ Erhan; its source is not public.
619
520
 
620
- The web dashboard and Chrome extension that this CLI talks to are *not* open
621
- source — they're proprietary products owned by Zeynep Aslı Erhan. Only the
622
- CLI in this directory falls under MIT.
521
+ Website: <https://promptlikeengineer.com/?utm_source=npm&utm_medium=readme&utm_campaign=ple_dist>
623
522
 
624
523
  ---
625
524
 
@@ -11,11 +11,15 @@ exports.diffCommand = diffCommand;
11
11
  const api_client_1 = require("../lib/api-client");
12
12
  const format_1 = require("../lib/format");
13
13
  const diff_1 = require("../lib/diff");
14
+ const localHistory_1 = require("./localHistory");
15
+ const local_1 = require("./local");
14
16
  const history_1 = require("./history");
15
17
  function label(title, v) {
16
18
  return `${title} v${v.version_number} (${(0, history_1.semverOf)(v)})`;
17
19
  }
18
20
  async function diffCommand(name, a, b, options = {}) {
21
+ if ((0, local_1.isSignedOut)())
22
+ return (0, localHistory_1.localDiff)(name, a, b, options);
19
23
  const prompt = await (0, history_1.resolveForHistory)(name, options.project);
20
24
  if (!prompt) {
21
25
  process.exitCode = 1;
@@ -3,7 +3,6 @@
3
3
  * Shared helpers for `ple log`, `ple diff`, `ple rollback` (W1-4).
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.HISTORY_NEEDS_ACCOUNT = void 0;
7
6
  exports.semverOf = semverOf;
8
7
  exports.sortNewestFirst = sortNewestFirst;
9
8
  exports.findVersion = findVersion;
@@ -12,8 +11,6 @@ exports.resolveForHistory = resolveForHistory;
12
11
  exports.versionNotFound = versionNotFound;
13
12
  const api_client_1 = require("../lib/api-client");
14
13
  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
14
  /** "1.2.3" from the semver columns, else release_tag, else "v<n>". */
18
15
  function semverOf(v) {
19
16
  if (v.major_version != null && v.minor_version != null && v.patch_version != null) {
@@ -48,10 +45,6 @@ function currentVersion(history) {
48
45
  }
49
46
  /** Signed-in guard + name/--project resolution. Returns null when unresolved (message already printed). */
50
47
  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
48
  await (0, api_client_1.ensureAuthed)();
56
49
  const projectId = project ? await (0, promptResolver_1.resolveProjectId)(project) : undefined;
57
50
  const prompt = await (0, promptResolver_1.resolvePromptByName)(name, { projectId });
@@ -42,6 +42,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
42
42
  exports.isSignedOut = isSignedOut;
43
43
  exports.noteIgnoredProject = noteIgnoredProject;
44
44
  exports.emptyHint = emptyHint;
45
+ exports.resolveOrExplain = resolveOrExplain;
45
46
  exports.localList = localList;
46
47
  exports.localShow = localShow;
47
48
  exports.localGet = localGet;
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+ /**
3
+ * Signed-out `ple log` / `ple diff` / `ple rollback` — over the local,
4
+ * append-only history (lib/localHistory.ts). No network, ever.
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.localLog = localLog;
41
+ exports.localDiff = localDiff;
42
+ exports.localRollback = localRollback;
43
+ const readline = __importStar(require("readline"));
44
+ const store = __importStar(require("../lib/localStore"));
45
+ const history = __importStar(require("../lib/localHistory"));
46
+ const format_1 = require("../lib/format");
47
+ const diff_1 = require("../lib/diff");
48
+ const local_1 = require("./local");
49
+ function versionNotFound(ref, versions) {
50
+ const known = [...versions].reverse().slice(0, 8).map((v) => `v${v.version}`).join(', ');
51
+ return new Error(`No version '${ref}'. Known: ${known || 'none'}${versions.length > 8 ? ', …' : ''} — see \`ple log\`.`);
52
+ }
53
+ /** Tell the user when the file on disk was edited outside `ple` (not in history yet). */
54
+ function noteUnrecorded(p, latest) {
55
+ if (latest && latest.body.trim() !== p.body.trim()) {
56
+ console.error(format_1.c.muted(`(The file on disk differs from v${latest.version} — it was edited outside ple. ` +
57
+ `Run \`ple save "${p.slug}" --force\` or a rollback to record it.)`));
58
+ }
59
+ }
60
+ function localLog(name, options) {
61
+ (0, local_1.noteIgnoredProject)(options.project);
62
+ const p = (0, local_1.resolveOrExplain)(name);
63
+ if (!p)
64
+ return;
65
+ const all = history.listVersions(p.slug);
66
+ const limit = Math.max(1, Math.min(Number.parseInt(options.limit ?? '20', 10) || 20, 100));
67
+ const shown = [...all].reverse().slice(0, limit);
68
+ const currentNo = all.length > 0 ? all[all.length - 1].version : null;
69
+ if (options.json) {
70
+ console.log(JSON.stringify(shown.map((v) => ({
71
+ version: v.version,
72
+ created_at: v.saved,
73
+ note: v.note || null,
74
+ current: v.version === currentNo,
75
+ })), null, 2));
76
+ return;
77
+ }
78
+ console.log(format_1.c.title(p.title) + format_1.c.muted(` ${all.length} version${all.length === 1 ? '' : 's'} (local)`));
79
+ if (shown.length === 0) {
80
+ console.log(format_1.c.muted(' No versions yet — the next `ple save` records one.'));
81
+ return;
82
+ }
83
+ for (const v of shown) {
84
+ const mark = v.version === currentNo ? format_1.c.success('*') : ' ';
85
+ console.log(`${mark} ${format_1.c.accent(`v${v.version}`.padEnd(5))} ${format_1.c.muted((0, format_1.timeAgo)(v.saved).padEnd(8))} ` +
86
+ (0, format_1.truncate)(v.note.replace(/\s+/g, ' '), 60));
87
+ }
88
+ if (all.length > shown.length) {
89
+ console.log(format_1.c.muted(` … ${all.length - shown.length} older (use --limit)`));
90
+ }
91
+ noteUnrecorded(p, all.length > 0 ? all[all.length - 1] : null);
92
+ console.log(format_1.c.muted(`\nCompare: ple diff "${p.slug}" <a> <b> · Restore: ple rollback "${p.slug}" <version>`));
93
+ }
94
+ function localDiff(name, a, b, options) {
95
+ (0, local_1.noteIgnoredProject)(options.project);
96
+ const p = (0, local_1.resolveOrExplain)(name);
97
+ if (!p)
98
+ return;
99
+ const versions = history.listVersions(p.slug);
100
+ const current = versions[versions.length - 1];
101
+ if (!current)
102
+ throw new Error(`'${p.title}' has no versions yet — the next \`ple save\` records one.`);
103
+ let from;
104
+ let to;
105
+ const need = (ref) => history.findVersion(versions, ref) ?? (() => { throw versionNotFound(ref, versions); })();
106
+ if (a && b) {
107
+ from = need(a);
108
+ to = need(b);
109
+ }
110
+ else if (a) {
111
+ from = need(a);
112
+ to = current;
113
+ }
114
+ else {
115
+ to = current;
116
+ const older = versions[versions.length - 2];
117
+ if (!older) {
118
+ console.log(format_1.c.muted(`'${p.title}' has a single version — nothing to compare yet.`));
119
+ return;
120
+ }
121
+ from = older;
122
+ }
123
+ const useColor = options.color !== false && format_1.c.success.level > 0;
124
+ const lines = (0, diff_1.unifiedDiff)(from.body, to.body, {
125
+ fromLabel: `${p.title} v${from.version}`,
126
+ toLabel: `${p.title} v${to.version}`,
127
+ colors: useColor ? { header: format_1.c.title, hunk: format_1.c.accent, add: format_1.c.success, del: format_1.c.error } : undefined,
128
+ });
129
+ if (lines.length === 0) {
130
+ console.log(format_1.c.muted(`v${from.version} and v${to.version} have identical content.`));
131
+ return;
132
+ }
133
+ for (const line of lines)
134
+ console.log(line);
135
+ }
136
+ function defaultConfirm(question) {
137
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
138
+ return new Promise((resolve) => {
139
+ rl.question(question, (answer) => {
140
+ rl.close();
141
+ resolve(/^y(es)?$/i.test(answer.trim()));
142
+ });
143
+ });
144
+ }
145
+ async function localRollback(name, ref, options, deps = {}) {
146
+ (0, local_1.noteIgnoredProject)(options.project);
147
+ const p = (0, local_1.resolveOrExplain)(name);
148
+ if (!p)
149
+ return;
150
+ // Anything edited outside ple is recorded first, so a rollback can never
151
+ // hide the text it replaces.
152
+ history.recordIfChanged(p.slug, { title: p.title, description: p.description, tags: p.tags, body: p.body }, { onDisk: null, note: 'Edited outside ple' });
153
+ const versions = history.listVersions(p.slug);
154
+ const target = history.findVersion(versions, ref);
155
+ if (!target)
156
+ throw versionNotFound(ref, versions);
157
+ const current = versions[versions.length - 1];
158
+ if (current && current.body.trim() === target.body.trim()) {
159
+ console.log(format_1.c.muted(`v${target.version} is already the current content — nothing to do.`));
160
+ return;
161
+ }
162
+ if (!options.yes) {
163
+ const interactive = deps.isTTY ?? Boolean(process.stdin.isTTY && process.stdout.isTTY);
164
+ if (!interactive) {
165
+ throw new Error('Refusing to roll back without confirmation. Re-run with --yes.');
166
+ }
167
+ const ok = await (deps.confirm ?? defaultConfirm)(`Restore '${p.title}' to v${target.version}? This adds a new version; nothing is deleted. [y/N] `);
168
+ if (!ok) {
169
+ console.log(format_1.c.muted('Cancelled.'));
170
+ return;
171
+ }
172
+ }
173
+ // Body is restored; the title, description and tags you have now are kept.
174
+ const saved = store.save({ slug: p.slug, title: p.title, description: p.description, tags: p.tags, body: target.body });
175
+ const created = history.recordIfChanged(p.slug, { title: saved.title, description: saved.description, tags: saved.tags, body: saved.body }, { onDisk: null, note: `Restored from v${target.version}` });
176
+ console.log(format_1.c.success(`✓ Restored v${target.version} as a new version. Nothing was deleted.`) + format_1.c.muted(` — ${p.title}`));
177
+ if (created)
178
+ console.log(format_1.c.muted(` now at v${created.version}`));
179
+ console.log(format_1.c.muted(`Undo with: ple rollback "${p.slug}" v${current.version}`));
180
+ }
@@ -9,8 +9,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.logCommand = logCommand;
10
10
  const api_client_1 = require("../lib/api-client");
11
11
  const format_1 = require("../lib/format");
12
+ const localHistory_1 = require("./localHistory");
13
+ const local_1 = require("./local");
12
14
  const history_1 = require("./history");
13
15
  async function logCommand(name, options = {}) {
16
+ if ((0, local_1.isSignedOut)())
17
+ return (0, localHistory_1.localLog)(name, options);
14
18
  const prompt = await (0, history_1.resolveForHistory)(name, options.project);
15
19
  if (!prompt) {
16
20
  process.exitCode = 1;
@@ -44,6 +44,8 @@ exports.rollbackCommand = rollbackCommand;
44
44
  const readline = __importStar(require("readline"));
45
45
  const api_client_1 = require("../lib/api-client");
46
46
  const format_1 = require("../lib/format");
47
+ const localHistory_1 = require("./localHistory");
48
+ const local_1 = require("./local");
47
49
  const history_1 = require("./history");
48
50
  function defaultConfirm(question) {
49
51
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
@@ -55,6 +57,8 @@ function defaultConfirm(question) {
55
57
  });
56
58
  }
57
59
  async function rollbackCommand(name, ref, options = {}, deps = {}) {
60
+ if ((0, local_1.isSignedOut)())
61
+ return (0, localHistory_1.localRollback)(name, ref, options, deps);
58
62
  const prompt = await (0, history_1.resolveForHistory)(name, options.project);
59
63
  if (!prompt) {
60
64
  process.exitCode = 1;
@@ -46,6 +46,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
46
46
  exports.collectTag = collectTag;
47
47
  exports.saveCommand = saveCommand;
48
48
  const store = __importStar(require("../lib/localStore"));
49
+ const history = __importStar(require("../lib/localHistory"));
49
50
  const format_1 = require("../lib/format");
50
51
  const promptVariables_1 = require("../lib/promptVariables");
51
52
  /**
@@ -120,7 +121,8 @@ async function saveCommand(title, options = {}) {
120
121
  const slug = store.slugify(cleanTitle);
121
122
  const previous = store.read(slug);
122
123
  // Overwriting someone's prompt silently is the one unrecoverable thing this
123
- // command could do — the local store keeps no versions. Farklı başlıklar
124
+ // command could do — the old text is kept in the local history
125
+ // (lib/localHistory.ts), but --force stays an explicit step. Farklı başlıklar
124
126
  // aynı slug'a inebilir ("a/b" ve "a:b" → "ab"); mesaj bu yüzden mevcut
125
127
  // kaydın GERÇEK başlığını söyler, kullanıcının hiç yazmadığı slug'ı değil.
126
128
  if (previous && !options.force) {
@@ -131,12 +133,15 @@ async function saveCommand(title, options = {}) {
131
133
  }
132
134
  // On --force, fields the user did not re-specify are CARRIED OVER.
133
135
  // Overwriting the body must not silently wipe tags and the description —
134
- // the local store keeps no versions, so that loss is unrecoverable.
136
+ // the prompt file itself is replaced (the old body survives in the history).
135
137
  const tags = options.tag && options.tag.length > 0 ? options.tag : (previous?.tags ?? []);
136
138
  const description = options.description?.trim() ?? previous?.description ?? '';
137
139
  const saved = store.save({ slug, title: cleanTitle, description, tags, body });
140
+ const version = history.recordIfChanged(slug, { title: saved.title, description: saved.description, tags: saved.tags, body: saved.body }, { onDisk: previous ? { title: previous.title, description: previous.description, tags: previous.tags, body: previous.body } : null });
138
141
  console.log(format_1.c.success(`✓ Saved: ${saved.title}`) + format_1.c.muted(` (${saved.slug})`));
139
142
  console.log(format_1.c.muted(` ${store.filePath(saved.slug)}`));
143
+ if (version)
144
+ console.log(format_1.c.muted(` version: v${version.version} (history: ple log "${saved.slug}")`));
140
145
  const vars = (0, promptVariables_1.extractVariables)(saved.body);
141
146
  if (vars.length > 0) {
142
147
  console.log(format_1.c.muted(` variables: ${vars.map((v) => `{{${v}}}`).join(', ')}`));
@@ -8,8 +8,8 @@
8
8
  * someone asks for it.
9
9
  *
10
10
  * One-way (local → account) on purpose. Pulling the account library down would
11
- * need conflict rules the local store cannot express — it keeps no versions —
12
- * and a half-correct merge silently losing an edit is worse than no pull.
11
+ * need conflict rules the local store cannot express (the local history is
12
+ * a private, append-only log, not a mergeable one) and a half-correct merge silently losing an edit is worse than no pull.
13
13
  */
14
14
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15
15
  if (k2 === undefined) k2 = k;
@@ -47,6 +47,7 @@ var __importStar = (this && this.__importStar) || (function () {
47
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
48
  exports.syncCommand = syncCommand;
49
49
  const store = __importStar(require("../lib/localStore"));
50
+ const history = __importStar(require("../lib/localHistory"));
50
51
  const api_client_1 = require("../lib/api-client");
51
52
  const format_1 = require("../lib/format");
52
53
  const libraryCache_1 = require("../lib/libraryCache");
@@ -131,4 +132,5 @@ async function syncCommand(options = {}) {
131
132
  // would duplicate, so say so rather than letting someone find out.
132
133
  console.log(format_1.c.muted(`\nLocal files kept in ${store.promptsDir()} (sync copies, it does not move).`));
133
134
  console.log(format_1.c.muted('Re-running would upload them again — delete the local copies first if that is not what you want.'));
135
+ console.log(format_1.c.muted(`Only the current text of each prompt is uploaded; the local version history stays in ${history.historyRoot()}.`));
134
136
  }
package/dist/index.js CHANGED
@@ -137,7 +137,7 @@ program
137
137
  .action(runWithErrorHandler((opts) => (0, import_1.importCommand)(opts)));
138
138
  program
139
139
  .command('log <name>')
140
- .description('Version history of a prompt (* = current)')
140
+ .description('Version history of a prompt (* = current). Signed out: the local history')
141
141
  .option('--project <repo>', 'Scope to one repo (name, slug, or id) when titles collide')
142
142
  .option('-l, --limit <n>', 'Max versions to show (default 20)', '20')
143
143
  .option('--json', 'Print as JSON')
@@ -169,7 +169,7 @@ configCmd
169
169
  .action(runWithErrorHandler(config_1.configSetCommand));
170
170
  program
171
171
  .command('rollback <name> <version>')
172
- .description('Restore an old version as a new one — nothing is deleted')
172
+ .description('Restore an old version as a new one — nothing is deleted (signed out: local history)')
173
173
  .option('--project <repo>', 'Scope to one repo (name, slug, or id) when titles collide')
174
174
  .option('-y, --yes', 'Skip the confirmation prompt')
175
175
  .action(runWithErrorHandler((name, version, opts) => (0, rollback_1.rollbackCommand)(name, version, opts)));
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ /**
3
+ * Local, append-only version history — `~/.promptlike/history/<slug>/v0001.md`.
4
+ *
5
+ * WHY: signed out, `ple save --force` used to overwrite a prompt for good. The
6
+ * account has versions; the local store now keeps its own, so `ple log`,
7
+ * `ple diff` and `ple rollback` work without an account.
8
+ *
9
+ * RULES (deliberate, and covered by tests):
10
+ * - Append-only. Files are created with the exclusive flag (`wx`), so nothing
11
+ * here ever overwrites or deletes a version. There is no limit and no pruning.
12
+ * - A new version is written only when the prompt BODY changed.
13
+ * - Rollback never rewrites history: the old body becomes a NEW version.
14
+ * - Nothing here touches the network.
15
+ *
16
+ * Each version file is the same Markdown+frontmatter shape as the prompt store
17
+ * (greppable, diffable), plus `version:`, `saved:` and an optional `note:`.
18
+ */
19
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ var desc = Object.getOwnPropertyDescriptor(m, k);
22
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
23
+ desc = { enumerable: true, get: function() { return m[k]; } };
24
+ }
25
+ Object.defineProperty(o, k2, desc);
26
+ }) : (function(o, m, k, k2) {
27
+ if (k2 === undefined) k2 = k;
28
+ o[k2] = m[k];
29
+ }));
30
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
31
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
32
+ }) : function(o, v) {
33
+ o["default"] = v;
34
+ });
35
+ var __importStar = (this && this.__importStar) || (function () {
36
+ var ownKeys = function(o) {
37
+ ownKeys = Object.getOwnPropertyNames || function (o) {
38
+ var ar = [];
39
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
40
+ return ar;
41
+ };
42
+ return ownKeys(o);
43
+ };
44
+ return function (mod) {
45
+ if (mod && mod.__esModule) return mod;
46
+ var result = {};
47
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
48
+ __setModuleDefault(result, mod);
49
+ return result;
50
+ };
51
+ })();
52
+ Object.defineProperty(exports, "__esModule", { value: true });
53
+ exports.historyRoot = historyRoot;
54
+ exports.historyDir = historyDir;
55
+ exports.listVersions = listVersions;
56
+ exports.latestVersion = latestVersion;
57
+ exports.recordIfChanged = recordIfChanged;
58
+ exports.findVersion = findVersion;
59
+ const fs = __importStar(require("fs"));
60
+ const path = __importStar(require("path"));
61
+ const store = __importStar(require("./localStore"));
62
+ function historyRoot() {
63
+ return path.join(store.localRoot(), 'history');
64
+ }
65
+ function historyDir(slug) {
66
+ return path.join(historyRoot(), slug);
67
+ }
68
+ function versionFile(slug, n) {
69
+ return path.join(historyDir(slug), `v${String(n).padStart(4, '0')}.md`);
70
+ }
71
+ function oneLine(v) {
72
+ return v.replace(/\r?\n/g, ' ').trim();
73
+ }
74
+ function parseVersion(n, raw, slug) {
75
+ const p = store.parse(slug, raw);
76
+ const header = raw.startsWith('---') ? raw.slice(3, Math.max(raw.indexOf('\n---', 3), 3)) : '';
77
+ const note = header.match(/^note:[ \t]*(.*)$/m);
78
+ return {
79
+ version: n,
80
+ saved: p.updated,
81
+ note: note ? note[1].trim() : '',
82
+ title: p.title,
83
+ description: p.description,
84
+ tags: p.tags,
85
+ body: p.body,
86
+ };
87
+ }
88
+ /** All versions, oldest first. Unreadable files are skipped, never fatal. */
89
+ function listVersions(slug) {
90
+ const dir = historyDir(slug);
91
+ if (!fs.existsSync(dir))
92
+ return [];
93
+ const out = [];
94
+ for (const f of fs.readdirSync(dir)) {
95
+ const m = f.match(/^v(\d+)\.md$/);
96
+ if (!m)
97
+ continue;
98
+ try {
99
+ out.push(parseVersion(Number(m[1]), fs.readFileSync(path.join(dir, f), 'utf-8'), slug));
100
+ }
101
+ catch {
102
+ /* a damaged file must not hide the rest of the history */
103
+ }
104
+ }
105
+ return out.sort((a, b) => a.version - b.version);
106
+ }
107
+ function latestVersion(slug) {
108
+ const all = listVersions(slug);
109
+ return all.length > 0 ? all[all.length - 1] : null;
110
+ }
111
+ /** Append one version. Never overwrites: on a number clash it takes the next one. */
112
+ function append(slug, snap, note) {
113
+ const dir = historyDir(slug);
114
+ fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
115
+ const saved = new Date().toISOString();
116
+ const base = store.serialize({ slug, ...snap, created: saved, updated: saved });
117
+ const extra = [`version: __N__`, `saved: ${saved}`, ...(note ? [`note: ${oneLine(note)}`] : [])];
118
+ let n = (latestVersion(slug)?.version ?? 0) + 1;
119
+ for (;;) {
120
+ const text = base.replace(/^---\n/, `---\n${extra.join('\n').replace('__N__', String(n))}\n`);
121
+ try {
122
+ fs.writeFileSync(versionFile(slug, n), text, { flag: 'wx', mode: 0o600 });
123
+ return parseVersion(n, text, slug);
124
+ }
125
+ catch (err) {
126
+ if (err.code !== 'EEXIST')
127
+ throw err;
128
+ n++; // another process got there first — never overwrite
129
+ }
130
+ }
131
+ }
132
+ const same = (a, b) => a.trim() === b.trim();
133
+ /**
134
+ * Record `current` as a new version if its body differs from the newest one.
135
+ * First contact with a prompt that already exists on disk but has no history
136
+ * (saved before this feature) records what is on disk FIRST, so the text about
137
+ * to be overwritten is not lost. Returns the version written, or null.
138
+ */
139
+ function recordIfChanged(slug, current, options = {}) {
140
+ let latest = latestVersion(slug);
141
+ if (!latest && options.onDisk && options.onDisk.body.trim()) {
142
+ latest = append(slug, options.onDisk, '');
143
+ }
144
+ if (latest && same(latest.body, current.body))
145
+ return null;
146
+ if (!current.body.trim())
147
+ return null;
148
+ return append(slug, current, options.note ?? '');
149
+ }
150
+ /** Resolve `3`, `v3` or `#3`. */
151
+ function findVersion(versions, ref) {
152
+ const m = ref.trim().toLowerCase().match(/^[v#]?(\d+)$/);
153
+ if (!m)
154
+ return null;
155
+ return versions.find((v) => v.version === Number(m[1])) ?? null;
156
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptlike",
3
- "version": "0.6.2",
3
+ "version": "0.7.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"
@@ -40,6 +40,13 @@
40
40
  },
41
41
  "license": "MIT",
42
42
  "homepage": "https://promptlikeengineer.com",
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git+https://github.com/zeynepaslierhann/promptlike-plugin.git"
46
+ },
47
+ "bugs": {
48
+ "url": "https://github.com/zeynepaslierhann/promptlike-plugin/issues"
49
+ },
43
50
  "publishConfig": {
44
51
  "access": "public"
45
52
  },