promptlike 0.2.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/LICENSE +21 -0
- package/README.md +422 -0
- package/dist/commands/copy.js +40 -0
- package/dist/commands/get.js +75 -0
- package/dist/commands/improve.js +53 -0
- package/dist/commands/list.js +36 -0
- package/dist/commands/login.js +105 -0
- package/dist/commands/logout.js +18 -0
- package/dist/commands/loop.js +83 -0
- package/dist/commands/search.js +35 -0
- package/dist/commands/show.js +62 -0
- package/dist/index.js +85 -0
- package/dist/lib/api-client.js +192 -0
- package/dist/lib/clipboard.js +70 -0
- package/dist/lib/config.js +91 -0
- package/dist/lib/constants.js +28 -0
- package/dist/lib/format.js +70 -0
- package/dist/lib/loopApi.js +103 -0
- package/dist/lib/loopUx.js +223 -0
- package/dist/lib/promptResolver.js +75 -0
- package/dist/lib/promptVariables.js +42 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Zeynep Aslı Erhan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
# promptlike (ple)
|
|
2
|
+
|
|
3
|
+
> Your personal prompt library in the terminal. Open source CLI for PromptLikeEngineer.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/promptlike)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://nodejs.org/)
|
|
8
|
+
|
|
9
|
+
`ple` lets you reach the prompts you've saved on
|
|
10
|
+
[promptlikeengineer.com](https://promptlikeengineer.com) without leaving your
|
|
11
|
+
terminal. Search, read, copy. That's it.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
ple list # see every prompt you've saved
|
|
15
|
+
ple copy "code review" # find by title and copy to clipboard
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The CLI talks to the same PromptLikeEngineer web API your account uses, so
|
|
19
|
+
anything you save on the web is instantly available here. You need a (free)
|
|
20
|
+
PromptLikeEngineer account to log in.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Contents
|
|
25
|
+
|
|
26
|
+
1. [Install](#install)
|
|
27
|
+
2. [Quick start](#quick-start)
|
|
28
|
+
3. [Commands](#commands)
|
|
29
|
+
4. [Configuration](#configuration)
|
|
30
|
+
5. [How it works](#how-it-works)
|
|
31
|
+
6. [Development](#development)
|
|
32
|
+
7. [Publishing a new version](#publishing-a-new-version)
|
|
33
|
+
8. [Troubleshooting](#troubleshooting)
|
|
34
|
+
9. [Contributing](#contributing)
|
|
35
|
+
10. [License](#license)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install -g promptlike
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Requires Node.js ≥18 and one of `pbcopy` (macOS), `xclip` / `wl-clipboard`
|
|
46
|
+
(Linux), or `clip.exe` (Windows) on `PATH` for the `copy` command.
|
|
47
|
+
|
|
48
|
+
> **Don't have an account yet?** Sign up at
|
|
49
|
+
> [promptlikeengineer.com](https://promptlikeengineer.com) first — the CLI
|
|
50
|
+
> needs an existing account to log into.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Quick start
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
ple login # email + password (password stays masked)
|
|
58
|
+
ple list # show your prompts
|
|
59
|
+
ple copy "Senior Reviewer" # send the prompt to your clipboard
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
That's the minimum. Once you've copied a prompt, paste it into ChatGPT, Claude,
|
|
63
|
+
Cursor, your shell, anywhere — `ple` doesn't know or care.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Commands
|
|
68
|
+
|
|
69
|
+
### `ple login`
|
|
70
|
+
|
|
71
|
+
Authenticates with email + password and stores the session at
|
|
72
|
+
`~/.config/promptlike/config.json` (`0600`, owner-only). Password is never
|
|
73
|
+
echoed to the terminal.
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
$ ple login
|
|
77
|
+
Email: you@example.com
|
|
78
|
+
Password: ********
|
|
79
|
+
✓ Logged in as you@example.com
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### `ple logout`
|
|
83
|
+
|
|
84
|
+
Removes the local session file. The session itself expires naturally on its
|
|
85
|
+
own clock — this just clears the local copy.
|
|
86
|
+
|
|
87
|
+
### `ple list [--tag <name>] [--limit <n>]`
|
|
88
|
+
|
|
89
|
+
Lists every prompt your account has access to. The server scopes results to
|
|
90
|
+
you automatically.
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
$ ple list
|
|
94
|
+
ID TITLE UPDATED
|
|
95
|
+
──────── ──────────────────────────────────────── ──────────
|
|
96
|
+
12ab34cd Senior Code Reviewer 2d ago
|
|
97
|
+
98ef76dc Bug Triage Assistant 5d ago
|
|
98
|
+
|
|
99
|
+
$ ple list --tag debug # filter by tag (server-side)
|
|
100
|
+
$ ple list --limit 50 # default 30, max 100
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### `ple copy <name>`
|
|
104
|
+
|
|
105
|
+
Looks up a prompt by title substring (case-insensitive) or short ID, joins
|
|
106
|
+
the role / description / context fields, and pipes the result to your system
|
|
107
|
+
clipboard.
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
$ ple copy "code review"
|
|
111
|
+
✓ Copied: Senior Code Reviewer (12ab34cd, 487 chars)
|
|
112
|
+
|
|
113
|
+
$ ple copy 12ab34cd # short ID also works
|
|
114
|
+
|
|
115
|
+
$ ple copy "code" # ambiguous match shows candidates:
|
|
116
|
+
'code' matched multiple prompts. Use a more specific name or short id:
|
|
117
|
+
12ab34cd Senior Code Reviewer
|
|
118
|
+
44aa55bb Code Refactor Helper
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### `ple show <name>`
|
|
122
|
+
|
|
123
|
+
Same lookup as `copy`, but renders the prompt in the terminal with section
|
|
124
|
+
headers (`── ROLE ──`, `── DESCRIPTION ──`, `── CONTEXT ──`) instead of putting
|
|
125
|
+
it on the clipboard.
|
|
126
|
+
|
|
127
|
+
### `ple get <name> [--var key=value...] [--copy]`
|
|
128
|
+
|
|
129
|
+
Prints the prompt **raw to stdout** — no colors, no decoration — so agents and
|
|
130
|
+
scripts can parse or pipe it directly. Fills `{{variable}}` placeholders from
|
|
131
|
+
repeatable `--var` flags. Human messages (warnings, unfilled variables) go to
|
|
132
|
+
stderr, keeping stdout clean.
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# fill placeholders and print
|
|
136
|
+
$ ple get "code review" --var lang=python --var tone=formal
|
|
137
|
+
|
|
138
|
+
# pipe the filled prompt straight into an agent
|
|
139
|
+
$ ple get "code review" --var lang=python | claude
|
|
140
|
+
|
|
141
|
+
# also copy to clipboard
|
|
142
|
+
$ ple get "code review" --var lang=python --copy
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Unfilled `{{variable}}` placeholders are left intact (not silently dropped) and
|
|
146
|
+
reported on stderr.
|
|
147
|
+
|
|
148
|
+
### `ple improve <name> [--focus <hint>]`
|
|
149
|
+
|
|
150
|
+
Loop Engineering, single round (**Pro**). The API generates 2-3 AI variants of
|
|
151
|
+
the prompt's current version (concise / structured / chain-of-thought), each
|
|
152
|
+
shown with its rationale, shortened section previews and a char/~token
|
|
153
|
+
comparison against the current version. Pick a winner interactively (`0`
|
|
154
|
+
cancels) and it's saved as a new version with a `Loop(<strategy>): <rationale>`
|
|
155
|
+
changelog.
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
$ ple improve "code review" --focus "shorter"
|
|
159
|
+
|
|
160
|
+
[1] CONCISE · 412 chars · ~103 tokens (-75 chars vs current)
|
|
161
|
+
why: Cuts filler, keeps the checklist.
|
|
162
|
+
...
|
|
163
|
+
Pick a winner [1-3], 0 to cancel: 1
|
|
164
|
+
✓ Saved 'Senior Code Reviewer' as v5 (concise).
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### `ple loop <name> [--exec <cmd>] [--rounds <n>] [--focus <hint>]`
|
|
168
|
+
|
|
169
|
+
Multi-round improve (**Pro**) — connect your own agent as the judge. With
|
|
170
|
+
`--exec`, every variant is run through your command: the prompt text is
|
|
171
|
+
delivered as the `PLE_PROMPT` env var **and** on stdin, and a literal `{}` in
|
|
172
|
+
the command is substituted (quoted). The first ~20 lines of stdout appear under
|
|
173
|
+
each variant (60s timeout per run). Each round's winner is saved as a new
|
|
174
|
+
version and becomes the base for the next round; between rounds you're asked
|
|
175
|
+
whether to continue, and Ctrl-C is always a safe exit.
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# let Claude judge each variant, three rounds deep
|
|
179
|
+
$ ple loop "code review" --exec 'claude -p {}' --rounds 3
|
|
180
|
+
|
|
181
|
+
# judge with your own eyes only
|
|
182
|
+
$ ple loop "code review" --rounds 2
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
> **Security note:** write the placeholder bare — `{}` — never inside quotes
|
|
186
|
+
> (`"{}"`). The CLI substitutes it with a fully shell-escaped string; wrapping
|
|
187
|
+
> it in your own quotes breaks that escaping and lets a malicious variant text
|
|
188
|
+
> inject shell commands. The prompt is also available as `$PLE_PROMPT` and on
|
|
189
|
+
> stdin, which avoid the shell entirely.
|
|
190
|
+
|
|
191
|
+
### `ple search <keyword>`
|
|
192
|
+
|
|
193
|
+
Case-insensitive `ilike` search across `title` and `description`. Version body
|
|
194
|
+
(`content`) is not searched — that's tracked in the [V2 backlog](#scope--v2).
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
$ ple search debug
|
|
198
|
+
2 results:
|
|
199
|
+
|
|
200
|
+
Bug Triage Assistant · 98ef76dc · 5d ago
|
|
201
|
+
An assistant that triages bug reports based on severity and reproducibility.
|
|
202
|
+
|
|
203
|
+
Debug Helper · 33cc44dd · 2w ago
|
|
204
|
+
Walk through systematic debugging steps for runtime errors.
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### `ple --help` / `ple <cmd> --help`
|
|
208
|
+
|
|
209
|
+
Standard `commander` help output for either the root command or any
|
|
210
|
+
sub-command.
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Configuration
|
|
215
|
+
|
|
216
|
+
| Path | Purpose | Permissions |
|
|
217
|
+
|---|---|---|
|
|
218
|
+
| `~/.config/promptlike/config.json` | Local session token storage | `0600` |
|
|
219
|
+
|
|
220
|
+
Shape of the config file:
|
|
221
|
+
|
|
222
|
+
```json
|
|
223
|
+
{
|
|
224
|
+
"access_token": "eyJ…",
|
|
225
|
+
"refresh_token": "v1.M…",
|
|
226
|
+
"email": "you@example.com",
|
|
227
|
+
"user_id": "00000000-0000-0000-0000-000000000000",
|
|
228
|
+
"expires_at": 1714502400
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Tokens are refreshed automatically when the access token has ≤60 seconds left.
|
|
233
|
+
If the refresh fails (e.g. you signed out elsewhere), the next command tells
|
|
234
|
+
you to run `ple login`.
|
|
235
|
+
|
|
236
|
+
### Optional environment variables
|
|
237
|
+
|
|
238
|
+
The CLI ships with the production API URL baked in. You can point it at a
|
|
239
|
+
different deployment (e.g. a local dev server) for testing:
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
export PROMPTLIKE_API_URL="http://localhost:3000"
|
|
243
|
+
ple list
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
That URL is the only backend detail the CLI knows — there is no Supabase key
|
|
247
|
+
to configure.
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## How it works
|
|
252
|
+
|
|
253
|
+
```
|
|
254
|
+
┌──────────────┐ ┌────────────────────────────┐
|
|
255
|
+
│ ple <cmd> │ │ ~/.config/promptlike/ │
|
|
256
|
+
│ (CLI) │◄──────►│ config.json │
|
|
257
|
+
└──────┬───────┘ │ (access + refresh token, │
|
|
258
|
+
│ │ chmod 600) │
|
|
259
|
+
│ └────────────────────────────┘
|
|
260
|
+
│ HTTPS + Authorization: Bearer <access_token>
|
|
261
|
+
▼
|
|
262
|
+
┌──────────────────────────────────────┐
|
|
263
|
+
│ PromptLikeEngineer web API (Next.js)│
|
|
264
|
+
│ ──────────────────────────────── │
|
|
265
|
+
│ POST /api/auth/cli/login │
|
|
266
|
+
│ GET /api/prompts?tag&search&limit │
|
|
267
|
+
│ GET /api/prompts/{id} │
|
|
268
|
+
│ rate limiting · validation · RLS │
|
|
269
|
+
└──────────────────────────────────────┘
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
- **Auth:** `ple login` posts email + password to `/api/auth/cli/login`; the
|
|
273
|
+
server signs you in and returns tokens the CLI stores locally. Every data
|
|
274
|
+
request carries `Authorization: Bearer <access_token>`. Tokens refresh
|
|
275
|
+
silently via `/api/auth/cli/refresh`.
|
|
276
|
+
- **Data:** all requests go through the same Next.js web API the app uses, so
|
|
277
|
+
rate limiting, input validation, and safe error messages apply uniformly.
|
|
278
|
+
Row-level security still scopes every read to your account.
|
|
279
|
+
- **Clipboard:** native `pbcopy` / `xclip` / `wl-copy` / `clip.exe`. No extra
|
|
280
|
+
npm dependency, no Electron, no native modules to compile.
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## Development
|
|
285
|
+
|
|
286
|
+
The CLI lives in the `cli/` directory of the PromptLikeEngineer monorepo.
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
cd PromptLikeEngineer/cli
|
|
290
|
+
npm install
|
|
291
|
+
npm run dev # tsc --watch
|
|
292
|
+
node dist/index.js list # or `npm link` then `ple list`
|
|
293
|
+
|
|
294
|
+
# point the CLI at a local API while developing
|
|
295
|
+
PROMPTLIKE_API_URL=http://localhost:3000 node dist/index.js list
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Scripts
|
|
299
|
+
|
|
300
|
+
| Script | What it does |
|
|
301
|
+
|---|---|
|
|
302
|
+
| `npm run build` | Compiles TS → `dist/`, marks `dist/index.js` executable |
|
|
303
|
+
| `npm run dev` | `tsc --watch` for live rebuilds |
|
|
304
|
+
| `npm run typecheck` | `tsc --noEmit` |
|
|
305
|
+
| `npm run clean` | Removes `dist/` |
|
|
306
|
+
|
|
307
|
+
### Project layout
|
|
308
|
+
|
|
309
|
+
```
|
|
310
|
+
cli/
|
|
311
|
+
├── src/
|
|
312
|
+
│ ├── index.ts # commander dispatcher + global error handler
|
|
313
|
+
│ ├── commands/ # one file per command, async default export
|
|
314
|
+
│ │ ├── login.ts # masked password prompt + api login
|
|
315
|
+
│ │ ├── logout.ts # delete config file
|
|
316
|
+
│ │ ├── list.ts # list with --tag / --limit
|
|
317
|
+
│ │ ├── copy.ts # resolve + fetch + clipboard
|
|
318
|
+
│ │ ├── show.ts # resolve + 3-part colored render
|
|
319
|
+
│ │ └── search.ts # title + description search
|
|
320
|
+
│ └── lib/
|
|
321
|
+
│ ├── constants.ts # API_BASE_URL + WEB_APP_URL
|
|
322
|
+
│ ├── config.ts # read/write ~/.config/promptlike/config.json
|
|
323
|
+
│ ├── api-client.ts # fetch wrapper: bearer auth, refresh, error mapping
|
|
324
|
+
│ ├── clipboard.ts # spawn(pbcopy/xclip/clip) + Wayland fallback
|
|
325
|
+
│ ├── format.ts # chalk palette, timeAgo, truncate, joinPromptParts
|
|
326
|
+
│ ├── promptResolver.ts # name → prompt (id prefix or title search)
|
|
327
|
+
│ └── promptVariables.ts # {{variable}} extract + fill
|
|
328
|
+
└── dist/ # tsc output, what gets published
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Adding a new command
|
|
332
|
+
|
|
333
|
+
1. Create `src/commands/<name>.ts`, `export async function`.
|
|
334
|
+
2. If it needs auth, call `await ensureAuthed()` from `../lib/api-client`
|
|
335
|
+
(throws a clear "log in" message + refreshes a soon-to-expire token), then
|
|
336
|
+
call the typed api-client helpers (`listPrompts`, `getPromptById`, …).
|
|
337
|
+
3. Wire it up in `src/index.ts` with `program.command('<name>')` + the
|
|
338
|
+
`runWithErrorHandler` wrapper for consistent error output.
|
|
339
|
+
4. `npm run build` and try it locally.
|
|
340
|
+
|
|
341
|
+
### Self-contained
|
|
342
|
+
|
|
343
|
+
The CLI defines its own minimal types (in `lib/api-client.ts`) and does not
|
|
344
|
+
depend on the repo's `shared/types/` — it talks to the web API purely over
|
|
345
|
+
HTTP, so there is no type-sync step for the CLI.
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## Publishing a new version
|
|
350
|
+
|
|
351
|
+
Publishing is automated: pushing a `cli-v*` git tag runs the
|
|
352
|
+
`.github/workflows/cli-publish.yml` workflow, which typechecks, tests, builds,
|
|
353
|
+
and runs `npm publish --access public` (using the `NPM_TOKEN` repo secret).
|
|
354
|
+
|
|
355
|
+
```bash
|
|
356
|
+
npm version patch # bump package.json (or minor / major)
|
|
357
|
+
git commit -am "cli: v0.2.1"
|
|
358
|
+
git tag cli-v0.2.1
|
|
359
|
+
git push origin main --tags # tag push triggers the publish workflow
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
To publish manually instead:
|
|
363
|
+
|
|
364
|
+
```bash
|
|
365
|
+
npm run build
|
|
366
|
+
npm publish --dry-run # verify only dist/, README.md, LICENSE ship
|
|
367
|
+
npm publish --access public
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
`package.json#files` and `.npmignore` keep `src/`, `tsconfig.json`, and tests
|
|
371
|
+
out of the published tarball — only `dist/`, `LICENSE`, and `README.md` ship.
|
|
372
|
+
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
## Troubleshooting
|
|
376
|
+
|
|
377
|
+
| Symptom | Cause | Fix |
|
|
378
|
+
|---|---|---|
|
|
379
|
+
| `Not logged in. Run ple login first.` | No session on disk | `ple login` |
|
|
380
|
+
| `Session expired. Log in again: ple login` | Refresh token rejected | `ple login` again |
|
|
381
|
+
| `Invalid email or password. If you signed up with Google…` | OAuth-only account has no password | Set a password in Account settings on the web, then `ple login` |
|
|
382
|
+
| `Clipboard command (xclip) not found` | Linux without xclip / wl-copy | `apt install xclip` (X11) or `apt install wl-clipboard` (Wayland) |
|
|
383
|
+
| `No prompt matched 'X'.` | Name doesn't match anything | Run `ple list` to see real titles |
|
|
384
|
+
| `'X' matched multiple prompts.` | Substring matched several rows | Use a more specific name or the short ID |
|
|
385
|
+
| `Rate limited. Try again in Ns.` | Too many requests in a short window | Wait the suggested seconds and retry |
|
|
386
|
+
| `Cannot reach <url>. Check your connection.` | Network / wrong `PROMPTLIKE_API_URL` | Check connectivity or unset the override |
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## Scope / V2
|
|
391
|
+
|
|
392
|
+
What this CLI does **not** do yet (PRs welcome):
|
|
393
|
+
|
|
394
|
+
- Create / edit / delete prompts (read + copy only — write paths live on the web)
|
|
395
|
+
- `ple search` over version body (`content`); needs a server-side full-text index
|
|
396
|
+
- `--project <name>` filter on `ple list`
|
|
397
|
+
- Interactive picker (think `fzf`-style)
|
|
398
|
+
- Configurable color theme
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
## Contributing
|
|
403
|
+
|
|
404
|
+
The CLI is open source — bug reports, feature requests, and pull requests are
|
|
405
|
+
welcome.
|
|
406
|
+
|
|
407
|
+
- **Bugs:** open an issue with the command you ran, the error, your OS, and
|
|
408
|
+
Node version.
|
|
409
|
+
- **Features:** check [Scope / V2](#scope--v2) first; if it's there, mention
|
|
410
|
+
the issue you're picking up.
|
|
411
|
+
- **Code style:** TypeScript strict, no `any`, no `@ts-ignore`. Keep new
|
|
412
|
+
modules small and single-purpose (`src/lib/<thing>.ts`).
|
|
413
|
+
|
|
414
|
+
The web dashboard and Chrome extension that this CLI talks to are *not* open
|
|
415
|
+
source — they're proprietary products owned by Zeynep Aslı Erhan. Only the
|
|
416
|
+
CLI in this directory falls under MIT.
|
|
417
|
+
|
|
418
|
+
---
|
|
419
|
+
|
|
420
|
+
## License
|
|
421
|
+
|
|
422
|
+
[MIT](LICENSE) © 2026 Zeynep Aslı Erhan
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.copyCommand = copyCommand;
|
|
4
|
+
const api_client_1 = require("../lib/api-client");
|
|
5
|
+
const promptResolver_1 = require("../lib/promptResolver");
|
|
6
|
+
const clipboard_1 = require("../lib/clipboard");
|
|
7
|
+
const format_1 = require("../lib/format");
|
|
8
|
+
/**
|
|
9
|
+
* `ple copy <name>` — resolve a prompt by title (or short id) and copy its
|
|
10
|
+
* content to the system clipboard.
|
|
11
|
+
*/
|
|
12
|
+
async function copyCommand(name) {
|
|
13
|
+
await (0, api_client_1.ensureAuthed)();
|
|
14
|
+
const prompt = await (0, promptResolver_1.resolvePromptByName)(name);
|
|
15
|
+
if (!prompt) {
|
|
16
|
+
process.exitCode = 1;
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const version = (0, promptResolver_1.fetchPromptContent)(prompt);
|
|
20
|
+
if (!version) {
|
|
21
|
+
console.error(format_1.c.error(`'${prompt.title}' has no usable version.`));
|
|
22
|
+
process.exitCode = 1;
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const text = (0, format_1.joinPromptParts)(version);
|
|
26
|
+
if (!text.trim()) {
|
|
27
|
+
console.error(format_1.c.error(`'${prompt.title}' has empty content.`));
|
|
28
|
+
process.exitCode = 1;
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
await (0, clipboard_1.copyToClipboard)(text);
|
|
33
|
+
console.log(format_1.c.success(`✓ Copied: ${prompt.title}`) +
|
|
34
|
+
format_1.c.muted(` (${(0, format_1.shortId)(prompt.id)}, ${text.length} chars)`));
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
console.error(format_1.c.error(`Clipboard error: ${err instanceof Error ? err.message : String(err)}`));
|
|
38
|
+
process.exitCode = 1;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCommand = getCommand;
|
|
4
|
+
exports.collectVar = collectVar;
|
|
5
|
+
const api_client_1 = require("../lib/api-client");
|
|
6
|
+
const promptResolver_1 = require("../lib/promptResolver");
|
|
7
|
+
const clipboard_1 = require("../lib/clipboard");
|
|
8
|
+
const format_1 = require("../lib/format");
|
|
9
|
+
const promptVariables_1 = require("../lib/promptVariables");
|
|
10
|
+
/**
|
|
11
|
+
* `ple get <name> [--var key=value...]` — resolve a prompt, fill `{{name}}`
|
|
12
|
+
* variables, and write the **raw text to stdout**.
|
|
13
|
+
*
|
|
14
|
+
* Design: stdout contains ONLY the filled prompt (no color, no decoration) so
|
|
15
|
+
* agents/scripts can parse and pipe it directly. All human-facing messages
|
|
16
|
+
* (warnings, errors, unfilled variables) go to stderr. This is what sets it
|
|
17
|
+
* apart from `ple show` (colored, human-readable) and `ple copy` (clipboard).
|
|
18
|
+
*
|
|
19
|
+
* ple get "code review" --var lang=python --var tone=formal
|
|
20
|
+
* ple get "code review" --var lang=python | claude # pipe to an agent
|
|
21
|
+
*/
|
|
22
|
+
async function getCommand(name, options = {}) {
|
|
23
|
+
await (0, api_client_1.ensureAuthed)();
|
|
24
|
+
const prompt = await (0, promptResolver_1.resolvePromptByName)(name);
|
|
25
|
+
if (!prompt) {
|
|
26
|
+
process.exitCode = 1;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const version = (0, promptResolver_1.fetchPromptContent)(prompt);
|
|
30
|
+
if (!version) {
|
|
31
|
+
console.error(format_1.c.error(`'${prompt.title}' has no usable version.`));
|
|
32
|
+
process.exitCode = 1;
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const raw = (0, format_1.joinPromptParts)(version);
|
|
36
|
+
if (!raw.trim()) {
|
|
37
|
+
console.error(format_1.c.error(`'${prompt.title}' has empty content.`));
|
|
38
|
+
process.exitCode = 1;
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const values = options.var ?? {};
|
|
42
|
+
const filled = (0, promptVariables_1.fillVariables)(raw, values);
|
|
43
|
+
// Warn about any variables left unfilled — to stderr (keep stdout clean).
|
|
44
|
+
const remaining = (0, promptVariables_1.extractVariables)(filled);
|
|
45
|
+
if (remaining.length > 0) {
|
|
46
|
+
console.error(format_1.c.warn(`⚠ Unfilled variables: ${remaining.map((v) => `{{${v}}}`).join(', ')}`));
|
|
47
|
+
console.error(format_1.c.muted(` Fill with: --var ${remaining[0]}=...`));
|
|
48
|
+
}
|
|
49
|
+
// THE OUTPUT — raw, to stdout (agent-readable).
|
|
50
|
+
process.stdout.write(filled.endsWith('\n') ? filled : filled + '\n');
|
|
51
|
+
if (options.copy) {
|
|
52
|
+
try {
|
|
53
|
+
await (0, clipboard_1.copyToClipboard)(filled);
|
|
54
|
+
console.error(format_1.c.success('✓ Also copied to clipboard.'));
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
console.error(format_1.c.error(`Clipboard error: ${err instanceof Error ? err.message : String(err)}`));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Commander collector for `--var key=value` (repeatable flag).
|
|
63
|
+
*/
|
|
64
|
+
function collectVar(value, previous) {
|
|
65
|
+
const idx = value.indexOf('=');
|
|
66
|
+
if (idx === -1) {
|
|
67
|
+
throw new Error(`Invalid --var '${value}' — expected key=value.`);
|
|
68
|
+
}
|
|
69
|
+
const key = value.slice(0, idx).trim();
|
|
70
|
+
const val = value.slice(idx + 1);
|
|
71
|
+
if (!key) {
|
|
72
|
+
throw new Error(`Invalid --var '${value}' — key cannot be empty.`);
|
|
73
|
+
}
|
|
74
|
+
return { ...previous, [key]: val };
|
|
75
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loopChangelog = loopChangelog;
|
|
4
|
+
exports.improveCommand = improveCommand;
|
|
5
|
+
const api_client_1 = require("../lib/api-client");
|
|
6
|
+
const promptResolver_1 = require("../lib/promptResolver");
|
|
7
|
+
const format_1 = require("../lib/format");
|
|
8
|
+
const loopApi_1 = require("../lib/loopApi");
|
|
9
|
+
const loopUx_1 = require("../lib/loopUx");
|
|
10
|
+
/** Changelog format shared by `improve` and `loop`. */
|
|
11
|
+
function loopChangelog(variant) {
|
|
12
|
+
return `Loop(${variant.strategy}): ${variant.rationale}`.trim();
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* `ple improve <name> [--focus <hint>]` — single-round Loop Engineering.
|
|
16
|
+
*
|
|
17
|
+
* Resolves the prompt (same lookup as get/show), asks the API for AI
|
|
18
|
+
* variants of the current version, renders them numbered + colored, lets
|
|
19
|
+
* the user pick a winner interactively (0 = cancel), and saves the pick as
|
|
20
|
+
* a new version with a `Loop(<strategy>): <rationale>` changelog.
|
|
21
|
+
*
|
|
22
|
+
* Pro feature: the server answers 403 for Free accounts / exhausted AI
|
|
23
|
+
* budgets — `loopApi` maps that to a clear upgrade message.
|
|
24
|
+
*/
|
|
25
|
+
async function improveCommand(name, options = {}) {
|
|
26
|
+
await (0, api_client_1.ensureAuthed)();
|
|
27
|
+
const prompt = await (0, promptResolver_1.resolvePromptByName)(name);
|
|
28
|
+
if (!prompt) {
|
|
29
|
+
process.exitCode = 1;
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const version = (0, promptResolver_1.fetchPromptContent)(prompt);
|
|
33
|
+
const baseline = version ? (0, format_1.joinPromptParts)(version) : '';
|
|
34
|
+
console.log(format_1.c.muted(`Generating variants for '${prompt.title}'…`));
|
|
35
|
+
const { variants, tokensUsed } = await (0, loopApi_1.requestVariants)(prompt.id, { focus: options.focus });
|
|
36
|
+
if (variants.length === 0) {
|
|
37
|
+
console.error(format_1.c.error('The API returned no variants. Try again in a moment.'));
|
|
38
|
+
process.exitCode = 1;
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
(0, loopUx_1.renderVariants)(variants, baseline);
|
|
42
|
+
console.log();
|
|
43
|
+
console.log(format_1.c.muted(`${tokensUsed} AI tokens used.`));
|
|
44
|
+
const pick = await (0, loopUx_1.selectVariant)(variants.length);
|
|
45
|
+
if (pick === 0) {
|
|
46
|
+
console.log(format_1.c.muted('Cancelled — nothing saved.'));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const winner = variants[pick - 1];
|
|
50
|
+
const result = await (0, loopApi_1.saveWinner)(prompt.id, winner, loopChangelog(winner));
|
|
51
|
+
const versionLabel = result.versionNumber !== undefined ? `v${result.versionNumber}` : 'a new version';
|
|
52
|
+
console.log(format_1.c.success(`✓ Saved '${prompt.title}' as ${versionLabel} (${winner.strategy}).`));
|
|
53
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listCommand = listCommand;
|
|
4
|
+
const api_client_1 = require("../lib/api-client");
|
|
5
|
+
const constants_1 = require("../lib/constants");
|
|
6
|
+
const format_1 = require("../lib/format");
|
|
7
|
+
/**
|
|
8
|
+
* `ple list [--tag X] [--limit N]` — list the user's prompts.
|
|
9
|
+
*
|
|
10
|
+
* Tag filtering is done server-side (`?tag=`); the API returns only the
|
|
11
|
+
* matching prompts. The list endpoint does not return per-item tags, so the
|
|
12
|
+
* table shows id / title / updated.
|
|
13
|
+
*/
|
|
14
|
+
async function listCommand(options) {
|
|
15
|
+
const limit = Math.max(1, Math.min(100, parseInt(options.limit ?? '30', 10) || 30));
|
|
16
|
+
await (0, api_client_1.ensureAuthed)();
|
|
17
|
+
const prompts = await (0, api_client_1.listPrompts)({ tag: options.tag, limit });
|
|
18
|
+
if (prompts.length === 0) {
|
|
19
|
+
if (options.tag) {
|
|
20
|
+
console.log(format_1.c.muted(`No prompts matched tag '${options.tag}'.`));
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
console.log(format_1.c.muted(`No prompts yet. Create one at ${constants_1.WEB_APP_URL}`));
|
|
24
|
+
}
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
console.log(format_1.c.label('ID TITLE UPDATED'));
|
|
28
|
+
console.log(format_1.c.label('──────── ──────────────────────────────────────── ──────────'));
|
|
29
|
+
for (const p of prompts) {
|
|
30
|
+
const id = format_1.c.muted((0, format_1.shortId)(p.id));
|
|
31
|
+
const title = (0, format_1.truncate)(p.title, 40).padEnd(40);
|
|
32
|
+
const updated = format_1.c.muted((0, format_1.timeAgo)(p.updated_at));
|
|
33
|
+
console.log(`${id} ${title} ${updated}`);
|
|
34
|
+
}
|
|
35
|
+
console.log(format_1.c.muted(`\n${prompts.length} prompt${prompts.length === 1 ? '' : 's'} listed.`));
|
|
36
|
+
}
|