promptlike 0.12.1 → 0.12.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 CHANGED
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.12.3 — 2026-10-30
4
+
5
+ - **Fix: a queued report could be tagged with the wrong account.** The account id was read after a failed send, the
6
+ token before it: if another terminal switched accounts in between, one account's note could be queued under (and
7
+ later sent as) the other. Token and account id now come from one read of the saved login.
8
+ - **`ple feedback` now says whether a queued report was written under an account** (a line in the text output,
9
+ `"account": true|false` in `--json`), and `--help` and the README spell out when a queued report goes out
10
+ anonymously: signed out or the login could not be checked, another account signed in at sending time, a session
11
+ about to expire, or one the server refuses. The help text no longer says `PLE_FEEDBACK_QUEUE=off` only "turns that
12
+ off"; it writes nothing, as since 0.12.2.
13
+
14
+ ## 0.12.2 — 2026-10-30
15
+
16
+ - **Fix: `PLE_FEEDBACK_QUEUE=off` now writes nothing.** It used to stop only the sending later; an undelivered
17
+ `ple feedback` report was still saved to `~/.promptlike/feedback/queue.json`. Now it is not saved at all (exit code
18
+ `4` still says it was not sent; `--json` carries `"queued": false`).
19
+ - **Fix: a queued report is never linked to an account that was not the author's.** A report queued while signed out
20
+ was attached to whichever account was signed in when it was finally sent. A queued report now remembers the account
21
+ id it was written under: it goes out with that same account only, and anonymously otherwise (also for reports
22
+ queued by 0.11.0 to 0.12.1, which stored no id).
23
+ - `ple import --scan` without `--all` on a non-terminal exits 1 too, like `ple import github:…` and `ple import ple:…`
24
+ since 0.12.1 (this was true in 0.12.1 but not written down).
25
+
3
26
  ## 0.12.1 — 2026-10-30
4
27
 
5
28
  - **Fix: `ple import` exits 1 when nothing was imported because it could not ask.** Run without a terminal (a script,
package/README.md CHANGED
@@ -749,7 +749,7 @@ ple feedback --type missing --json "no way to rename a repo from the CLI"
749
749
  | `--prompt <title\|id>` | The prompt it is about: its **title or id**, never its text |
750
750
  | `--email <address>` | Where to answer you (optional) |
751
751
  | `--agent <name>` | Mark the report as written by an AI agent with this name |
752
- | `--json` | One JSON line on stdout: `{"ok":true,"id":"…","exit_code":0,…}` — on failure `{"ok":false,"exit_code":2,"error":"…"}`, or `{"ok":false,"queued":true,"exit_code":4,…}` |
752
+ | `--json` | One JSON line on stdout: `{"ok":true,"id":"…","exit_code":0,…}` — on failure `{"ok":false,"exit_code":2,"error":"…"}`, or `{"ok":false,"queued":true,"account":true,"exit_code":4,…}` (`"queued":false` with `PLE_FEEDBACK_QUEUE=off`; `account` says whether it was written under an account) |
753
753
 
754
754
  It never asks a question and never waits for input, so an agent can call it. A message is 1 to 2000 characters;
755
755
  one that looks like an API key or token is **refused** (the kind is named, the value never echoed).
@@ -769,12 +769,17 @@ 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 |
772
+ | `4` | Server or network problem — the report was saved to the local queue (with `PLE_FEEDBACK_QUEUE=off`: nothing was saved) |
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
776
776
  2 second limit, at most once every 15 minutes, never after the offline commands (`save`, `log`, `diff`, `rollback`,
777
- `suggest`, `import`) and never when the command failed. Turn it off with `PLE_FEEDBACK_QUEUE=off`.
777
+ `suggest`, `import`) and never when the command failed. A report written while you are signed in is sent with that
778
+ same account only, and only while that account is still signed in with a session that is not about to expire and
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
782
+ delivered is simply not sent (exit code 4, run `ple feedback` again when you are online).
778
783
 
779
784
  **Pointer on a miss.** When `ple search` finds nothing, or `ple get` fails, one line goes to stderr:
780
785
  `Missing something? ple feedback --type missing "..."` (never into the output you pipe).
