@hasna/prompts 0.3.12 → 0.3.14
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/versions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAOnC,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAmE9D"}
|
package/dist/cli/index.js
CHANGED
|
@@ -11770,35 +11770,6 @@ var init_ids = __esm(() => {
|
|
|
11770
11770
|
init_database();
|
|
11771
11771
|
});
|
|
11772
11772
|
|
|
11773
|
-
// src/types/index.ts
|
|
11774
|
-
var PromptNotFoundError, VersionConflictError, DuplicateSlugError, ProjectNotFoundError;
|
|
11775
|
-
var init_types2 = __esm(() => {
|
|
11776
|
-
PromptNotFoundError = class PromptNotFoundError extends Error {
|
|
11777
|
-
constructor(id) {
|
|
11778
|
-
super(`Prompt not found: ${id}`);
|
|
11779
|
-
this.name = "PromptNotFoundError";
|
|
11780
|
-
}
|
|
11781
|
-
};
|
|
11782
|
-
VersionConflictError = class VersionConflictError extends Error {
|
|
11783
|
-
constructor(id) {
|
|
11784
|
-
super(`Version conflict on prompt: ${id}`);
|
|
11785
|
-
this.name = "VersionConflictError";
|
|
11786
|
-
}
|
|
11787
|
-
};
|
|
11788
|
-
DuplicateSlugError = class DuplicateSlugError extends Error {
|
|
11789
|
-
constructor(slug) {
|
|
11790
|
-
super(`A prompt with slug "${slug}" already exists`);
|
|
11791
|
-
this.name = "DuplicateSlugError";
|
|
11792
|
-
}
|
|
11793
|
-
};
|
|
11794
|
-
ProjectNotFoundError = class ProjectNotFoundError extends Error {
|
|
11795
|
-
constructor(id) {
|
|
11796
|
-
super(`Project not found: ${id}`);
|
|
11797
|
-
this.name = "ProjectNotFoundError";
|
|
11798
|
-
}
|
|
11799
|
-
};
|
|
11800
|
-
});
|
|
11801
|
-
|
|
11802
11773
|
// src/db/collections.ts
|
|
11803
11774
|
function rowToCollection(row) {
|
|
11804
11775
|
return {
|
|
@@ -11858,6 +11829,35 @@ var init_collections = __esm(() => {
|
|
|
11858
11829
|
init_ids();
|
|
11859
11830
|
});
|
|
11860
11831
|
|
|
11832
|
+
// src/types/index.ts
|
|
11833
|
+
var PromptNotFoundError, VersionConflictError, DuplicateSlugError, ProjectNotFoundError;
|
|
11834
|
+
var init_types2 = __esm(() => {
|
|
11835
|
+
PromptNotFoundError = class PromptNotFoundError extends Error {
|
|
11836
|
+
constructor(id) {
|
|
11837
|
+
super(`Prompt not found: ${id}`);
|
|
11838
|
+
this.name = "PromptNotFoundError";
|
|
11839
|
+
}
|
|
11840
|
+
};
|
|
11841
|
+
VersionConflictError = class VersionConflictError extends Error {
|
|
11842
|
+
constructor(id) {
|
|
11843
|
+
super(`Version conflict on prompt: ${id}`);
|
|
11844
|
+
this.name = "VersionConflictError";
|
|
11845
|
+
}
|
|
11846
|
+
};
|
|
11847
|
+
DuplicateSlugError = class DuplicateSlugError extends Error {
|
|
11848
|
+
constructor(slug) {
|
|
11849
|
+
super(`A prompt with slug "${slug}" already exists`);
|
|
11850
|
+
this.name = "DuplicateSlugError";
|
|
11851
|
+
}
|
|
11852
|
+
};
|
|
11853
|
+
ProjectNotFoundError = class ProjectNotFoundError extends Error {
|
|
11854
|
+
constructor(id) {
|
|
11855
|
+
super(`Project not found: ${id}`);
|
|
11856
|
+
this.name = "ProjectNotFoundError";
|
|
11857
|
+
}
|
|
11858
|
+
};
|
|
11859
|
+
});
|
|
11860
|
+
|
|
11861
11861
|
// src/lib/duplicates.ts
|
|
11862
11862
|
function tokenize(text) {
|
|
11863
11863
|
return new Set(text.toLowerCase().replace(/[^a-z0-9\s]/g, " ").split(/\s+/).filter((w) => w.length > 2));
|
|
@@ -12337,54 +12337,10 @@ var {
|
|
|
12337
12337
|
Help
|
|
12338
12338
|
} = import__.default;
|
|
12339
12339
|
|
|
12340
|
-
// src/cli/index.tsx
|
|
12341
|
-
import chalk3 from "chalk";
|
|
12342
|
-
import { createRequire as createRequire2 } from "module";
|
|
12343
|
-
|
|
12344
|
-
// src/db/versions.ts
|
|
12345
|
-
init_database();
|
|
12346
|
-
init_ids();
|
|
12347
|
-
init_types2();
|
|
12348
|
-
function rowToVersion(row) {
|
|
12349
|
-
return {
|
|
12350
|
-
id: row["id"],
|
|
12351
|
-
prompt_id: row["prompt_id"],
|
|
12352
|
-
body: row["body"],
|
|
12353
|
-
version: row["version"],
|
|
12354
|
-
changed_by: row["changed_by"] ?? null,
|
|
12355
|
-
created_at: row["created_at"]
|
|
12356
|
-
};
|
|
12357
|
-
}
|
|
12358
|
-
function listVersions(promptId) {
|
|
12359
|
-
const db = getDatabase();
|
|
12360
|
-
const rows = db.query("SELECT * FROM prompt_versions WHERE prompt_id = ? ORDER BY version DESC").all(promptId);
|
|
12361
|
-
return rows.map(rowToVersion);
|
|
12362
|
-
}
|
|
12363
|
-
function getVersion(promptId, version) {
|
|
12364
|
-
const db = getDatabase();
|
|
12365
|
-
const row = db.query("SELECT * FROM prompt_versions WHERE prompt_id = ? AND version = ?").get(promptId, version);
|
|
12366
|
-
if (!row)
|
|
12367
|
-
return null;
|
|
12368
|
-
return rowToVersion(row);
|
|
12369
|
-
}
|
|
12370
|
-
function restoreVersion(promptId, version, changedBy) {
|
|
12371
|
-
const db = getDatabase();
|
|
12372
|
-
const ver = getVersion(promptId, version);
|
|
12373
|
-
if (!ver)
|
|
12374
|
-
throw new PromptNotFoundError(`${promptId}@v${version}`);
|
|
12375
|
-
const current = db.query("SELECT version FROM prompts WHERE id = ?").get(promptId);
|
|
12376
|
-
if (!current)
|
|
12377
|
-
throw new PromptNotFoundError(promptId);
|
|
12378
|
-
const newVersion = current.version + 1;
|
|
12379
|
-
db.run(`UPDATE prompts SET body = ?, version = ?, updated_at = datetime('now'),
|
|
12380
|
-
is_template = (CASE WHEN body LIKE '%{{%' THEN 1 ELSE 0 END)
|
|
12381
|
-
WHERE id = ?`, [ver.body, newVersion, promptId]);
|
|
12382
|
-
db.run(`INSERT INTO prompt_versions (id, prompt_id, body, version, changed_by)
|
|
12383
|
-
VALUES (?, ?, ?, ?, ?)`, [generateId("VER"), promptId, ver.body, newVersion, changedBy ?? null]);
|
|
12384
|
-
}
|
|
12385
|
-
|
|
12386
12340
|
// src/cli/index.tsx
|
|
12387
12341
|
init_collections();
|
|
12342
|
+
import chalk4 from "chalk";
|
|
12343
|
+
import { createRequire as createRequire2 } from "module";
|
|
12388
12344
|
|
|
12389
12345
|
// src/db/projects.ts
|
|
12390
12346
|
init_database();
|
|
@@ -12817,38 +12773,6 @@ complete -F _prompts_completions prompts
|
|
|
12817
12773
|
`;
|
|
12818
12774
|
}
|
|
12819
12775
|
|
|
12820
|
-
// src/lib/diff.ts
|
|
12821
|
-
function diffTexts(a, b) {
|
|
12822
|
-
const aLines = a.split(`
|
|
12823
|
-
`);
|
|
12824
|
-
const bLines = b.split(`
|
|
12825
|
-
`);
|
|
12826
|
-
const m = aLines.length;
|
|
12827
|
-
const n = bLines.length;
|
|
12828
|
-
const lcs = Array.from({ length: m + 1 }, () => new Array(n + 1).fill(0));
|
|
12829
|
-
for (let i2 = 1;i2 <= m; i2++) {
|
|
12830
|
-
for (let j2 = 1;j2 <= n; j2++) {
|
|
12831
|
-
lcs[i2][j2] = aLines[i2 - 1] === bLines[j2 - 1] ? (lcs[i2 - 1][j2 - 1] ?? 0) + 1 : Math.max(lcs[i2 - 1][j2] ?? 0, lcs[i2][j2 - 1] ?? 0);
|
|
12832
|
-
}
|
|
12833
|
-
}
|
|
12834
|
-
const trace = [];
|
|
12835
|
-
let i = m, j = n;
|
|
12836
|
-
while (i > 0 || j > 0) {
|
|
12837
|
-
if (i > 0 && j > 0 && aLines[i - 1] === bLines[j - 1]) {
|
|
12838
|
-
trace.unshift({ type: "unchanged", content: aLines[i - 1] ?? "" });
|
|
12839
|
-
i--;
|
|
12840
|
-
j--;
|
|
12841
|
-
} else if (j > 0 && (i === 0 || (lcs[i][j - 1] ?? 0) >= (lcs[i - 1][j] ?? 0))) {
|
|
12842
|
-
trace.unshift({ type: "added", content: bLines[j - 1] ?? "" });
|
|
12843
|
-
j--;
|
|
12844
|
-
} else {
|
|
12845
|
-
trace.unshift({ type: "removed", content: aLines[i - 1] ?? "" });
|
|
12846
|
-
i--;
|
|
12847
|
-
}
|
|
12848
|
-
}
|
|
12849
|
-
return trace;
|
|
12850
|
-
}
|
|
12851
|
-
|
|
12852
12776
|
// src/lib/lint.ts
|
|
12853
12777
|
function lintPrompt(p) {
|
|
12854
12778
|
const issues = [];
|
|
@@ -13319,45 +13243,159 @@ Warning: missing vars: ${result.missing_vars.join(", ")}`));
|
|
|
13319
13243
|
});
|
|
13320
13244
|
}
|
|
13321
13245
|
|
|
13246
|
+
// src/cli/commands/versions.ts
|
|
13247
|
+
init_prompts();
|
|
13248
|
+
import chalk3 from "chalk";
|
|
13249
|
+
|
|
13250
|
+
// src/db/versions.ts
|
|
13251
|
+
init_database();
|
|
13252
|
+
init_ids();
|
|
13253
|
+
init_types2();
|
|
13254
|
+
function rowToVersion(row) {
|
|
13255
|
+
return {
|
|
13256
|
+
id: row["id"],
|
|
13257
|
+
prompt_id: row["prompt_id"],
|
|
13258
|
+
body: row["body"],
|
|
13259
|
+
version: row["version"],
|
|
13260
|
+
changed_by: row["changed_by"] ?? null,
|
|
13261
|
+
created_at: row["created_at"]
|
|
13262
|
+
};
|
|
13263
|
+
}
|
|
13264
|
+
function listVersions(promptId) {
|
|
13265
|
+
const db = getDatabase();
|
|
13266
|
+
const rows = db.query("SELECT * FROM prompt_versions WHERE prompt_id = ? ORDER BY version DESC").all(promptId);
|
|
13267
|
+
return rows.map(rowToVersion);
|
|
13268
|
+
}
|
|
13269
|
+
function getVersion(promptId, version) {
|
|
13270
|
+
const db = getDatabase();
|
|
13271
|
+
const row = db.query("SELECT * FROM prompt_versions WHERE prompt_id = ? AND version = ?").get(promptId, version);
|
|
13272
|
+
if (!row)
|
|
13273
|
+
return null;
|
|
13274
|
+
return rowToVersion(row);
|
|
13275
|
+
}
|
|
13276
|
+
function restoreVersion(promptId, version, changedBy) {
|
|
13277
|
+
const db = getDatabase();
|
|
13278
|
+
const ver = getVersion(promptId, version);
|
|
13279
|
+
if (!ver)
|
|
13280
|
+
throw new PromptNotFoundError(`${promptId}@v${version}`);
|
|
13281
|
+
const current = db.query("SELECT version FROM prompts WHERE id = ?").get(promptId);
|
|
13282
|
+
if (!current)
|
|
13283
|
+
throw new PromptNotFoundError(promptId);
|
|
13284
|
+
const newVersion = current.version + 1;
|
|
13285
|
+
db.run(`UPDATE prompts SET body = ?, version = ?, updated_at = datetime('now'),
|
|
13286
|
+
is_template = (CASE WHEN body LIKE '%{{%' THEN 1 ELSE 0 END)
|
|
13287
|
+
WHERE id = ?`, [ver.body, newVersion, promptId]);
|
|
13288
|
+
db.run(`INSERT INTO prompt_versions (id, prompt_id, body, version, changed_by)
|
|
13289
|
+
VALUES (?, ?, ?, ?, ?)`, [generateId("VER"), promptId, ver.body, newVersion, changedBy ?? null]);
|
|
13290
|
+
}
|
|
13291
|
+
|
|
13292
|
+
// src/lib/diff.ts
|
|
13293
|
+
function diffTexts(a, b) {
|
|
13294
|
+
const aLines = a.split(`
|
|
13295
|
+
`);
|
|
13296
|
+
const bLines = b.split(`
|
|
13297
|
+
`);
|
|
13298
|
+
const m = aLines.length;
|
|
13299
|
+
const n = bLines.length;
|
|
13300
|
+
const lcs = Array.from({ length: m + 1 }, () => new Array(n + 1).fill(0));
|
|
13301
|
+
for (let i2 = 1;i2 <= m; i2++) {
|
|
13302
|
+
for (let j2 = 1;j2 <= n; j2++) {
|
|
13303
|
+
lcs[i2][j2] = aLines[i2 - 1] === bLines[j2 - 1] ? (lcs[i2 - 1][j2 - 1] ?? 0) + 1 : Math.max(lcs[i2 - 1][j2] ?? 0, lcs[i2][j2 - 1] ?? 0);
|
|
13304
|
+
}
|
|
13305
|
+
}
|
|
13306
|
+
const trace = [];
|
|
13307
|
+
let i = m, j = n;
|
|
13308
|
+
while (i > 0 || j > 0) {
|
|
13309
|
+
if (i > 0 && j > 0 && aLines[i - 1] === bLines[j - 1]) {
|
|
13310
|
+
trace.unshift({ type: "unchanged", content: aLines[i - 1] ?? "" });
|
|
13311
|
+
i--;
|
|
13312
|
+
j--;
|
|
13313
|
+
} else if (j > 0 && (i === 0 || (lcs[i][j - 1] ?? 0) >= (lcs[i - 1][j] ?? 0))) {
|
|
13314
|
+
trace.unshift({ type: "added", content: bLines[j - 1] ?? "" });
|
|
13315
|
+
j--;
|
|
13316
|
+
} else {
|
|
13317
|
+
trace.unshift({ type: "removed", content: aLines[i - 1] ?? "" });
|
|
13318
|
+
i--;
|
|
13319
|
+
}
|
|
13320
|
+
}
|
|
13321
|
+
return trace;
|
|
13322
|
+
}
|
|
13323
|
+
|
|
13324
|
+
// src/cli/commands/versions.ts
|
|
13325
|
+
function registerVersionCommands(program2) {
|
|
13326
|
+
program2.command("history <id>").description("Show version history for a prompt").action((id) => {
|
|
13327
|
+
try {
|
|
13328
|
+
const prompt = getPrompt(id);
|
|
13329
|
+
if (!prompt)
|
|
13330
|
+
handleError(program2, `Prompt not found: ${id}`);
|
|
13331
|
+
const versions = listVersions(prompt.id);
|
|
13332
|
+
if (isJson(program2)) {
|
|
13333
|
+
output(program2, versions);
|
|
13334
|
+
} else {
|
|
13335
|
+
console.log(chalk3.bold(`Version history for ${prompt.slug}:`));
|
|
13336
|
+
for (const v of versions) {
|
|
13337
|
+
const current = v.version === prompt.version ? chalk3.green(" \u2190 current") : "";
|
|
13338
|
+
const by = v.changed_by ? chalk3.gray(` by ${v.changed_by}`) : "";
|
|
13339
|
+
console.log(` v${v.version} ${chalk3.gray(v.created_at)}${by}${current}`);
|
|
13340
|
+
}
|
|
13341
|
+
}
|
|
13342
|
+
} catch (e) {
|
|
13343
|
+
handleError(program2, e);
|
|
13344
|
+
}
|
|
13345
|
+
});
|
|
13346
|
+
program2.command("restore <id> <version>").description("Restore a prompt to a previous version").option("--agent <name>").action((id, version, opts) => {
|
|
13347
|
+
try {
|
|
13348
|
+
const prompt = getPrompt(id);
|
|
13349
|
+
if (!prompt)
|
|
13350
|
+
handleError(program2, `Prompt not found: ${id}`);
|
|
13351
|
+
restoreVersion(prompt.id, parseInt(version), opts["agent"]);
|
|
13352
|
+
if (isJson(program2))
|
|
13353
|
+
output(program2, { restored: true, id: prompt.id, version: parseInt(version) });
|
|
13354
|
+
else
|
|
13355
|
+
console.log(chalk3.green(`Restored ${prompt.slug} to v${version}`));
|
|
13356
|
+
} catch (e) {
|
|
13357
|
+
handleError(program2, e);
|
|
13358
|
+
}
|
|
13359
|
+
});
|
|
13360
|
+
program2.command("diff <id> <v1> [v2]").description("Show diff between two versions of a prompt (v2 defaults to current)").action((id, v1, v2) => {
|
|
13361
|
+
try {
|
|
13362
|
+
const prompt = getPrompt(id);
|
|
13363
|
+
if (!prompt)
|
|
13364
|
+
handleError(program2, `Prompt not found: ${id}`);
|
|
13365
|
+
const versions = listVersions(prompt.id);
|
|
13366
|
+
const versionA = versions.find((v) => v.version === parseInt(v1));
|
|
13367
|
+
if (!versionA)
|
|
13368
|
+
handleError(program2, `Version ${v1} not found`);
|
|
13369
|
+
const bodyB = v2 ? versions.find((v) => v.version === parseInt(v2))?.body ?? null : prompt.body;
|
|
13370
|
+
if (bodyB === null)
|
|
13371
|
+
handleError(program2, `Version ${v2} not found`);
|
|
13372
|
+
const lines = diffTexts(versionA.body, bodyB);
|
|
13373
|
+
if (isJson(program2)) {
|
|
13374
|
+
output(program2, lines);
|
|
13375
|
+
return;
|
|
13376
|
+
}
|
|
13377
|
+
const label2 = v2 ? `v${v2}` : "current";
|
|
13378
|
+
console.log(chalk3.bold(`${prompt.slug}: v${v1} \u2192 ${label2}`));
|
|
13379
|
+
for (const l of lines) {
|
|
13380
|
+
if (l.type === "added")
|
|
13381
|
+
console.log(chalk3.green(`+ ${l.content}`));
|
|
13382
|
+
else if (l.type === "removed")
|
|
13383
|
+
console.log(chalk3.red(`- ${l.content}`));
|
|
13384
|
+
else
|
|
13385
|
+
console.log(chalk3.gray(` ${l.content}`));
|
|
13386
|
+
}
|
|
13387
|
+
} catch (e) {
|
|
13388
|
+
handleError(program2, e);
|
|
13389
|
+
}
|
|
13390
|
+
});
|
|
13391
|
+
}
|
|
13392
|
+
|
|
13322
13393
|
// src/cli/index.tsx
|
|
13323
13394
|
var require2 = createRequire2(import.meta.url);
|
|
13324
13395
|
var pkg = require2("../../package.json");
|
|
13325
13396
|
var program2 = new Command().name("prompts").version(pkg.version).description("Reusable prompt library \u2014 save, search, render prompts from any AI session").option("--json", "Output as JSON").option("--project <name>", "Active project (name, slug, or ID) for scoped operations");
|
|
13326
13397
|
registerPromptCommands(program2);
|
|
13327
|
-
program2
|
|
13328
|
-
try {
|
|
13329
|
-
const prompt = getPrompt(id);
|
|
13330
|
-
if (!prompt)
|
|
13331
|
-
handleError(program2, `Prompt not found: ${id}`);
|
|
13332
|
-
const versions = listVersions(prompt.id);
|
|
13333
|
-
if (isJson(program2)) {
|
|
13334
|
-
output(program2, versions);
|
|
13335
|
-
} else {
|
|
13336
|
-
console.log(chalk3.bold(`Version history for ${prompt.slug}:`));
|
|
13337
|
-
for (const v of versions) {
|
|
13338
|
-
const current = v.version === prompt.version ? chalk3.green(" \u2190 current") : "";
|
|
13339
|
-
const by = v.changed_by ? chalk3.gray(` by ${v.changed_by}`) : "";
|
|
13340
|
-
console.log(` v${v.version} ${chalk3.gray(v.created_at)}${by}${current}`);
|
|
13341
|
-
}
|
|
13342
|
-
}
|
|
13343
|
-
} catch (e) {
|
|
13344
|
-
handleError(program2, e);
|
|
13345
|
-
}
|
|
13346
|
-
});
|
|
13347
|
-
program2.command("restore <id> <version>").description("Restore a prompt to a previous version").option("--agent <name>").action((id, version, opts) => {
|
|
13348
|
-
try {
|
|
13349
|
-
const prompt = getPrompt(id);
|
|
13350
|
-
if (!prompt)
|
|
13351
|
-
handleError(program2, `Prompt not found: ${id}`);
|
|
13352
|
-
restoreVersion(prompt.id, parseInt(version), opts["agent"]);
|
|
13353
|
-
if (isJson(program2))
|
|
13354
|
-
output(program2, { restored: true, id: prompt.id, version: parseInt(version) });
|
|
13355
|
-
else
|
|
13356
|
-
console.log(chalk3.green(`Restored ${prompt.slug} to v${version}`));
|
|
13357
|
-
} catch (e) {
|
|
13358
|
-
handleError(program2, e);
|
|
13359
|
-
}
|
|
13360
|
-
});
|
|
13398
|
+
registerVersionCommands(program2);
|
|
13361
13399
|
program2.command("collections").description("List all collections").action(() => {
|
|
13362
13400
|
try {
|
|
13363
13401
|
const cols = listCollections();
|
|
@@ -13365,9 +13403,9 @@ program2.command("collections").description("List all collections").action(() =>
|
|
|
13365
13403
|
output(program2, cols);
|
|
13366
13404
|
} else {
|
|
13367
13405
|
for (const c of cols) {
|
|
13368
|
-
console.log(`${
|
|
13406
|
+
console.log(`${chalk4.bold(c.name)} ${chalk4.gray(`${c.prompt_count} prompt(s)`)}`);
|
|
13369
13407
|
if (c.description)
|
|
13370
|
-
console.log(
|
|
13408
|
+
console.log(chalk4.gray(" " + c.description));
|
|
13371
13409
|
}
|
|
13372
13410
|
}
|
|
13373
13411
|
} catch (e) {
|
|
@@ -13380,7 +13418,7 @@ program2.command("move <id> <collection>").description("Move a prompt to a diffe
|
|
|
13380
13418
|
if (isJson(program2))
|
|
13381
13419
|
output(program2, { moved: true, id, collection });
|
|
13382
13420
|
else
|
|
13383
|
-
console.log(`${
|
|
13421
|
+
console.log(`${chalk4.green("Moved")} ${id} \u2192 ${chalk4.bold(collection)}`);
|
|
13384
13422
|
} catch (e) {
|
|
13385
13423
|
handleError(program2, e);
|
|
13386
13424
|
}
|
|
@@ -13392,7 +13430,7 @@ program2.command("export").description("Export prompts as JSON").option("-c, --c
|
|
|
13392
13430
|
if (opts["output"]) {
|
|
13393
13431
|
const { writeFileSync: writeFileSync2 } = await import("fs");
|
|
13394
13432
|
writeFileSync2(opts["output"], json);
|
|
13395
|
-
console.log(
|
|
13433
|
+
console.log(chalk4.green(`Exported ${data.prompts.length} prompt(s) to ${opts["output"]}`));
|
|
13396
13434
|
} else {
|
|
13397
13435
|
console.log(json);
|
|
13398
13436
|
}
|
|
@@ -13409,11 +13447,11 @@ program2.command("import <file>").description("Import prompts from a JSON file")
|
|
|
13409
13447
|
if (isJson(program2))
|
|
13410
13448
|
output(program2, results);
|
|
13411
13449
|
else {
|
|
13412
|
-
console.log(
|
|
13450
|
+
console.log(chalk4.green(`Created: ${results.created}, Updated: ${results.updated}`));
|
|
13413
13451
|
if (results.errors.length > 0) {
|
|
13414
|
-
console.error(
|
|
13452
|
+
console.error(chalk4.red(`Errors: ${results.errors.length}`));
|
|
13415
13453
|
for (const e of results.errors)
|
|
13416
|
-
console.error(
|
|
13454
|
+
console.error(chalk4.red(` ${e.item}: ${e.error}`));
|
|
13417
13455
|
}
|
|
13418
13456
|
}
|
|
13419
13457
|
} catch (e) {
|
|
@@ -13426,19 +13464,19 @@ program2.command("stats").description("Show usage statistics").action(() => {
|
|
|
13426
13464
|
if (isJson(program2)) {
|
|
13427
13465
|
output(program2, stats);
|
|
13428
13466
|
} else {
|
|
13429
|
-
console.log(
|
|
13467
|
+
console.log(chalk4.bold("Prompt Stats"));
|
|
13430
13468
|
console.log(` Total: ${stats.total_prompts} Templates: ${stats.total_templates} Collections: ${stats.total_collections}`);
|
|
13431
13469
|
if (stats.most_used.length > 0) {
|
|
13432
|
-
console.log(
|
|
13470
|
+
console.log(chalk4.bold(`
|
|
13433
13471
|
Most used:`));
|
|
13434
13472
|
for (const p of stats.most_used)
|
|
13435
|
-
console.log(` ${
|
|
13473
|
+
console.log(` ${chalk4.green(p.slug)} ${chalk4.gray(`${p.use_count}\xD7`)}`);
|
|
13436
13474
|
}
|
|
13437
13475
|
if (stats.by_collection.length > 0) {
|
|
13438
|
-
console.log(
|
|
13476
|
+
console.log(chalk4.bold(`
|
|
13439
13477
|
By collection:`));
|
|
13440
13478
|
for (const c of stats.by_collection)
|
|
13441
|
-
console.log(` ${
|
|
13479
|
+
console.log(` ${chalk4.bold(c.collection)} ${chalk4.gray(`${c.count}`)}`);
|
|
13442
13480
|
}
|
|
13443
13481
|
}
|
|
13444
13482
|
} catch (e) {
|
|
@@ -13454,12 +13492,12 @@ program2.command("recent [n]").description("Show recently used prompts (default:
|
|
|
13454
13492
|
return;
|
|
13455
13493
|
}
|
|
13456
13494
|
if (prompts.length === 0) {
|
|
13457
|
-
console.log(
|
|
13495
|
+
console.log(chalk4.gray("No recently used prompts."));
|
|
13458
13496
|
return;
|
|
13459
13497
|
}
|
|
13460
13498
|
for (const p of prompts) {
|
|
13461
|
-
const ago =
|
|
13462
|
-
console.log(`${
|
|
13499
|
+
const ago = chalk4.gray(new Date(p.last_used_at).toLocaleString());
|
|
13500
|
+
console.log(`${chalk4.bold(p.id)} ${chalk4.green(p.slug)} ${p.title} ${ago}`);
|
|
13463
13501
|
}
|
|
13464
13502
|
} catch (e) {
|
|
13465
13503
|
handleError(program2, e);
|
|
@@ -13474,27 +13512,27 @@ program2.command("lint").description("Check prompt quality: missing descriptions
|
|
|
13474
13512
|
return;
|
|
13475
13513
|
}
|
|
13476
13514
|
if (results.length === 0) {
|
|
13477
|
-
console.log(
|
|
13515
|
+
console.log(chalk4.green("\u2713 All prompts pass lint."));
|
|
13478
13516
|
return;
|
|
13479
13517
|
}
|
|
13480
13518
|
let errors = 0, warns = 0, infos = 0;
|
|
13481
13519
|
for (const { prompt: p, issues } of results) {
|
|
13482
13520
|
console.log(`
|
|
13483
|
-
${
|
|
13521
|
+
${chalk4.bold(p.slug)} ${chalk4.gray(p.id)}`);
|
|
13484
13522
|
for (const issue of issues) {
|
|
13485
13523
|
if (issue.severity === "error") {
|
|
13486
|
-
console.log(
|
|
13524
|
+
console.log(chalk4.red(` \u2717 [${issue.rule}] ${issue.message}`));
|
|
13487
13525
|
errors++;
|
|
13488
13526
|
} else if (issue.severity === "warn") {
|
|
13489
|
-
console.log(
|
|
13527
|
+
console.log(chalk4.yellow(` \u26A0 [${issue.rule}] ${issue.message}`));
|
|
13490
13528
|
warns++;
|
|
13491
13529
|
} else {
|
|
13492
|
-
console.log(
|
|
13530
|
+
console.log(chalk4.gray(` \u2139 [${issue.rule}] ${issue.message}`));
|
|
13493
13531
|
infos++;
|
|
13494
13532
|
}
|
|
13495
13533
|
}
|
|
13496
13534
|
}
|
|
13497
|
-
console.log(
|
|
13535
|
+
console.log(chalk4.bold(`
|
|
13498
13536
|
${results.length} prompt(s) with issues \u2014 ${errors} errors, ${warns} warnings, ${infos} info`));
|
|
13499
13537
|
if (errors > 0)
|
|
13500
13538
|
process.exit(1);
|
|
@@ -13515,24 +13553,24 @@ program2.command("stale [days]").description("List prompts not used in N days (d
|
|
|
13515
13553
|
return;
|
|
13516
13554
|
}
|
|
13517
13555
|
if (expired.length > 0) {
|
|
13518
|
-
console.log(
|
|
13556
|
+
console.log(chalk4.red(`
|
|
13519
13557
|
Expired (${expired.length}):`));
|
|
13520
13558
|
for (const p of expired)
|
|
13521
|
-
console.log(
|
|
13559
|
+
console.log(chalk4.red(` \u2717 ${p.slug}`) + chalk4.gray(` expired ${new Date(p.expires_at).toLocaleDateString()}`));
|
|
13522
13560
|
}
|
|
13523
13561
|
if (stale.length === 0 && expired.length === 0) {
|
|
13524
|
-
console.log(
|
|
13562
|
+
console.log(chalk4.green(`No stale prompts (threshold: ${threshold} days).`));
|
|
13525
13563
|
return;
|
|
13526
13564
|
}
|
|
13527
13565
|
if (stale.length > 0) {
|
|
13528
|
-
console.log(
|
|
13566
|
+
console.log(chalk4.bold(`
|
|
13529
13567
|
Stale prompts (not used in ${threshold}+ days):`));
|
|
13530
13568
|
for (const p of stale) {
|
|
13531
|
-
const last = p.last_used_at ?
|
|
13532
|
-
console.log(` ${
|
|
13569
|
+
const last = p.last_used_at ? chalk4.gray(new Date(p.last_used_at).toLocaleDateString()) : chalk4.red("never");
|
|
13570
|
+
console.log(` ${chalk4.green(p.slug)} ${chalk4.gray(`${p.use_count}\xD7`)} last used: ${last}`);
|
|
13533
13571
|
}
|
|
13534
13572
|
}
|
|
13535
|
-
console.log(
|
|
13573
|
+
console.log(chalk4.gray(`
|
|
13536
13574
|
${stale.length} stale prompt(s)`));
|
|
13537
13575
|
} catch (e) {
|
|
13538
13576
|
handleError(program2, e);
|
|
@@ -13544,7 +13582,7 @@ program2.command("pin <id>").description("Pin a prompt so it always appears firs
|
|
|
13544
13582
|
if (isJson(program2))
|
|
13545
13583
|
output(program2, p);
|
|
13546
13584
|
else
|
|
13547
|
-
console.log(
|
|
13585
|
+
console.log(chalk4.yellow(`\uD83D\uDCCC Pinned ${chalk4.bold(p.slug)}`));
|
|
13548
13586
|
} catch (e) {
|
|
13549
13587
|
handleError(program2, e);
|
|
13550
13588
|
}
|
|
@@ -13555,7 +13593,7 @@ program2.command("unpin <id>").description("Unpin a prompt").action((id) => {
|
|
|
13555
13593
|
if (isJson(program2))
|
|
13556
13594
|
output(program2, p);
|
|
13557
13595
|
else
|
|
13558
|
-
console.log(
|
|
13596
|
+
console.log(chalk4.gray(`Unpinned ${chalk4.bold(p.slug)}`));
|
|
13559
13597
|
} catch (e) {
|
|
13560
13598
|
handleError(program2, e);
|
|
13561
13599
|
}
|
|
@@ -13587,7 +13625,7 @@ program2.command("copy <id>").description("Copy prompt body to clipboard and inc
|
|
|
13587
13625
|
if (isJson(program2))
|
|
13588
13626
|
output(program2, { copied: true, id: prompt.id, slug: prompt.slug });
|
|
13589
13627
|
else
|
|
13590
|
-
console.log(
|
|
13628
|
+
console.log(chalk4.green(`Copied ${chalk4.bold(prompt.slug)} to clipboard`));
|
|
13591
13629
|
} catch (e) {
|
|
13592
13630
|
handleError(program2, e);
|
|
13593
13631
|
}
|
|
@@ -13599,9 +13637,9 @@ projectCmd.command("create <name>").description("Create a new project").option("
|
|
|
13599
13637
|
if (isJson(program2))
|
|
13600
13638
|
output(program2, project);
|
|
13601
13639
|
else {
|
|
13602
|
-
console.log(`${
|
|
13640
|
+
console.log(`${chalk4.green("Created")} project ${chalk4.bold(project.name)} \u2014 ${chalk4.gray(project.slug)}`);
|
|
13603
13641
|
if (project.description)
|
|
13604
|
-
console.log(
|
|
13642
|
+
console.log(chalk4.gray(` ${project.description}`));
|
|
13605
13643
|
}
|
|
13606
13644
|
} catch (e) {
|
|
13607
13645
|
handleError(program2, e);
|
|
@@ -13615,13 +13653,13 @@ projectCmd.command("list").description("List all projects").action(() => {
|
|
|
13615
13653
|
return;
|
|
13616
13654
|
}
|
|
13617
13655
|
if (projects.length === 0) {
|
|
13618
|
-
console.log(
|
|
13656
|
+
console.log(chalk4.gray("No projects."));
|
|
13619
13657
|
return;
|
|
13620
13658
|
}
|
|
13621
13659
|
for (const p of projects) {
|
|
13622
|
-
console.log(`${
|
|
13660
|
+
console.log(`${chalk4.bold(p.name)} ${chalk4.gray(p.slug)} ${chalk4.cyan(`${p.prompt_count} prompt(s)`)}`);
|
|
13623
13661
|
if (p.description)
|
|
13624
|
-
console.log(
|
|
13662
|
+
console.log(chalk4.gray(` ${p.description}`));
|
|
13625
13663
|
}
|
|
13626
13664
|
} catch (e) {
|
|
13627
13665
|
handleError(program2, e);
|
|
@@ -13632,7 +13670,7 @@ projectCmd.command("get <id>").description("Get project details").action((id) =>
|
|
|
13632
13670
|
const project = getProject(id);
|
|
13633
13671
|
if (!project)
|
|
13634
13672
|
handleError(program2, `Project not found: ${id}`);
|
|
13635
|
-
output(program2, isJson(program2) ? project : `${
|
|
13673
|
+
output(program2, isJson(program2) ? project : `${chalk4.bold(project.name)} ${chalk4.gray(project.slug)} ${chalk4.cyan(`${project.prompt_count} prompt(s)`)}`);
|
|
13636
13674
|
} catch (e) {
|
|
13637
13675
|
handleError(program2, e);
|
|
13638
13676
|
}
|
|
@@ -13648,15 +13686,15 @@ projectCmd.command("prompts <id>").description("List all prompts for a project (
|
|
|
13648
13686
|
return;
|
|
13649
13687
|
}
|
|
13650
13688
|
if (prompts.length === 0) {
|
|
13651
|
-
console.log(
|
|
13689
|
+
console.log(chalk4.gray("No prompts."));
|
|
13652
13690
|
return;
|
|
13653
13691
|
}
|
|
13654
|
-
console.log(
|
|
13692
|
+
console.log(chalk4.bold(`Prompts for project: ${project.name}`));
|
|
13655
13693
|
for (const p of prompts) {
|
|
13656
|
-
const scope = p.project_id ?
|
|
13694
|
+
const scope = p.project_id ? chalk4.cyan(" [project]") : chalk4.gray(" [global]");
|
|
13657
13695
|
console.log(fmtPrompt(p) + scope);
|
|
13658
13696
|
}
|
|
13659
|
-
console.log(
|
|
13697
|
+
console.log(chalk4.gray(`
|
|
13660
13698
|
${prompts.length} prompt(s)`));
|
|
13661
13699
|
} catch (e) {
|
|
13662
13700
|
handleError(program2, e);
|
|
@@ -13671,7 +13709,7 @@ projectCmd.command("delete <id>").description("Delete a project (prompts become
|
|
|
13671
13709
|
const { createInterface } = await import("readline");
|
|
13672
13710
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
13673
13711
|
await new Promise((resolve) => {
|
|
13674
|
-
rl.question(
|
|
13712
|
+
rl.question(chalk4.yellow(`Delete project "${project.name}"? Prompts will become global. [y/N] `), (ans) => {
|
|
13675
13713
|
rl.close();
|
|
13676
13714
|
if (ans.toLowerCase() !== "y") {
|
|
13677
13715
|
console.log("Cancelled.");
|
|
@@ -13685,7 +13723,7 @@ projectCmd.command("delete <id>").description("Delete a project (prompts become
|
|
|
13685
13723
|
if (isJson(program2))
|
|
13686
13724
|
output(program2, { deleted: true, id: project.id });
|
|
13687
13725
|
else
|
|
13688
|
-
console.log(
|
|
13726
|
+
console.log(chalk4.red(`Deleted project ${project.name}`));
|
|
13689
13727
|
} catch (e) {
|
|
13690
13728
|
handleError(program2, e);
|
|
13691
13729
|
}
|
|
@@ -13698,15 +13736,15 @@ program2.command("audit").description("Check for orphaned project refs, empty co
|
|
|
13698
13736
|
return;
|
|
13699
13737
|
}
|
|
13700
13738
|
if (report.issues.length === 0) {
|
|
13701
|
-
console.log(
|
|
13739
|
+
console.log(chalk4.green("\u2713 No audit issues found."));
|
|
13702
13740
|
return;
|
|
13703
13741
|
}
|
|
13704
13742
|
for (const issue of report.issues) {
|
|
13705
|
-
const sym = issue.severity === "error" ?
|
|
13706
|
-
const slug = issue.slug ?
|
|
13743
|
+
const sym = issue.severity === "error" ? chalk4.red("\u2717") : issue.severity === "warn" ? chalk4.yellow("\u26A0") : chalk4.gray("\u2139");
|
|
13744
|
+
const slug = issue.slug ? chalk4.green(` ${issue.slug}`) : "";
|
|
13707
13745
|
console.log(`${sym}${slug} ${issue.message}`);
|
|
13708
13746
|
}
|
|
13709
|
-
console.log(
|
|
13747
|
+
console.log(chalk4.bold(`
|
|
13710
13748
|
${report.issues.length} issue(s) \u2014 ${report.errors} errors, ${report.warnings} warnings, ${report.info} info`));
|
|
13711
13749
|
if (report.errors > 0)
|
|
13712
13750
|
process.exit(1);
|
|
@@ -13723,12 +13761,12 @@ program2.command("unused").description("List prompts that have never been used (
|
|
|
13723
13761
|
return;
|
|
13724
13762
|
}
|
|
13725
13763
|
if (unused.length === 0) {
|
|
13726
|
-
console.log(
|
|
13764
|
+
console.log(chalk4.green("All prompts have been used at least once."));
|
|
13727
13765
|
return;
|
|
13728
13766
|
}
|
|
13729
|
-
console.log(
|
|
13767
|
+
console.log(chalk4.bold(`Unused prompts (${unused.length}):`));
|
|
13730
13768
|
for (const p of unused) {
|
|
13731
|
-
console.log(` ${fmtPrompt(p)} ${
|
|
13769
|
+
console.log(` ${fmtPrompt(p)} ${chalk4.gray(`created ${new Date(p.created_at).toLocaleDateString()}`)}`);
|
|
13732
13770
|
}
|
|
13733
13771
|
} catch (e) {
|
|
13734
13772
|
handleError(program2, e);
|
|
@@ -13742,12 +13780,12 @@ program2.command("trending").description("Most used prompts in the last N days")
|
|
|
13742
13780
|
return;
|
|
13743
13781
|
}
|
|
13744
13782
|
if (results.length === 0) {
|
|
13745
|
-
console.log(
|
|
13783
|
+
console.log(chalk4.gray("No usage data yet."));
|
|
13746
13784
|
return;
|
|
13747
13785
|
}
|
|
13748
|
-
console.log(
|
|
13786
|
+
console.log(chalk4.bold(`Trending (last ${opts["days"] ?? "7"} days):`));
|
|
13749
13787
|
for (const r of results) {
|
|
13750
|
-
console.log(` ${
|
|
13788
|
+
console.log(` ${chalk4.green(r.slug)} ${chalk4.bold(String(r.uses))}\xD7 ${chalk4.gray(r.title)}`);
|
|
13751
13789
|
}
|
|
13752
13790
|
} catch (e) {
|
|
13753
13791
|
handleError(program2, e);
|
|
@@ -13760,7 +13798,7 @@ program2.command("expire <id> [date]").description("Set expiry date for a prompt
|
|
|
13760
13798
|
if (isJson(program2))
|
|
13761
13799
|
output(program2, p);
|
|
13762
13800
|
else
|
|
13763
|
-
console.log(expiresAt ?
|
|
13801
|
+
console.log(expiresAt ? chalk4.yellow(`Expires ${p.slug} on ${new Date(expiresAt).toLocaleDateString()}`) : chalk4.gray(`Cleared expiry for ${p.slug}`));
|
|
13764
13802
|
} catch (e) {
|
|
13765
13803
|
handleError(program2, e);
|
|
13766
13804
|
}
|
|
@@ -13783,38 +13821,7 @@ program2.command("duplicate <id>").description("Clone a prompt with a new slug")
|
|
|
13783
13821
|
if (isJson(program2))
|
|
13784
13822
|
output(program2, prompt);
|
|
13785
13823
|
else
|
|
13786
|
-
console.log(`${
|
|
13787
|
-
} catch (e) {
|
|
13788
|
-
handleError(program2, e);
|
|
13789
|
-
}
|
|
13790
|
-
});
|
|
13791
|
-
program2.command("diff <id> <v1> [v2]").description("Show diff between two versions of a prompt (v2 defaults to current)").action((id, v1, v2) => {
|
|
13792
|
-
try {
|
|
13793
|
-
const prompt = getPrompt(id);
|
|
13794
|
-
if (!prompt)
|
|
13795
|
-
handleError(program2, `Prompt not found: ${id}`);
|
|
13796
|
-
const versions = listVersions(prompt.id);
|
|
13797
|
-
const versionA = versions.find((v) => v.version === parseInt(v1));
|
|
13798
|
-
if (!versionA)
|
|
13799
|
-
handleError(program2, `Version ${v1} not found`);
|
|
13800
|
-
const bodyB = v2 ? versions.find((v) => v.version === parseInt(v2))?.body ?? null : prompt.body;
|
|
13801
|
-
if (bodyB === null)
|
|
13802
|
-
handleError(program2, `Version ${v2} not found`);
|
|
13803
|
-
const lines = diffTexts(versionA.body, bodyB);
|
|
13804
|
-
if (isJson(program2)) {
|
|
13805
|
-
output(program2, lines);
|
|
13806
|
-
return;
|
|
13807
|
-
}
|
|
13808
|
-
const label2 = v2 ? `v${v2}` : "current";
|
|
13809
|
-
console.log(chalk3.bold(`${prompt.slug}: v${v1} \u2192 ${label2}`));
|
|
13810
|
-
for (const l of lines) {
|
|
13811
|
-
if (l.type === "added")
|
|
13812
|
-
console.log(chalk3.green(`+ ${l.content}`));
|
|
13813
|
-
else if (l.type === "removed")
|
|
13814
|
-
console.log(chalk3.red(`- ${l.content}`));
|
|
13815
|
-
else
|
|
13816
|
-
console.log(chalk3.gray(` ${l.content}`));
|
|
13817
|
-
}
|
|
13824
|
+
console.log(`${chalk4.green("Duplicated")} ${chalk4.bold(p.slug)} \u2192 ${chalk4.bold(prompt.slug)}`);
|
|
13818
13825
|
} catch (e) {
|
|
13819
13826
|
handleError(program2, e);
|
|
13820
13827
|
}
|
|
@@ -13827,7 +13834,7 @@ program2.command("chain <id> [next]").description("Set the next prompt in a chai
|
|
|
13827
13834
|
if (isJson(program2))
|
|
13828
13835
|
output(program2, p);
|
|
13829
13836
|
else
|
|
13830
|
-
console.log(nextSlug ? `${
|
|
13837
|
+
console.log(nextSlug ? `${chalk4.green(p.slug)} \u2192 ${chalk4.bold(nextSlug)}` : chalk4.gray(`Cleared chain for ${p.slug}`));
|
|
13831
13838
|
return;
|
|
13832
13839
|
}
|
|
13833
13840
|
const prompt = getPrompt(id);
|
|
@@ -13845,7 +13852,7 @@ program2.command("chain <id> [next]").description("Set the next prompt in a chai
|
|
|
13845
13852
|
output(program2, chain);
|
|
13846
13853
|
return;
|
|
13847
13854
|
}
|
|
13848
|
-
console.log(chain.map((c) =>
|
|
13855
|
+
console.log(chain.map((c) => chalk4.green(c.slug)).join(chalk4.gray(" \u2192 ")));
|
|
13849
13856
|
} catch (e) {
|
|
13850
13857
|
handleError(program2, e);
|
|
13851
13858
|
}
|
|
@@ -13866,7 +13873,7 @@ program2.command("watch [dir]").description("Watch a directory for .md changes a
|
|
|
13866
13873
|
const watchDir = resolve(dir ?? join7(process.cwd(), ".prompts"));
|
|
13867
13874
|
if (!existsSync5(watchDir))
|
|
13868
13875
|
mkdirSync4(watchDir, { recursive: true });
|
|
13869
|
-
console.log(
|
|
13876
|
+
console.log(chalk4.bold(`Watching ${watchDir} for .md changes\u2026`) + chalk4.gray(" (Ctrl+C to stop)"));
|
|
13870
13877
|
const { importFromMarkdown: importFromMarkdown2 } = await Promise.resolve().then(() => (init_importer(), exports_importer));
|
|
13871
13878
|
const { readFileSync: readFileSync2 } = await import("fs");
|
|
13872
13879
|
const fsWatch = (await import("fs")).watch;
|
|
@@ -13877,10 +13884,10 @@ program2.command("watch [dir]").description("Watch a directory for .md changes a
|
|
|
13877
13884
|
try {
|
|
13878
13885
|
const content = readFileSync2(filePath, "utf-8");
|
|
13879
13886
|
const result = importFromMarkdown2([{ filename, content }], opts["agent"]);
|
|
13880
|
-
const action = result.created > 0 ?
|
|
13881
|
-
console.log(`${action}: ${
|
|
13887
|
+
const action = result.created > 0 ? chalk4.green("Created") : chalk4.yellow("Updated");
|
|
13888
|
+
console.log(`${action}: ${chalk4.bold(filename.replace(".md", ""))} ${chalk4.gray(new Date().toLocaleTimeString())}`);
|
|
13882
13889
|
} catch {
|
|
13883
|
-
console.error(
|
|
13890
|
+
console.error(chalk4.red(`Failed to import: ${filename}`));
|
|
13884
13891
|
}
|
|
13885
13892
|
});
|
|
13886
13893
|
await new Promise(() => {});
|
|
@@ -13893,17 +13900,17 @@ program2.command("import-slash-commands").description("Auto-scan .claude/command
|
|
|
13893
13900
|
return;
|
|
13894
13901
|
}
|
|
13895
13902
|
if (scanned.length === 0) {
|
|
13896
|
-
console.log(
|
|
13903
|
+
console.log(chalk4.gray("No slash command files found."));
|
|
13897
13904
|
return;
|
|
13898
13905
|
}
|
|
13899
|
-
console.log(
|
|
13906
|
+
console.log(chalk4.bold(`Scanned ${scanned.length} file(s):`));
|
|
13900
13907
|
for (const s of scanned)
|
|
13901
|
-
console.log(
|
|
13908
|
+
console.log(chalk4.gray(` ${s.source}/${s.file}`));
|
|
13902
13909
|
console.log(`
|
|
13903
|
-
${
|
|
13910
|
+
${chalk4.green(`Created: ${imported.created}`)} ${chalk4.yellow(`Updated: ${imported.updated}`)}`);
|
|
13904
13911
|
if (imported.errors.length > 0) {
|
|
13905
13912
|
for (const e of imported.errors)
|
|
13906
|
-
console.error(
|
|
13913
|
+
console.error(chalk4.red(` \u2717 ${e.item}: ${e.error}`));
|
|
13907
13914
|
}
|
|
13908
13915
|
} catch (e) {
|
|
13909
13916
|
handleError(program2, e);
|
|
@@ -13918,7 +13925,7 @@ program2.command("remove <id>").alias("rm").alias("uninstall").description("Remo
|
|
|
13918
13925
|
const { createInterface } = await import("readline");
|
|
13919
13926
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
13920
13927
|
await new Promise((resolve) => {
|
|
13921
|
-
rl.question(
|
|
13928
|
+
rl.question(chalk4.yellow(`Remove "${prompt.slug}"? [y/N] `), (ans) => {
|
|
13922
13929
|
rl.close();
|
|
13923
13930
|
if (ans.toLowerCase() !== "y") {
|
|
13924
13931
|
console.log("Cancelled.");
|
|
@@ -13932,7 +13939,7 @@ program2.command("remove <id>").alias("rm").alias("uninstall").description("Remo
|
|
|
13932
13939
|
if (isJson(program2))
|
|
13933
13940
|
output(program2, { deleted: true, id: prompt.id });
|
|
13934
13941
|
else
|
|
13935
|
-
console.log(
|
|
13942
|
+
console.log(chalk4.red(`Removed ${prompt.slug}`));
|
|
13936
13943
|
} catch (e) {
|
|
13937
13944
|
handleError(program2, e);
|
|
13938
13945
|
}
|
|
@@ -13952,7 +13959,7 @@ scheduleCmd.command("add <id> <cron>").description("Schedule a prompt to run on
|
|
|
13952
13959
|
output(program2, schedule);
|
|
13953
13960
|
return;
|
|
13954
13961
|
}
|
|
13955
|
-
console.log(
|
|
13962
|
+
console.log(chalk4.green(`Scheduled "${prompt.slug}" [${schedule.id}]`));
|
|
13956
13963
|
console.log(` Cron: ${cron}`);
|
|
13957
13964
|
console.log(` Next run: ${schedule.next_run_at}`);
|
|
13958
13965
|
} catch (e) {
|
|
@@ -13967,11 +13974,11 @@ scheduleCmd.command("list [id]").description("List schedules, optionally filtere
|
|
|
13967
13974
|
return;
|
|
13968
13975
|
}
|
|
13969
13976
|
if (!schedules.length) {
|
|
13970
|
-
console.log(
|
|
13977
|
+
console.log(chalk4.gray("No schedules."));
|
|
13971
13978
|
return;
|
|
13972
13979
|
}
|
|
13973
13980
|
for (const s of schedules) {
|
|
13974
|
-
console.log(`${
|
|
13981
|
+
console.log(`${chalk4.bold(s.id)} ${chalk4.cyan(s.prompt_slug)} cron:${s.cron} next:${s.next_run_at} runs:${s.run_count}`);
|
|
13975
13982
|
}
|
|
13976
13983
|
} catch (e) {
|
|
13977
13984
|
handleError(program2, e);
|
|
@@ -13983,7 +13990,7 @@ scheduleCmd.command("remove <scheduleId>").alias("delete").description("Remove a
|
|
|
13983
13990
|
if (isJson(program2))
|
|
13984
13991
|
output(program2, { deleted: true, id: scheduleId });
|
|
13985
13992
|
else
|
|
13986
|
-
console.log(
|
|
13993
|
+
console.log(chalk4.red(`Removed schedule ${scheduleId}`));
|
|
13987
13994
|
} catch (e) {
|
|
13988
13995
|
handleError(program2, e);
|
|
13989
13996
|
}
|
|
@@ -13992,7 +13999,7 @@ scheduleCmd.command("due").description("Show and execute all due schedules").opt
|
|
|
13992
13999
|
try {
|
|
13993
14000
|
const due = getDueSchedules();
|
|
13994
14001
|
if (!due.length) {
|
|
13995
|
-
console.log(
|
|
14002
|
+
console.log(chalk4.gray("No prompts due."));
|
|
13996
14003
|
return;
|
|
13997
14004
|
}
|
|
13998
14005
|
if (isJson(program2)) {
|
|
@@ -14000,13 +14007,13 @@ scheduleCmd.command("due").description("Show and execute all due schedules").opt
|
|
|
14000
14007
|
return;
|
|
14001
14008
|
}
|
|
14002
14009
|
for (const d of due) {
|
|
14003
|
-
console.log(
|
|
14010
|
+
console.log(chalk4.bold(`
|
|
14004
14011
|
[${d.id}] ${d.prompt_slug}`));
|
|
14005
|
-
console.log(
|
|
14006
|
-
console.log(
|
|
14012
|
+
console.log(chalk4.gray(`Next run: ${d.next_run_at} | Runs: ${d.run_count}`));
|
|
14013
|
+
console.log(chalk4.white(d.rendered));
|
|
14007
14014
|
}
|
|
14008
14015
|
if (!opts.dryRun)
|
|
14009
|
-
console.log(
|
|
14016
|
+
console.log(chalk4.green(`
|
|
14010
14017
|
\u2713 Marked ${due.length} schedule(s) as ran.`));
|
|
14011
14018
|
} catch (e) {
|
|
14012
14019
|
handleError(program2, e);
|
|
@@ -14029,7 +14036,7 @@ scheduleCmd.command("next <cron>").description("Preview when a cron expression w
|
|
|
14029
14036
|
output(program2, { cron, next_runs: runs });
|
|
14030
14037
|
return;
|
|
14031
14038
|
}
|
|
14032
|
-
console.log(
|
|
14039
|
+
console.log(chalk4.bold(`Next ${count} runs for "${cron}":`));
|
|
14033
14040
|
for (const r of runs)
|
|
14034
14041
|
console.log(` ${r}`);
|
|
14035
14042
|
} catch (e) {
|