promptlike 0.12.3 → 0.12.5

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,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.12.5 — 2026-10-31
4
+
5
+ - **Fix: a passing outage no longer ends a login.** If refreshing an expired session met a server error or rate limit
6
+ (HTTP 5xx / 429), `ple feedback` filed the report as "login refused" and told a signed-in user to run `ple login`.
7
+ Now only a definitive rejection counts as refused; an outage is treated like being offline (the report is queued,
8
+ the saved login is kept and the text says so).
9
+ - **`ple feedback` names the reason also when it sends at once without an account** (`"anonymous_reason"` in `--json`,
10
+ a line in the text output), not only when it queues.
11
+ - **`--help` numbers come from the code** (queue size, retry interval, `list` default and maximum rows), and
12
+ `ple feedback list --help` / `close --help` now print their own exit-code table.
13
+ - **`ple feedback close` no longer says "Nothing was changed" after a timeout or a server error**: the request may
14
+ have been applied. It says so and points to `ple feedback list`; `list` still says nothing was changed.
15
+
16
+ ## 0.12.4 — 2026-10-31
17
+
18
+ - **Fix: `ple improve` and `ple loop` crashed on Node 18** (`crypto is not defined`): the attempt id used the global
19
+ `crypto`, which Node 18 does not have. It now imports it. A test fails if any source file uses the global again,
20
+ and CI loads every compiled module and runs a command on Node 18, 20 and 22.
21
+ - **`ple feedback` names the real reason a queued report is anonymous** (no account signed in, the saved login could
22
+ not be checked while offline, or the login is no longer valid / the server did not accept it), also as
23
+ `"anonymous_reason"` in `--json`. Before, a login the server had refused (401/403) followed by a server error was
24
+ described as "no account was signed in". Exit code `4` in `--help` and the README now also covers `list` and
25
+ `close` ("nothing was changed"), and the offline-and-expired-session and signed-out-by-sending-time cases are listed.
26
+
3
27
  ## 0.12.3 — 2026-10-30
4
28
 
5
29
  - **Fix: a queued report could be tagged with the wrong account.** The account id was read after a failed send, the
package/README.md CHANGED
@@ -769,7 +769,7 @@ anonymous. Who wrote it is decided from `--agent`, else from `PLE_AGENT=<name>`,
769
769
  | `1` | Something unexpected |
770
770
  | `2` | Usage or validation error — nothing was sent (bad flag, empty or too long message, secret found, rejected by the server) |
771
771
  | `3` | Rate limited — try again after the delay shown |
772
- | `4` | Server or network problem — the report was saved to the local queue (with `PLE_FEEDBACK_QUEUE=off`: nothing was saved) |
772
+ | `4` | Server or network problem — the report was saved to the local queue (with `PLE_FEEDBACK_QUEUE=off`: nothing was saved); `list`: nothing was changed; `close`: it may have been applied, check with `ple feedback list` |
773
773
 
774
774
  **Offline queue.** A report that could not be delivered is saved to `~/.promptlike/feedback/queue.json` (at most 50;
775
775
  the oldest is dropped when it is full; mode `0600`). After any other `ple` command it is sent silently, with a
@@ -777,8 +777,8 @@ the oldest is dropped when it is full; mode `0600`). After any other `ple` comma
777
777
  `suggest`, `import`) and never when the command failed. A report written while you are signed in is sent with that
778
778
  same account only, and only while that account is still signed in with a session that is not about to expire and
779
779
  that the server accepts. In every other case it goes out anonymously: written signed out (or while the saved login
780
- could not be checked, e.g. offline with an expired session), another account signed in at sending time, or the
781
- session refused. Signing in later never attaches an older report to the new account. Turn it off with `PLE_FEEDBACK_QUEUE=off`: then nothing is written to disk and a report that cannot be
780
+ could not be checked, e.g. offline, or the server busy, with an expired session), signed out by the time it is sent, another account
781
+ signed in at sending time, or the session refused. Signing in later never attaches an older report to the new account. Turn it off with `PLE_FEEDBACK_QUEUE=off`: then nothing is written to disk and a report that cannot be
782
782
  delivered is simply not sent (exit code 4, run `ple feedback` again when you are online).
