promptlike 0.2.0 → 0.2.2

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/README.md CHANGED
@@ -350,21 +350,50 @@ HTTP, so there is no type-sync step for the CLI.
350
350
 
351
351
  Publishing is automated: pushing a `cli-v*` git tag runs the
352
352
  `.github/workflows/cli-publish.yml` workflow, which typechecks, tests, builds,
353
- and runs `npm publish --access public` (using the `NPM_TOKEN` repo secret).
353
+ and runs `npm publish --access public`.
354
+
355
+ Auth is **npm Trusted Publishing (OIDC)** — no token. npm verifies via OpenID
356
+ Connect that this exact repo + workflow is the package's configured trusted
357
+ publisher (npmjs.com/package/promptlike → Settings → Trusted Publisher:
358
+ `zeynepaslierhann` / `PromptLikeEngineer` / `cli-publish.yml`). The workflow
359
+ needs `permissions: id-token: write` and npm >= 11.5.1 (the runner upgrades npm
360
+ on Node 22), which the current workflow already sets.
361
+
362
+ This CLI lives in a monorepo, so bump the version **without** letting `npm`
363
+ create its own tag/commit, then push a `cli-v<version>` tag whose number
364
+ matches `package.json` exactly. Run everything from the repo root:
354
365
 
355
366
  ```bash
356
- npm version patch # bump package.json (or minor / major)
357
- git commit -am "cli: v0.2.1"
367
+ # 1. Bump cli/package.json only (no auto tag, no auto commit)
368
+ npm --prefix cli version patch --no-git-tag-version # or minor / major
369
+
370
+ # 2. Commit the bump (grab the new number from cli/package.json)
371
+ git add cli/package.json cli/package-lock.json
372
+ git commit -m "chore(cli): v0.2.1"
373
+ git push origin main
374
+
375
+ # 3. Tag that commit — the tag push is what triggers publishing
358
376
  git tag cli-v0.2.1
359
- git push origin main --tags # tag push triggers the publish workflow
377
+ git push origin cli-v0.2.1
360
378
  ```
361
379
 
362
- To publish manually instead:
380
+ Rules the automation relies on:
381
+
382
+ - The tag number **must** equal `cli/package.json#version` (npm rejects a
383
+ mismatch, and a version can never be published twice).
384
+ - Push the tag on its own (`git push origin cli-v0.2.1`), **not**
385
+ `git push --tags` — that would also push any stray local tags.
386
+ - If the run fails on the test step, nothing is published (publish runs last);
387
+ fix, move the tag to the new commit (`git tag -d` + delete remote + re-tag),
388
+ and push again.
389
+
390
+ To publish manually instead (only if CI is unavailable):
363
391
 
364
392
  ```bash
393
+ cd cli
365
394
  npm run build
366
395
  npm publish --dry-run # verify only dist/, README.md, LICENSE ship
367
- npm publish --access public
396
+ npm publish --access public # requires npm login + 2FA OTP
368
397
  ```
369
398
 
370
399
  `package.json#files` and `.npmignore` keep `src/`, `tsconfig.json`, and tests
@@ -30,6 +30,7 @@ async function copyCommand(name) {
30
30
  }
31
31
  try {
32
32
  await (0, clipboard_1.copyToClipboard)(text);
33
+ (0, api_client_1.recordPromptUse)(prompt.id); // Most Used verisi (REV-6) — fire-and-forget
33
34
  console.log(format_1.c.success(`✓ Copied: ${prompt.title}`) +
34
35
  format_1.c.muted(` (${(0, format_1.shortId)(prompt.id)}, ${text.length} chars)`));
35
36
  }
@@ -47,6 +47,7 @@ async function getCommand(name, options = {}) {
47
47
  console.error(format_1.c.muted(` Fill with: --var ${remaining[0]}=...`));
48
48
  }
49
49
  // THE OUTPUT — raw, to stdout (agent-readable).
50
+ (0, api_client_1.recordPromptUse)(prompt.id); // Most Used verisi (REV-6) — fire-and-forget
50
51
  process.stdout.write(filled.endsWith('\n') ? filled : filled + '\n');
