promptlike 0.6.1 → 0.6.3
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 +29 -0
- package/README.md +22 -152
- package/dist/lib/api-client.js +100 -12
- package/package.json +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.3 — 2026-10-13
|
|
4
|
+
|
|
5
|
+
- **Package metadata:** `repository` and `bugs` now point to the public plugin repository
|
|
6
|
+
(github.com/zeynepaslierhann/promptlike-plugin), which is where issues can be filed. No code change.
|
|
7
|
+
- **Docs (npm page):** the README no longer calls the CLI "open source" or invites pull
|
|
8
|
+
requests: the source is not public, the npm package is MIT-licensed. It no longer lists
|
|
9
|
+
the Chrome extension (not published) among what a free account adds, says that Free
|
|
10
|
+
holds up to 3 versions of each prompt (the 4th save asks you to upgrade), and gives feedback by email or on the plugin
|
|
11
|
+
repository. Maintainer notes (development, publishing) moved out of the README into
|
|
12
|
+
`DEVELOPMENT.md`, which is not part of the package. "Scope / V2" no longer says the CLI
|
|
13
|
+
cannot create prompts (`ple save` does).
|
|
14
|
+
|
|
15
|
+
## 0.6.2 — 2026-10-12
|
|
16
|
+
|
|
17
|
+
- **Fix:** a network problem while your session is being refreshed (no DNS,
|
|
18
|
+
connection refused, a dropped Wi-Fi) no longer says "Session expired. Log in
|
|
19
|
+
again". It now says the server could not be reached: check your connection
|
|
20
|
+
and run the command again. Your saved login is kept. A temporary server
|
|
21
|
+
problem during the refresh (busy, rate limited, 5xx) asks you to run the
|
|
22
|
+
command again in a moment and keeps your login; only if it keeps happening
|
|
23
|
+
does it suggest `ple login`. Only a definite rejection from the server (the
|
|
24
|
+
refresh token expired, was revoked or was already used) still asks you to log
|
|
25
|
+
in again right away. Nothing is retried automatically.
|
|
26
|
+
- **Fix:** when the session refresh itself gets no answer within 30 s, the
|
|
27
|
+
message no longer says "the server may still have completed the request;
|
|
28
|
+
check before retrying" (that warning is for your own writes and was
|
|
29
|
+
misleading on read commands). It now says the refresh did not finish and to
|
|
30
|
+
run the command again; if it then reports an expired session, run `ple login`.
|
|
31
|
+
|
|
3
32
|
## 0.6.1 — 2026-10-12
|
|
4
33
|
|
|
5
34
|
- **Fix:** `ple <name>` commands (show, copy, get, log, ...) now find a prompt by its
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# promptlike (ple)
|
|
2
2
|
|
|
3
|
-
> Your personal prompt library in the terminal.
|
|
3
|
+
> Your personal prompt library in the terminal. The CLI for PromptLikeEngineer (MIT-licensed npm package).
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/promptlike)
|
|
6
6
|
[](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
|
|
24
|
-
|
|
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. [
|
|
43
|
-
7. [
|
|
44
|
-
8. [
|
|
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
|
|
|
@@ -448,140 +446,14 @@ to configure.
|
|
|
448
446
|
|
|
449
447
|
---
|
|
450
448
|
|
|
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
449
|
## Troubleshooting
|
|
580
450
|
|
|
581
451
|
| Symptom | Cause | Fix |
|
|
582
452
|
|---|---|---|
|
|
583
453
|
| `Not logged in. Run ple login first.` | No session on disk | `ple login` |
|
|
584
|
-
| `Session expired. Log in again: ple login` |
|
|
454
|
+
| `Session expired. Log in again: ple login` | The server rejected the refresh token (expired, revoked or already used) | `ple login` again |
|
|
455
|
+
| `Cannot reach <url>. Could not refresh your session…` | Network problem while refreshing the session | Check your connection and run the command again; your saved login is kept |
|
|
456
|
+
| `Could not refresh your session right now (…)` | The server could not refresh the session for a moment (busy, rate limited) | Run the command again in a moment; your saved login is kept. If it keeps happening, run `ple login` |
|
|
585
457
|
| `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` |
|
|
586
458
|
| `Clipboard command (xclip) not found` | Linux without xclip / wl-copy | `apt install xclip` (X11) or `apt install wl-clipboard` (Wayland) |
|
|
587
459
|
| `No prompt matched 'X'.` | Name doesn't match anything | Run `ple list` to see real titles |
|
|
@@ -593,9 +465,9 @@ out of the published tarball — only `dist/`, `LICENSE`, and `README.md` ship.
|
|
|
593
465
|
|
|
594
466
|
## Scope / V2
|
|
595
467
|
|
|
596
|
-
What this CLI does **not** do yet
|
|
468
|
+
What this CLI does **not** do yet:
|
|
597
469
|
|
|
598
|
-
-
|
|
470
|
+
- Delete prompts (`ple save` creates and updates; deleting is done on the web)
|
|
599
471
|
- `ple search` over version body (`content`); needs a server-side full-text index
|
|
600
472
|
- `--project <name>` filter on `ple list`
|
|
601
473
|
- Interactive picker (think `fzf`-style)
|
|
@@ -603,21 +475,19 @@ What this CLI does **not** do yet (PRs welcome):
|
|
|
603
475
|
|
|
604
476
|
---
|
|
605
477
|
|
|
606
|
-
##
|
|
478
|
+
## Feedback
|
|
607
479
|
|
|
608
|
-
|
|
609
|
-
|
|
480
|
+
Bug reports and feature requests: email
|
|
481
|
+
[zeynepaslierhan@gmail.com](mailto:zeynepaslierhan@gmail.com) or open an issue on
|
|
482
|
+
[github.com/zeynepaslierhann/promptlike-plugin](https://github.com/zeynepaslierhann/promptlike-plugin/issues).
|
|
483
|
+
For a bug, include the command you ran, the error, your OS, and your Node version.
|
|
484
|
+
Check [Scope / V2](#scope--v2) before asking for a feature.
|
|
610
485
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
the issue you're picking up.
|
|
615
|
-
- **Code style:** TypeScript strict, no `any`, no `@ts-ignore`. Keep new
|
|
616
|
-
modules small and single-purpose (`src/lib/<thing>.ts`).
|
|
486
|
+
The `promptlike` and `promptlike-mcp` npm packages are MIT-licensed. The
|
|
487
|
+
PromptLikeEngineer web app they talk to is a hosted product owned by Zeynep Aslı
|
|
488
|
+
Erhan; its source is not public.
|
|
617
489
|
|
|
618
|
-
|
|
619
|
-
source — they're proprietary products owned by Zeynep Aslı Erhan. Only the
|
|
620
|
-
CLI in this directory falls under MIT.
|
|
490
|
+
Website: <https://promptlikeengineer.com/?utm_source=npm&utm_medium=readme&utm_campaign=ple_dist>
|
|
621
491
|
|
|
622
492
|
---
|
|
623
493
|
|
package/dist/lib/api-client.js
CHANGED
|
@@ -14,9 +14,12 @@
|
|
|
14
14
|
* - map 429 / error bodies to clean, user-facing Error messages
|
|
15
15
|
* - bound every request with a timeout (O5 / PLE-03): a server that keeps the
|
|
16
16
|
* connection open without answering must not hang a command forever
|
|
17
|
+
* - only a definitive refresh rejection means "session expired" (O11): a
|
|
18
|
+
* network error or a temporary server failure keeps the saved login
|
|
17
19
|
*/
|
|
18
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.USE_SURFACES = exports.RequestTimeoutError = exports.USE_EVENT_TIMEOUT_MS = exports.IMPORT_TIMEOUT_MS = exports.WRITE_TIMEOUT_MS = exports.READ_TIMEOUT_MS = void 0;
|
|
21
|
+
exports.USE_SURFACES = exports.NetworkError = exports.ApiError = exports.DEFINITIVE_REFRESH_CODES = exports.REFRESH_UNAVAILABLE_LAST_RESORT = exports.REFRESH_NETWORK_ADVICE = exports.REFRESH_TIMEOUT_ADVICE = exports.RequestTimeoutError = exports.USE_EVENT_TIMEOUT_MS = exports.IMPORT_TIMEOUT_MS = exports.WRITE_TIMEOUT_MS = exports.READ_TIMEOUT_MS = void 0;
|
|
22
|
+
exports.refreshUnavailableMessage = refreshUnavailableMessage;
|
|
20
23
|
exports.login = login;
|
|
21
24
|
exports.ensureAuthed = ensureAuthed;
|
|
22
25
|
exports.listPrompts = listPrompts;
|
|
@@ -50,15 +53,91 @@ exports.IMPORT_TIMEOUT_MS = 120000;
|
|
|
50
53
|
exports.USE_EVENT_TIMEOUT_MS = 5000;
|
|
51
54
|
/** Zaman aşımı hatası — `refreshSession` bunu "oturum bitti"ye çevirmesin diye ayrı sınıf. */
|
|
52
55
|
class RequestTimeoutError extends Error {
|
|
53
|
-
constructor(timeoutMs, method) {
|
|
54
|
-
const
|
|
56
|
+
constructor(timeoutMs, method, advice) {
|
|
57
|
+
const defaultAdvice = method === 'GET'
|
|
55
58
|
? 'Check your connection and try again.'
|
|
56
59
|
: 'The server may still have completed the request; check before retrying.';
|
|
57
|
-
super(`No response from ${constants_1.API_BASE_URL} within ${Math.round(timeoutMs / 1000)}s. ${advice}`);
|
|
60
|
+
super(`No response from ${constants_1.API_BASE_URL} within ${Math.round(timeoutMs / 1000)}s. ${advice ?? defaultAdvice}`);
|
|
61
|
+
this.timeoutMs = timeoutMs;
|
|
58
62
|
this.name = 'RequestTimeoutError';
|
|
59
63
|
}
|
|
60
64
|
}
|
|
61
65
|
exports.RequestTimeoutError = RequestTimeoutError;
|
|
66
|
+
/**
|
|
67
|
+
* Oturum yenileme zaman aşımına uğradığında kullanıcıya söylenecek şey. Yenileme
|
|
68
|
+
* kullanıcının komutu değil, arka plandaki bir POST'tur; "yazma sunucuda
|
|
69
|
+
* tamamlanmış olabilir, önce kontrol et" uyarısı okuma komutunda bile çıkıp
|
|
70
|
+
* yanıltırdı. Sunucu yenilemeyi tamamlamış ama yeni token yerelde saklanmamış
|
|
71
|
+
* olabilir; bu durumda bir sonraki çalıştırma "Session expired" der.
|
|
72
|
+
*/
|
|
73
|
+
exports.REFRESH_TIMEOUT_ADVICE = 'Session refresh did not finish. Run the command again; if it then says the session expired, run `ple login`.';
|
|
74
|
+
/**
|
|
75
|
+
* Yenileme isteği sunucuya hiç ulaşamadığında (DNS, bağlantı reddi, kopma; O11).
|
|
76
|
+
* Ağ hatası oturumun bittiğini göstermez: yerel oturum silinmez (yalnız `ple
|
|
77
|
+
* logout` siler), kullanıcı gereksiz yere `ple login`'e yönlendirilmez.
|
|
78
|
+
*/
|
|
79
|
+
exports.REFRESH_NETWORK_ADVICE = 'Could not refresh your session: check your connection and run the command again. Your saved login is kept.';
|
|
80
|
+
/**
|
|
81
|
+
* Sunucu yenilemeyi kesin reddetmedi ama tamamlayamadı (503 + Retry-After, 429,
|
|
82
|
+
* 5xx, tanınmayan yanıt; O11). Web `/api/auth/cli/refresh` sözleşmesi: bunlar
|
|
83
|
+
* geçicidir, oturum korunur, sonra yeniden denenir. Otomatik tekrar YOK.
|
|
84
|
+
* Son çare cümlesi: web tanınmayan üst servis hatasını (kodsuz 401/403, yeni bir
|
|
85
|
+
* GoTrue kodu) da 503 geçici sayar; refresh token gerçekten iptal edilmişse
|
|
86
|
+
* kullanıcı "az sonra tekrar dene"de takılı kalmasın.
|
|
87
|
+
*/
|
|
88
|
+
exports.REFRESH_UNAVAILABLE_LAST_RESORT = 'If this keeps happening, run `ple login`.';
|
|
89
|
+
function refreshUnavailableMessage(detail) {
|
|
90
|
+
return `Could not refresh your session right now (${detail}). Run the command again in a moment; your saved login is kept. ${exports.REFRESH_UNAVAILABLE_LAST_RESORT}`;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Sunucunun yenilemeyi KESİN reddettiğini gösteren yanıt kodları (O11). Web
|
|
94
|
+
* `src/app/api/auth/cli/refresh/_handlers/classify.ts` DEFINITIVE_CODES (GoTrue
|
|
95
|
+
* `error_code`) ile aynı liste + rotanın kendi `SESSION_EXPIRED` kodu; tutarlılık
|
|
96
|
+
* `api-client.refresh.test.ts` ile kilitli. Yalnız bunlar (ya da 401 / 400)
|
|
97
|
+
* "Session expired" sayılır; tanınmayan her şey geçicidir (emin değilsen oturumu bitirme).
|
|
98
|
+
*/
|
|
99
|
+
exports.DEFINITIVE_REFRESH_CODES = new Set([
|
|
100
|
+
'SESSION_EXPIRED',
|
|
101
|
+
'refresh_token_not_found',
|
|
102
|
+
'refresh_token_already_used',
|
|
103
|
+
'session_expired',
|
|
104
|
+
'session_not_found',
|
|
105
|
+
'invalid_grant',
|
|
106
|
+
'user_not_found',
|
|
107
|
+
'user_banned',
|
|
108
|
+
'validation_failed',
|
|
109
|
+
]);
|
|
110
|
+
/** HTTP hatası; durum kodu ve sunucu kodu korunur (yenileme sınıflaması için). İleti değişmedi. */
|
|
111
|
+
class ApiError extends Error {
|
|
112
|
+
constructor(message, status, code) {
|
|
113
|
+
super(message);
|
|
114
|
+
this.status = status;
|
|
115
|
+
this.code = code;
|
|
116
|
+
this.name = 'ApiError';
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.ApiError = ApiError;
|
|
120
|
+
/** İstek sunucuya ulaşamadı (DNS, bağlantı reddi, kopma). Varsayılan ileti eskisiyle aynı. */
|
|
121
|
+
class NetworkError extends Error {
|
|
122
|
+
constructor(detail, advice = 'Check your connection.') {
|
|
123
|
+
super(`Cannot reach ${constants_1.API_BASE_URL}. ${advice} (${detail})`);
|
|
124
|
+
this.detail = detail;
|
|
125
|
+
this.name = 'NetworkError';
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.NetworkError = NetworkError;
|
|
129
|
+
/**
|
|
130
|
+
* Yenileme yanıtı oturumun gerçekten bittiğini mi söylüyor? Web sözleşmesi:
|
|
131
|
+
* 401 SESSION_EXPIRED (kesin ret) ve 400 (refresh_token eksik: yerel oturum
|
|
132
|
+
* kaydı bozuk) kesindir; 503 / 429 / 5xx / ağ / zaman aşımı geçicidir.
|
|
133
|
+
*/
|
|
134
|
+
function isDefinitiveRefreshRejection(err) {
|
|
135
|
+
if (!(err instanceof ApiError))
|
|
136
|
+
return false;
|
|
137
|
+
if (err.status === 401 || err.status === 400)
|
|
138
|
+
return true;
|
|
139
|
+
return err.code !== undefined && exports.DEFINITIVE_REFRESH_CODES.has(err.code);
|
|
140
|
+
}
|
|
62
141
|
/**
|
|
63
142
|
* Hata süre aşımından mı geldi? Önce sinyalin kendisine bakılır: eski Node /
|
|
64
143
|
* undici sürümlerinde gövde okuması yarıda kesilince hata `TimeoutError` yerine
|
|
@@ -113,12 +192,13 @@ async function toError(res) {
|
|
|
113
192
|
catch {
|
|
114
193
|
// Non-JSON error body — fall back to a generic message below.
|
|
115
194
|
}
|
|
195
|
+
const code = typeof body.code === 'string' ? body.code : undefined;
|
|
116
196
|
if (body.error)
|
|
117
|
-
return new
|
|
118
|
-
if (
|
|
119
|
-
return new
|
|
197
|
+
return new ApiError(body.error, res.status, code);
|
|
198
|
+
if (code && ERROR_FALLBACKS[code]) {
|
|
199
|
+
return new ApiError(ERROR_FALLBACKS[code], res.status, code);
|
|
120
200
|
}
|
|
121
|
-
return new
|
|
201
|
+
return new ApiError(`Request failed (${res.status}).`, res.status, code);
|
|
122
202
|
}
|
|
123
203
|
function getAccessTokenOrThrow() {
|
|
124
204
|
const config = (0, config_1.readConfig)();
|
|
@@ -154,9 +234,17 @@ async function refreshSession() {
|
|
|
154
234
|
}
|
|
155
235
|
catch (err) {
|
|
156
236
|
// Asılı sunucu "oturumun bitti, yeniden giriş yap" demek değildir.
|
|
157
|
-
if (err instanceof RequestTimeoutError)
|
|
158
|
-
throw err;
|
|
159
|
-
|
|
237
|
+
if (err instanceof RequestTimeoutError) {
|
|
238
|
+
throw new RequestTimeoutError(err.timeoutMs, 'POST', exports.REFRESH_TIMEOUT_ADVICE);
|
|
239
|
+
}
|
|
240
|
+
// Yalnız sunucunun kesin reddi oturumu bitirir (O11).
|
|
241
|
+
if (isDefinitiveRefreshRejection(err))
|
|
242
|
+
throw new Error(SESSION_EXPIRED);
|
|
243
|
+
// Ağ hatası (DNS, bağlantı reddi): sunucuya ulaşılamadı, oturum hakkında bilgi yok.
|
|
244
|
+
if (err instanceof NetworkError)
|
|
245
|
+
throw new NetworkError(err.detail, exports.REFRESH_NETWORK_ADVICE);
|
|
246
|
+
// 503 / 429 / 5xx / tanınmayan yanıt: geçici; yerel oturum korunur.
|
|
247
|
+
throw new Error(refreshUnavailableMessage(err instanceof Error ? err.message : String(err)));
|
|
160
248
|
}
|
|
161
249
|
persist(data);
|
|
162
250
|
}
|
|
@@ -187,7 +275,7 @@ async function apiFetch(path, opts = {}) {
|
|
|
187
275
|
catch (err) {
|
|
188
276
|
if (isTimeout(err, signal))
|
|
189
277
|
throw new RequestTimeoutError(timeoutMs, method);
|
|
190
|
-
throw new
|
|
278
|
+
throw new NetworkError(err instanceof Error ? err.message : String(err));
|
|
191
279
|
}
|
|
192
280
|
// Reactive refresh: expired/invalid access token → refresh once, retry once.
|
|
193
281
|
if (res.status === 401 && auth) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "promptlike",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
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
|
},
|