783
783
 
784
784
  **Pointer on a miss.** When `ple search` finds nothing, or `ple get` fails, one line goes to stderr:
@@ -794,7 +794,9 @@ ple feedback close <id> --commit <sha> [--status done|wontfix] [--json]
794
794
  `list` prints what the server returns (with `--json`: `{"ok":true,"exit_code":0,"items":[…]}` exactly as sent, e-mail
795
795
  addresses included). `close` marks an item `done` (default) or `wontfix` and records the commit that resolved it
796
796
  (`--commit` is required for `done`). They use `0` ok · `1` not signed in or not allowed · `2` bad input · `3` rate limit ·
797
- `4` server or network problem (nothing is queued for these two).
797
+ `4` server or network problem (nothing is queued for these two; after a `close` that got no clean answer the change may
798
+ have been applied: check with `ple feedback list` before closing it again). `ple feedback list --help` and
799
+ `ple feedback close --help` print their own table.
798
800
 
799
801
  ### `ple config get [key]` · `ple config set <key> <value>`
800
802
 
@@ -20,7 +20,7 @@
20
20
  * one it is anonymous.
21
21
  */
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.FEEDBACK_EXIT_CODES_HELP = exports.EXIT_QUEUED = exports.EXIT_RATE_LIMITED = exports.EXIT_USAGE = exports.EXIT_UNEXPECTED = exports.EXIT_SENT = void 0;
23
+ exports.MAX_LIST_LIMIT = exports.DEFAULT_LIST_LIMIT = exports.FEEDBACK_CLOSE_EXIT_CODES_HELP = exports.FEEDBACK_LIST_EXIT_CODES_HELP = exports.FEEDBACK_EXIT_CODES_HELP = exports.EXIT_QUEUED = exports.EXIT_RATE_LIMITED = exports.EXIT_USAGE = exports.EXIT_UNEXPECTED = exports.EXIT_SENT = void 0;
24
24
  exports.feedbackCommand = feedbackCommand;
25
25
  exports.feedbackListCommand = feedbackListCommand;
26
26
  exports.feedbackCloseCommand = feedbackCloseCommand;
@@ -43,7 +43,23 @@ exports.FEEDBACK_EXIT_CODES_HELP = [
43
43
  '1 unexpected problem (list / close: also not signed in, or not allowed)',
44
44
  '2 usage or validation error — nothing was sent',
45
45
  '3 rate limited — try again after the delay shown',
46
- '4 server or network problem — saved to the local queue and sent by a later `ple` command (with PLE_FEEDBACK_QUEUE=off: not saved, not sent)',
46
+ '4 server or network problem — a report is saved to the local queue and sent by a later `ple` command (PLE_FEEDBACK_QUEUE=off: not saved); list: nothing was changed; close: it may have been applied, check with `ple feedback list`',
47
+ ];
48
+ /** `list --help`: the same codes, in the words that fit a read. */
49
+ exports.FEEDBACK_LIST_EXIT_CODES_HELP = [
50
+ '0 listed',
51
+ '1 not signed in, not the owner account, session not accepted, or an unexpected answer',
52
+ '2 bad --status / --limit',
53
+ '3 rate limited — try again after the delay shown',
54
+ '4 server or network problem — nothing was changed',
55
+ ];
56
+ /** `close --help`: the same codes, in the words that fit a write. */
57
+ exports.FEEDBACK_CLOSE_EXIT_CODES_HELP = [
58
+ '0 closed',
59
+ '1 not signed in, not the owner account, session not accepted, or an unexpected answer',
60
+ '2 bad id, --commit or --status, or no feedback with that id',
61
+ '3 rate limited — try again after the delay shown',
62
+ '4 server or network problem — if the request was already sent the change may have been applied: check with `ple feedback list`, do not assume it failed',
47
63
  ];