51
52
  if (options.copy) {
52
53
  try {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loopChangelog = loopChangelog;
4
+ exports.parsePick = parsePick;
4
5
  exports.improveCommand = improveCommand;
5
6
  const api_client_1 = require("../lib/api-client");
6
7
  const promptResolver_1 = require("../lib/promptResolver");
@@ -11,6 +12,18 @@ const loopUx_1 = require("../lib/loopUx");
11
12
  function loopChangelog(variant) {
12
13
  return `Loop(${variant.strategy}): ${variant.rationale}`.trim();
13
14
  }
15
+ /** Parse/validate `--pick` against the variant count. undefined = not passed
16
+ * (fall back to interactive). Throws on out-of-range. */
17
+ function parsePick(raw, max) {
18
+ if (raw === undefined)
19
+ return undefined;
20
+ const trimmed = raw.trim();
21
+ const n = Number.parseInt(trimmed, 10);
22
+ if (Number.isNaN(n) || String(n) !== trimmed || n < 0 || n > max) {
23
+ throw new Error(`Invalid --pick '${raw}' — expected 0 (cancel) or 1..${max}.`);
24
+ }
25
+ return n;
26
+ }
14
27
  /**
15
28
  * `ple improve <name> [--focus <hint>]` — single-round Loop Engineering.
16
29
  *
@@ -41,7 +54,8 @@ async function improveCommand(name, options = {}) {
41
54
  (0, loopUx_1.renderVariants)(variants, baseline);
42
55
  console.log();
43
56
  console.log(format_1.c.muted(`${tokensUsed} AI tokens used.`));
44
- const pick = await (0, loopUx_1.selectVariant)(variants.length);
57
+ const override = parsePick(options.pick, variants.length);
58
+ const pick = override !== undefined ? override : await (0, loopUx_1.selectVariant)(variants.length);
45
59
  if (pick === 0) {
46
60
  console.log(format_1.c.muted('Cancelled — nothing saved.'));
47
61
  return;
@@ -60,7 +60,8 @@ async function loopCommand(name, options = {}) {
60
60
  }
61
61
  console.log();
62
62
  console.log(format_1.c.muted(`${tokensUsed} AI tokens used this round.`));
63
- const pick = await (0, loopUx_1.selectVariant)(variants.length);
63
+ const override = (0, improve_1.parsePick)(options.pick, variants.length);
64
+ const pick = override !== undefined ? override : await (0, loopUx_1.selectVariant)(variants.length);
64
65
  if (pick === 0) {
65
66
  console.log(format_1.c.muted('Cancelled — nothing saved this round.'));
66
67
  return;
@@ -73,7 +74,8 @@ async function loopCommand(name, options = {}) {
73
74
  // round generates from it. Track it locally for size comparisons.
74
75
  baseline = (0, loopUx_1.variantText)(winner);
75
76
  if (round < rounds) {
76
- const goOn = await (0, loopUx_1.confirmContinue)();
77
+ // --pick verildiyse non-interactive niyet → sonraki tura otomatik geç.
78
+ const goOn = override !== undefined ? true : await (0, loopUx_1.confirmContinue)();
77
79
  if (!goOn) {
78
80
  console.log(format_1.c.muted(`Stopped after round ${round}.`));
79
81
  return;
@@ -23,6 +23,7 @@ async function showCommand(name) {
23
23
  process.exitCode = 1;
24
24
  return;
25
25
  }
26
+ (0, api_client_1.recordPromptUse)(prompt.id); // Most Used verisi (REV-6) — fire-and-forget
26
27
  // Header
27
28
  console.log();
28
29
  console.log(format_1.c.title(prompt.title));
package/dist/index.js CHANGED
@@ -68,6 +68,7 @@ program
68
68
  .action(runWithErrorHandler(get_1.getCommand));
69
69
  program
70
70
  .command('improve <name>')
71
+ .option('-p, --pick <n>', 'Non-interactive: auto-pick variant N (1..3), 0 to cancel — for scripts/agents')
71
72
  .description('Generate AI variants of a prompt, pick a winner, save it as a new version (Pro)')
72
73
  .option('-f, --focus <hint>', "Steer the variants (e.g. 'shorter', 'more explicit output format')")
73
74
  .action(runWithErrorHandler(improve_1.improveCommand));
@@ -77,6 +78,7 @@ program
77
78
  .option('-e, --exec <cmd>', 'Test each variant: prompt passed via PLE_PROMPT env + stdin; {} placeholder substituted')
78
79
  .option('-r, --rounds <n>', 'Number of improvement rounds', '1')
79
80
  .option('-f, --focus <hint>', 'Steer the variants')
81
+ .option('-p, --pick <n>', 'Non-interactive: auto-pick variant N each round + auto-continue — for scripts/agents')
80
82
  .action(runWithErrorHandler(loop_1.loopCommand));
81
83
  program
82
84
  .command('search <keyword>')
@@ -18,6 +18,7 @@ exports.login = login;
18
18
  exports.ensureAuthed = ensureAuthed;
19
19
  exports.listPrompts = listPrompts;
20
20
  exports.getPromptById = getPromptById;
21
+ exports.recordPromptUse = recordPromptUse;
21
22
  const constants_1 = require("./constants");
22
23
  const config_1 = require("./config");
23
24
  const NOT_LOGGED_IN = 'Not logged in. Run `ple login` first.';
@@ -110,7 +111,12 @@ async function refreshSession() {
110
111
  /** Core request helper. See module doc for behavior. */
111
112
  async function apiFetch(path, opts = {}) {
112
113
  const { method = 'GET', body, query, auth = true } = opts;
113
- const headers = { 'Content-Type': 'application/json' };
114
+ const headers = {
115
+ 'Content-Type': 'application/json',
116
+ // REV-6: sunucu CLI surumunu bilsin — eski CLI + degismis API semasi
117
+ // sessizce kirilmasin (kontrat gozlemlenebilirligi / min-version zemini)
118
+ 'X-CLI-Version': constants_1.CLI_VERSION,
119
+ };
114
120
  if (auth) {
115
121
  headers['Authorization'] = `Bearer ${getAccessTokenOrThrow()}`;
116
122
  }
@@ -190,3 +196,14 @@ async function getPromptById(id) {
190
196
  throw err;
191
197
  }
192
198
  }
199
+ /**
200
+ * Kullanım kaydı (REV-6) — `ple copy/get/show` sonrası fire-and-forget.
201
+ * Most Used + ⌘K sıralaması eskiden yalnız web kopyalarını sayıyordu; ana
202
+ * reuse yüzeyi terminal olduğundan metrik köreliyordu. Hata YUTULUR:
203
+ * telemetri asıl komutu asla kırmaz.
204
+ */
205
+ function recordPromptUse(promptId) {
206
+ apiFetch(`/api/prompts/${promptId}/use`, { method: 'POST' }).catch(() => {
207
+ /* sessiz — telemetri */
208
+ });
209
+ }
@@ -23,6 +23,6 @@ function resolveEnv(key, fallback) {
23
23
  /** Base URL of the web API the CLI calls (no trailing slash). */
24
24
  exports.API_BASE_URL = resolveEnv('PROMPTLIKE_API_URL', BAKED_API_URL).replace(/\/+$/, '');
25
25
  exports.CLI_NAME = 'ple';
26
- exports.CLI_VERSION = '0.2.0';
26
+ exports.CLI_VERSION = '0.2.2';
27
27
  /** Web app URL — shown to the user when their prompt list is empty. */
28
28
  exports.WEB_APP_URL = 'https://promptlikeengineer.com';
@@ -58,13 +58,15 @@ function truncate(str, max) {
58
58
  return str;
59
59
  return str.slice(0, max - 1) + '…';
60
60
  }
61
- /** Üç parçalı içeriği (role/description/context) tek metne birleştir. */
61
+ /** Üç parçalı içeriği (role/description/context) tek metne birleştir.
62
+ * Yapısal parçalardan yeniden kurar ve BOŞ bölümleri atlar → yalnız-description
63
+ * bir prompt'ta başıboş `---` ayraçları çıkmaz (E2E bulgusu F2). Stored `content`
64
+ * yalnız üç parça da boşken (gerçek legacy tek-alan kaydı) yedek olarak kullanılır. */
62
65
  function joinPromptParts(parts) {
63
- // Eski kayıtlarda content tek alanda — onu önce dene
64
- if (parts.content && parts.content.trim())
65
- return parts.content;
66
66
  const segments = [parts.role_text, parts.description_text, parts.context_text]
67
67
  .map((s) => (s || '').trim())
68
68
  .filter(Boolean);
69
- return segments.join('\n\n---\n\n');
69
+ if (segments.length > 0)
70
+ return segments.join('\n\n---\n\n');
71
+ return parts.content && parts.content.trim() ? parts.content.trim() : '';
70
72
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptlike",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
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"