@@ -851,8 +856,8 @@ Scripts should treat any non-zero code as failure; `2` is the one worth retrying
851
856
  command: `ple whoami-typo` prints `error: unknown command` with the nearest command and exits `2`, like a usage
852
857
  error in `ple feedback`; retrying will not help.
853
858
 
854
- `ple feedback` has its own table (`0` sent · `1` unexpected · `2` usage or validation · `3` rate limited · `4` queued for
855
- later) — see [its section](#ple-feedback-message--tell-the-maker-what-is-missing-or-broken).
859
+ `ple feedback` has its own table (`0` sent · `1` unexpected · `2` usage or validation · `3` rate limited · `4` server or network
860
+ problem: queued for later, or not saved with `PLE_FEEDBACK_QUEUE=off`) — see [its section](#ple-feedback-message--tell-the-maker-what-is-missing-or-broken).
856
861
 
857
862
  ## Security notes
858
863
 
@@ -933,7 +938,7 @@ to configure.
933
938
  | `PLE_SUGGEST=off` | `ple suggest --hook` stays silent |
934
939
  | `PLE_UPDATE_CHECK=off` | No update notice, no cache read, no request to npm |
935
940
  | `NO_UPDATE_NOTIFIER=1` | Same (any value turns it off, even empty); a non-empty `CI` other than `false` / `0` does too |
936
- | `PLE_FEEDBACK_QUEUE=off` | Reports that `ple feedback` could not deliver are not retried by later commands (they are still saved) |
941
+ | `PLE_FEEDBACK_QUEUE=off` | Reports that `ple feedback` could not deliver are not saved and not retried (exit code 4 still tells you it was not sent) |
937
942
  | `PLE_AGENT=<name>` | `ple feedback` marks its reports as written by this agent (also read: `AI_AGENT`, `CLAUDECODE`, `CODEX_*`, `CURSOR_*`) |
938
943
  | `PLE_SURFACE`, `PLE_VIA` | How `copy/get/show` report a use (e.g. `hook`, `suggestion`) |
939
944
  | `PROMPTLIKE_HOME` | Local store location (default `~/.promptlike`) |
@@ -43,7 +43,7 @@ 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, sent by a later `ple` command',
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)',
47
47
  ];
48
48
  // ---------------------------------------------------------------------------
49
49
  // Output