48
64
  // ---------------------------------------------------------------------------
49
65
  // Output
@@ -78,7 +94,11 @@ async function defaultToken() {
78
94
  // The server could not be reached to refresh the session: it cannot take the report either.
79
95
  if (err instanceof api_client_1.NetworkError || err instanceof api_client_1.RequestTimeoutError)
80
96
  return { unreachable: err.message };
81
- return {}; // a dead session must not block a report: it goes out anonymously
97
+ // A passing outage of the refresh (503 / 429 / 5xx) says nothing about the login: it stays valid, and the
98
+ // report waits like an offline one instead of being filed as "refused".
99
+ if (err instanceof api_client_1.ApiError && (err.status === 429 || err.status >= 500))
100
+ return { unreachable: err.message };
101
+ return { dead: true }; // a definitively rejected session must not block a report: it goes out anonymously
82
102
  }
83
103
  }
84
104
  async function feedbackCommand(messageParts, opts = {}, deps = {}) {
@@ -117,6 +137,9 @@ async function submit(message, opts, deps, json) {
117
137
  const send = deps.send ?? ((p, o) => (0, feedbackApi_1.sendFeedback)(p, o));
118
138
  let result;
119
139
  let attachedAccount = Boolean(auth.token);
140
+ // Why a report is NOT tied to an account (said when it is queued): nobody signed in, the login could not be
141
+ // checked (offline), or the login is dead / refused by the server.
142
+ let anonReason = auth.unreachable ? 'unchecked' : auth.dead ? 'refused' : 'signed_out';
120
143
  if (auth.unreachable) {
121
144
  result = { kind: 'unavailable', message: auth.unreachable };
122
145
  attachedAccount = false;
@@ -126,6 +149,7 @@ async function submit(message, opts, deps, json) {
126
149
  if (result.kind === 'auth' && auth.token) {
127
150
  // The server did not accept the session: the report still matters, send it without one.
128
151
  attachedAccount = false;
152
+ anonReason = 'refused';
129
153
  result = await send(payload, { token: undefined });
130
154
  }
131
155
  }
@@ -134,10 +158,10 @@ async function submit(message, opts, deps, json) {
134
158
  case 'sent':
135
159
  setExit(exports.EXIT_SENT);
136
160
  if (json)
137
- emitJson({ ok: true, ...(result.id ? { id: result.id } : {}), exit_code: exports.EXIT_SENT, ...base, account: attachedAccount });
161
+ emitJson({ ok: true, ...(result.id ? { id: result.id } : {}), exit_code: exports.EXIT_SENT, ...base, account: attachedAccount, ...(attachedAccount ? {} : { anonymous_reason: anonReason }) });
138
162
  else {
139
163
  console.log(format_1.c.success('✓ Feedback sent — thank you.') + (result.id ? format_1.c.muted(` (id ${result.id})`) : ''));
140
- console.log(format_1.c.muted(attachedAccount ? ' Tied to your account.' : ' Sent anonymously (sign in with `ple login` to attach it to your account).'));
164
+ console.log(format_1.c.muted(attachedAccount ? ' Tied to your account.' : ` Sent anonymously (${ANON_REASON_TEXT[anonReason]}).${anonReason === 'signed_out' ? ' Sign in with `ple login` to attach reports to your account.' : ''}`));
141
165
  }
142
166
  return;
143
167
  case 'invalid':
@@ -149,14 +173,19 @@ async function submit(message, opts, deps, json) {
149
173
  return fail(json, exports.EXIT_RATE_LIMITED, `Rate limited. Try again${wait !== undefined ? ` in ${wait}s` : ' in a moment'}.`, { retry_after: wait ?? null });
150
174
  }
151
175
  case 'unavailable':
152
- return queueIt(payload, result.message, json, env, deps, base, attachedAccount ? auth.userId : undefined);
176
+ return queueIt(payload, result.message, json, env, deps, base, attachedAccount ? auth.userId : undefined, anonReason);
153
177
  case 'auth':
154
178
  return fail(json, exports.EXIT_UNEXPECTED, `The server refused the report (HTTP ${result.status}).`);
155
179
  default:
156
180
  return fail(json, exports.EXIT_UNEXPECTED, `Unexpected answer from the server (HTTP ${result.status}): ${result.message}`);
157
181
  }
158
182
  }
159
- function queueIt(payload, reason, json, env, deps, base, userId) {
183
+ const ANON_REASON_TEXT = {
184
+ signed_out: 'no account was signed in',
185
+ unchecked: 'the saved login could not be checked right now (offline or the server is busy); it is kept',
186
+ refused: 'the saved login is no longer valid or the server did not accept it',
187
+ };
188
+ function queueIt(payload, reason, json, env, deps, base, userId, anonReason) {
160
189
  // `PLE_FEEDBACK_QUEUE=off`: nothing is written to disk (data minimisation); the report is simply not delivered.
161
190
  if (!(0, feedbackQueue_1.queueEnabled)(env)) {
162
191
  setExit(exports.EXIT_QUEUED);
@@ -185,6 +214,7 @@ function queueIt(payload, reason, json, env, deps, base, userId) {
185
214
  exit_code: exports.EXIT_QUEUED,
186
215
  queue_size: queued.size,
187
216
  account: Boolean(userId),
217
+ ...(userId ? {} : { anonymous_reason: anonReason }),
188
218
  ...(queued.droppedOldest ? { dropped_oldest: true } : {}),
189
219
  send_later: sendsLater,
190
220
  error: reason,
@@ -196,7 +226,7 @@ function queueIt(payload, reason, json, env, deps, base, userId) {
196
226
  console.error(format_1.c.muted(` Saved to the local queue (${queued.size} waiting${queued.droppedOldest ? ', the oldest one was dropped' : ''}). ${note}`));
197
227
  console.error(format_1.c.muted(userId
198
228
  ? ' Written under your account: it is sent with that account only if it is still signed in then, otherwise anonymously.'
199
- : ' It will be sent anonymously (no account was signed in, or the saved login could not be checked).'));
229
+ : ` It will be sent anonymously (${ANON_REASON_TEXT[anonReason]}).`));
200
230
  }
201
231
  async function ownerAuth() {
202
232
  if ((0, config_1.configStatus)() !== 'valid')
@@ -213,11 +243,13 @@ async function ownerAuth() {
213
243
  return token ? { token } : { error: 'This command needs a session. Sign in first: ple login', code: exports.EXIT_UNEXPECTED };
214
244
  }
215
245
  /** The same status → exit code mapping for both owner commands. Returns null when the response is a success (2xx). */
216
- function ownerFailure(out) {
246
+ function ownerFailure(out, writes = false) {
247
+ // A read changes nothing. A write that got no clean answer (timeout, 5xx) may or may not have been applied.
248
+ const unsure = 'It may have been applied: check with `ple feedback list` before closing it again.';
217
249
  if (out.kind === 'config')
218
250
  return { code: exports.EXIT_USAGE, error: out.message };
219
251
  if (out.kind === 'unreachable')
220
- return { code: exports.EXIT_QUEUED, error: `${out.message} Nothing was changed.` };
252
+ return { code: exports.EXIT_QUEUED, error: `${out.message} ${writes ? unsure : 'Nothing was changed.'}` };
221
253
  const { status, body } = out;
222
254
  if (status >= 200 && status < 300)
223
255
  return null;
@@ -238,10 +270,11 @@ function ownerFailure(out) {
238
270
  return { code: exports.EXIT_USAGE, error: (0, feedbackApi_1.serverMessage)(body, fallback) + (details ? ` (${details})` : '') };
239
271
  }
240
272
  if (status >= 500 || status === 408)
241
- return { code: exports.EXIT_QUEUED, error: `The server answered HTTP ${status}. Nothing was changed.` };
273
+ return { code: exports.EXIT_QUEUED, error: `The server answered HTTP ${status}. ${writes ? unsure : 'Nothing was changed.'}` };
242
274
  return { code: exports.EXIT_UNEXPECTED, error: (0, feedbackApi_1.serverMessage)(body, `The server answered HTTP ${status}.`) };
243
275
  }
244
- const MAX_LIST_LIMIT = 200;
276
+ exports.DEFAULT_LIST_LIMIT = 50;
277
+ exports.MAX_LIST_LIMIT = 200;
245
278
  async function feedbackListCommand(opts = {}, deps = {}) {
246
279
  const json = opts.json === true;
247
280
  try {
@@ -249,10 +282,10 @@ async function feedbackListCommand(opts = {}, deps = {}) {
249
282
  if (status !== undefined && !feedbackApi_1.FEEDBACK_STATUSES.includes(status)) {
250
283
  return fail(json, exports.EXIT_USAGE, `--status must be one of: ${feedbackApi_1.FEEDBACK_STATUSES.join(', ')}.`);
251
284
  }
252
- let limit = 50;
285
+ let limit = exports.DEFAULT_LIST_LIMIT;
253
286
  if (opts.limit !== undefined) {
254
- if (!/^\d{1,4}$/.test(opts.limit.trim()) || Number(opts.limit) < 1 || Number(opts.limit) > MAX_LIST_LIMIT) {
255
- return fail(json, exports.EXIT_USAGE, `--limit must be a whole number from 1 to ${MAX_LIST_LIMIT}.`);
287
+ if (!/^\d{1,4}$/.test(opts.limit.trim()) || Number(opts.limit) < 1 || Number(opts.limit) > exports.MAX_LIST_LIMIT) {
288
+ return fail(json, exports.EXIT_USAGE, `--limit must be a whole number from 1 to ${exports.MAX_LIST_LIMIT}.`);
256
289
  }
257
290
  limit = Number(opts.limit);
258
291
  }
@@ -351,7 +384,7 @@ async function feedbackCloseCommand(id, opts = {}, deps = {}) {
351
384
  timeoutMs: feedbackApi_1.OWNER_TIMEOUT_MS,
352
385
  fetchImpl: deps.fetchImpl,
353
386
  });
354
- const failure = ownerFailure(out);
387
+ const failure = ownerFailure(out, true);
355
388
  if (failure)
356
389
  return fail(json, failure.code, failure.error, failure.extra);
357
390
  setExit(exports.EXIT_SENT);
@@ -18,6 +18,7 @@ exports.saveWinner = saveWinner;
18
18
  exports.createPrompt = createPrompt;
19
19
  exports.patchDescription = patchDescription;
20
20
  exports.addTagByName = addTagByName;
21
+ const crypto_1 = require("crypto");
21
22
  const constants_1 = require("./constants");
22
23
  const config_1 = require("./config");
23
24
  /**
@@ -133,7 +134,7 @@ async function requestVariants(promptId, opts = {}) {
133
134
  const body = {
134
135
  // Her tur ayrı bilinçli üretim: nonce, aynı dakikadaki idempotency
135
136
  // çakışmasını (bedava üretim + sahte critical alarm) önler.
136
- attempt: crypto.randomUUID(),
137
+ attempt: (0, crypto_1.randomUUID)(),
137
138
  };
138
139
  if (opts.count !== undefined)
139
140
  body.count = opts.count;
package/dist/program.js CHANGED
@@ -36,6 +36,7 @@ const suggest_1 = require("./commands/suggest");
36
36
  const config_1 = require("./commands/config");
37
37
  const repo_1 = require("./commands/repo");
38
38
  const feedback_1 = require("./commands/feedback");
39
+ const feedbackQueue_1 = require("./lib/feedbackQueue");
39
40
  const feedbackApi_1 = require("./lib/feedbackApi");
40
41
  const feedbackInput_1 = require("./lib/feedbackInput");
41
42
  const feedbackHint_1 = require("./lib/feedbackHint");
@@ -332,10 +333,12 @@ function buildProgram() {
332
333
  'account; signed out it is anonymous. Do not put secrets or personal data in the message: a message that',
333
334
  'looks like a key or token is refused.',
334
335
  '',
335
- 'If the server cannot be reached the report is saved to ~/.promptlike/feedback/queue.json (max 50) and',
336
- 'sent by a later `ple` command (at most every 15 minutes). A report written while you are signed in goes',
337
- 'out with that same account only; otherwise (signed out, another account, a session about to expire or',
338
- 'refused) it goes out anonymously. With PLE_FEEDBACK_QUEUE=off nothing is saved or sent later.',
336
+ `If the server cannot be reached the report is saved to ~/.promptlike/feedback/queue.json (max ${feedbackQueue_1.QUEUE_MAX}) and`,
337
+ `sent by a later \`ple\` command (at most every ${feedbackQueue_1.RETRY_INTERVAL_MS / 60000} minutes). A report written while you are signed in goes`,
338
+ 'out with that same account only; otherwise (signed out by then, another account, a session about to expire',
339
+ 'or refused, or a login that could not be checked while offline or the server is busy) it goes out',
340
+ 'anonymously. With',
341
+ 'PLE_FEEDBACK_QUEUE=off nothing is saved or sent later.',
339
342
  '',
340
343
  'Exit codes:',
341
344
  ...feedback_1.FEEDBACK_EXIT_CODES_HELP.map((l) => ` ${l}`),
@@ -347,8 +350,9 @@ function buildProgram() {
347
350
  .command('list')
348
351
  .description('List the feedback people sent (owner)')
349
352
  .addOption(new commander_1.Option('--status <status>', `Only this status: ${feedbackApi_1.FEEDBACK_STATUSES.join(' | ')}`))
350
- .option('-l, --limit <n>', 'Max rows (default 50)')
353
+ .option('-l, --limit <n>', `Max rows (default ${feedback_1.DEFAULT_LIST_LIMIT}, at most ${feedback_1.MAX_LIST_LIMIT})`)
351
354
  .option('--json', 'Print the items as JSON, exactly as the server returned them')
355
+ .addHelpText('after', ['', 'Exit codes:', ...feedback_1.FEEDBACK_LIST_EXIT_CODES_HELP.map((l) => ` ${l}`), ''].join('\n'))
352
356
  .action(runWithErrorHandler(async (opts, cmd) => (0, feedback_1.feedbackListCommand)({ ...opts, json: opts.json ?? cmd.optsWithGlobals().json === true })));
353
357
  feedback
354
358
  .command('close <id>')
@@ -356,6 +360,7 @@ function buildProgram() {
356
360
  .option('--commit <sha>', 'The commit that resolved it (required for done)')
357
361
  .addOption(new commander_1.Option('--status <status>', 'done (default) or wontfix'))
358
362
  .option('--json', 'Print the result as one JSON line')
363
+ .addHelpText('after', ['', 'Exit codes:', ...feedback_1.FEEDBACK_CLOSE_EXIT_CODES_HELP.map((l) => ` ${l}`), ''].join('\n'))
359
364
  .action(runWithErrorHandler(async (id, opts, cmd) => (0, feedback_1.feedbackCloseCommand)(id, { ...opts, json: opts.json ?? cmd.optsWithGlobals().json === true })));
360
365
  // ---- insights & settings ------------------------------------------------
361
366
  program
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptlike",
3
- "version": "0.12.3",
3
+ "version": "0.12.5",
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"