@hasna/prompts 0.3.16 → 0.3.17
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/qol.d.ts.map +1 -1
- package/dist/cli/index.js +0 -58
- package/package.json +1 -1
|
@@ -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;
|
|
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,CAwX1D"}
|
package/dist/cli/index.js
CHANGED
|
@@ -13577,7 +13577,6 @@ function registerVersionCommands(program2) {
|
|
|
13577
13577
|
// src/cli/commands/qol.ts
|
|
13578
13578
|
init_prompts();
|
|
13579
13579
|
init_collections();
|
|
13580
|
-
init_search();
|
|
13581
13580
|
init_template();
|
|
13582
13581
|
import chalk4 from "chalk";
|
|
13583
13582
|
function registerQolCommands(program2) {
|
|
@@ -13594,63 +13593,6 @@ function registerQolCommands(program2) {
|
|
|
13594
13593
|
handleError(program2, e);
|
|
13595
13594
|
}
|
|
13596
13595
|
});
|
|
13597
|
-
program2.command("render <id>").description("Render a template prompt with variable substitution").option("--var <kv>", "Variable as key=value (repeatable)", (val, acc) => {
|
|
13598
|
-
acc.push(val);
|
|
13599
|
-
return acc;
|
|
13600
|
-
}, []).option("--vars <json>", "Variables as JSON object").action((id, opts) => {
|
|
13601
|
-
try {
|
|
13602
|
-
const prompt = getPrompt(id);
|
|
13603
|
-
if (!prompt)
|
|
13604
|
-
handleError(program2, `Prompt not found: ${id}`);
|
|
13605
|
-
const vars = {};
|
|
13606
|
-
if (opts.vars) {
|
|
13607
|
-
Object.assign(vars, JSON.parse(opts.vars));
|
|
13608
|
-
}
|
|
13609
|
-
for (const kv of opts.var) {
|
|
13610
|
-
const eq = kv.indexOf("=");
|
|
13611
|
-
if (eq === -1)
|
|
13612
|
-
handleError(program2, `Invalid --var format (expected key=value): ${kv}`);
|
|
13613
|
-
vars[kv.slice(0, eq)] = kv.slice(eq + 1);
|
|
13614
|
-
}
|
|
13615
|
-
const { rendered, missing_vars, used_defaults } = renderTemplate(prompt.body, vars);
|
|
13616
|
-
if (isJson(program2)) {
|
|
13617
|
-
output(program2, { rendered, missing_vars, used_defaults });
|
|
13618
|
-
return;
|
|
13619
|
-
}
|
|
13620
|
-
if (missing_vars.length > 0) {
|
|
13621
|
-
console.error(chalk4.yellow(`Warning: unresolved variables: ${missing_vars.join(", ")}`));
|
|
13622
|
-
}
|
|
13623
|
-
if (used_defaults.length > 0 && !isJson(program2)) {
|
|
13624
|
-
console.error(chalk4.gray(`Using defaults for: ${used_defaults.join(", ")}`));
|
|
13625
|
-
}
|
|
13626
|
-
process.stdout.write(rendered);
|
|
13627
|
-
} catch (e) {
|
|
13628
|
-
handleError(program2, e);
|
|
13629
|
-
}
|
|
13630
|
-
});
|
|
13631
|
-
program2.command("similar <id>").description("Find prompts similar to the given one (by tags and collection)").option("-n, --limit <n>", "Max results", "5").action((id, opts) => {
|
|
13632
|
-
try {
|
|
13633
|
-
const prompt = getPrompt(id);
|
|
13634
|
-
if (!prompt)
|
|
13635
|
-
handleError(program2, `Prompt not found: ${id}`);
|
|
13636
|
-
const limit = parseInt(opts.limit ?? "5") || 5;
|
|
13637
|
-
const results = findSimilar(prompt.id, limit);
|
|
13638
|
-
if (isJson(program2)) {
|
|
13639
|
-
output(program2, results.map((r) => r.prompt));
|
|
13640
|
-
return;
|
|
13641
|
-
}
|
|
13642
|
-
if (results.length === 0) {
|
|
13643
|
-
console.log(chalk4.gray("No similar prompts found."));
|
|
13644
|
-
return;
|
|
13645
|
-
}
|
|
13646
|
-
console.log(chalk4.bold(`Similar to ${chalk4.green(prompt.slug)}:`));
|
|
13647
|
-
for (const r of results) {
|
|
13648
|
-
console.log(` ${fmtPrompt(r.prompt)} ${chalk4.gray(`score:${r.score}`)}`);
|
|
13649
|
-
}
|
|
13650
|
-
} catch (e) {
|
|
13651
|
-
handleError(program2, e);
|
|
13652
|
-
}
|
|
13653
|
-
});
|
|
13654
13596
|
program2.command("edit <id>").description("Open a prompt in $EDITOR for full editing (title, body, description, tags, collection)").option("--agent <name>", "Attribution").action(async (id, opts) => {
|
|
13655
13597
|
try {
|
|
13656
13598
|
const prompt = getPrompt(id);
|