@@ -65,12 +65,14 @@ function fail(json, code, error, extra = {}) {
65
65
  // ---------------------------------------------------------------------------
66
66
  // ple feedback "<message>"
67
67
  // ---------------------------------------------------------------------------
68
+ /** The token and the id of the account it belongs to, read from ONE snapshot of the saved login (another terminal may switch accounts at any moment). */
68
69
  async function defaultToken() {
69
70
  if ((0, config_1.configStatus)() !== 'valid')
70
71
  return {};
71
72
  try {
72
73
  await (0, api_client_1.ensureAuthed)();
73
- return { token: (0, config_1.readConfig)()?.access_token };
74
+ const config = (0, config_1.readConfig)();
75
+ return { token: config?.access_token, userId: config?.user_id || undefined };
74
76
  }
75
77
  catch (err) {
76
78
  // The server could not be reached to refresh the session: it cannot take the report either.
@@ -147,32 +149,42 @@ async function submit(message, opts, deps, json) {
147
149
  return fail(json, exports.EXIT_RATE_LIMITED, `Rate limited. Try again${wait !== undefined ? ` in ${wait}s` : ' in a moment'}.`, { retry_after: wait ?? null });
148
150
  }
149
151
  case 'unavailable':
150
- return queueIt(payload, result.message, json, env, deps, base);
152
+ return queueIt(payload, result.message, json, env, deps, base, attachedAccount ? auth.userId : undefined);
151
153
  case 'auth':
152
154
  return fail(json, exports.EXIT_UNEXPECTED, `The server refused the report (HTTP ${result.status}).`);
153
155
  default:
154
156
  return fail(json, exports.EXIT_UNEXPECTED, `Unexpected answer from the server (HTTP ${result.status}): ${result.message}`);
155
157
  }
156
158
  }
157
- function queueIt(payload, reason, json, env, deps, base) {
159
+ function queueIt(payload, reason, json, env, deps, base, userId) {
160
+ // `PLE_FEEDBACK_QUEUE=off`: nothing is written to disk (data minimisation); the report is simply not delivered.
161
+ if (!(0, feedbackQueue_1.queueEnabled)(env)) {
162
+ setExit(exports.EXIT_QUEUED);
163
+ if (json) {
164
+ emitJson({ ok: false, queued: false, exit_code: exports.EXIT_QUEUED, send_later: false, error: reason, ...base });
165
+ return;
166
+ }
167
+ console.error(format_1.c.warn(`⚠ Could not deliver the report (${reason})`));
168
+ console.error(format_1.c.muted(' Nothing was saved (PLE_FEEDBACK_QUEUE=off); run `ple feedback` again when you are online.'));
169
+ return;
170
+ }
158
171
  let queued;
159
172
  try {
160
- queued = (deps.queue ?? ((p) => (0, feedbackQueue_1.enqueue)(p)))(payload);
173
+ queued = (deps.queue ?? ((p, u) => (0, feedbackQueue_1.enqueue)(p, Date.now(), u)))(payload, userId);
161
174
  }
162
175
  catch (err) {
163
176
  return fail(json, exports.EXIT_UNEXPECTED, `Could not reach the server (${reason}) and could not save the report locally either: ${(0, format_1.safeText)(err instanceof Error ? err.message : String(err)).slice(0, 160)}`);
164
177
  }
165
- const sendsLater = (0, feedbackQueue_1.queueEnabled)(env);
178
+ const sendsLater = true;
166
179
  setExit(exports.EXIT_QUEUED);
167
- const note = sendsLater
168
- ? 'It will be sent by a later `ple` command.'
169
- : 'Sending later is off (PLE_FEEDBACK_QUEUE=off); run `ple feedback` again when you are online.';
180
+ const note = 'It will be sent by a later `ple` command.';
170
181
  if (json) {
171
182
  emitJson({
172
183
  ok: false,
173
184
  queued: true,
174
185
  exit_code: exports.EXIT_QUEUED,
175
186
  queue_size: queued.size,
187
+ account: Boolean(userId),
176
188
  ...(queued.droppedOldest ? { dropped_oldest: true } : {}),
177
189
  send_later: sendsLater,
178
190
  error: reason,
@@ -182,6 +194,9 @@ function queueIt(payload, reason, json, env, deps, base) {
182
194
  }
183
195
  console.error(format_1.c.warn(`⚠ Could not deliver the report (${reason})`));
184
196
  console.error(format_1.c.muted(` Saved to the local queue (${queued.size} waiting${queued.droppedOldest ? ', the oldest one was dropped' : ''}). ${note}`));
197
+ console.error(format_1.c.muted(userId
198
+ ? ' 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).'));
185
200
  }
186
201
  async function ownerAuth() {
187
202
  if ((0, config_1.configStatus)() !== 'valid')
@@ -11,6 +11,12 @@
11
11
  * {@link MAX_QUEUE_FILE_BYTES} on disk. A file that is unreadable, too big or not ours reads as empty and
12
12
  * is replaced by the next write; a single entry that is off (wrong shape, over a limit) is dropped on its own.
13
13
  *
14
+ * Whose report it is: a report queued while signed in remembers the account's id (`user_id`) and is sent later with
15
+ * the session only while that SAME account is signed in. Queued signed out (or from an older version, which stored
16
+ * no id), or when another account is signed in at flush time, it goes out anonymously: signing in afterwards never
17
+ * attaches an earlier note to the new account.
18
+ * `PLE_FEEDBACK_QUEUE=off` means nothing is saved at all (see `ple feedback`), so there is nothing to send later.
19
+ *
14
20
  * Sending later: after ANY other `ple` command, at most once every {@link RETRY_INTERVAL_MS}, within a
15
21
  * {@link FLUSH_TIMEOUT_MS} budget, silently — no output, every error swallowed (the same idea as the update
16
22
  * notice: stamp before the attempt, so a slow or failed one is not retried by the next command in a burst).
@@ -97,6 +103,7 @@ function readQueue() {
97
103
  qid: typeof e.qid === 'string' && /^[0-9a-f]{8,32}$/.test(e.qid) ? e.qid : newQid(),
98
104
  queued_at: typeof e.queued_at === 'string' ? e.queued_at.slice(0, 40) : '',
99
105
  payload,
106
+ ...(typeof e.user_id === 'string' && e.user_id && e.user_id.length <= 64 ? { user_id: e.user_id } : {}),
100
107
  });
101
108
  }
102
109
  return { version: 1, last_attempt_at: isTime(o.last_attempt_at) ? o.last_attempt_at : 0, items: items.slice(-exports.QUEUE_MAX) };
@@ -117,10 +124,10 @@ function writeQueue(state) {
117
124
  * Add one report. The retry timer starts now (`last_attempt_at`), so the very next command does not try
118
125
  * again against a network that just failed. Throws when the file cannot be written.
119
126
  */
120
- function enqueue(payload, now = Date.now()) {
127
+ function enqueue(payload, now = Date.now(), userId) {
121
128
  const state = readQueue();
122
129
  const droppedOldest = state.items.length >= exports.QUEUE_MAX;
123
- const items = [...state.items, { qid: newQid(), queued_at: new Date(now).toISOString(), payload }].slice(-exports.QUEUE_MAX);
130
+ const items = [...state.items, { qid: newQid(), queued_at: new Date(now).toISOString(), payload, ...(userId ? { user_id: userId } : {}) }].slice(-exports.QUEUE_MAX);
124
131
  writeQueue({ version: 1, last_attempt_at: now, items });
125
132
  return { size: items.length, droppedOldest };
126
133
  }
@@ -136,10 +143,11 @@ function isFlushDue(state, now) {
136
143
  const age = now - state.last_attempt_at;
137
144
  return state.last_attempt_at === 0 || age < 0 || age >= exports.RETRY_INTERVAL_MS;
138
145
  }
139
- function sessionToken() {
146
+ /** The saved session's token and account id, when it is not about to expire. */
147
+ function sessionOf() {
140
148
  try {
141
149
  const config = (0, config_1.readConfig)();
142
- return config && !(0, config_1.isTokenExpiringSoon)(config) ? config.access_token : undefined;
150
+ return config && !(0, config_1.isTokenExpiringSoon)(config) ? { token: config.access_token, userId: config.user_id } : undefined;
143
151
  }
144
152
  catch {
145
153
  return undefined;
@@ -178,13 +186,15 @@ async function flushQueue(deps = {}) {
178
186
  writeQueue({ ...state, last_attempt_at: now });
179
187
  result.attempted = true;
180
188
  const send = deps.send ?? ((p, o) => (0, feedbackApi_1.sendFeedback)(p, o));
181
- const token = deps.token === undefined ? sessionToken() : deps.token ?? undefined;
189
+ const session = deps.session === undefined ? sessionOf() : deps.session ?? undefined;
182
190
  const deadline = Date.now() + exports.FLUSH_TIMEOUT_MS;
183
191
  const done = new Set();
184
192
  for (const item of state.items) {
185
193
  const left = deadline - Date.now();
186
194
  if (left < 100)
187
195
  break;
196
+ // Only the account that queued the report may be attached to it; everything else goes out anonymously.
197
+ const token = session && item.user_id && item.user_id === session.userId ? session.token : undefined;
188
198
  let out = await send(item.payload, { token, timeoutMs: left });
189
199
  if (out.kind === 'auth' && token) {
190
200
  const again = deadline - Date.now();
package/dist/program.js CHANGED
@@ -333,7 +333,9 @@ function buildProgram() {
333
333
  'looks like a key or token is refused.',
334
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; PLE_FEEDBACK_QUEUE=off turns that off).',
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.',
337
339
  '',
338
340
  'Exit codes:',
339
341
  ...feedback_1.FEEDBACK_EXIT_CODES_HELP.map((l) => ` ${l}`),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptlike",
3
- "version": "0.12.1",
3
+ "version": "0.12.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"