promptlike 0.10.1 → 0.12.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/CHANGELOG.md +61 -0
- package/README.md +175 -5
- package/dist/commands/feedback.js +351 -0
- package/dist/commands/import.js +6 -1
- package/dist/commands/importPle.js +237 -0
- package/dist/commands/local.js +3 -1
- package/dist/commands/localHistory.js +1 -1
- package/dist/commands/repo.js +49 -0
- package/dist/commands/save.js +71 -0
- package/dist/commands/search.js +4 -1
- package/dist/commands/suggest.js +37 -4
- package/dist/commands/visibility.js +138 -0
- package/dist/commands/whoami.js +80 -0
- package/dist/help.js +5 -3
- package/dist/index.js +5 -1
- package/dist/lib/accountSave.js +159 -0
- package/dist/lib/api-client.js +45 -0
- package/dist/lib/feedbackApi.js +134 -0
- package/dist/lib/feedbackHint.js +15 -0
- package/dist/lib/feedbackInput.js +182 -0
- package/dist/lib/feedbackQueue.js +219 -0
- package/dist/lib/feedbackSource.js +53 -0
- package/dist/lib/libraryCache.js +1 -0
- package/dist/lib/localStore.js +18 -8
- package/dist/lib/loopApi.js +38 -2
- package/dist/lib/pleSpec.js +33 -0
- package/dist/lib/promptResolver.js +51 -5
- package/dist/lib/publicApi.js +92 -0
- package/dist/lib/rank.js +24 -6
- package/dist/lib/titleMatch.js +32 -0
- package/dist/program.js +165 -6
- package/package.json +1 -1
package/dist/lib/rank.js
CHANGED
|
@@ -12,7 +12,11 @@
|
|
|
12
12
|
* 600 characters of the body ×0.5 — plus a small log bonus for past use.
|
|
13
13
|
*
|
|
14
14
|
* Noise gate (a wrong nudge costs more than a missed one): a prompt qualifies
|
|
15
|
-
* only with a title or tag hit, or with at least two distinct terms matched
|
|
15
|
+
* only with a title or tag hit, or with at least two distinct terms matched —
|
|
16
|
+
* and, the longer the task, with proportionally more terms: one generic word
|
|
17
|
+
* ("write") in the title of an unrelated prompt must not carry a 5-term task
|
|
18
|
+
* (see {@link requiredMatches}). Matches scoring under {@link RELATIVE_CUT} of the best one
|
|
19
|
+
* are dropped too: when something fits well, a far weaker neighbour is noise.
|
|
16
20
|
* Case, Turkish letters and accents are folded away on both sides ("kök neden" =
|
|
17
21
|
* "kok neden", "İngilizce" = "ingilizce"). Folding, stop words and tokenisation are
|
|
18
22
|
* the SAME code as the server's `src/lib/suggest.ts` (MCP `suggest_prompts`): the
|
|
@@ -20,10 +24,11 @@
|
|
|
20
24
|
* src/lib/suggest.test.ts fails when the two copies drift.
|
|
21
25
|
*/
|
|
22
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.MIN_SCORE = exports.BODY_HEAD = exports.MAX_TERMS = void 0;
|
|
27
|
+
exports.RELATIVE_CUT = exports.TERMS_PER_REQUIRED_MATCH = exports.MIN_SCORE = exports.BODY_HEAD = exports.MAX_TERMS = void 0;
|
|
24
28
|
exports.foldText = foldText;
|
|
25
29
|
exports.tokenize = tokenize;
|
|
26
30
|
exports.taskTerms = taskTerms;
|
|
31
|
+
exports.requiredMatches = requiredMatches;
|
|
27
32
|
exports.rankLibrary = rankLibrary;
|
|
28
33
|
// <fold-text:begin> — copy of the same block in src/lib/suggest.ts (byte-identical; src/lib/suggest.test.ts locks it)
|
|
29
34
|
/**
|
|
@@ -61,6 +66,18 @@ function taskTerms(task) {
|
|
|
61
66
|
exports.BODY_HEAD = 600;
|
|
62
67
|
/** Minimum score to be suggested at all. */
|
|
63
68
|
exports.MIN_SCORE = 2;
|
|
69
|
+
/** A task of up to this many terms needs one matched term; every further started group of this size, one more. */
|
|
70
|
+
exports.TERMS_PER_REQUIRED_MATCH = 4;
|
|
71
|
+
/** A match scoring below this share of the best match is dropped (the best one always stays). */
|
|
72
|
+
exports.RELATIVE_CUT = 0.5;
|
|
73
|
+
/**
|
|
74
|
+
* Distinct task terms a prompt has to match: 1 up to 4 terms, 2 for 5-8, 3 for 9-12 (the hook keeps ≤12).
|
|
75
|
+
* A long task can name one prompt by a single generic word without being about it; a short one cannot afford
|
|
76
|
+
* to demand more than one.
|
|
77
|
+
*/
|
|
78
|
+
function requiredMatches(termCount) {
|
|
79
|
+
return Math.max(1, Math.ceil(termCount / exports.TERMS_PER_REQUIRED_MATCH));
|
|
80
|
+
}
|
|
64
81
|
const WEIGHTS = { title: 3, tag: 2, description: 1, body: 0.5 };
|
|
65
82
|
/**
|
|
66
83
|
* A term hits a field token when one is a prefix of the other and the
|
|
@@ -91,6 +108,7 @@ function rankLibrary(items, task, limit = 3) {
|
|
|
91
108
|
if (terms.length === 0 || items.length === 0)
|
|
92
109
|
return [];
|
|
93
110
|
const fields = items.map(fieldsOf);
|
|
111
|
+
const needed = requiredMatches(terms.length);
|
|
94
112
|
// Document frequency per term over the whole library → idf.
|
|
95
113
|
const n = items.length;
|
|
96
114
|
const idf = new Map();
|
|
@@ -127,14 +145,14 @@ function rankLibrary(items, task, limit = 3) {
|
|
|
127
145
|
strongHit = true;
|
|
128
146
|
score += (idf.get(term) ?? 0) * w;
|
|
129
147
|
}
|
|
130
|
-
if (!strongHit && matched < 2)
|
|
148
|
+
if (matched < needed || (!strongHit && matched < 2))
|
|
131
149
|
return;
|
|
132
150
|
score += Math.log1p(Math.max(0, item.uses ?? 0)) * 0.3;
|
|
133
151
|
if (score < exports.MIN_SCORE)
|
|
134
152
|
return;
|
|
135
153
|
ranked.push({ item, score: Math.round(score * 100) / 100 });
|
|
136
154
|
});
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
155
|
+
ranked.sort((a, b) => b.score - a.score || (b.item.uses ?? 0) - (a.item.uses ?? 0));
|
|
156
|
+
const floor = ranked.length > 0 ? ranked[0].score * exports.RELATIVE_CUT : 0;
|
|
157
|
+
return ranked.filter((r) => r.score >= floor).slice(0, Math.max(1, Math.min(limit, 10)));
|
|
140
158
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* How a typed name is compared with a prompt title or slug.
|
|
4
|
+
*
|
|
5
|
+
* `ple get "hat baslangici"` must find "Hat başlangıcı", and `ple get "iş akışı"` must find "İş akışı özeti":
|
|
6
|
+
* JavaScript's `toLowerCase()` turns "İ" into "i" + a combining dot and leaves "ı" alone, so a plain
|
|
7
|
+
* lower-case compare misses every Turkish title typed without the letters or with a capital İ/I. The
|
|
8
|
+
* comparison key is the SAME fold the suggestion ranker uses (`foldText` in rank.ts, kept byte-identical
|
|
9
|
+
* with the server's `src/lib/suggest.ts` by a test there): case, Turkish letters and accents folded away.
|
|
10
|
+
* Whitespace runs collapse to one space and the ends are trimmed.
|
|
11
|
+
*
|
|
12
|
+
* The raw (unfolded) lower-case compare still goes first in every resolver, so an exact title always
|
|
13
|
+
* beats a looser match; this key is what makes the looser step see through letters.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.foldKey = foldKey;
|
|
17
|
+
exports.foldedIncludes = foldedIncludes;
|
|
18
|
+
exports.foldedEquals = foldedEquals;
|
|
19
|
+
const rank_1 = require("./rank");
|
|
20
|
+
/** Comparison key of a title, slug or typed name. */
|
|
21
|
+
function foldKey(text) {
|
|
22
|
+
return (0, rank_1.foldText)(text).replace(/\s+/g, ' ').trim();
|
|
23
|
+
}
|
|
24
|
+
/** True when `typed` (partial allowed) is inside `haystack`, ignoring case, Turkish letters and accents. */
|
|
25
|
+
function foldedIncludes(haystack, typed) {
|
|
26
|
+
const needle = foldKey(typed);
|
|
27
|
+
return needle !== '' && foldKey(haystack).includes(needle);
|
|
28
|
+
}
|
|
29
|
+
/** True when the two texts are the same name, ignoring case, Turkish letters, accents and spacing. */
|
|
30
|
+
function foldedEquals(a, b) {
|
|
31
|
+
return foldKey(a) === foldKey(b);
|
|
32
|
+
}
|
package/dist/program.js
CHANGED
|
@@ -7,12 +7,14 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.runWithErrorHandler = runWithErrorHandler;
|
|
10
|
+
exports.closestCommand = closestCommand;
|
|
10
11
|
exports.buildProgram = buildProgram;
|
|
11
12
|
const commander_1 = require("commander");
|
|
12
13
|
const constants_1 = require("./lib/constants");
|
|
13
14
|
const format_1 = require("./lib/format");
|
|
14
15
|
const login_1 = require("./commands/login");
|
|
15
16
|
const logout_1 = require("./commands/logout");
|
|
17
|
+
const whoami_1 = require("./commands/whoami");
|
|
16
18
|
const list_1 = require("./commands/list");
|
|
17
19
|
const copy_1 = require("./commands/copy");
|
|
18
20
|
const show_1 = require("./commands/show");
|
|
@@ -25,6 +27,7 @@ const sync_1 = require("./commands/sync");
|
|
|
25
27
|
const export_1 = require("./commands/export");
|
|
26
28
|
const stats_1 = require("./commands/stats");
|
|
27
29
|
const import_1 = require("./commands/import");
|
|
30
|
+
const visibility_1 = require("./commands/visibility");
|
|
28
31
|
const log_1 = require("./commands/log");
|
|
29
32
|
const diff_1 = require("./commands/diff");
|
|
30
33
|
const rollback_1 = require("./commands/rollback");
|
|
@@ -32,6 +35,10 @@ const tag_1 = require("./commands/tag");
|
|
|
32
35
|
const suggest_1 = require("./commands/suggest");
|
|
33
36
|
const config_1 = require("./commands/config");
|
|
34
37
|
const repo_1 = require("./commands/repo");
|
|
38
|
+
const feedback_1 = require("./commands/feedback");
|
|
39
|
+
const feedbackApi_1 = require("./lib/feedbackApi");
|
|
40
|
+
const feedbackInput_1 = require("./lib/feedbackInput");
|
|
41
|
+
const feedbackHint_1 = require("./lib/feedbackHint");
|
|
35
42
|
const errors_1 = require("./lib/errors");
|
|
36
43
|
const help_1 = require("./help");
|
|
37
44
|
/**
|
|
@@ -39,7 +46,7 @@ const help_1 = require("./help");
|
|
|
39
46
|
* command: 1 = fix your input/login/plan, 2 = network/server problem, retry later.
|
|
40
47
|
* A command that already set `process.exitCode` keeps its own code.
|
|
41
48
|
*/
|
|
42
|
-
function runWithErrorHandler(fn) {
|
|
49
|
+
function runWithErrorHandler(fn, opts = {}) {
|
|
43
50
|
return async (...args) => {
|
|
44
51
|
try {
|
|
45
52
|
await fn(...args);
|
|
@@ -47,10 +54,71 @@ function runWithErrorHandler(fn) {
|
|
|
47
54
|
catch (err) {
|
|
48
55
|
const message = err instanceof Error ? err.message : String(err);
|
|
49
56
|
console.error(format_1.c.error(`✗ ${message}`));
|
|
57
|
+
if (opts.hint)
|
|
58
|
+
(0, feedbackHint_1.printFeedbackHint)();
|
|
50
59
|
process.exit(process.exitCode || (0, errors_1.exitCodeFor)(err));
|
|
51
60
|
}
|
|
61
|
+
if (opts.hint === 'failure' && process.exitCode)
|
|
62
|
+
(0, feedbackHint_1.printFeedbackHint)();
|
|
52
63
|
};
|
|
53
64
|
}
|
|
65
|
+
/** Long names of the options that were typed on the command line (never their values). */
|
|
66
|
+
function typedFlagNames(cmd) {
|
|
67
|
+
return cmd.options
|
|
68
|
+
.filter((o) => cmd.getOptionValueSource(o.attributeName()) === 'cli')
|
|
69
|
+
.map((o) => o.long ?? '')
|
|
70
|
+
.filter(Boolean);
|
|
71
|
+
}
|
|
72
|
+
/** Optimal-string-alignment distance (insert, delete, substitute, swap neighbours) — typo-sized strings only. */
|
|
73
|
+
function editDistance(a, b) {
|
|
74
|
+
const d = Array.from({ length: a.length + 1 }, (_, i) => [i, ...new Array(b.length).fill(0)]);
|
|
75
|
+
for (let j = 1; j <= b.length; j++)
|
|
76
|
+
d[0][j] = j;
|
|
77
|
+
for (let i = 1; i <= a.length; i++) {
|
|
78
|
+
for (let j = 1; j <= b.length; j++) {
|
|
79
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
80
|
+
d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
|
|
81
|
+
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1])
|
|
82
|
+
d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return d[a.length][b.length];
|
|
86
|
+
}
|
|
87
|
+
/** The registered command (or alias) that `typed` most likely meant — a typo or a prefix — or undefined. */
|
|
88
|
+
function closestCommand(typed, names) {
|
|
89
|
+
const t = typed.toLowerCase();
|
|
90
|
+
if (t.length < 2)
|
|
91
|
+
return undefined;
|
|
92
|
+
let best;
|
|
93
|
+
for (const name of names) {
|
|
94
|
+
// A real prefix ("sugg" → suggest) beats any typo; otherwise allow ~1 edit per 3 letters, at most 3.
|
|
95
|
+
const max = Math.min(3, Math.max(1, Math.floor(name.length / 3)));
|
|
96
|
+
const dist = name.startsWith(t) && t.length >= 3 ? 0 : editDistance(t, name);
|
|
97
|
+
if (dist > max)
|
|
98
|
+
continue;
|
|
99
|
+
if (!best || dist < best.score)
|
|
100
|
+
best = { name, score: dist };
|
|
101
|
+
}
|
|
102
|
+
return best?.name;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* An unknown sub-command is a usage error — exit 2, the same code `ple feedback` uses for bad usage — with the
|
|
106
|
+
* nearest command named and the way to the full list. Without this commander exits 1, the code every
|
|
107
|
+
* script reads as "your input or login is wrong". Bare `ple` and `ple --help` are not routed here.
|
|
108
|
+
*/
|
|
109
|
+
function failOnUnknownCommand(cmd) {
|
|
110
|
+
cmd.on('command:*', (operands) => {
|
|
111
|
+
const typed = operands[0] ?? '';
|
|
112
|
+
const names = cmd.commands.flatMap((s) => [s.name(), ...s.aliases()]).filter((n) => n !== 'help');
|
|
113
|
+
const guess = closestCommand(typed, names);
|
|
114
|
+
const path = cmd.parent ? `${cmd.parent.name()} ${cmd.name()}` : cmd.name();
|
|
115
|
+
const lines = [`error: unknown command '${typed}'`];
|
|
116
|
+
if (guess)
|
|
117
|
+
lines.push(`(Did you mean ${guess}?)`);
|
|
118
|
+
lines.push(`Run \`${path} --help\` to see the commands.`);
|
|
119
|
+
cmd.error(lines.join('\n'), { exitCode: 2, code: 'ple.unknownCommand' });
|
|
120
|
+
});
|
|
121
|
+
}
|
|
54
122
|
function buildProgram() {
|
|
55
123
|
const program = new commander_1.Command();
|
|
56
124
|
program
|
|
@@ -59,6 +127,7 @@ function buildProgram() {
|
|
|
59
127
|
.version(constants_1.CLI_VERSION)
|
|
60
128
|
.configureHelp({ formatHelp: help_1.formatRootHelp })
|
|
61
129
|
.showSuggestionAfterError();
|
|
130
|
+
failOnUnknownCommand(program);
|
|
62
131
|
const scope = (cmd) => cmd.option('--project <repo>', 'Limit to one repo (name, slug or id) — use when titles collide');
|
|
63
132
|
// ---- prompts ------------------------------------------------------------
|
|
64
133
|
program
|
|
@@ -68,7 +137,18 @@ function buildProgram() {
|
|
|
68
137
|
.option('-d, --description <text>', 'Short description')
|
|
69
138
|
.option('-t, --tag <name>', 'Tag (repeatable)', save_1.collectTag, [])
|
|
70
139
|
.option('-f, --force', 'Overwrite an existing local prompt')
|
|
71
|
-
.
|
|
140
|
+
.option('--project <repo>', 'Save into this repo of your account (name, slug or id) — needs `ple login`; safe to run again')
|
|
141
|
+
.addHelpText('after', [
|
|
142
|
+
'',
|
|
143
|
+
'Examples:',
|
|
144
|
+
' ple save "code review" -m "Review this diff: {{diff}}"',
|
|
145
|
+
' pbpaste | ple save "bug triage" --tag triage',
|
|
146
|
+
' ple save "code review" -m "..." --project my-prompts # into your account; run again to update',
|
|
147
|
+
'',
|
|
148
|
+
'With --project: the title inside the repo is the identity. A new title creates the prompt; the same title',
|
|
149
|
+
'with different text adds a new version (nothing is overwritten); the same text says "unchanged" and sends',
|
|
150
|
+
'nothing. Signed out, --project still saves locally and warns that the account was not written.',
|
|
151
|
+
].join('\n'))
|
|
72
152
|
.action(runWithErrorHandler(save_1.saveCommand));
|
|
73
153
|
scope(program
|
|
74
154
|
.command('get <name>')
|
|
@@ -77,7 +157,7 @@ function buildProgram() {
|
|
|
77
157
|
.option('-c, --copy', 'Also copy the output to the clipboard')
|
|
78
158
|
.option('-l, --label <name>', 'Read the version a deployment label points at (e.g. production)'))
|
|
79
159
|
.addHelpText('after', '\nExample:\n ple get "code review" --var diff="$(git diff)" | claude')
|
|
80
|
-
.action(runWithErrorHandler(get_1.getCommand));
|
|
160
|
+
.action(runWithErrorHandler(get_1.getCommand, { hint: 'failure' }));
|
|
81
161
|
scope(program.command('show <name>').description('Show a prompt in the terminal')).action(runWithErrorHandler(show_1.showCommand));
|
|
82
162
|
scope(program
|
|
83
163
|
.command('copy <name>')
|
|
@@ -94,7 +174,7 @@ function buildProgram() {
|
|
|
94
174
|
program
|
|
95
175
|
.command('search <keyword>')
|
|
96
176
|
.description('Search titles and descriptions; also finds prompts only on this machine (incl. body and tags)')
|
|
97
|
-
.action(runWithErrorHandler(search_1.searchCommand));
|
|
177
|
+
.action(runWithErrorHandler(search_1.searchCommand, { hint: 'throw' }));
|
|
98
178
|
scope(program
|
|
99
179
|
.command('log <name>')
|
|
100
180
|
.description('Version history of a prompt (* = current). Signed out: the local history')
|
|
@@ -131,6 +211,7 @@ function buildProgram() {
|
|
|
131
211
|
.command('repo')
|
|
132
212
|
.description('Create and manage repos (collections of prompts) in your account')
|
|
133
213
|
.addHelpText('after', '\nExamples:\n ple repo create "team-prompts" --description "Shared review prompts"\n ple repo list\n ple repo visibility team-prompts public --yes\n\nRepos are private unless you say --public. Deleting a repo is only possible on the web.');
|
|
214
|
+
failOnUnknownCommand(repo);
|
|
134
215
|
repo.command('create <name>')
|
|
135
216
|
.description('Create a repo (private by default)')
|
|
136
217
|
.option('--private', 'Only you and people you invite can see it (default)')
|
|
@@ -151,6 +232,20 @@ function buildProgram() {
|
|
|
151
232
|
.option('-y, --yes', 'Confirm without asking (required when making a repo public in a script)')
|
|
152
233
|
.option('--json', 'Print the result as JSON')
|
|
153
234
|
.action(runWithErrorHandler((ref, value, opts) => (0, repo_1.repoVisibilityCommand)(ref, value, opts)));
|
|
235
|
+
repo.command('license <repo> <value>')
|
|
236
|
+
.description('Declare the license of a repo\'s prompts (owner only): CC-BY-4.0 | CC-BY-SA-4.0 | CC0-1.0 | MIT | Apache-2.0 | none')
|
|
237
|
+
.option('--json', 'Print the result as JSON')
|
|
238
|
+
.action(runWithErrorHandler(repo_1.repoLicenseCommand));
|
|
239
|
+
// ---- visibility of single prompts ---------------------------------------
|
|
240
|
+
program
|
|
241
|
+
.command('visibility [args...]')
|
|
242
|
+
.description('Make one prompt public or private: ple visibility <prompt> public|private (or --all in a repo)')
|
|
243
|
+
.option('--project <repo>', 'Scope the prompt name to this repo; required with --all')
|
|
244
|
+
.option('--all', 'Every prompt in --project: ple visibility --all --project <repo> public')
|
|
245
|
+
.option('-y, --yes', 'Confirm without asking (required when making prompts public in a script)')
|
|
246
|
+
.option('--json', 'Print the result as JSON')
|
|
247
|
+
.addHelpText('after', '\nExamples:\n ple visibility "code review" public --yes\n ple visibility --all --project ortak-web public --yes\n\nA prompt page is public only when the repo AND the prompt are public: see ple repo visibility.')
|
|
248
|
+
.action(runWithErrorHandler(visibility_1.visibilityCommand));
|
|
154
249
|
// ---- account ------------------------------------------------------------
|
|
155
250
|
program
|
|
156
251
|
.command('login')
|
|
@@ -160,6 +255,13 @@ function buildProgram() {
|
|
|
160
255
|
.command('logout')
|
|
161
256
|
.description('Delete the local session file')
|
|
162
257
|
.action(runWithErrorHandler(logout_1.logoutCommand));
|
|
258
|
+
program
|
|
259
|
+
.command('whoami')
|
|
260
|
+
.alias('account')
|
|
261
|
+
.description('Show the signed-in account: email, plan, and how much of the plan limits you use')
|
|
262
|
+
.option('--json', 'Print as one JSON line')
|
|
263
|
+
.addHelpText('after', '\nSigned out it says so and exits with code 1. The session token is never printed.')
|
|
264
|
+
.action(runWithErrorHandler(whoami_1.whoamiCommand));
|
|
163
265
|
// ---- import / export / sync --------------------------------------------
|
|
164
266
|
program
|
|
165
267
|
.command('sync')
|
|
@@ -169,7 +271,7 @@ function buildProgram() {
|
|
|
169
271
|
.action(runWithErrorHandler(sync_1.syncCommand));
|
|
170
272
|
program
|
|
171
273
|
.command('import [source]')
|
|
172
|
-
.description('Bring in prompts from a public GitHub repo (github:owner/repo) or your agent folders (--scan)')
|
|
274
|
+
.description('Bring in prompts from a public GitHub repo (github:owner/repo), a public PromptLikeEngineer repo (ple:user/repo) or your agent folders (--scan)')
|
|
173
275
|
.option('--scan', 'Scan this repo and your home folder for agent prompt files')
|
|
174
276
|
.option('--check', 'Check prompts imported from GitHub for upstream changes')
|
|
175
277
|
.option('--apply', 'With --check: add the upstream changes as new versions (nothing is overwritten)')
|
|
@@ -182,6 +284,8 @@ function buildProgram() {
|
|
|
182
284
|
' ple import github:anthropics/skills --dry-run # what is there, and under which license',
|
|
183
285
|
' ple import github:anthropics/skills/skills/pdf # one folder; pick 1,3-5 / all',
|
|
184
286
|
' ple import github:owner/repo@v1.2 --all # a tag, branch or commit; no questions',
|
|
287
|
+
' ple import ple:zeynepaslierhan/ortak-web --dry-run # public prompts of another user, works signed out',
|
|
288
|
+
' ple import ple:zeynepaslierhan/ortak-web/"Code Review" # one prompt by title or id',
|
|
185
289
|
' ple import --check # did anything change on GitHub since?',
|
|
186
290
|
' ple import --check --apply # add the changes as new versions',
|
|
187
291
|
' ple import --scan --dry-run # prompts already on this machine',
|
|
@@ -200,6 +304,57 @@ function buildProgram() {
|
|
|
200
304
|
.option('-o, --out <path>', 'agents-md: file to write (default stdout) · skill: parent folder (default .)')
|
|
201
305
|
.option('--zip', 'skill: write <name>.zip (upload in Claude) instead of a folder')
|
|
202
306
|
.option('-f, --force', 'Overwrite an existing file or folder (never through a symbolic link)')).action(runWithErrorHandler(export_1.exportCommand));
|
|
307
|
+
// ---- feedback -----------------------------------------------------------
|
|
308
|
+
const feedback = program
|
|
309
|
+
.command('feedback [message...]')
|
|
310
|
+
.description('Tell the maker what is missing, broken or confusing — no questions asked, works from agents')
|
|
311
|
+
.addOption(new commander_1.Option('--type <type>', `What kind of note: ${feedbackInput_1.FEEDBACK_TYPES.join(' | ')} (default ${feedbackInput_1.DEFAULT_FEEDBACK_TYPE})`))
|
|
312
|
+
.option('--prompt <title|id>', 'The prompt this is about (its title or id — the prompt text is never sent)')
|
|
313
|
+
.option('--email <address>', 'Where to answer you (optional)')
|
|
314
|
+
.option('--agent <name>', 'Mark the report as written by an AI agent with this name (auto-detected from the environment otherwise)')
|
|
315
|
+
.option('--json', 'Print the outcome as one JSON line on stdout')
|
|
316
|
+
// Usage errors (unknown flag, missing argument) must end with exit code 2, not commander's 1. Set BEFORE
|
|
317
|
+
// the subcommands below so they inherit it.
|
|
318
|
+
.exitOverride((err) => {
|
|
319
|
+
if (err.exitCode !== 0)
|
|
320
|
+
process.exit(2);
|
|
321
|
+
})
|
|
322
|
+
.addHelpText('after', [
|
|
323
|
+
'',
|
|
324
|
+
'Examples:',
|
|
325
|
+
' ple feedback "ple search should also look inside prompt bodies"',
|
|
326
|
+
' ple feedback --type bug --prompt "code review" "get printed the wrong version"',
|
|
327
|
+
' ple feedback --type missing --json "no way to rename a repo from the CLI"',
|
|
328
|
+
'',
|
|
329
|
+
'Sent: the type, your message, the prompt title/id and email if you gave them, whether a person or an',
|
|
330
|
+
'agent wrote it, and the ple version, OS + CPU, Node version and the command name with the flag NAMES',
|
|
331
|
+
'you used. Never a prompt body, a file, a path or a flag value. Signed in, the report is tied to your',
|
|
332
|
+
'account; signed out it is anonymous. Do not put secrets or personal data in the message: a message that',
|
|
333
|
+
'looks like a key or token is refused.',
|
|
334
|
+
'',
|
|
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).',
|
|
337
|
+
'',
|
|
338
|
+
'Exit codes:',
|
|
339
|
+
...feedback_1.FEEDBACK_EXIT_CODES_HELP.map((l) => ` ${l}`),
|
|
340
|
+
'',
|
|
341
|
+
'Owner commands (need a session): `ple feedback list` and `ple feedback close <id> --commit <sha>`.',
|
|
342
|
+
].join('\n'))
|
|
343
|
+
.action(runWithErrorHandler(async (message, opts, cmd) => (0, feedback_1.feedbackCommand)(message ?? [], opts, { flagNames: typedFlagNames(cmd) })));
|
|
344
|
+
feedback
|
|
345
|
+
.command('list')
|
|
346
|
+
.description('List the feedback people sent (owner)')
|
|
347
|
+
.addOption(new commander_1.Option('--status <status>', `Only this status: ${feedbackApi_1.FEEDBACK_STATUSES.join(' | ')}`))
|
|
348
|
+
.option('-l, --limit <n>', 'Max rows (default 50)')
|
|
349
|
+
.option('--json', 'Print the items as JSON, exactly as the server returned them')
|
|
350
|
+
.action(runWithErrorHandler(async (opts, cmd) => (0, feedback_1.feedbackListCommand)({ ...opts, json: opts.json ?? cmd.optsWithGlobals().json === true })));
|
|
351
|
+
feedback
|
|
352
|
+
.command('close <id>')
|
|
353
|
+
.description('Mark a piece of feedback as done (or wontfix) with the commit that resolved it (owner)')
|
|
354
|
+
.option('--commit <sha>', 'The commit that resolved it (required for done)')
|
|
355
|
+
.addOption(new commander_1.Option('--status <status>', 'done (default) or wontfix'))
|
|
356
|
+
.option('--json', 'Print the result as one JSON line')
|
|
357
|
+
.action(runWithErrorHandler(async (id, opts, cmd) => (0, feedback_1.feedbackCloseCommand)(id, { ...opts, json: opts.json ?? cmd.optsWithGlobals().json === true })));
|
|
203
358
|
// ---- insights & settings ------------------------------------------------
|
|
204
359
|
program
|
|
205
360
|
.command('stats')
|
|
@@ -212,10 +367,14 @@ function buildProgram() {
|
|
|
212
367
|
.description('Which saved prompt fits this task? Local match — the text never leaves your machine')
|
|
213
368
|
.option('--json', 'Print matches as JSON')
|
|
214
369
|
.option('-l, --limit <n>', 'Max matches (default 3)', '3')
|
|
370
|
+
.option('-t, --tag <name>', 'Only prompts with this tag; repeat to require several (all must match)', save_1.collectTag, [])
|
|
371
|
+
.option('--project <repo>', 'Only prompts of this repo (name, slug or id) — needs `ple login`')
|
|
215
372
|
.option('--hook', 'Claude Code UserPromptSubmit mode: read hook JSON on stdin, print a short hint or nothing')
|
|
216
373
|
.option('--refresh-cache', 'Refresh the local library cache from your account and exit')
|
|
217
|
-
.action(runWithErrorHandler((text, opts) => (0, suggest_1.suggestCommand)(text ?? [], opts)))
|
|
374
|
+
.action(runWithErrorHandler((text, opts) => (0, suggest_1.suggestCommand)(text ?? [], opts)))
|
|
375
|
+
.addHelpText('after', '\nExamples:\n ple suggest "review this pull request"\n ple suggest "fix the flaky test" --tag debug\n ple suggest "weekly report" --project my-prompts');
|
|
218
376
|
const configCmd = program.command('config').description('CLI preferences (suggest on|off)');
|
|
377
|
+
failOnUnknownCommand(configCmd);
|
|
219
378
|
configCmd
|
|
220
379
|
.command('get [key]')
|
|
221
380
|
.description('Show a setting (or all)')
|
package/package.json
CHANGED