@hasna/prompts 0.3.18 → 0.3.19
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/dist/cli/commands/prompts.d.ts.map +1 -1
- package/dist/cli/commands/qol.d.ts.map +1 -1
- package/dist/cli/index.js +96 -58
- package/dist/cli/utils.d.ts +1 -0
- package/dist/cli/utils.d.ts.map +1 -1
- package/dist/db/prompts.d.ts +1 -1
- package/dist/db/prompts.d.ts.map +1 -1
- package/dist/index.js +8 -4
- package/dist/mcp/index.js +17 -7
- package/dist/server/index.js +8 -4
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/prompts.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAOnC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/prompts.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAOnC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAmW7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qol.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/qol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAQnC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"qol.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/qol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAQnC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAkW1D"}
|
package/dist/cli/index.js
CHANGED
|
@@ -12067,6 +12067,7 @@ function listPrompts(filter = {}) {
|
|
|
12067
12067
|
const db = getDatabase();
|
|
12068
12068
|
const conditions = [];
|
|
12069
12069
|
const params = [];
|
|
12070
|
+
const orderParams = [];
|
|
12070
12071
|
if (filter.collection) {
|
|
12071
12072
|
conditions.push("collection = ?");
|
|
12072
12073
|
params.push(filter.collection);
|
|
@@ -12090,18 +12091,20 @@ function listPrompts(filter = {}) {
|
|
|
12090
12091
|
if (filter.project_id !== undefined && filter.project_id !== null) {
|
|
12091
12092
|
conditions.push("(project_id = ? OR project_id IS NULL)");
|
|
12092
12093
|
params.push(filter.project_id);
|
|
12093
|
-
orderBy =
|
|
12094
|
+
orderBy = "(CASE WHEN project_id = ? THEN 0 ELSE 1 END), pinned DESC, use_count DESC, updated_at DESC";
|
|
12095
|
+
orderParams.push(filter.project_id);
|
|
12094
12096
|
}
|
|
12095
12097
|
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
12096
12098
|
const limit = filter.limit ?? 20;
|
|
12097
12099
|
const offset = filter.offset ?? 0;
|
|
12098
|
-
const rows = db.query(`SELECT * FROM prompts ${where} ORDER BY ${orderBy} LIMIT ? OFFSET ?`).all(...params, limit, offset);
|
|
12100
|
+
const rows = db.query(`SELECT * FROM prompts ${where} ORDER BY ${orderBy} LIMIT ? OFFSET ?`).all(...params, ...orderParams, limit, offset);
|
|
12099
12101
|
return rows.map(rowToPrompt);
|
|
12100
12102
|
}
|
|
12101
12103
|
function listPromptsSlim(filter = {}) {
|
|
12102
12104
|
const db = getDatabase();
|
|
12103
12105
|
const conditions = [];
|
|
12104
12106
|
const params = [];
|
|
12107
|
+
const orderParams = [];
|
|
12105
12108
|
if (filter.collection) {
|
|
12106
12109
|
conditions.push("collection = ?");
|
|
12107
12110
|
params.push(filter.collection);
|
|
@@ -12124,12 +12127,13 @@ function listPromptsSlim(filter = {}) {
|
|
|
12124
12127
|
if (filter.project_id) {
|
|
12125
12128
|
conditions.push("(project_id = ? OR project_id IS NULL)");
|
|
12126
12129
|
params.push(filter.project_id);
|
|
12127
|
-
orderBy =
|
|
12130
|
+
orderBy = "(CASE WHEN project_id = ? THEN 0 ELSE 1 END), pinned DESC, use_count DESC, updated_at DESC";
|
|
12131
|
+
orderParams.push(filter.project_id);
|
|
12128
12132
|
}
|
|
12129
12133
|
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
12130
12134
|
const limit = filter.limit ?? 20;
|
|
12131
12135
|
const offset = filter.offset ?? 0;
|
|
12132
|
-
const rows = db.query(`SELECT id, slug, name, title, description, collection, tags, variables, is_template, source, pinned, next_prompt, expires_at, project_id, use_count, last_used_at, created_at, updated_at FROM prompts ${where} ORDER BY ${orderBy} LIMIT ? OFFSET ?`).all(...params, limit, offset);
|
|
12136
|
+
const rows = db.query(`SELECT id, slug, name, title, description, collection, tags, variables, is_template, source, pinned, next_prompt, expires_at, project_id, use_count, last_used_at, created_at, updated_at FROM prompts ${where} ORDER BY ${orderBy} LIMIT ? OFFSET ?`).all(...params, ...orderParams, limit, offset);
|
|
12133
12137
|
return rows.map(rowToSlimPrompt);
|
|
12134
12138
|
}
|
|
12135
12139
|
function updatePrompt(idOrSlug, input) {
|
|
@@ -12183,16 +12187,22 @@ function usePrompt(idOrSlug) {
|
|
|
12183
12187
|
db.run("INSERT INTO usage_log (id, prompt_id) VALUES (?, ?)", [generateId("UL"), prompt.id]);
|
|
12184
12188
|
return requirePrompt(prompt.id);
|
|
12185
12189
|
}
|
|
12186
|
-
function getTrending(days = 7, limit = 10) {
|
|
12190
|
+
function getTrending(days = 7, limit = 10, projectId) {
|
|
12187
12191
|
const db = getDatabase();
|
|
12188
12192
|
const cutoff = new Date(Date.now() - days * 24 * 60 * 60 * 1000).toISOString();
|
|
12189
|
-
|
|
12193
|
+
const projectFilter = projectId ? "AND (p.project_id = ? OR p.project_id IS NULL)" : "";
|
|
12194
|
+
const rows = db.query(`SELECT p.id, p.slug, p.title, COUNT(ul.id) as uses
|
|
12190
12195
|
FROM usage_log ul
|
|
12191
12196
|
JOIN prompts p ON p.id = ul.prompt_id
|
|
12192
12197
|
WHERE ul.used_at >= ?
|
|
12198
|
+
${projectFilter}
|
|
12193
12199
|
GROUP BY p.id
|
|
12194
12200
|
ORDER BY uses DESC
|
|
12195
|
-
LIMIT ?`)
|
|
12201
|
+
LIMIT ?`);
|
|
12202
|
+
if (projectId) {
|
|
12203
|
+
return rows.all(cutoff, projectId, limit);
|
|
12204
|
+
}
|
|
12205
|
+
return rows.all(cutoff, limit);
|
|
12196
12206
|
}
|
|
12197
12207
|
function setExpiry(idOrSlug, expiresAt) {
|
|
12198
12208
|
const db = getDatabase();
|
|
@@ -13117,6 +13127,46 @@ function getActiveProjectId(program2) {
|
|
|
13117
13127
|
const db = getDatabase();
|
|
13118
13128
|
return resolveProject(db, projectName);
|
|
13119
13129
|
}
|
|
13130
|
+
async function writeToClipboard(text) {
|
|
13131
|
+
const run = async (cmd) => {
|
|
13132
|
+
const proc = Bun.spawn(cmd, { stdin: "pipe", stdout: "ignore", stderr: "ignore" });
|
|
13133
|
+
proc.stdin.write(text);
|
|
13134
|
+
proc.stdin.end();
|
|
13135
|
+
const exitCode = await proc.exited;
|
|
13136
|
+
if (exitCode !== 0) {
|
|
13137
|
+
throw new Error(`Clipboard command failed: ${cmd[0]}`);
|
|
13138
|
+
}
|
|
13139
|
+
};
|
|
13140
|
+
if (process.platform === "darwin") {
|
|
13141
|
+
await run(["pbcopy"]);
|
|
13142
|
+
return;
|
|
13143
|
+
}
|
|
13144
|
+
if (process.platform === "linux") {
|
|
13145
|
+
const candidates = [
|
|
13146
|
+
["xclip", "-selection", "clipboard"],
|
|
13147
|
+
["xsel", "--clipboard", "--input"]
|
|
13148
|
+
];
|
|
13149
|
+
const available = candidates.filter((cmd) => {
|
|
13150
|
+
const tool = cmd[0];
|
|
13151
|
+
if (!tool)
|
|
13152
|
+
return false;
|
|
13153
|
+
if (typeof Bun.which !== "function")
|
|
13154
|
+
return true;
|
|
13155
|
+
return Boolean(Bun.which(tool));
|
|
13156
|
+
});
|
|
13157
|
+
if (available.length === 0) {
|
|
13158
|
+
throw new Error("No clipboard tool found. Install xclip or xsel, or use `prompts use` / `prompts share` without clipboard.");
|
|
13159
|
+
}
|
|
13160
|
+
for (const cmd of available) {
|
|
13161
|
+
try {
|
|
13162
|
+
await run(cmd);
|
|
13163
|
+
return;
|
|
13164
|
+
} catch {}
|
|
13165
|
+
}
|
|
13166
|
+
throw new Error("Failed to copy to clipboard using available tools. Use `prompts use` or `prompts share` without clipboard.");
|
|
13167
|
+
}
|
|
13168
|
+
throw new Error("Clipboard is not supported on this platform. Use `prompts use` or `prompts share` without clipboard.");
|
|
13169
|
+
}
|
|
13120
13170
|
function output(program2, data) {
|
|
13121
13171
|
if (isJson(program2)) {
|
|
13122
13172
|
console.log(JSON.stringify(data, null, 2));
|
|
@@ -13237,7 +13287,7 @@ function registerPromptCommands(program2) {
|
|
|
13237
13287
|
handleError(program2, e);
|
|
13238
13288
|
}
|
|
13239
13289
|
});
|
|
13240
|
-
program2.command("list").description("List prompts").option("-c, --collection <name>", "Filter by collection").option("-t, --tags <tags>", "Filter by tags (comma-separated)").option("--templates", "Show only templates").option("--recent", "Sort by recently used").option("-n, --limit <n>", "Max results", "50").action((opts) => {
|
|
13290
|
+
program2.command("list").description("List prompts").option("-c, --collection <name>", "Filter by collection").option("-t, --tags <tags>", "Filter by tags (comma-separated)").option("--templates", "Show only templates").option("--recent", "Sort by recently used").option("-n, --limit <n>", "Max results", "50").option("-o, --offset <n>", "Skip first N results", "0").action((opts) => {
|
|
13241
13291
|
try {
|
|
13242
13292
|
const project_id = getActiveProjectId(program2);
|
|
13243
13293
|
let prompts = listPrompts({
|
|
@@ -13245,6 +13295,7 @@ function registerPromptCommands(program2) {
|
|
|
13245
13295
|
tags: opts["tags"] ? opts["tags"].split(",").map((t) => t.trim()) : undefined,
|
|
13246
13296
|
is_template: opts["templates"] ? true : undefined,
|
|
13247
13297
|
limit: parseInt(opts["limit"]) || 50,
|
|
13298
|
+
offset: parseInt(opts["offset"] ?? "0") || 0,
|
|
13248
13299
|
...project_id !== null ? { project_id } : {}
|
|
13249
13300
|
});
|
|
13250
13301
|
if (opts["recent"]) {
|
|
@@ -13264,13 +13315,14 @@ ${prompts.length} prompt(s)`));
|
|
|
13264
13315
|
handleError(program2, e);
|
|
13265
13316
|
}
|
|
13266
13317
|
});
|
|
13267
|
-
program2.command("search <query>").description("Full-text search across prompts (FTS5)").option("-c, --collection <name>").option("-t, --tags <tags>").option("-n, --limit <n>", "Max results", "20").action((query, opts) => {
|
|
13318
|
+
program2.command("search <query>").description("Full-text search across prompts (FTS5)").option("-c, --collection <name>").option("-t, --tags <tags>").option("-n, --limit <n>", "Max results", "20").option("-o, --offset <n>", "Skip first N results", "0").action((query, opts) => {
|
|
13268
13319
|
try {
|
|
13269
13320
|
const project_id = getActiveProjectId(program2);
|
|
13270
13321
|
const results = searchPrompts(query, {
|
|
13271
13322
|
collection: opts["collection"],
|
|
13272
13323
|
tags: opts["tags"] ? opts["tags"].split(",").map((t) => t.trim()) : undefined,
|
|
13273
13324
|
limit: parseInt(opts["limit"] ?? "20") || 20,
|
|
13325
|
+
offset: parseInt(opts["offset"] ?? "0") || 0,
|
|
13274
13326
|
...project_id !== null ? { project_id } : {}
|
|
13275
13327
|
});
|
|
13276
13328
|
if (isJson(program2)) {
|
|
@@ -13317,9 +13369,16 @@ Warning: missing vars: ${result.missing_vars.join(", ")}`));
|
|
|
13317
13369
|
handleError(program2, e);
|
|
13318
13370
|
}
|
|
13319
13371
|
});
|
|
13320
|
-
program2.command("templates").description("List template prompts").option("-c, --collection <name>").action((opts) => {
|
|
13372
|
+
program2.command("templates").description("List template prompts").option("-c, --collection <name>").option("-n, --limit <n>", "Max results", "50").option("-o, --offset <n>", "Skip first N results", "0").action((opts) => {
|
|
13321
13373
|
try {
|
|
13322
|
-
const
|
|
13374
|
+
const project_id = getActiveProjectId(program2);
|
|
13375
|
+
const prompts = listPrompts({
|
|
13376
|
+
is_template: true,
|
|
13377
|
+
collection: opts["collection"],
|
|
13378
|
+
limit: parseInt(opts["limit"] ?? "50") || 50,
|
|
13379
|
+
offset: parseInt(opts["offset"] ?? "0") || 0,
|
|
13380
|
+
...project_id !== null ? { project_id } : {}
|
|
13381
|
+
});
|
|
13323
13382
|
if (isJson(program2)) {
|
|
13324
13383
|
output(program2, prompts);
|
|
13325
13384
|
} else if (prompts.length === 0) {
|
|
@@ -13704,27 +13763,7 @@ function registerQolCommands(program2) {
|
|
|
13704
13763
|
const markdown = lines.join(`
|
|
13705
13764
|
`);
|
|
13706
13765
|
if (opts.clipboard) {
|
|
13707
|
-
|
|
13708
|
-
if (platform2 === "darwin") {
|
|
13709
|
-
const proc = Bun.spawn(["pbcopy"], { stdin: "pipe" });
|
|
13710
|
-
proc.stdin.write(markdown);
|
|
13711
|
-
proc.stdin.end();
|
|
13712
|
-
await proc.exited;
|
|
13713
|
-
} else if (platform2 === "linux") {
|
|
13714
|
-
try {
|
|
13715
|
-
const proc = Bun.spawn(["xclip", "-selection", "clipboard"], { stdin: "pipe" });
|
|
13716
|
-
proc.stdin.write(markdown);
|
|
13717
|
-
proc.stdin.end();
|
|
13718
|
-
await proc.exited;
|
|
13719
|
-
} catch {
|
|
13720
|
-
const proc = Bun.spawn(["xsel", "--clipboard", "--input"], { stdin: "pipe" });
|
|
13721
|
-
proc.stdin.write(markdown);
|
|
13722
|
-
proc.stdin.end();
|
|
13723
|
-
await proc.exited;
|
|
13724
|
-
}
|
|
13725
|
-
} else {
|
|
13726
|
-
handleError(program2, "Clipboard not supported on this platform.");
|
|
13727
|
-
}
|
|
13766
|
+
await writeToClipboard(markdown);
|
|
13728
13767
|
console.log(chalk4.green(`Copied ${chalk4.bold(p.slug)} to clipboard`));
|
|
13729
13768
|
} else {
|
|
13730
13769
|
if (isJson(program2))
|
|
@@ -14381,7 +14420,11 @@ By collection:`));
|
|
|
14381
14420
|
program2.command("recent [n]").description("Show recently used prompts (default: 10)").action((n) => {
|
|
14382
14421
|
try {
|
|
14383
14422
|
const limit = parseInt(n ?? "10") || 10;
|
|
14384
|
-
const
|
|
14423
|
+
const project_id = getActiveProjectId(program2);
|
|
14424
|
+
const prompts = listPrompts({
|
|
14425
|
+
limit,
|
|
14426
|
+
...project_id !== null ? { project_id } : {}
|
|
14427
|
+
}).filter((p) => p.last_used_at !== null).sort((a, b) => (b.last_used_at ?? "").localeCompare(a.last_used_at ?? "")).slice(0, limit);
|
|
14385
14428
|
if (isJson(program2)) {
|
|
14386
14429
|
output(program2, prompts);
|
|
14387
14430
|
return;
|
|
@@ -14400,7 +14443,12 @@ program2.command("recent [n]").description("Show recently used prompts (default:
|
|
|
14400
14443
|
});
|
|
14401
14444
|
program2.command("lint").description("Check prompt quality: missing descriptions, undocumented vars, short bodies, no tags").option("-c, --collection <name>", "Lint only this collection").action((opts) => {
|
|
14402
14445
|
try {
|
|
14403
|
-
const
|
|
14446
|
+
const project_id = getActiveProjectId(program2);
|
|
14447
|
+
const prompts = listPrompts({
|
|
14448
|
+
collection: opts["collection"],
|
|
14449
|
+
limit: 1e4,
|
|
14450
|
+
...project_id !== null ? { project_id } : {}
|
|
14451
|
+
});
|
|
14404
14452
|
const results = lintAll(prompts);
|
|
14405
14453
|
if (isJson(program2)) {
|
|
14406
14454
|
output(program2, results);
|
|
@@ -14438,8 +14486,12 @@ ${results.length} prompt(s) with issues \u2014 ${errors} errors, ${warns} warnin
|
|
|
14438
14486
|
program2.command("stale [days]").description("List prompts not used in N days (default: 30)").action((days) => {
|
|
14439
14487
|
try {
|
|
14440
14488
|
const threshold = parseInt(days ?? "30") || 30;
|
|
14489
|
+
const project_id = getActiveProjectId(program2);
|
|
14441
14490
|
const cutoff = new Date(Date.now() - threshold * 24 * 60 * 60 * 1000).toISOString();
|
|
14442
|
-
const all = listPrompts({
|
|
14491
|
+
const all = listPrompts({
|
|
14492
|
+
limit: 1e4,
|
|
14493
|
+
...project_id !== null ? { project_id } : {}
|
|
14494
|
+
});
|
|
14443
14495
|
const stale = all.filter((p) => p.last_used_at === null || p.last_used_at < cutoff).sort((a, b) => (a.last_used_at ?? "").localeCompare(b.last_used_at ?? ""));
|
|
14444
14496
|
const now = new Date().toISOString();
|
|
14445
14497
|
const expired = all.filter((p) => p.expires_at !== null && p.expires_at < now);
|
|
@@ -14496,27 +14548,7 @@ program2.command("unpin <id>").description("Unpin a prompt").action((id) => {
|
|
|
14496
14548
|
program2.command("copy <id>").description("Copy prompt body to clipboard and increment use counter").action(async (id) => {
|
|
14497
14549
|
try {
|
|
14498
14550
|
const prompt = usePrompt(id);
|
|
14499
|
-
|
|
14500
|
-
if (platform2 === "darwin") {
|
|
14501
|
-
const proc = Bun.spawn(["pbcopy"], { stdin: "pipe" });
|
|
14502
|
-
proc.stdin.write(prompt.body);
|
|
14503
|
-
proc.stdin.end();
|
|
14504
|
-
await proc.exited;
|
|
14505
|
-
} else if (platform2 === "linux") {
|
|
14506
|
-
try {
|
|
14507
|
-
const proc = Bun.spawn(["xclip", "-selection", "clipboard"], { stdin: "pipe" });
|
|
14508
|
-
proc.stdin.write(prompt.body);
|
|
14509
|
-
proc.stdin.end();
|
|
14510
|
-
await proc.exited;
|
|
14511
|
-
} catch {
|
|
14512
|
-
const proc = Bun.spawn(["xsel", "--clipboard", "--input"], { stdin: "pipe" });
|
|
14513
|
-
proc.stdin.write(prompt.body);
|
|
14514
|
-
proc.stdin.end();
|
|
14515
|
-
await proc.exited;
|
|
14516
|
-
}
|
|
14517
|
-
} else {
|
|
14518
|
-
handleError(program2, "Clipboard not supported on this platform. Use `prompts use` instead.");
|
|
14519
|
-
}
|
|
14551
|
+
await writeToClipboard(prompt.body);
|
|
14520
14552
|
if (isJson(program2))
|
|
14521
14553
|
output(program2, { copied: true, id: prompt.id, slug: prompt.slug });
|
|
14522
14554
|
else
|
|
@@ -14649,7 +14681,12 @@ ${report.issues.length} issue(s) \u2014 ${report.errors} errors, ${report.warnin
|
|
|
14649
14681
|
});
|
|
14650
14682
|
program2.command("unused").description("List prompts that have never been used (use_count = 0)").option("-c, --collection <name>").option("-n, --limit <n>", "Max results", "50").action((opts) => {
|
|
14651
14683
|
try {
|
|
14652
|
-
const
|
|
14684
|
+
const project_id = getActiveProjectId(program2);
|
|
14685
|
+
const all = listPrompts({
|
|
14686
|
+
collection: opts["collection"],
|
|
14687
|
+
limit: parseInt(opts["limit"] ?? "50") || 50,
|
|
14688
|
+
...project_id !== null ? { project_id } : {}
|
|
14689
|
+
});
|
|
14653
14690
|
const unused = all.filter((p) => p.use_count === 0).sort((a, b) => a.created_at.localeCompare(b.created_at));
|
|
14654
14691
|
if (isJson(program2)) {
|
|
14655
14692
|
output(program2, unused);
|
|
@@ -14669,7 +14706,8 @@ program2.command("unused").description("List prompts that have never been used (
|
|
|
14669
14706
|
});
|
|
14670
14707
|
program2.command("trending").description("Most used prompts in the last N days").option("--days <n>", "Lookback window in days", "7").option("-n, --limit <n>", "Max results", "10").action((opts) => {
|
|
14671
14708
|
try {
|
|
14672
|
-
const
|
|
14709
|
+
const project_id = getActiveProjectId(program2);
|
|
14710
|
+
const results = getTrending(parseInt(opts["days"] ?? "7") || 7, parseInt(opts["limit"] ?? "10") || 10, project_id);
|
|
14673
14711
|
if (isJson(program2)) {
|
|
14674
14712
|
output(program2, results);
|
|
14675
14713
|
return;
|
package/dist/cli/utils.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Command } from "commander";
|
|
|
2
2
|
import type { Prompt } from "../types/index.js";
|
|
3
3
|
export declare function isJson(program: Command): boolean;
|
|
4
4
|
export declare function getActiveProjectId(program: Command): string | null;
|
|
5
|
+
export declare function writeToClipboard(text: string): Promise<void>;
|
|
5
6
|
export declare function output(program: Command, data: unknown): void;
|
|
6
7
|
export declare function handleError(program: Command, e: unknown): never;
|
|
7
8
|
export declare function fmtPrompt(p: Prompt): string;
|
package/dist/cli/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/cli/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/C,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAEhD;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAKlE;AAED,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAM5D;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,KAAK,CAQ/D;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAK3C"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/cli/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/C,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAEhD;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAKlE;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA8ClE;AAED,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAM5D;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,KAAK,CAQ/D;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAK3C"}
|
package/dist/db/prompts.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare function listPromptsSlim(filter?: ListPromptsFilter): SlimPrompt[
|
|
|
9
9
|
export declare function updatePrompt(idOrSlug: string, input: UpdatePromptInput): Prompt;
|
|
10
10
|
export declare function deletePrompt(idOrSlug: string): void;
|
|
11
11
|
export declare function usePrompt(idOrSlug: string): Prompt;
|
|
12
|
-
export declare function getTrending(days?: number, limit?: number): Array<{
|
|
12
|
+
export declare function getTrending(days?: number, limit?: number, projectId?: string | null): Array<{
|
|
13
13
|
id: string;
|
|
14
14
|
slug: string;
|
|
15
15
|
title: string;
|
package/dist/db/prompts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/db/prompts.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,MAAM,EACN,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EAGlB,MAAM,mBAAmB,CAAA;AA2B1B,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,UAAU,CAWlH;AA2BD,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CA0C7D;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOzD;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAItD;AAED,wBAAgB,WAAW,CAAC,MAAM,GAAE,iBAAsB,GAAG,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/db/prompts.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,MAAM,EACN,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EAGlB,MAAM,mBAAmB,CAAA;AA2B1B,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,UAAU,CAWlH;AA2BD,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CA0C7D;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOzD;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAItD;AAED,wBAAgB,WAAW,CAAC,MAAM,GAAE,iBAAsB,GAAG,MAAM,EAAE,CA8CpE;AAED,yFAAyF;AACzF,wBAAgB,eAAe,CAAC,MAAM,GAAE,iBAAsB,GAAG,UAAU,EAAE,CAiC5E;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAiD/E;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAInD;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CASlD;AAED,wBAAgB,WAAW,CAAC,IAAI,SAAI,EAAE,KAAK,SAAK,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAkB7I;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAK5E;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAK/E;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,CAKnE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,UAAQ,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAE,CA6BtI;AAED,wBAAgB,cAAc;;;;;YAOJ,MAAM;cAAQ,MAAM;cAAQ,MAAM;eAAS,MAAM;mBAAa,MAAM;;;YAGpE,MAAM;cAAQ,MAAM;cAAQ,MAAM;eAAS,MAAM;sBAAgB,MAAM;;;oBAG/D,MAAM;eAAS,MAAM;;;gBAGzB,MAAM;eAAS,MAAM;;EAGlD"}
|
package/dist/index.js
CHANGED
|
@@ -10100,6 +10100,7 @@ function listPrompts(filter = {}) {
|
|
|
10100
10100
|
const db = getDatabase();
|
|
10101
10101
|
const conditions = [];
|
|
10102
10102
|
const params = [];
|
|
10103
|
+
const orderParams = [];
|
|
10103
10104
|
if (filter.collection) {
|
|
10104
10105
|
conditions.push("collection = ?");
|
|
10105
10106
|
params.push(filter.collection);
|
|
@@ -10123,18 +10124,20 @@ function listPrompts(filter = {}) {
|
|
|
10123
10124
|
if (filter.project_id !== undefined && filter.project_id !== null) {
|
|
10124
10125
|
conditions.push("(project_id = ? OR project_id IS NULL)");
|
|
10125
10126
|
params.push(filter.project_id);
|
|
10126
|
-
orderBy =
|
|
10127
|
+
orderBy = "(CASE WHEN project_id = ? THEN 0 ELSE 1 END), pinned DESC, use_count DESC, updated_at DESC";
|
|
10128
|
+
orderParams.push(filter.project_id);
|
|
10127
10129
|
}
|
|
10128
10130
|
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
10129
10131
|
const limit = filter.limit ?? 20;
|
|
10130
10132
|
const offset = filter.offset ?? 0;
|
|
10131
|
-
const rows = db.query(`SELECT * FROM prompts ${where} ORDER BY ${orderBy} LIMIT ? OFFSET ?`).all(...params, limit, offset);
|
|
10133
|
+
const rows = db.query(`SELECT * FROM prompts ${where} ORDER BY ${orderBy} LIMIT ? OFFSET ?`).all(...params, ...orderParams, limit, offset);
|
|
10132
10134
|
return rows.map(rowToPrompt);
|
|
10133
10135
|
}
|
|
10134
10136
|
function listPromptsSlim(filter = {}) {
|
|
10135
10137
|
const db = getDatabase();
|
|
10136
10138
|
const conditions = [];
|
|
10137
10139
|
const params = [];
|
|
10140
|
+
const orderParams = [];
|
|
10138
10141
|
if (filter.collection) {
|
|
10139
10142
|
conditions.push("collection = ?");
|
|
10140
10143
|
params.push(filter.collection);
|
|
@@ -10157,12 +10160,13 @@ function listPromptsSlim(filter = {}) {
|
|
|
10157
10160
|
if (filter.project_id) {
|
|
10158
10161
|
conditions.push("(project_id = ? OR project_id IS NULL)");
|
|
10159
10162
|
params.push(filter.project_id);
|
|
10160
|
-
orderBy =
|
|
10163
|
+
orderBy = "(CASE WHEN project_id = ? THEN 0 ELSE 1 END), pinned DESC, use_count DESC, updated_at DESC";
|
|
10164
|
+
orderParams.push(filter.project_id);
|
|
10161
10165
|
}
|
|
10162
10166
|
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
10163
10167
|
const limit = filter.limit ?? 20;
|
|
10164
10168
|
const offset = filter.offset ?? 0;
|
|
10165
|
-
const rows = db.query(`SELECT id, slug, name, title, description, collection, tags, variables, is_template, source, pinned, next_prompt, expires_at, project_id, use_count, last_used_at, created_at, updated_at FROM prompts ${where} ORDER BY ${orderBy} LIMIT ? OFFSET ?`).all(...params, limit, offset);
|
|
10169
|
+
const rows = db.query(`SELECT id, slug, name, title, description, collection, tags, variables, is_template, source, pinned, next_prompt, expires_at, project_id, use_count, last_used_at, created_at, updated_at FROM prompts ${where} ORDER BY ${orderBy} LIMIT ? OFFSET ?`).all(...params, ...orderParams, limit, offset);
|
|
10166
10170
|
return rows.map(rowToSlimPrompt);
|
|
10167
10171
|
}
|
|
10168
10172
|
function updatePrompt(idOrSlug, input) {
|
package/dist/mcp/index.js
CHANGED
|
@@ -14733,6 +14733,7 @@ function listPrompts(filter = {}) {
|
|
|
14733
14733
|
const db = getDatabase();
|
|
14734
14734
|
const conditions = [];
|
|
14735
14735
|
const params = [];
|
|
14736
|
+
const orderParams = [];
|
|
14736
14737
|
if (filter.collection) {
|
|
14737
14738
|
conditions.push("collection = ?");
|
|
14738
14739
|
params.push(filter.collection);
|
|
@@ -14756,18 +14757,20 @@ function listPrompts(filter = {}) {
|
|
|
14756
14757
|
if (filter.project_id !== undefined && filter.project_id !== null) {
|
|
14757
14758
|
conditions.push("(project_id = ? OR project_id IS NULL)");
|
|
14758
14759
|
params.push(filter.project_id);
|
|
14759
|
-
orderBy =
|
|
14760
|
+
orderBy = "(CASE WHEN project_id = ? THEN 0 ELSE 1 END), pinned DESC, use_count DESC, updated_at DESC";
|
|
14761
|
+
orderParams.push(filter.project_id);
|
|
14760
14762
|
}
|
|
14761
14763
|
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
14762
14764
|
const limit = filter.limit ?? 20;
|
|
14763
14765
|
const offset = filter.offset ?? 0;
|
|
14764
|
-
const rows = db.query(`SELECT * FROM prompts ${where} ORDER BY ${orderBy} LIMIT ? OFFSET ?`).all(...params, limit, offset);
|
|
14766
|
+
const rows = db.query(`SELECT * FROM prompts ${where} ORDER BY ${orderBy} LIMIT ? OFFSET ?`).all(...params, ...orderParams, limit, offset);
|
|
14765
14767
|
return rows.map(rowToPrompt);
|
|
14766
14768
|
}
|
|
14767
14769
|
function listPromptsSlim(filter = {}) {
|
|
14768
14770
|
const db = getDatabase();
|
|
14769
14771
|
const conditions = [];
|
|
14770
14772
|
const params = [];
|
|
14773
|
+
const orderParams = [];
|
|
14771
14774
|
if (filter.collection) {
|
|
14772
14775
|
conditions.push("collection = ?");
|
|
14773
14776
|
params.push(filter.collection);
|
|
@@ -14790,12 +14793,13 @@ function listPromptsSlim(filter = {}) {
|
|
|
14790
14793
|
if (filter.project_id) {
|
|
14791
14794
|
conditions.push("(project_id = ? OR project_id IS NULL)");
|
|
14792
14795
|
params.push(filter.project_id);
|
|
14793
|
-
orderBy =
|
|
14796
|
+
orderBy = "(CASE WHEN project_id = ? THEN 0 ELSE 1 END), pinned DESC, use_count DESC, updated_at DESC";
|
|
14797
|
+
orderParams.push(filter.project_id);
|
|
14794
14798
|
}
|
|
14795
14799
|
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
14796
14800
|
const limit = filter.limit ?? 20;
|
|
14797
14801
|
const offset = filter.offset ?? 0;
|
|
14798
|
-
const rows = db.query(`SELECT id, slug, name, title, description, collection, tags, variables, is_template, source, pinned, next_prompt, expires_at, project_id, use_count, last_used_at, created_at, updated_at FROM prompts ${where} ORDER BY ${orderBy} LIMIT ? OFFSET ?`).all(...params, limit, offset);
|
|
14802
|
+
const rows = db.query(`SELECT id, slug, name, title, description, collection, tags, variables, is_template, source, pinned, next_prompt, expires_at, project_id, use_count, last_used_at, created_at, updated_at FROM prompts ${where} ORDER BY ${orderBy} LIMIT ? OFFSET ?`).all(...params, ...orderParams, limit, offset);
|
|
14799
14803
|
return rows.map(rowToSlimPrompt);
|
|
14800
14804
|
}
|
|
14801
14805
|
function updatePrompt(idOrSlug, input) {
|
|
@@ -14849,16 +14853,22 @@ function usePrompt(idOrSlug) {
|
|
|
14849
14853
|
db.run("INSERT INTO usage_log (id, prompt_id) VALUES (?, ?)", [generateId("UL"), prompt.id]);
|
|
14850
14854
|
return requirePrompt(prompt.id);
|
|
14851
14855
|
}
|
|
14852
|
-
function getTrending(days = 7, limit = 10) {
|
|
14856
|
+
function getTrending(days = 7, limit = 10, projectId) {
|
|
14853
14857
|
const db = getDatabase();
|
|
14854
14858
|
const cutoff = new Date(Date.now() - days * 24 * 60 * 60 * 1000).toISOString();
|
|
14855
|
-
|
|
14859
|
+
const projectFilter = projectId ? "AND (p.project_id = ? OR p.project_id IS NULL)" : "";
|
|
14860
|
+
const rows = db.query(`SELECT p.id, p.slug, p.title, COUNT(ul.id) as uses
|
|
14856
14861
|
FROM usage_log ul
|
|
14857
14862
|
JOIN prompts p ON p.id = ul.prompt_id
|
|
14858
14863
|
WHERE ul.used_at >= ?
|
|
14864
|
+
${projectFilter}
|
|
14859
14865
|
GROUP BY p.id
|
|
14860
14866
|
ORDER BY uses DESC
|
|
14861
|
-
LIMIT ?`)
|
|
14867
|
+
LIMIT ?`);
|
|
14868
|
+
if (projectId) {
|
|
14869
|
+
return rows.all(cutoff, projectId, limit);
|
|
14870
|
+
}
|
|
14871
|
+
return rows.all(cutoff, limit);
|
|
14862
14872
|
}
|
|
14863
14873
|
function setExpiry(idOrSlug, expiresAt) {
|
|
14864
14874
|
const db = getDatabase();
|
package/dist/server/index.js
CHANGED
|
@@ -10085,6 +10085,7 @@ function listPrompts(filter = {}) {
|
|
|
10085
10085
|
const db = getDatabase();
|
|
10086
10086
|
const conditions = [];
|
|
10087
10087
|
const params = [];
|
|
10088
|
+
const orderParams = [];
|
|
10088
10089
|
if (filter.collection) {
|
|
10089
10090
|
conditions.push("collection = ?");
|
|
10090
10091
|
params.push(filter.collection);
|
|
@@ -10108,18 +10109,20 @@ function listPrompts(filter = {}) {
|
|
|
10108
10109
|
if (filter.project_id !== undefined && filter.project_id !== null) {
|
|
10109
10110
|
conditions.push("(project_id = ? OR project_id IS NULL)");
|
|
10110
10111
|
params.push(filter.project_id);
|
|
10111
|
-
orderBy =
|
|
10112
|
+
orderBy = "(CASE WHEN project_id = ? THEN 0 ELSE 1 END), pinned DESC, use_count DESC, updated_at DESC";
|
|
10113
|
+
orderParams.push(filter.project_id);
|
|
10112
10114
|
}
|
|
10113
10115
|
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
10114
10116
|
const limit = filter.limit ?? 20;
|
|
10115
10117
|
const offset = filter.offset ?? 0;
|
|
10116
|
-
const rows = db.query(`SELECT * FROM prompts ${where} ORDER BY ${orderBy} LIMIT ? OFFSET ?`).all(...params, limit, offset);
|
|
10118
|
+
const rows = db.query(`SELECT * FROM prompts ${where} ORDER BY ${orderBy} LIMIT ? OFFSET ?`).all(...params, ...orderParams, limit, offset);
|
|
10117
10119
|
return rows.map(rowToPrompt);
|
|
10118
10120
|
}
|
|
10119
10121
|
function listPromptsSlim(filter = {}) {
|
|
10120
10122
|
const db = getDatabase();
|
|
10121
10123
|
const conditions = [];
|
|
10122
10124
|
const params = [];
|
|
10125
|
+
const orderParams = [];
|
|
10123
10126
|
if (filter.collection) {
|
|
10124
10127
|
conditions.push("collection = ?");
|
|
10125
10128
|
params.push(filter.collection);
|
|
@@ -10142,12 +10145,13 @@ function listPromptsSlim(filter = {}) {
|
|
|
10142
10145
|
if (filter.project_id) {
|
|
10143
10146
|
conditions.push("(project_id = ? OR project_id IS NULL)");
|
|
10144
10147
|
params.push(filter.project_id);
|
|
10145
|
-
orderBy =
|
|
10148
|
+
orderBy = "(CASE WHEN project_id = ? THEN 0 ELSE 1 END), pinned DESC, use_count DESC, updated_at DESC";
|
|
10149
|
+
orderParams.push(filter.project_id);
|
|
10146
10150
|
}
|
|
10147
10151
|
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
10148
10152
|
const limit = filter.limit ?? 20;
|
|
10149
10153
|
const offset = filter.offset ?? 0;
|
|
10150
|
-
const rows = db.query(`SELECT id, slug, name, title, description, collection, tags, variables, is_template, source, pinned, next_prompt, expires_at, project_id, use_count, last_used_at, created_at, updated_at FROM prompts ${where} ORDER BY ${orderBy} LIMIT ? OFFSET ?`).all(...params, limit, offset);
|
|
10154
|
+
const rows = db.query(`SELECT id, slug, name, title, description, collection, tags, variables, is_template, source, pinned, next_prompt, expires_at, project_id, use_count, last_used_at, created_at, updated_at FROM prompts ${where} ORDER BY ${orderBy} LIMIT ? OFFSET ?`).all(...params, ...orderParams, limit, offset);
|
|
10151
10155
|
return rows.map(rowToSlimPrompt);
|
|
10152
10156
|
}
|
|
10153
10157
|
function updatePrompt(idOrSlug, input) {
|