promptlike 0.6.3 → 0.8.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 +65 -0
- package/README.md +135 -11
- package/dist/commands/diff.js +4 -0
- package/dist/commands/export.js +14 -1
- package/dist/commands/history.js +0 -7
- package/dist/commands/list.js +5 -2
- package/dist/commands/local.js +1 -0
- package/dist/commands/localHistory.js +180 -0
- package/dist/commands/log.js +4 -0
- package/dist/commands/logout.js +9 -4
- package/dist/commands/repo.js +171 -0
- package/dist/commands/rollback.js +4 -0
- package/dist/commands/save.js +7 -2
- package/dist/commands/show.js +4 -4
- package/dist/commands/sync.js +4 -2
- package/dist/help.js +65 -0
- package/dist/index.js +9 -171
- package/dist/lib/api-client.js +109 -5
- package/dist/lib/config.js +53 -30
- package/dist/lib/confirm.js +53 -0
- package/dist/lib/constants.js +47 -2
- package/dist/lib/errors.js +17 -0
- package/dist/lib/format.js +16 -0
- package/dist/lib/fsSafe.js +171 -0
- package/dist/lib/libraryCache.js +6 -7
- package/dist/lib/localHistory.js +157 -0
- package/dist/lib/localStore.js +4 -4
- package/dist/lib/promptResolver.js +11 -1
- package/dist/lib/repoRef.js +118 -0
- package/dist/lib/settings.js +2 -2
- package/dist/program.js +197 -0
- package/package.json +1 -1
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `ple repo ...` — repos (projects) of your account.
|
|
4
|
+
*
|
|
5
|
+
* ple repo create <name> [--private|--public] [--description <text>]
|
|
6
|
+
* ple repo list
|
|
7
|
+
* ple repo show <repo>
|
|
8
|
+
* ple repo visibility <repo> private|public
|
|
9
|
+
*
|
|
10
|
+
* Everything is enforced on the SERVER (session, plan limit, name rules, slug
|
|
11
|
+
* uniqueness, owner-only visibility); the checks here only give a faster, clearer
|
|
12
|
+
* message. There is deliberately no `delete`: it cannot be undone, so it stays in
|
|
13
|
+
* the web app.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.toRepoJson = toRepoJson;
|
|
17
|
+
exports.explainRepoError = explainRepoError;
|
|
18
|
+
exports.repoCreateCommand = repoCreateCommand;
|
|
19
|
+
exports.repoListCommand = repoListCommand;
|
|
20
|
+
exports.repoShowCommand = repoShowCommand;
|
|
21
|
+
exports.repoVisibilityCommand = repoVisibilityCommand;
|
|
22
|
+
const api_client_1 = require("../lib/api-client");
|
|
23
|
+
const confirm_1 = require("../lib/confirm");
|
|
24
|
+
const format_1 = require("../lib/format");
|
|
25
|
+
const local_1 = require("./local");
|
|
26
|
+
const constants_1 = require("../lib/constants");
|
|
27
|
+
const repoRef_1 = require("../lib/repoRef");
|
|
28
|
+
const SIGN_IN_FIRST = 'Repos live in your account. Sign in first: ple login';
|
|
29
|
+
function toRepoJson(r) {
|
|
30
|
+
return {
|
|
31
|
+
id: r.id,
|
|
32
|
+
name: r.name,
|
|
33
|
+
slug: r.slug ?? null,
|
|
34
|
+
description: r.description,
|
|
35
|
+
visibility: r.visibility,
|
|
36
|
+
role: r.role,
|
|
37
|
+
prompt_count: r.prompt_count,
|
|
38
|
+
member_count: r.member_count,
|
|
39
|
+
created_at: r.created_at,
|
|
40
|
+
updated_at: r.updated_at,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function requireAccount() {
|
|
44
|
+
if ((0, local_1.isSignedOut)())
|
|
45
|
+
throw new Error(SIGN_IN_FIRST);
|
|
46
|
+
}
|
|
47
|
+
/** Turn the server's refusals into "what happened + what to do". */
|
|
48
|
+
function explainRepoError(err) {
|
|
49
|
+
if (err instanceof api_client_1.ApiError) {
|
|
50
|
+
if (err.status === 403 && err.code === 'LIMIT_EXCEEDED') {
|
|
51
|
+
throw new Error(`Your plan's repo limit is reached (Free includes 1 repo). Upgrade at ${constants_1.WEB_APP_URL}/pricing, or use the repo you already have: ple repo list`);
|
|
52
|
+
}
|
|
53
|
+
if (err.status === 403) {
|
|
54
|
+
throw new Error(err.message);
|
|
55
|
+
}
|
|
56
|
+
if (err.status === 409) {
|
|
57
|
+
throw new Error('You already have a repo with that name or URL slug. Pick a different name (see: ple repo list).');
|
|
58
|
+
}
|
|
59
|
+
if (err.status === 404) {
|
|
60
|
+
throw new Error('Repo not found, or you have no access to it. See: ple repo list');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
throw err;
|
|
64
|
+
}
|
|
65
|
+
async function repoCreateCommand(name, options = {}) {
|
|
66
|
+
// Local checks first: no network, no session needed to learn the name is wrong.
|
|
67
|
+
const cleanName = (0, repoRef_1.validateRepoName)(name);
|
|
68
|
+
const description = (0, repoRef_1.validateRepoDescription)(options.description);
|
|
69
|
+
const visibility = (0, repoRef_1.pickVisibility)(options);
|
|
70
|
+
requireAccount();
|
|
71
|
+
await (0, api_client_1.ensureAuthed)();
|
|
72
|
+
let repo;
|
|
73
|
+
try {
|
|
74
|
+
repo = await (0, api_client_1.createProject)({ name: cleanName, description, visibility });
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
explainRepoError(err);
|
|
78
|
+
}
|
|
79
|
+
if (options.json) {
|
|
80
|
+
console.log(JSON.stringify({ ok: true, repo: toRepoJson(repo) }, null, 2));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
console.log(format_1.c.success(`✓ Created ${visibility} repo '${repo.name}'`) + format_1.c.muted(` (${repo.slug ?? (0, repoRef_1.slugFromName)(repo.name)}, ${(0, format_1.shortId)(repo.id)})`));
|
|
84
|
+
if (visibility === 'public') {
|
|
85
|
+
console.log(format_1.c.warn(' Public: anyone can read its public prompts. Make it private again: ple repo visibility ' + (0, format_1.shortId)(repo.id) + ' private'));
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
console.log(format_1.c.muted(' Private: only you and people you invite can see it.'));
|
|
89
|
+
}
|
|
90
|
+
console.log(format_1.c.muted(` Next: ple import --scan --project ${(0, format_1.shortId)(repo.id)} (or ple sync, then move prompts on the web)`));
|
|
91
|
+
}
|
|
92
|
+
async function repoListCommand(options = {}) {
|
|
93
|
+
requireAccount();
|
|
94
|
+
await (0, api_client_1.ensureAuthed)();
|
|
95
|
+
const repos = await (0, api_client_1.listProjectsDetailed)();
|
|
96
|
+
if (options.json) {
|
|
97
|
+
console.log(JSON.stringify({ repos: repos.map(toRepoJson) }, null, 2));
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (repos.length === 0) {
|
|
101
|
+
console.log(format_1.c.muted('No repos yet. Create one: ple repo create "my-prompts"'));
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
console.log(format_1.c.label('ID NAME VISIBILITY ROLE PROMPTS UPDATED'));
|
|
105
|
+
console.log(format_1.c.label('──────── ────────────────────────────── ────────── ────── ─────── ──────────'));
|
|
106
|
+
for (const r of repos) {
|
|
107
|
+
const vis = r.visibility === 'public' ? format_1.c.warn('public ') : format_1.c.muted('private ');
|
|
108
|
+
console.log(`${format_1.c.muted((0, format_1.shortId)(r.id))} ${(0, format_1.truncate)(r.name, 30).padEnd(30)} ${vis} ${r.role.padEnd(6)} ${String(r.prompt_count).padStart(7)} ${format_1.c.muted(r.updated_at ? (0, format_1.timeAgo)(r.updated_at) : '-')}`);
|
|
109
|
+
}
|
|
110
|
+
console.log(format_1.c.muted(`\n${repos.length} repo${repos.length === 1 ? '' : 's'} listed.`));
|
|
111
|
+
}
|
|
112
|
+
async function repoShowCommand(ref, options = {}) {
|
|
113
|
+
requireAccount();
|
|
114
|
+
await (0, api_client_1.ensureAuthed)();
|
|
115
|
+
const repo = (0, repoRef_1.resolveRepoRef)(ref, await (0, api_client_1.listProjectsDetailed)());
|
|
116
|
+
if (options.json) {
|
|
117
|
+
console.log(JSON.stringify({ repo: toRepoJson(repo) }, null, 2));
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
console.log(format_1.c.title(repo.name));
|
|
121
|
+
const row = (k, v) => console.log(`${format_1.c.label(k.padEnd(12))}${v}`);
|
|
122
|
+
row('id', repo.id);
|
|
123
|
+
row('slug', repo.slug ?? '-');
|
|
124
|
+
row('visibility', repo.visibility);
|
|
125
|
+
row('your role', repo.role);
|
|
126
|
+
row('prompts', String(repo.prompt_count));
|
|
127
|
+
row('members', String(repo.member_count));
|
|
128
|
+
row('updated', repo.updated_at ? (0, format_1.timeAgo)(repo.updated_at) : '-');
|
|
129
|
+
if (repo.description)
|
|
130
|
+
row('description', repo.description);
|
|
131
|
+
}
|
|
132
|
+
async function repoVisibilityCommand(ref, value, options = {}, deps = {}) {
|
|
133
|
+
const target = (0, repoRef_1.parseVisibility)(value);
|
|
134
|
+
requireAccount();
|
|
135
|
+
await (0, api_client_1.ensureAuthed)();
|
|
136
|
+
const repo = (0, repoRef_1.resolveRepoRef)(ref, await (0, api_client_1.listProjectsDetailed)());
|
|
137
|
+
if (repo.role !== 'owner') {
|
|
138
|
+
throw new Error(`Only the owner can change a repo's visibility (your role in '${repo.name}': ${repo.role}).`);
|
|
139
|
+
}
|
|
140
|
+
if (repo.visibility === target) {
|
|
141
|
+
if (options.json)
|
|
142
|
+
console.log(JSON.stringify({ ok: true, changed: false, repo: toRepoJson(repo) }, null, 2));
|
|
143
|
+
else
|
|
144
|
+
console.log(format_1.c.muted(`'${repo.name}' is already ${target}. Nothing changed.`));
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
// Making a repo public is the one step here that exposes data. It needs a
|
|
148
|
+
// person to say yes (or a script to say --yes); going private never asks.
|
|
149
|
+
if (target === 'public' && !options.yes) {
|
|
150
|
+
const interactive = deps.isTTY ?? Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
151
|
+
if (!interactive) {
|
|
152
|
+
throw new Error(`Making '${repo.name}' public needs confirmation: re-run with --yes.`);
|
|
153
|
+
}
|
|
154
|
+
const ok = await (deps.confirm ?? confirm_1.confirm)(`Make '${repo.name}' public? Its public prompts become readable by anyone. [y/N] `);
|
|
155
|
+
if (!ok) {
|
|
156
|
+
console.log(format_1.c.muted('Cancelled — nothing changed.'));
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
await (0, api_client_1.setProjectVisibility)(repo.id, target);
|
|
162
|
+
}
|
|
163
|
+
catch (err) {
|
|
164
|
+
explainRepoError(err);
|
|
165
|
+
}
|
|
166
|
+
if (options.json) {
|
|
167
|
+
console.log(JSON.stringify({ ok: true, changed: true, repo: toRepoJson({ ...repo, visibility: target }) }, null, 2));
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
console.log(format_1.c.success(`✓ '${repo.name}' is now ${target}.`));
|
|
171
|
+
}
|
|
@@ -44,6 +44,8 @@ exports.rollbackCommand = rollbackCommand;
|
|
|
44
44
|
const readline = __importStar(require("readline"));
|
|
45
45
|
const api_client_1 = require("../lib/api-client");
|
|
46
46
|
const format_1 = require("../lib/format");
|
|
47
|
+
const localHistory_1 = require("./localHistory");
|
|
48
|
+
const local_1 = require("./local");
|
|
47
49
|
const history_1 = require("./history");
|
|
48
50
|
function defaultConfirm(question) {
|
|
49
51
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
@@ -55,6 +57,8 @@ function defaultConfirm(question) {
|
|
|
55
57
|
});
|
|
56
58
|
}
|
|
57
59
|
async function rollbackCommand(name, ref, options = {}, deps = {}) {
|
|
60
|
+
if ((0, local_1.isSignedOut)())
|
|
61
|
+
return (0, localHistory_1.localRollback)(name, ref, options, deps);
|
|
58
62
|
const prompt = await (0, history_1.resolveForHistory)(name, options.project);
|
|
59
63
|
if (!prompt) {
|
|
60
64
|
process.exitCode = 1;
|
package/dist/commands/save.js
CHANGED
|
@@ -46,6 +46,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
46
46
|
exports.collectTag = collectTag;
|
|
47
47
|
exports.saveCommand = saveCommand;
|
|
48
48
|
const store = __importStar(require("../lib/localStore"));
|
|
49
|
+
const history = __importStar(require("../lib/localHistory"));
|
|
49
50
|
const format_1 = require("../lib/format");
|
|
50
51
|
const promptVariables_1 = require("../lib/promptVariables");
|
|
51
52
|
/**
|
|
@@ -120,7 +121,8 @@ async function saveCommand(title, options = {}) {
|
|
|
120
121
|
const slug = store.slugify(cleanTitle);
|
|
121
122
|
const previous = store.read(slug);
|
|
122
123
|
// Overwriting someone's prompt silently is the one unrecoverable thing this
|
|
123
|
-
// command could do — the
|
|
124
|
+
// command could do — the old text is kept in the local history
|
|
125
|
+
// (lib/localHistory.ts), but --force stays an explicit step. Farklı başlıklar
|
|
124
126
|
// aynı slug'a inebilir ("a/b" ve "a:b" → "ab"); mesaj bu yüzden mevcut
|
|
125
127
|
// kaydın GERÇEK başlığını söyler, kullanıcının hiç yazmadığı slug'ı değil.
|
|
126
128
|
if (previous && !options.force) {
|
|
@@ -131,12 +133,15 @@ async function saveCommand(title, options = {}) {
|
|
|
131
133
|
}
|
|
132
134
|
// On --force, fields the user did not re-specify are CARRIED OVER.
|
|
133
135
|
// Overwriting the body must not silently wipe tags and the description —
|
|
134
|
-
// the
|
|
136
|
+
// the prompt file itself is replaced (the old body survives in the history).
|
|
135
137
|
const tags = options.tag && options.tag.length > 0 ? options.tag : (previous?.tags ?? []);
|
|
136
138
|
const description = options.description?.trim() ?? previous?.description ?? '';
|
|
137
139
|
const saved = store.save({ slug, title: cleanTitle, description, tags, body });
|
|
140
|
+
const version = history.recordIfChanged(slug, { title: saved.title, description: saved.description, tags: saved.tags, body: saved.body }, { onDisk: previous ? { title: previous.title, description: previous.description, tags: previous.tags, body: previous.body } : null });
|
|
138
141
|
console.log(format_1.c.success(`✓ Saved: ${saved.title}`) + format_1.c.muted(` (${saved.slug})`));
|
|
139
142
|
console.log(format_1.c.muted(` ${store.filePath(saved.slug)}`));
|
|
143
|
+
if (version)
|
|
144
|
+
console.log(format_1.c.muted(` version: v${version.version} (history: ple log "${saved.slug}")`));
|
|
140
145
|
const vars = (0, promptVariables_1.extractVariables)(saved.body);
|
|
141
146
|
if (vars.length > 0) {
|
|
142
147
|
console.log(format_1.c.muted(` variables: ${vars.map((v) => `{{${v}}}`).join(', ')}`));
|
package/dist/commands/show.js
CHANGED
|
@@ -46,7 +46,7 @@ async function showCommand(name, options = {}) {
|
|
|
46
46
|
!version.description_text &&
|
|
47
47
|
!version.context_text) {
|
|
48
48
|
console.log();
|
|
49
|
-
console.log(version.content);
|
|
49
|
+
console.log((0, format_1.safeText)(version.content, true));
|
|
50
50
|
console.log();
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
@@ -54,17 +54,17 @@ async function showCommand(name, options = {}) {
|
|
|
54
54
|
if (version.role_text?.trim()) {
|
|
55
55
|
console.log();
|
|
56
56
|
console.log(format_1.c.accent('── ROLE ──'));
|
|
57
|
-
console.log(version.role_text.trim());
|
|
57
|
+
console.log((0, format_1.safeText)(version.role_text.trim(), true));
|
|
58
58
|
}
|
|
59
59
|
if (version.description_text?.trim()) {
|
|
60
60
|
console.log();
|
|
61
61
|
console.log(format_1.c.accent('── DESCRIPTION ──'));
|
|
62
|
-
console.log(version.description_text.trim());
|
|
62
|
+
console.log((0, format_1.safeText)(version.description_text.trim(), true));
|
|
63
63
|
}
|
|
64
64
|
if (version.context_text?.trim()) {
|
|
65
65
|
console.log();
|
|
66
66
|
console.log(format_1.c.accent('── CONTEXT ──'));
|
|
67
|
-
console.log(version.context_text.trim());
|
|
67
|
+
console.log((0, format_1.safeText)(version.context_text.trim(), true));
|
|
68
68
|
}
|
|
69
69
|
console.log();
|
|
70
70
|
}
|
package/dist/commands/sync.js
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* someone asks for it.
|
|
9
9
|
*
|
|
10
10
|
* One-way (local → account) on purpose. Pulling the account library down would
|
|
11
|
-
* need conflict rules the local store cannot express
|
|
12
|
-
* and a half-correct merge silently losing an edit is worse than no pull.
|
|
11
|
+
* need conflict rules the local store cannot express (the local history is
|
|
12
|
+
* a private, append-only log, not a mergeable one) and a half-correct merge silently losing an edit is worse than no pull.
|
|
13
13
|
*/
|
|
14
14
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
15
|
if (k2 === undefined) k2 = k;
|
|
@@ -47,6 +47,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
48
|
exports.syncCommand = syncCommand;
|
|
49
49
|
const store = __importStar(require("../lib/localStore"));
|
|
50
|
+
const history = __importStar(require("../lib/localHistory"));
|
|
50
51
|
const api_client_1 = require("../lib/api-client");
|
|
51
52
|
const format_1 = require("../lib/format");
|
|
52
53
|
const libraryCache_1 = require("../lib/libraryCache");
|
|
@@ -131,4 +132,5 @@ async function syncCommand(options = {}) {
|
|
|
131
132
|
// would duplicate, so say so rather than letting someone find out.
|
|
132
133
|
console.log(format_1.c.muted(`\nLocal files kept in ${store.promptsDir()} (sync copies, it does not move).`));
|
|
133
134
|
console.log(format_1.c.muted('Re-running would upload them again — delete the local copies first if that is not what you want.'));
|
|
135
|
+
console.log(format_1.c.muted(`Only the current text of each prompt is uploaded; the local version history stays in ${history.historyRoot()}.`));
|
|
134
136
|
}
|
package/dist/help.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Grouped `ple --help`. commander lists commands in registration order with no
|
|
4
|
+
* headings; with ~20 commands that is a wall of text. This prints the same
|
|
5
|
+
* commands under task-based headings. A test (program.test.ts) fails when a
|
|
6
|
+
* command is registered but missing from GROUPS, so the help cannot drift.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.COMMAND_GROUPS = void 0;
|
|
10
|
+
exports.formatRootHelp = formatRootHelp;
|
|
11
|
+
const commander_1 = require("commander");
|
|
12
|
+
exports.COMMAND_GROUPS = [
|
|
13
|
+
{ title: 'Prompts', commands: ['save', 'get', 'show', 'copy', 'list', 'search', 'log', 'diff', 'rollback', 'improve', 'loop'] },
|
|
14
|
+
{ title: 'Repos', commands: ['repo'] },
|
|
15
|
+
{ title: 'Account', commands: ['login', 'logout'] },
|
|
16
|
+
{ title: 'Import / export / sync', commands: ['import', 'export', 'sync'] },
|
|
17
|
+
{ title: 'Insights & settings', commands: ['stats', 'suggest', 'config'] },
|
|
18
|
+
];
|
|
19
|
+
const EXAMPLES = [
|
|
20
|
+
'ple save "code review" -m "Review this diff: {{diff}}" # no account needed',
|
|
21
|
+
'ple get "code review" --var diff="$(git diff)" | claude',
|
|
22
|
+
'ple repo create "team-prompts" # private by default',
|
|
23
|
+
'ple login && ple sync --dry-run',
|
|
24
|
+
];
|
|
25
|
+
const EXIT_CODES = [
|
|
26
|
+
'0 success',
|
|
27
|
+
'1 fix it yourself: bad input, not signed in, not found, not allowed, plan limit',
|
|
28
|
+
'2 try again later: no network, timeout, rate limit, server error',
|
|
29
|
+
];
|
|
30
|
+
function formatRootHelp(cmd, helper) {
|
|
31
|
+
// configureHelp() is inherited by subcommands; only the root gets the grouped layout.
|
|
32
|
+
if (cmd.parent)
|
|
33
|
+
return commander_1.Help.prototype.formatHelp.call(helper, cmd, helper);
|
|
34
|
+
const lines = [];
|
|
35
|
+
lines.push(`Usage: ${helper.commandUsage(cmd)}`, '');
|
|
36
|
+
lines.push(helper.commandDescription(cmd), '');
|
|
37
|
+
const subs = helper.visibleCommands(cmd);
|
|
38
|
+
const byName = new Map(subs.map((s) => [s.name(), s]));
|
|
39
|
+
const width = Math.max(...subs.map((s) => helper.subcommandTerm(s).length)) + 2;
|
|
40
|
+
const seen = new Set();
|
|
41
|
+
const render = (title, names) => {
|
|
42
|
+
const rows = names.map((n) => byName.get(n)).filter((s) => s !== undefined);
|
|
43
|
+
if (rows.length === 0)
|
|
44
|
+
return;
|
|
45
|
+
lines.push(`${title}:`);
|
|
46
|
+
for (const s of rows) {
|
|
47
|
+
seen.add(s.name());
|
|
48
|
+
lines.push(` ${helper.subcommandTerm(s).padEnd(width)}${helper.subcommandDescription(s)}`);
|
|
49
|
+
}
|
|
50
|
+
lines.push('');
|
|
51
|
+
};
|
|
52
|
+
for (const g of exports.COMMAND_GROUPS)
|
|
53
|
+
render(g.title, g.commands);
|
|
54
|
+
// A command nobody grouped still shows up (and fails the test) instead of vanishing.
|
|
55
|
+
render('Other', subs.map((s) => s.name()).filter((n) => !seen.has(n) && n !== 'help'));
|
|
56
|
+
lines.push('Options:');
|
|
57
|
+
for (const o of helper.visibleOptions(cmd)) {
|
|
58
|
+
lines.push(` ${helper.optionTerm(o).padEnd(width)}${helper.optionDescription(o)}`);
|
|
59
|
+
}
|
|
60
|
+
lines.push('');
|
|
61
|
+
lines.push('Examples:', ...EXAMPLES.map((e) => ` ${e}`), '');
|
|
62
|
+
lines.push('Exit codes:', ...EXIT_CODES.map((e) => ` ${e}`), '');
|
|
63
|
+
lines.push('Run `ple <command> --help` for a command, or `ple repo --help` for the repo commands.');
|
|
64
|
+
return lines.join('\n') + '\n';
|
|
65
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,176 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
/**
|
|
4
|
-
* promptlike CLI entry point.
|
|
5
|
-
*
|
|
6
|
-
* Registers the commands and runs `commander`. Each command's real logic lives
|
|
7
|
-
* under `src/commands/` — this file only does argument parsing + the global
|
|
8
|
-
* error wrapper.
|
|
4
|
+
* promptlike CLI entry point — builds the command table (src/program.ts) and runs it.
|
|
9
5
|
*/
|
|
10
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const search_1 = require("./commands/search");
|
|
20
|
-
const get_1 = require("./commands/get");
|
|
21
|
-
const improve_1 = require("./commands/improve");
|
|
22
|
-
const loop_1 = require("./commands/loop");
|
|
23
|
-
const save_1 = require("./commands/save");
|
|
24
|
-
const sync_1 = require("./commands/sync");
|
|
25
|
-
const export_1 = require("./commands/export");
|
|
26
|
-
const stats_1 = require("./commands/stats");
|
|
27
|
-
const import_1 = require("./commands/import");
|
|
28
|
-
const log_1 = require("./commands/log");
|
|
29
|
-
const diff_1 = require("./commands/diff");
|
|
30
|
-
const rollback_1 = require("./commands/rollback");
|
|
31
|
-
const suggest_1 = require("./commands/suggest");
|
|
32
|
-
const config_1 = require("./commands/config");
|
|
33
|
-
/** A single global try/catch — consistent error output for every command. */
|
|
34
|
-
function runWithErrorHandler(fn) {
|
|
35
|
-
return async (...args) => {
|
|
36
|
-
try {
|
|
37
|
-
await fn(...args);
|
|
38
|
-
}
|
|
39
|
-
catch (err) {
|
|
40
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
41
|
-
console.error(format_1.c.error(`✗ ${message}`));
|
|
42
|
-
process.exit(process.exitCode || 1);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
const program = new commander_1.Command();
|
|
47
|
-
program
|
|
48
|
-
.name(constants_1.CLI_NAME)
|
|
49
|
-
.description('Terminal access to your PromptLikeEngineer prompt library')
|
|
50
|
-
.version(constants_1.CLI_VERSION);
|
|
51
|
-
program
|
|
52
|
-
.command('save <title>')
|
|
53
|
-
.description('Save a prompt locally — no account needed')
|
|
54
|
-
.option('-m, --message <text>', 'Prompt body (or pipe it via stdin)')
|
|
55
|
-
.option('-d, --description <text>', 'Short description')
|
|
56
|
-
.option('-t, --tag <name>', 'Tag (repeatable)', save_1.collectTag, [])
|
|
57
|
-
.option('-f, --force', 'Overwrite an existing local prompt')
|
|
58
|
-
.action(runWithErrorHandler(save_1.saveCommand));
|
|
59
|
-
program
|
|
60
|
-
.command('sync')
|
|
61
|
-
.description('Upload your local prompts to your account (one-way, explicit)')
|
|
62
|
-
.option('--dry-run', 'List what would be uploaded, change nothing')
|
|
63
|
-
.action(runWithErrorHandler(sync_1.syncCommand));
|
|
64
|
-
program
|
|
65
|
-
.command('login')
|
|
66
|
-
.description('Sign in with email + password; store the session under ~/.config/promptlike/')
|
|
67
|
-
.action(runWithErrorHandler(login_1.loginCommand));
|
|
68
|
-
program
|
|
69
|
-
.command('logout')
|
|
70
|
-
.description('Delete the local session file')
|
|
71
|
-
.action(runWithErrorHandler(logout_1.logoutCommand));
|
|
72
|
-
program
|
|
73
|
-
.command('list')
|
|
74
|
-
.description('List your prompts')
|
|
75
|
-
.option('-t, --tag <name>', 'Filter by a specific tag')
|
|
76
|
-
.option('-l, --limit <n>', 'Max number of rows (default 30)', '30')
|
|
77
|
-
.action(runWithErrorHandler(list_1.listCommand));
|
|
78
|
-
program
|
|
79
|
-
.command('copy <name>')
|
|
80
|
-
.description('Copy a prompt to the clipboard (by title or short id)')
|
|
81
|
-
.option('--project <repo>', 'Scope to one repo (name, slug, or id) when titles collide')
|
|
82
|
-
.action(runWithErrorHandler(copy_1.copyCommand));
|
|
83
|
-
program
|
|
84
|
-
.command('show <name>')
|
|
85
|
-
.description('Show a prompt in the terminal')
|
|
86
|
-
.option('--project <repo>', 'Scope to one repo (name, slug, or id) when titles collide')
|
|
87
|
-
.action(runWithErrorHandler(show_1.showCommand));
|
|
88
|
-
program
|
|
89
|
-
.command('get <name>')
|
|
90
|
-
.description("Print a prompt raw to stdout; fill {{variables}} (agent/pipe friendly)")
|
|
91
|
-
.option('-v, --var <keyval>', 'Fill a variable — key=value (repeatable)', get_1.collectVar, {})
|
|
92
|
-
.option('-c, --copy', 'Also copy the output to the clipboard')
|
|
93
|
-
.option('--project <repo>', 'Scope to one repo (name, slug, or id) when titles collide')
|
|
94
|
-
.action(runWithErrorHandler(get_1.getCommand));
|
|
95
|
-
program
|
|
96
|
-
.command('improve <name>')
|
|
97
|
-
.option('-p, --pick <n>', 'Non-interactive: auto-pick variant N (1..3), 0 to cancel — for scripts/agents')
|
|
98
|
-
.description('Generate AI variants of a prompt, pick a winner, save it as a new version (Pro)')
|
|
99
|
-
.option('-f, --focus <hint>', "Steer the variants (e.g. 'shorter', 'more explicit output format')")
|
|
100
|
-
.option('--project <repo>', 'Scope to one repo (name, slug, or id) when titles collide')
|
|
101
|
-
.action(runWithErrorHandler(improve_1.improveCommand));
|
|
102
|
-
program
|
|
103
|
-
.command('loop <name>')
|
|
104
|
-
.description('Multi-round improve — optionally test each variant with your own agent command (Pro)')
|
|
105
|
-
.option('-e, --exec <cmd>', 'Test each variant: prompt passed via PLE_PROMPT env + stdin; {} placeholder substituted')
|
|
106
|
-
.option('-r, --rounds <n>', 'Number of improvement rounds', '1')
|
|
107
|
-
.option('-f, --focus <hint>', 'Steer the variants')
|
|
108
|
-
.option('-p, --pick <n>', 'Non-interactive: auto-pick variant N each round + auto-continue — for scripts/agents')
|
|
109
|
-
.option('--project <repo>', 'Scope to one repo (name, slug, or id) when titles collide')
|
|
110
|
-
.action(runWithErrorHandler(loop_1.loopCommand));
|
|
111
|
-
program
|
|
112
|
-
.command('export [name]')
|
|
113
|
-
.description('Export a prompt (or a whole repo with --project) as an AGENTS.md section or an Agent Skill (SKILL.md)')
|
|
114
|
-
.requiredOption('--format <format>', 'agents-md | skill')
|
|
115
|
-
.option('--project <repo>', 'Repo to export (no name) or to scope the name to')
|
|
116
|
-
.option('-o, --out <path>', 'agents-md: file to write (default stdout) · skill: parent folder (default .)')
|
|
117
|
-
.option('--zip', 'skill: write <name>.zip (upload in Claude) instead of a folder')
|
|
118
|
-
.option('-f, --force', 'Overwrite an existing file or folder')
|
|
119
|
-
.action(runWithErrorHandler(export_1.exportCommand));
|
|
120
|
-
program
|
|
121
|
-
.command('search <keyword>')
|
|
122
|
-
.description('Search titles and descriptions (signed out: also local prompt bodies and tags)')
|
|
123
|
-
.action(runWithErrorHandler(search_1.searchCommand));
|
|
124
|
-
program
|
|
125
|
-
.command('stats')
|
|
126
|
-
.description('How your library is used — uses by surface, most used, gathering dust')
|
|
127
|
-
.option('-r, --range <days>', 'Window: 7, 30 or 365 (Free: 7)', '7')
|
|
128
|
-
.option('--json', 'Print the raw summary as JSON')
|
|
129
|
-
.action(runWithErrorHandler(stats_1.statsCommand));
|
|
130
|
-
program
|
|
131
|
-
.command('import')
|
|
132
|
-
.description('Bring in prompts you already have: .claude/commands, SKILL.md, .cursor/commands, ~/.codex/prompts')
|
|
133
|
-
.option('--scan', 'Scan this repo and your home folder for agent prompt files')
|
|
134
|
-
.option('--dry-run', 'Only show what was found, import nothing')
|
|
135
|
-
.option('-a, --all', 'Import everything new without asking')
|
|
136
|
-
.option('--project <repo>', 'Import into this repo (signed in)')
|
|
137
|
-
.action(runWithErrorHandler((opts) => (0, import_1.importCommand)(opts)));
|
|
138
|
-
program
|
|
139
|
-
.command('log <name>')
|
|
140
|
-
.description('Version history of a prompt (* = current)')
|
|
141
|
-
.option('--project <repo>', 'Scope to one repo (name, slug, or id) when titles collide')
|
|
142
|
-
.option('-l, --limit <n>', 'Max versions to show (default 20)', '20')
|
|
143
|
-
.option('--json', 'Print as JSON')
|
|
144
|
-
.action(runWithErrorHandler(log_1.logCommand));
|
|
145
|
-
program
|
|
146
|
-
.command('diff <name> [a] [b]')
|
|
147
|
-
.description('Diff two versions (default: previous ↔ current). Refs: 3, v3 or 1.0.2')
|
|
148
|
-
.option('--project <repo>', 'Scope to one repo (name, slug, or id) when titles collide')
|
|
149
|
-
.option('--no-color', 'Plain output (automatic when piped)')
|
|
150
|
-
.action(runWithErrorHandler((name, a, b, opts) => (0, diff_1.diffCommand)(name, a, b, opts)));
|
|
151
|
-
program
|
|
152
|
-
.command('suggest [text...]')
|
|
153
|
-
.description('Which saved prompt fits this task? Local match — the text never leaves your machine')
|
|
154
|
-
.option('--json', 'Print matches as JSON')
|
|
155
|
-
.option('-l, --limit <n>', 'Max matches (default 3)', '3')
|
|
156
|
-
.option('--hook', 'Claude Code UserPromptSubmit mode: read hook JSON on stdin, print a short hint or nothing')
|
|
157
|
-
.option('--refresh-cache', 'Refresh the local library cache from your account and exit')
|
|
158
|
-
.action(runWithErrorHandler((text, opts) => (0, suggest_1.suggestCommand)(text ?? [], opts)));
|
|
159
|
-
const configCmd = program
|
|
160
|
-
.command('config')
|
|
161
|
-
.description('CLI preferences (suggest on|off)');
|
|
162
|
-
configCmd
|
|
163
|
-
.command('get [key]')
|
|
164
|
-
.description('Show a setting (or all)')
|
|
165
|
-
.action(runWithErrorHandler(config_1.configGetCommand));
|
|
166
|
-
configCmd
|
|
167
|
-
.command('set <key> <value>')
|
|
168
|
-
.description('Change a setting, e.g. `ple config set suggest off`')
|
|
169
|
-
.action(runWithErrorHandler(config_1.configSetCommand));
|
|
170
|
-
program
|
|
171
|
-
.command('rollback <name> <version>')
|
|
172
|
-
.description('Restore an old version as a new one — nothing is deleted')
|
|
173
|
-
.option('--project <repo>', 'Scope to one repo (name, slug, or id) when titles collide')
|
|
174
|
-
.option('-y, --yes', 'Skip the confirmation prompt')
|
|
175
|
-
.action(runWithErrorHandler((name, version, opts) => (0, rollback_1.rollbackCommand)(name, version, opts)));
|
|
176
|
-
program.parseAsync(process.argv);
|
|
7
|
+
const program_1 = require("./program");
|
|
8
|
+
(0, program_1.buildProgram)()
|
|
9
|
+
.parseAsync(process.argv)
|
|
10
|
+
.catch((err) => {
|
|
11
|
+
// Commands handle their own errors; this only catches a bug in the wiring itself.
|
|
12
|
+
console.error(`✗ ${err instanceof Error ? err.message : String(err)}`);
|
|
13
|
+
process.exit(1);
|
|
14
|
+
});
|