@tryghost/ghst 0.15.3 → 0.16.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/dist/index.js CHANGED
@@ -1292,12 +1292,31 @@ function assertDestructiveActionsEnabled(global, action = "this operation") {
1292
1292
  );
1293
1293
  }
1294
1294
  function isReadOnlyHttpMethod(method) {
1295
- const normalized = (method ?? "GET").toUpperCase();
1296
- return normalized === "GET" || normalized === "HEAD" || normalized === "OPTIONS";
1295
+ return method === "GET" || method === "HEAD" || method === "OPTIONS";
1296
+ }
1297
+ var DESTRUCTIVE_WRITE_RESOURCES = /* @__PURE__ */ new Set(["db"]);
1298
+ function getResourceSegment(path9) {
1299
+ if (!path9) {
1300
+ return null;
1301
+ }
1302
+ const [segment] = path9.split("/").filter(Boolean);
1303
+ return segment ? segment.toLowerCase() : null;
1304
+ }
1305
+ function isDestructiveRawRequest(options) {
1306
+ const method = (options.method ?? "GET").toUpperCase();
1307
+ if (method === "DELETE") {
1308
+ return true;
1309
+ }
1310
+ if (isReadOnlyHttpMethod(method)) {
1311
+ return false;
1312
+ }
1313
+ const resource = getResourceSegment(options.path);
1314
+ return resource !== null && DESTRUCTIVE_WRITE_RESOURCES.has(resource);
1297
1315
  }
1298
1316
 
1299
1317
  // src/lib/output.ts
1300
1318
  import process2 from "process";
1319
+ import { evaluate, parse } from "@jq-tools/jq";
1301
1320
  import chalk from "chalk";
1302
1321
  import Table from "cli-table3";
1303
1322
 
@@ -1322,40 +1341,27 @@ function isNonInteractive(env = process.env) {
1322
1341
  }
1323
1342
 
1324
1343
  // src/lib/output.ts
1325
- function applyJqSubset(data, jq) {
1326
- if (!jq) {
1327
- return data;
1328
- }
1329
- const rootArrayPattern = /^\.\[\]\.([a-zA-Z0-9_]+)$/;
1330
- const nestedArrayPattern = /^\.([a-zA-Z0-9_]+)\[\]\.([a-zA-Z0-9_]+)$/;
1331
- const singleFieldPattern = /^\.([a-zA-Z0-9_]+)$/;
1332
- const rootMatch = jq.match(rootArrayPattern);
1333
- if (rootMatch) {
1334
- const [, field = ""] = rootMatch;
1335
- return Array.isArray(data) ? data.map((entry) => entry[field]) : [];
1336
- }
1337
- const nestedMatch = jq.match(nestedArrayPattern);
1338
- if (nestedMatch) {
1339
- const [, collection = "", field = ""] = nestedMatch;
1340
- const collectionValue = data[collection];
1341
- return Array.isArray(collectionValue) ? collectionValue.map((entry) => entry[field]) : [];
1342
- }
1343
- const singleMatch = jq.match(singleFieldPattern);
1344
- if (singleMatch) {
1345
- const [, field = ""] = singleMatch;
1346
- return data[field];
1344
+ function describeJqError(error) {
1345
+ return error instanceof Error ? error.message : String(error);
1346
+ }
1347
+ function runJqFilter(data, filter) {
1348
+ try {
1349
+ return Array.from(evaluate(parse(filter), [data]));
1350
+ } catch (error) {
1351
+ throw new GhstError(`Invalid --jq filter: ${describeJqError(error)}`, {
1352
+ code: "E_JQ_FILTER",
1353
+ exitCode: 2 /* USAGE_ERROR */
1354
+ });
1347
1355
  }
1348
- throw new Error(`Unsupported --jq filter: ${jq}`);
1349
1356
  }
1350
1357
  function printJson(data, jq) {
1351
- const filtered = applyJqSubset(data, jq);
1352
- if (Array.isArray(filtered) && jq) {
1353
- for (const entry of filtered) {
1354
- console.log(JSON.stringify(entry));
1355
- }
1358
+ if (!jq) {
1359
+ console.log(JSON.stringify(data, null, 2));
1356
1360
  return;
1357
1361
  }
1358
- console.log(JSON.stringify(filtered, null, 2));
1362
+ for (const result of runJqFilter(data, jq)) {
1363
+ console.log(JSON.stringify(result));
1364
+ }
1359
1365
  }
1360
1366
  function formatStatus(status, useColor) {
1361
1367
  if (!useColor) {
@@ -1425,7 +1431,7 @@ function rowsFromCollection(payload, key, mapper) {
1425
1431
  }
1426
1432
  function stripHtml(value) {
1427
1433
  const html = String(value ?? "");
1428
- return html.replace(/<br\s*\/?>/gi, "\n").replace(/<\/p>/gi, "\n").replace(/<[^>]+>/g, " ").replace(/&nbsp;/gi, " ").replace(/&amp;/gi, "&").replace(/&lt;/gi, "<").replace(/&gt;/gi, ">").replace(/&#39;/gi, "'").replace(/&quot;/gi, '"').replace(/\s+/g, " ").trim();
1434
+ return html.replace(/<br\s*\/?>/gi, "\n").replace(/<\/p>/gi, "\n").replace(/<[^>]+>/g, " ").replace(/&nbsp;/gi, " ").replace(/&lt;/gi, "<").replace(/&gt;/gi, ">").replace(/&#39;/gi, "'").replace(/&quot;/gi, '"').replace(/&amp;/gi, "&").replace(/\s+/g, " ").trim();
1429
1435
  }
1430
1436
  function truncateValue(value, max = 64) {
1431
1437
  if (value.length <= max) {
@@ -2412,8 +2418,8 @@ function registerApiCommands(program) {
2412
2418
  const requestApi = options.contentApi ? "content" : "admin";
2413
2419
  const normalizedEndpointPath = normalizeGhostApiPath(endpointPath, requestApi);
2414
2420
  const global = getGlobalOptions(command);
2415
- if (!isReadOnlyHttpMethod(options.method)) {
2416
- assertDestructiveActionsEnabled(global, "raw API write request");
2421
+ if (isDestructiveRawRequest({ method: options.method, path: normalizedEndpointPath })) {
2422
+ assertDestructiveActionsEnabled(global, "destructive raw API request");
2417
2423
  }
2418
2424
  const connection = await resolveConnectionConfig(global);
2419
2425
  const client = new GhostClient({
@@ -3591,7 +3597,7 @@ function getByPath(source, keyPath) {
3591
3597
  function setByPath(target, keyPath, value) {
3592
3598
  const parts = keyPath.split(".");
3593
3599
  const leaf = parts.pop();
3594
- if (!leaf) {
3600
+ if (!leaf || leaf === "__proto__" || leaf === "constructor" || leaf === "prototype") {
3595
3601
  throw new GhstError("Invalid config path.", {
3596
3602
  code: "USAGE_ERROR",
3597
3603
  exitCode: 2 /* USAGE_ERROR */
@@ -3599,6 +3605,12 @@ function setByPath(target, keyPath, value) {
3599
3605
  }
3600
3606
  let cursor = target;
3601
3607
  for (const part of parts) {
3608
+ if (part === "__proto__" || part === "constructor" || part === "prototype") {
3609
+ throw new GhstError("Invalid config path.", {
3610
+ code: "USAGE_ERROR",
3611
+ exitCode: 2 /* USAGE_ERROR */
3612
+ });
3613
+ }
3602
3614
  const next = cursor[part];
3603
3615
  if (typeof next !== "object" || next === null) {
3604
3616
  cursor[part] = {};
@@ -4164,7 +4176,7 @@ function getFirstMember(payload) {
4164
4176
  return members[0] ?? {};
4165
4177
  }
4166
4178
  function emailFilter(email) {
4167
- const escaped = email.replace(/'/g, "\\'");
4179
+ const escaped = email.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
4168
4180
  return `email:'${escaped}'`;
4169
4181
  }
4170
4182
  async function getClient4(global) {
@@ -4671,6 +4683,10 @@ async function listPosts(global, params, allPages) {
4671
4683
  const limit = typeof params.limit === "number" ? params.limit : 100;
4672
4684
  return collectAllPages("posts", (page) => client.posts.browse({ ...params, page, limit }));
4673
4685
  }
4686
+ var GHOST_OBJECT_ID = /^[0-9a-f]{24}$/;
4687
+ function looksLikeGhostId(value) {
4688
+ return GHOST_OBJECT_ID.test(value);
4689
+ }
4674
4690
  async function getPost(global, idOrSlug, options) {
4675
4691
  const client = await getClient8(global);
4676
4692
  return client.posts.read(idOrSlug, options);
@@ -7066,6 +7082,9 @@ var MCP_TOOL_GROUP_METADATA = {
7066
7082
  socialweb: { title: "Social web" },
7067
7083
  stats: { title: "Stats" }
7068
7084
  };
7085
+ var READ_ONLY_HINT = { readOnlyHint: true };
7086
+ var WRITE_HINT = { readOnlyHint: false, destructiveHint: false };
7087
+ var DESTRUCTIVE_HINT = { readOnlyHint: false, destructiveHint: true };
7069
7088
  var mcpSiteArgSchema = SiteAliasSchema.optional();
7070
7089
  var mcpSiteSchema = z6.object({
7071
7090
  site: mcpSiteArgSchema
@@ -7264,7 +7283,7 @@ function toolResult(data) {
7264
7283
  };
7265
7284
  }
7266
7285
  function escapeNqlValue(value) {
7267
- return value.replace(/'/g, "\\'");
7286
+ return value.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
7268
7287
  }
7269
7288
  async function runSearch(global, query, limit) {
7270
7289
  const escaped = escapeNqlValue(query);
@@ -7284,8 +7303,12 @@ async function runSearch(global, query, limit) {
7284
7303
  };
7285
7304
  }
7286
7305
  async function callApi(global, options) {
7287
- if (!isReadOnlyHttpMethod(options.method)) {
7288
- assertDestructiveActionsEnabled(global, "raw API write request");
7306
+ const normalizedPath = normalizeGhostApiPath(
7307
+ options.path,
7308
+ options.contentApi ? "content" : "admin"
7309
+ );
7310
+ if (isDestructiveRawRequest({ method: options.method, path: normalizedPath })) {
7311
+ assertDestructiveActionsEnabled(global, "destructive raw API request");
7289
7312
  }
7290
7313
  const connection = await resolveConnectionConfig(global);
7291
7314
  const client = new GhostClient({
@@ -7295,7 +7318,7 @@ async function callApi(global, options) {
7295
7318
  contentKey: process.env.GHOST_CONTENT_API_KEY
7296
7319
  });
7297
7320
  const payload = await client.rawRequest(
7298
- normalizeGhostApiPath(options.path, options.contentApi ? "content" : "admin"),
7321
+ normalizedPath,
7299
7322
  options.method ?? "GET",
7300
7323
  options.body,
7301
7324
  options.params,
@@ -7323,6 +7346,7 @@ function registerCoreTools(server, global, enabledGroups) {
7323
7346
  "posts",
7324
7347
  "ghost_post_list",
7325
7348
  {
7349
+ annotations: READ_ONLY_HINT,
7326
7350
  description: "List Ghost posts.",
7327
7351
  inputSchema: z6.object({
7328
7352
  limit: z6.number().int().positive().max(100).optional(),
@@ -7343,6 +7367,7 @@ function registerCoreTools(server, global, enabledGroups) {
7343
7367
  "posts",
7344
7368
  "ghost_post_get",
7345
7369
  {
7370
+ annotations: READ_ONLY_HINT,
7346
7371
  description: "Get a Ghost post by id or slug.",
7347
7372
  inputSchema: z6.object({
7348
7373
  id: z6.string().optional(),
@@ -7366,6 +7391,7 @@ function registerCoreTools(server, global, enabledGroups) {
7366
7391
  "posts",
7367
7392
  "ghost_post_create",
7368
7393
  {
7394
+ annotations: WRITE_HINT,
7369
7395
  description: "Create a Ghost post.",
7370
7396
  inputSchema: z6.object({
7371
7397
  title: z6.string(),
@@ -7398,6 +7424,7 @@ function registerCoreTools(server, global, enabledGroups) {
7398
7424
  "posts",
7399
7425
  "ghost_post_update",
7400
7426
  {
7427
+ annotations: WRITE_HINT,
7401
7428
  description: "Update a Ghost post by id or slug, with optional email delivery settings on the publish transition.",
7402
7429
  inputSchema: z6.object({
7403
7430
  id: z6.string().optional(),
@@ -7441,6 +7468,7 @@ function registerCoreTools(server, global, enabledGroups) {
7441
7468
  "posts",
7442
7469
  "ghost_post_delete",
7443
7470
  {
7471
+ annotations: DESTRUCTIVE_HINT,
7444
7472
  description: "Delete a Ghost post.",
7445
7473
  inputSchema: z6.object({
7446
7474
  id: z6.string(),
@@ -7459,6 +7487,7 @@ function registerCoreTools(server, global, enabledGroups) {
7459
7487
  "posts",
7460
7488
  "ghost_post_publish",
7461
7489
  {
7490
+ annotations: WRITE_HINT,
7462
7491
  description: "Publish a Ghost post, with optional email delivery settings.",
7463
7492
  inputSchema: z6.object({
7464
7493
  id: z6.string(),
@@ -7482,6 +7511,7 @@ function registerCoreTools(server, global, enabledGroups) {
7482
7511
  "posts",
7483
7512
  "ghost_post_schedule",
7484
7513
  {
7514
+ annotations: WRITE_HINT,
7485
7515
  description: "Schedule a Ghost post, with optional email delivery settings.",
7486
7516
  inputSchema: z6.object({
7487
7517
  id: z6.string(),
@@ -7506,6 +7536,7 @@ function registerCoreTools(server, global, enabledGroups) {
7506
7536
  "posts",
7507
7537
  "ghost_image_upload",
7508
7538
  {
7539
+ annotations: WRITE_HINT,
7509
7540
  description: "Upload an image and return the uploaded image payload.",
7510
7541
  inputSchema: z6.object({
7511
7542
  file_path: z6.string().min(1),
@@ -7529,6 +7560,7 @@ function registerCoreTools(server, global, enabledGroups) {
7529
7560
  "pages",
7530
7561
  "ghost_page_list",
7531
7562
  {
7563
+ annotations: READ_ONLY_HINT,
7532
7564
  description: "List Ghost pages.",
7533
7565
  inputSchema: z6.object({
7534
7566
  limit: z6.number().int().positive().max(100).optional(),
@@ -7549,6 +7581,7 @@ function registerCoreTools(server, global, enabledGroups) {
7549
7581
  "pages",
7550
7582
  "ghost_page_get",
7551
7583
  {
7584
+ annotations: READ_ONLY_HINT,
7552
7585
  description: "Get a Ghost page by id or slug.",
7553
7586
  inputSchema: z6.object({
7554
7587
  id: z6.string().optional(),
@@ -7572,12 +7605,15 @@ function registerCoreTools(server, global, enabledGroups) {
7572
7605
  "pages",
7573
7606
  "ghost_page_create",
7574
7607
  {
7608
+ annotations: WRITE_HINT,
7575
7609
  description: "Create a Ghost page.",
7576
7610
  inputSchema: z6.object({
7577
7611
  title: z6.string(),
7612
+ slug: z6.string().optional(),
7578
7613
  html: z6.string().optional(),
7579
7614
  status: z6.enum(["draft", "published", "scheduled"]).optional(),
7580
7615
  publish_at: z6.string().datetime().optional(),
7616
+ tags: z6.array(z6.string()).optional(),
7581
7617
  visibility: z6.enum(["public", "members", "paid", "tiers"]).optional()
7582
7618
  })
7583
7619
  },
@@ -7586,9 +7622,11 @@ function registerCoreTools(server, global, enabledGroups) {
7586
7622
  global2,
7587
7623
  {
7588
7624
  title: args.title,
7625
+ slug: args.slug,
7589
7626
  html: args.html,
7590
7627
  status: args.status,
7591
7628
  published_at: args.publish_at,
7629
+ tags: args.tags,
7592
7630
  visibility: args.visibility
7593
7631
  },
7594
7632
  args.html ? "html" : void 0
@@ -7602,6 +7640,7 @@ function registerCoreTools(server, global, enabledGroups) {
7602
7640
  "pages",
7603
7641
  "ghost_page_update",
7604
7642
  {
7643
+ annotations: WRITE_HINT,
7605
7644
  description: "Update a Ghost page by id or slug.",
7606
7645
  inputSchema: z6.object({
7607
7646
  id: z6.string().optional(),
@@ -7610,6 +7649,7 @@ function registerCoreTools(server, global, enabledGroups) {
7610
7649
  html: z6.string().optional(),
7611
7650
  status: z6.enum(["draft", "published", "scheduled"]).optional(),
7612
7651
  publish_at: z6.string().datetime().optional(),
7652
+ tags: z6.array(z6.string()).optional(),
7613
7653
  visibility: z6.enum(["public", "members", "paid", "tiers"]).optional()
7614
7654
  })
7615
7655
  },
@@ -7622,6 +7662,7 @@ function registerCoreTools(server, global, enabledGroups) {
7622
7662
  html: args.html,
7623
7663
  status: args.status,
7624
7664
  published_at: args.publish_at,
7665
+ tags: args.tags,
7625
7666
  visibility: args.visibility
7626
7667
  },
7627
7668
  source: args.html ? "html" : void 0
@@ -7635,6 +7676,7 @@ function registerCoreTools(server, global, enabledGroups) {
7635
7676
  "pages",
7636
7677
  "ghost_page_delete",
7637
7678
  {
7679
+ annotations: DESTRUCTIVE_HINT,
7638
7680
  description: "Delete a Ghost page.",
7639
7681
  inputSchema: z6.object({
7640
7682
  id: z6.string(),
@@ -7655,6 +7697,7 @@ function registerCoreTools(server, global, enabledGroups) {
7655
7697
  "tags",
7656
7698
  "ghost_tag_list",
7657
7699
  {
7700
+ annotations: READ_ONLY_HINT,
7658
7701
  description: "List Ghost tags.",
7659
7702
  inputSchema: z6.object({
7660
7703
  limit: z6.number().int().positive().max(100).optional(),
@@ -7670,6 +7713,7 @@ function registerCoreTools(server, global, enabledGroups) {
7670
7713
  "tags",
7671
7714
  "ghost_tag_get",
7672
7715
  {
7716
+ annotations: READ_ONLY_HINT,
7673
7717
  description: "Get a Ghost tag by id or slug.",
7674
7718
  inputSchema: z6.object({
7675
7719
  id: z6.string().optional(),
@@ -7688,6 +7732,7 @@ function registerCoreTools(server, global, enabledGroups) {
7688
7732
  "tags",
7689
7733
  "ghost_tag_create",
7690
7734
  {
7735
+ annotations: WRITE_HINT,
7691
7736
  description: "Create a Ghost tag.",
7692
7737
  inputSchema: z6.object({
7693
7738
  name: z6.string(),
@@ -7703,6 +7748,7 @@ function registerCoreTools(server, global, enabledGroups) {
7703
7748
  "tags",
7704
7749
  "ghost_tag_update",
7705
7750
  {
7751
+ annotations: WRITE_HINT,
7706
7752
  description: "Update a Ghost tag.",
7707
7753
  inputSchema: z6.object({
7708
7754
  id: z6.string().optional(),
@@ -7728,6 +7774,7 @@ function registerCoreTools(server, global, enabledGroups) {
7728
7774
  "tags",
7729
7775
  "ghost_tag_delete",
7730
7776
  {
7777
+ annotations: DESTRUCTIVE_HINT,
7731
7778
  description: "Delete a Ghost tag.",
7732
7779
  inputSchema: z6.object({
7733
7780
  id: z6.string(),
@@ -7747,6 +7794,7 @@ function registerCoreTools(server, global, enabledGroups) {
7747
7794
  "members",
7748
7795
  "ghost_member_list",
7749
7796
  {
7797
+ annotations: READ_ONLY_HINT,
7750
7798
  description: "List Ghost members.",
7751
7799
  inputSchema: z6.object({
7752
7800
  limit: z6.number().int().positive().max(100).optional(),
@@ -7763,6 +7811,7 @@ function registerCoreTools(server, global, enabledGroups) {
7763
7811
  "members",
7764
7812
  "ghost_member_get",
7765
7813
  {
7814
+ annotations: READ_ONLY_HINT,
7766
7815
  description: "Get Ghost member by id or email.",
7767
7816
  inputSchema: z6.object({
7768
7817
  id: z6.string().optional(),
@@ -7782,6 +7831,7 @@ function registerCoreTools(server, global, enabledGroups) {
7782
7831
  "members",
7783
7832
  "ghost_member_create",
7784
7833
  {
7834
+ annotations: WRITE_HINT,
7785
7835
  description: "Create Ghost member.",
7786
7836
  inputSchema: z6.object({
7787
7837
  email: z6.string(),
@@ -7805,6 +7855,7 @@ function registerCoreTools(server, global, enabledGroups) {
7805
7855
  "members",
7806
7856
  "ghost_member_update",
7807
7857
  {
7858
+ annotations: WRITE_HINT,
7808
7859
  description: "Update Ghost member.",
7809
7860
  inputSchema: z6.object({
7810
7861
  id: z6.string().optional(),
@@ -7830,6 +7881,7 @@ function registerCoreTools(server, global, enabledGroups) {
7830
7881
  "members",
7831
7882
  "ghost_member_delete",
7832
7883
  {
7884
+ annotations: DESTRUCTIVE_HINT,
7833
7885
  description: "Delete Ghost member.",
7834
7886
  inputSchema: z6.object({
7835
7887
  id: z6.string(),
@@ -7847,6 +7899,7 @@ function registerCoreTools(server, global, enabledGroups) {
7847
7899
  "members",
7848
7900
  "ghost_member_import",
7849
7901
  {
7902
+ annotations: WRITE_HINT,
7850
7903
  description: "Import members from a CSV file path.",
7851
7904
  inputSchema: z6.object({
7852
7905
  file_path: z6.string().min(1),
@@ -7866,6 +7919,7 @@ function registerCoreTools(server, global, enabledGroups) {
7866
7919
  "members",
7867
7920
  "ghost_newsletter_list",
7868
7921
  {
7922
+ annotations: READ_ONLY_HINT,
7869
7923
  description: "List Ghost newsletters.",
7870
7924
  inputSchema: z6.object({
7871
7925
  limit: z6.number().int().positive().max(100).optional(),
@@ -7881,6 +7935,7 @@ function registerCoreTools(server, global, enabledGroups) {
7881
7935
  "members",
7882
7936
  "ghost_tier_list",
7883
7937
  {
7938
+ annotations: READ_ONLY_HINT,
7884
7939
  description: "List Ghost tiers.",
7885
7940
  inputSchema: z6.object({
7886
7941
  limit: z6.number().int().positive().max(100).optional(),
@@ -7896,6 +7951,7 @@ function registerCoreTools(server, global, enabledGroups) {
7896
7951
  "members",
7897
7952
  "ghost_offer_list",
7898
7953
  {
7954
+ annotations: READ_ONLY_HINT,
7899
7955
  description: "List Ghost offers.",
7900
7956
  inputSchema: z6.object({
7901
7957
  limit: z6.number().int().positive().max(100).optional(),
@@ -7913,6 +7969,7 @@ function registerCoreTools(server, global, enabledGroups) {
7913
7969
  "comments",
7914
7970
  "ghost_comment_list",
7915
7971
  {
7972
+ annotations: READ_ONLY_HINT,
7916
7973
  description: "List Ghost comments from the Admin moderation view.",
7917
7974
  inputSchema: z6.object({
7918
7975
  ...commentBrowseArgs,
@@ -7940,6 +7997,7 @@ function registerCoreTools(server, global, enabledGroups) {
7940
7997
  "comments",
7941
7998
  "ghost_comment_get",
7942
7999
  {
8000
+ annotations: READ_ONLY_HINT,
7943
8001
  description: "Get a Ghost comment with Admin moderation fields.",
7944
8002
  inputSchema: z6.object({
7945
8003
  id: z6.string()
@@ -7953,6 +8011,7 @@ function registerCoreTools(server, global, enabledGroups) {
7953
8011
  "comments",
7954
8012
  "ghost_comment_thread",
7955
8013
  {
8014
+ annotations: READ_ONLY_HINT,
7956
8015
  description: "Get a Ghost comment thread using the Admin moderation thread view.",
7957
8016
  inputSchema: z6.object({
7958
8017
  id: z6.string()
@@ -7966,6 +8025,7 @@ function registerCoreTools(server, global, enabledGroups) {
7966
8025
  "comments",
7967
8026
  "ghost_comment_replies",
7968
8027
  {
8028
+ annotations: READ_ONLY_HINT,
7969
8029
  description: "List replies for a Ghost comment using the raw replies endpoint.",
7970
8030
  inputSchema: z6.object({
7971
8031
  id: z6.string(),
@@ -7991,6 +8051,7 @@ function registerCoreTools(server, global, enabledGroups) {
7991
8051
  "comments",
7992
8052
  "ghost_comment_likes",
7993
8053
  {
8054
+ annotations: READ_ONLY_HINT,
7994
8055
  description: "List likes for a Ghost comment.",
7995
8056
  inputSchema: z6.object({
7996
8057
  id: z6.string(),
@@ -8016,6 +8077,7 @@ function registerCoreTools(server, global, enabledGroups) {
8016
8077
  "comments",
8017
8078
  "ghost_comment_reports",
8018
8079
  {
8080
+ annotations: READ_ONLY_HINT,
8019
8081
  description: "List reports for a Ghost comment.",
8020
8082
  inputSchema: z6.object({
8021
8083
  id: z6.string(),
@@ -8041,6 +8103,7 @@ function registerCoreTools(server, global, enabledGroups) {
8041
8103
  "comments",
8042
8104
  "ghost_comment_hide",
8043
8105
  {
8106
+ annotations: WRITE_HINT,
8044
8107
  description: "Hide a Ghost comment.",
8045
8108
  inputSchema: z6.object({
8046
8109
  id: z6.string()
@@ -8054,6 +8117,7 @@ function registerCoreTools(server, global, enabledGroups) {
8054
8117
  "comments",
8055
8118
  "ghost_comment_show",
8056
8119
  {
8120
+ annotations: WRITE_HINT,
8057
8121
  description: "Show a previously hidden Ghost comment.",
8058
8122
  inputSchema: z6.object({
8059
8123
  id: z6.string()
@@ -8067,6 +8131,7 @@ function registerCoreTools(server, global, enabledGroups) {
8067
8131
  "comments",
8068
8132
  "ghost_comment_delete",
8069
8133
  {
8134
+ annotations: DESTRUCTIVE_HINT,
8070
8135
  description: "Soft-delete a Ghost comment.",
8071
8136
  inputSchema: z6.object({
8072
8137
  id: z6.string(),
@@ -8086,6 +8151,7 @@ function registerCoreTools(server, global, enabledGroups) {
8086
8151
  "site",
8087
8152
  "ghost_site_info",
8088
8153
  {
8154
+ annotations: READ_ONLY_HINT,
8089
8155
  description: "Get Ghost site metadata."
8090
8156
  },
8091
8157
  async (global2) => toolResult(await getSiteInfo(global2))
@@ -8096,6 +8162,7 @@ function registerCoreTools(server, global, enabledGroups) {
8096
8162
  "site",
8097
8163
  "ghost_site_list",
8098
8164
  {
8165
+ annotations: READ_ONLY_HINT,
8099
8166
  description: "List configured Ghost site aliases without credentials."
8100
8167
  },
8101
8168
  async () => toolResult(await listConfiguredSites())
@@ -8106,6 +8173,7 @@ function registerCoreTools(server, global, enabledGroups) {
8106
8173
  "site",
8107
8174
  "ghost_theme_upload",
8108
8175
  {
8176
+ annotations: WRITE_HINT,
8109
8177
  description: "Upload a Ghost theme zip path and optionally activate it.",
8110
8178
  inputSchema: z6.object({
8111
8179
  file_path: z6.string().min(1),
@@ -8131,6 +8199,7 @@ function registerCoreTools(server, global, enabledGroups) {
8131
8199
  "site",
8132
8200
  "ghost_webhook_create",
8133
8201
  {
8202
+ annotations: WRITE_HINT,
8134
8203
  description: "Create a Ghost webhook.",
8135
8204
  inputSchema: z6.object({
8136
8205
  event: z6.string().min(1),
@@ -8158,6 +8227,7 @@ function registerCoreTools(server, global, enabledGroups) {
8158
8227
  "settings",
8159
8228
  "ghost_setting_list",
8160
8229
  {
8230
+ annotations: READ_ONLY_HINT,
8161
8231
  description: "List Ghost settings."
8162
8232
  },
8163
8233
  async (global2) => toolResult(await listSettings(global2))
@@ -8168,6 +8238,7 @@ function registerCoreTools(server, global, enabledGroups) {
8168
8238
  "settings",
8169
8239
  "ghost_setting_get",
8170
8240
  {
8241
+ annotations: READ_ONLY_HINT,
8171
8242
  description: "Get a Ghost setting by key.",
8172
8243
  inputSchema: z6.object({
8173
8244
  key: z6.string()
@@ -8181,6 +8252,7 @@ function registerCoreTools(server, global, enabledGroups) {
8181
8252
  "settings",
8182
8253
  "ghost_setting_set",
8183
8254
  {
8255
+ annotations: WRITE_HINT,
8184
8256
  description: "Set a Ghost setting by key.",
8185
8257
  inputSchema: z6.object({
8186
8258
  key: z6.string(),
@@ -8197,6 +8269,7 @@ function registerCoreTools(server, global, enabledGroups) {
8197
8269
  "users",
8198
8270
  "ghost_user_list",
8199
8271
  {
8272
+ annotations: READ_ONLY_HINT,
8200
8273
  description: "List Ghost staff users.",
8201
8274
  inputSchema: z6.object({
8202
8275
  limit: z6.number().int().positive().max(100).optional(),
@@ -8240,6 +8313,7 @@ function registerCoreTools(server, global, enabledGroups) {
8240
8313
  "search",
8241
8314
  "ghost_search",
8242
8315
  {
8316
+ annotations: READ_ONLY_HINT,
8243
8317
  description: "Search posts, pages, tags and members.",
8244
8318
  inputSchema: z6.object({
8245
8319
  query: z6.string().min(1),
@@ -8256,6 +8330,7 @@ function registerCoreTools(server, global, enabledGroups) {
8256
8330
  "socialweb",
8257
8331
  "ghost_socialweb_status",
8258
8332
  {
8333
+ annotations: READ_ONLY_HINT,
8259
8334
  description: "Show Ghost social web settings and connectivity status."
8260
8335
  },
8261
8336
  async (global2) => toolResult(await getSocialWebStatus(global2))
@@ -8266,6 +8341,7 @@ function registerCoreTools(server, global, enabledGroups) {
8266
8341
  "socialweb",
8267
8342
  "ghost_socialweb_enable",
8268
8343
  {
8344
+ annotations: WRITE_HINT,
8269
8345
  description: "Enable Ghost social web and return the resulting status."
8270
8346
  },
8271
8347
  async (global2) => toolResult(await enableSocialWeb(global2))
@@ -8276,6 +8352,7 @@ function registerCoreTools(server, global, enabledGroups) {
8276
8352
  "socialweb",
8277
8353
  "ghost_socialweb_disable",
8278
8354
  {
8355
+ annotations: WRITE_HINT,
8279
8356
  description: "Disable Ghost social web and return the resulting status."
8280
8357
  },
8281
8358
  async (global2) => toolResult(await disableSocialWeb(global2))
@@ -8286,6 +8363,7 @@ function registerCoreTools(server, global, enabledGroups) {
8286
8363
  "socialweb",
8287
8364
  "ghost_socialweb_profile",
8288
8365
  {
8366
+ annotations: READ_ONLY_HINT,
8289
8367
  description: "Get a social web profile by federated handle or me.",
8290
8368
  inputSchema: z6.object({
8291
8369
  handle: socialWebHandleSchema.optional()
@@ -8299,6 +8377,7 @@ function registerCoreTools(server, global, enabledGroups) {
8299
8377
  "socialweb",
8300
8378
  "ghost_socialweb_profile_update",
8301
8379
  {
8380
+ annotations: WRITE_HINT,
8302
8381
  description: "Update the current social web profile.",
8303
8382
  inputSchema: socialWebProfileUpdateSchema
8304
8383
  },
@@ -8318,6 +8397,7 @@ function registerCoreTools(server, global, enabledGroups) {
8318
8397
  "socialweb",
8319
8398
  "ghost_socialweb_search",
8320
8399
  {
8400
+ annotations: READ_ONLY_HINT,
8321
8401
  description: "Search social web accounts.",
8322
8402
  inputSchema: z6.object({
8323
8403
  query: z6.string().min(1)
@@ -8331,6 +8411,7 @@ function registerCoreTools(server, global, enabledGroups) {
8331
8411
  "socialweb",
8332
8412
  "ghost_socialweb_notes",
8333
8413
  {
8414
+ annotations: READ_ONLY_HINT,
8334
8415
  description: "List the social web note feed.",
8335
8416
  inputSchema: socialWebPaginationSchema
8336
8417
  },
@@ -8345,6 +8426,7 @@ function registerCoreTools(server, global, enabledGroups) {
8345
8426
  "socialweb",
8346
8427
  "ghost_socialweb_reader",
8347
8428
  {
8429
+ annotations: READ_ONLY_HINT,
8348
8430
  description: "List the social web reader feed.",
8349
8431
  inputSchema: socialWebPaginationSchema
8350
8432
  },
@@ -8359,6 +8441,7 @@ function registerCoreTools(server, global, enabledGroups) {
8359
8441
  "socialweb",
8360
8442
  "ghost_socialweb_notifications",
8361
8443
  {
8444
+ annotations: READ_ONLY_HINT,
8362
8445
  description: "List social web notifications.",
8363
8446
  inputSchema: socialWebPaginationSchema
8364
8447
  },
@@ -8373,6 +8456,7 @@ function registerCoreTools(server, global, enabledGroups) {
8373
8456
  "socialweb",
8374
8457
  "ghost_socialweb_notifications_count",
8375
8458
  {
8459
+ annotations: READ_ONLY_HINT,
8376
8460
  description: "Get the unread social web notification count."
8377
8461
  },
8378
8462
  async (global2) => toolResult(await getNotificationsCount(global2))
@@ -8383,6 +8467,7 @@ function registerCoreTools(server, global, enabledGroups) {
8383
8467
  "socialweb",
8384
8468
  "ghost_socialweb_posts",
8385
8469
  {
8470
+ annotations: READ_ONLY_HINT,
8386
8471
  description: "List posts for a social web account.",
8387
8472
  inputSchema: socialWebHandlePaginationSchema
8388
8473
  },
@@ -8404,6 +8489,7 @@ function registerCoreTools(server, global, enabledGroups) {
8404
8489
  "socialweb",
8405
8490
  "ghost_socialweb_likes",
8406
8491
  {
8492
+ annotations: READ_ONLY_HINT,
8407
8493
  description: "List posts liked by the current social web account.",
8408
8494
  inputSchema: socialWebPaginationSchema
8409
8495
  },
@@ -8418,6 +8504,7 @@ function registerCoreTools(server, global, enabledGroups) {
8418
8504
  "socialweb",
8419
8505
  "ghost_socialweb_followers",
8420
8506
  {
8507
+ annotations: READ_ONLY_HINT,
8421
8508
  description: "List followers for a social web account.",
8422
8509
  inputSchema: socialWebHandlePaginationSchema
8423
8510
  },
@@ -8434,6 +8521,7 @@ function registerCoreTools(server, global, enabledGroups) {
8434
8521
  "socialweb",
8435
8522
  "ghost_socialweb_following",
8436
8523
  {
8524
+ annotations: READ_ONLY_HINT,
8437
8525
  description: "List followed accounts for a social web account.",
8438
8526
  inputSchema: socialWebHandlePaginationSchema
8439
8527
  },
@@ -8450,6 +8538,7 @@ function registerCoreTools(server, global, enabledGroups) {
8450
8538
  "socialweb",
8451
8539
  "ghost_socialweb_post",
8452
8540
  {
8541
+ annotations: READ_ONLY_HINT,
8453
8542
  description: "Get a social web post by ActivityPub id.",
8454
8543
  inputSchema: z6.object({
8455
8544
  id: socialWebUrlSchema
@@ -8463,6 +8552,7 @@ function registerCoreTools(server, global, enabledGroups) {
8463
8552
  "socialweb",
8464
8553
  "ghost_socialweb_thread",
8465
8554
  {
8555
+ annotations: READ_ONLY_HINT,
8466
8556
  description: "Get a social web thread by ActivityPub id.",
8467
8557
  inputSchema: z6.object({
8468
8558
  id: socialWebUrlSchema
@@ -8476,6 +8566,7 @@ function registerCoreTools(server, global, enabledGroups) {
8476
8566
  "socialweb",
8477
8567
  "ghost_socialweb_follow",
8478
8568
  {
8569
+ annotations: WRITE_HINT,
8479
8570
  description: "Follow a federated social web account.",
8480
8571
  inputSchema: z6.object({
8481
8572
  handle: socialWebRemoteHandleSchema
@@ -8489,6 +8580,7 @@ function registerCoreTools(server, global, enabledGroups) {
8489
8580
  "socialweb",
8490
8581
  "ghost_socialweb_unfollow",
8491
8582
  {
8583
+ annotations: WRITE_HINT,
8492
8584
  description: "Unfollow a federated social web account.",
8493
8585
  inputSchema: z6.object({
8494
8586
  handle: socialWebRemoteHandleSchema
@@ -8502,6 +8594,7 @@ function registerCoreTools(server, global, enabledGroups) {
8502
8594
  "socialweb",
8503
8595
  "ghost_socialweb_like",
8504
8596
  {
8597
+ annotations: WRITE_HINT,
8505
8598
  description: "Like a social web post.",
8506
8599
  inputSchema: z6.object({
8507
8600
  id: socialWebUrlSchema
@@ -8515,6 +8608,7 @@ function registerCoreTools(server, global, enabledGroups) {
8515
8608
  "socialweb",
8516
8609
  "ghost_socialweb_unlike",
8517
8610
  {
8611
+ annotations: WRITE_HINT,
8518
8612
  description: "Unlike a social web post.",
8519
8613
  inputSchema: z6.object({
8520
8614
  id: socialWebUrlSchema
@@ -8528,6 +8622,7 @@ function registerCoreTools(server, global, enabledGroups) {
8528
8622
  "socialweb",
8529
8623
  "ghost_socialweb_repost",
8530
8624
  {
8625
+ annotations: WRITE_HINT,
8531
8626
  description: "Repost a social web post.",
8532
8627
  inputSchema: z6.object({
8533
8628
  id: socialWebUrlSchema
@@ -8541,6 +8636,7 @@ function registerCoreTools(server, global, enabledGroups) {
8541
8636
  "socialweb",
8542
8637
  "ghost_socialweb_derepost",
8543
8638
  {
8639
+ annotations: WRITE_HINT,
8544
8640
  description: "Undo a repost on a social web post.",
8545
8641
  inputSchema: z6.object({
8546
8642
  id: socialWebUrlSchema
@@ -8554,6 +8650,7 @@ function registerCoreTools(server, global, enabledGroups) {
8554
8650
  "socialweb",
8555
8651
  "ghost_socialweb_delete",
8556
8652
  {
8653
+ annotations: DESTRUCTIVE_HINT,
8557
8654
  description: "Delete a social web post authored by the current account.",
8558
8655
  inputSchema: z6.object({
8559
8656
  id: socialWebUrlSchema,
@@ -8571,6 +8668,7 @@ function registerCoreTools(server, global, enabledGroups) {
8571
8668
  "socialweb",
8572
8669
  "ghost_socialweb_note",
8573
8670
  {
8671
+ annotations: WRITE_HINT,
8574
8672
  description: "Create a new social web note.",
8575
8673
  inputSchema: socialWebContentSchema
8576
8674
  },
@@ -8589,6 +8687,7 @@ function registerCoreTools(server, global, enabledGroups) {
8589
8687
  "socialweb",
8590
8688
  "ghost_socialweb_reply",
8591
8689
  {
8690
+ annotations: WRITE_HINT,
8592
8691
  description: "Reply to a social web post.",
8593
8692
  inputSchema: socialWebContentSchema.extend({
8594
8693
  id: socialWebUrlSchema
@@ -8609,6 +8708,7 @@ function registerCoreTools(server, global, enabledGroups) {
8609
8708
  "socialweb",
8610
8709
  "ghost_socialweb_blocked_accounts",
8611
8710
  {
8711
+ annotations: READ_ONLY_HINT,
8612
8712
  description: "List blocked social web accounts.",
8613
8713
  inputSchema: socialWebPaginationSchema
8614
8714
  },
@@ -8625,6 +8725,7 @@ function registerCoreTools(server, global, enabledGroups) {
8625
8725
  "socialweb",
8626
8726
  "ghost_socialweb_blocked_domains",
8627
8727
  {
8728
+ annotations: READ_ONLY_HINT,
8628
8729
  description: "List blocked social web domains.",
8629
8730
  inputSchema: socialWebPaginationSchema
8630
8731
  },
@@ -8639,6 +8740,7 @@ function registerCoreTools(server, global, enabledGroups) {
8639
8740
  "socialweb",
8640
8741
  "ghost_socialweb_block",
8641
8742
  {
8743
+ annotations: WRITE_HINT,
8642
8744
  description: "Block a social web account by ActivityPub id.",
8643
8745
  inputSchema: z6.object({
8644
8746
  id: socialWebUrlSchema
@@ -8652,6 +8754,7 @@ function registerCoreTools(server, global, enabledGroups) {
8652
8754
  "socialweb",
8653
8755
  "ghost_socialweb_unblock",
8654
8756
  {
8757
+ annotations: WRITE_HINT,
8655
8758
  description: "Unblock a social web account by ActivityPub id.",
8656
8759
  inputSchema: z6.object({
8657
8760
  id: socialWebUrlSchema
@@ -8665,6 +8768,7 @@ function registerCoreTools(server, global, enabledGroups) {
8665
8768
  "socialweb",
8666
8769
  "ghost_socialweb_block_domain",
8667
8770
  {
8771
+ annotations: WRITE_HINT,
8668
8772
  description: "Block a social web domain.",
8669
8773
  inputSchema: z6.object({
8670
8774
  url: socialWebUrlSchema
@@ -8678,6 +8782,7 @@ function registerCoreTools(server, global, enabledGroups) {
8678
8782
  "socialweb",
8679
8783
  "ghost_socialweb_unblock_domain",
8680
8784
  {
8785
+ annotations: WRITE_HINT,
8681
8786
  description: "Unblock a social web domain.",
8682
8787
  inputSchema: z6.object({
8683
8788
  url: socialWebUrlSchema
@@ -8691,6 +8796,7 @@ function registerCoreTools(server, global, enabledGroups) {
8691
8796
  "socialweb",
8692
8797
  "ghost_socialweb_upload",
8693
8798
  {
8799
+ annotations: WRITE_HINT,
8694
8800
  description: "Upload an image for social web notes and replies.",
8695
8801
  inputSchema: z6.object({
8696
8802
  file_path: z6.string().min(1)
@@ -8706,6 +8812,7 @@ function registerCoreTools(server, global, enabledGroups) {
8706
8812
  "stats",
8707
8813
  "ghost_stats_overview",
8708
8814
  {
8815
+ annotations: READ_ONLY_HINT,
8709
8816
  description: "Get the Ghost analytics overview report.",
8710
8817
  inputSchema: z6.object({
8711
8818
  ...statsRangeArgs
@@ -8719,6 +8826,7 @@ function registerCoreTools(server, global, enabledGroups) {
8719
8826
  "stats",
8720
8827
  "ghost_stats_web",
8721
8828
  {
8829
+ annotations: READ_ONLY_HINT,
8722
8830
  description: "Get the Ghost web analytics report.",
8723
8831
  inputSchema: z6.object({
8724
8832
  ...statsWebArgs
@@ -8732,6 +8840,7 @@ function registerCoreTools(server, global, enabledGroups) {
8732
8840
  "stats",
8733
8841
  "ghost_stats_web_table",
8734
8842
  {
8843
+ annotations: READ_ONLY_HINT,
8735
8844
  description: "Get a focused Ghost web analytics table view.",
8736
8845
  inputSchema: z6.object({
8737
8846
  view: statsTableViewSchema,
@@ -8751,6 +8860,7 @@ function registerCoreTools(server, global, enabledGroups) {
8751
8860
  "stats",
8752
8861
  "ghost_stats_growth",
8753
8862
  {
8863
+ annotations: READ_ONLY_HINT,
8754
8864
  description: "Get Ghost member and revenue growth analytics.",
8755
8865
  inputSchema: z6.object({
8756
8866
  ...statsRangeArgs,
@@ -8767,6 +8877,7 @@ function registerCoreTools(server, global, enabledGroups) {
8767
8877
  "stats",
8768
8878
  "ghost_stats_posts",
8769
8879
  {
8880
+ annotations: READ_ONLY_HINT,
8770
8881
  description: "Get top Ghost posts by views.",
8771
8882
  inputSchema: z6.object({
8772
8883
  ...statsRangeArgs,
@@ -8783,6 +8894,7 @@ function registerCoreTools(server, global, enabledGroups) {
8783
8894
  "stats",
8784
8895
  "ghost_stats_email",
8785
8896
  {
8897
+ annotations: READ_ONLY_HINT,
8786
8898
  description: "Get Ghost email analytics grouped by newsletter.",
8787
8899
  inputSchema: z6.object({
8788
8900
  ...statsRangeArgs,
@@ -8804,6 +8916,7 @@ function registerCoreTools(server, global, enabledGroups) {
8804
8916
  "stats",
8805
8917
  "ghost_stats_email_clicks",
8806
8918
  {
8919
+ annotations: READ_ONLY_HINT,
8807
8920
  description: "Get Ghost email click analytics for a newsletter, optionally filtered by post ids.",
8808
8921
  inputSchema: z6.object({
8809
8922
  ...statsRangeArgs,
@@ -8827,6 +8940,7 @@ function registerCoreTools(server, global, enabledGroups) {
8827
8940
  "stats",
8828
8941
  "ghost_stats_email_subscribers",
8829
8942
  {
8943
+ annotations: READ_ONLY_HINT,
8830
8944
  description: "Get Ghost newsletter subscriber analytics.",
8831
8945
  inputSchema: z6.object({
8832
8946
  ...statsRangeArgs,
@@ -8846,6 +8960,7 @@ function registerCoreTools(server, global, enabledGroups) {
8846
8960
  "stats",
8847
8961
  "ghost_stats_post",
8848
8962
  {
8963
+ annotations: READ_ONLY_HINT,
8849
8964
  description: "Get Ghost analytics for a single post.",
8850
8965
  inputSchema: z6.object({
8851
8966
  id: z6.string(),
@@ -8860,6 +8975,7 @@ function registerCoreTools(server, global, enabledGroups) {
8860
8975
  "stats",
8861
8976
  "ghost_stats_post_web",
8862
8977
  {
8978
+ annotations: READ_ONLY_HINT,
8863
8979
  description: "Get Ghost web analytics for a single post.",
8864
8980
  inputSchema: z6.object({
8865
8981
  id: z6.string(),
@@ -8874,6 +8990,7 @@ function registerCoreTools(server, global, enabledGroups) {
8874
8990
  "stats",
8875
8991
  "ghost_stats_post_growth",
8876
8992
  {
8993
+ annotations: READ_ONLY_HINT,
8877
8994
  description: "Get Ghost growth analytics for a single post.",
8878
8995
  inputSchema: z6.object({
8879
8996
  id: z6.string(),
@@ -8888,6 +9005,7 @@ function registerCoreTools(server, global, enabledGroups) {
8888
9005
  "stats",
8889
9006
  "ghost_stats_post_newsletter",
8890
9007
  {
9008
+ annotations: READ_ONLY_HINT,
8891
9009
  description: "Get Ghost email performance analytics for a single post.",
8892
9010
  inputSchema: z6.object({
8893
9011
  id: z6.string(),
@@ -8904,6 +9022,7 @@ function registerCoreTools(server, global, enabledGroups) {
8904
9022
  "stats",
8905
9023
  "ghost_stats_post_referrers",
8906
9024
  {
9025
+ annotations: READ_ONLY_HINT,
8907
9026
  description: "Get Ghost referrer analytics for a single post.",
8908
9027
  inputSchema: z6.object({
8909
9028
  id: z6.string(),
@@ -10692,8 +10811,67 @@ function registerOfferCommands(program) {
10692
10811
  });
10693
10812
  }
10694
10813
 
10695
- // src/commands/page.ts
10814
+ // src/lib/content-input.ts
10696
10815
  import fs10 from "fs/promises";
10816
+ import MarkdownIt2 from "markdown-it";
10817
+ var markdownRenderer2 = new MarkdownIt2({ html: true, linkify: true, breaks: true });
10818
+ function renderMarkdown(markdown) {
10819
+ return markdownRenderer2.render(markdown);
10820
+ }
10821
+ async function readOptionalFile(filePath) {
10822
+ if (!filePath) {
10823
+ return void 0;
10824
+ }
10825
+ return fs10.readFile(filePath, "utf8");
10826
+ }
10827
+ async function readOptionalStdin(enabled) {
10828
+ if (!enabled) {
10829
+ return void 0;
10830
+ }
10831
+ const chunks = [];
10832
+ for await (const chunk of process.stdin) {
10833
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)));
10834
+ }
10835
+ const value = Buffer.concat(chunks).toString("utf8").trim();
10836
+ return value.length > 0 ? value : void 0;
10837
+ }
10838
+ function wrapRawHtmlCard(html) {
10839
+ return `<!--kg-card-begin: html-->
10840
+ ${html}
10841
+ <!--kg-card-end: html-->`;
10842
+ }
10843
+ function asResourcePayload(value, collectionKey) {
10844
+ if (!value || typeof value !== "object") {
10845
+ throw new GhstError("Invalid --from-json payload: expected JSON object.", {
10846
+ code: "VALIDATION_ERROR",
10847
+ exitCode: 7 /* VALIDATION_ERROR */
10848
+ });
10849
+ }
10850
+ const record = value;
10851
+ const collection = record[collectionKey];
10852
+ if (Array.isArray(collection) && collection.length > 0) {
10853
+ const first = collection[0];
10854
+ if (first && typeof first === "object") {
10855
+ return first;
10856
+ }
10857
+ }
10858
+ return record;
10859
+ }
10860
+ async function readOptionalResourceJson(filePath, collectionKey) {
10861
+ if (!filePath) {
10862
+ return {};
10863
+ }
10864
+ const payload = JSON.parse(await fs10.readFile(filePath, "utf8"));
10865
+ return asResourcePayload(payload, collectionKey);
10866
+ }
10867
+ function assignDefined(target, values) {
10868
+ for (const [key, value] of Object.entries(values)) {
10869
+ if (value !== void 0) {
10870
+ target[key] = value;
10871
+ }
10872
+ }
10873
+ return target;
10874
+ }
10697
10875
 
10698
10876
  // src/schemas/page.ts
10699
10877
  import { z as z11 } from "zod";
@@ -10702,13 +10880,18 @@ var VisibilitySchema = z11.enum(["public", "members", "paid", "tiers"]);
10702
10880
  function withSingleContentSource(schema) {
10703
10881
  return schema.superRefine((value, ctx) => {
10704
10882
  const data = value;
10705
- const contentSources = [data.html, data.htmlFile, data.lexicalFile].filter(
10706
- (entry) => entry !== void 0
10707
- );
10883
+ const contentSources = [
10884
+ data.html,
10885
+ data.htmlFile,
10886
+ data.lexicalFile,
10887
+ data.markdownFile,
10888
+ data.markdownStdin,
10889
+ data.htmlRawFile
10890
+ ].filter((entry) => entry !== void 0 && entry !== false);
10708
10891
  if (contentSources.length > 1) {
10709
10892
  ctx.addIssue({
10710
10893
  code: z11.ZodIssueCode.custom,
10711
- message: "Use only one of --html, --html-file, or --lexical-file."
10894
+ message: "Use only one content source: --html, --html-file, --lexical-file, --markdown-file, --markdown-stdin, or --html-raw-file."
10712
10895
  });
10713
10896
  }
10714
10897
  });
@@ -10733,14 +10916,23 @@ var PageGetInputSchema = z11.object({
10733
10916
  });
10734
10917
  var PageCreateInputSchema = withSingleContentSource(
10735
10918
  z11.object({
10736
- title: z11.string().min(1),
10737
- status: StatusSchema.default("draft"),
10919
+ title: z11.string().min(1).optional(),
10920
+ slug: z11.string().min(1).optional(),
10921
+ status: StatusSchema.optional(),
10738
10922
  publishAt: z11.string().datetime().optional(),
10739
10923
  html: z11.string().optional(),
10740
10924
  htmlFile: z11.string().min(1).optional(),
10741
10925
  lexicalFile: z11.string().min(1).optional(),
10926
+ markdownFile: z11.string().min(1).optional(),
10927
+ markdownStdin: z11.boolean().optional(),
10928
+ htmlRawFile: z11.string().min(1).optional(),
10929
+ fromJson: z11.string().min(1).optional(),
10930
+ tags: z11.string().optional(),
10742
10931
  featured: z11.boolean().optional(),
10743
10932
  visibility: VisibilitySchema.optional()
10933
+ }).refine((data) => Boolean(data.title || data.fromJson), {
10934
+ message: "Provide --title or --from-json.",
10935
+ path: ["title"]
10744
10936
  }).refine((data) => !(data.status === "scheduled" && !data.publishAt), {
10745
10937
  message: "publish-at is required when status is scheduled",
10746
10938
  path: ["publishAt"]
@@ -10756,6 +10948,11 @@ var PageUpdateInputSchema = withSingleContentSource(
10756
10948
  html: z11.string().optional(),
10757
10949
  htmlFile: z11.string().min(1).optional(),
10758
10950
  lexicalFile: z11.string().min(1).optional(),
10951
+ markdownFile: z11.string().min(1).optional(),
10952
+ markdownStdin: z11.boolean().optional(),
10953
+ htmlRawFile: z11.string().min(1).optional(),
10954
+ fromJson: z11.string().min(1).optional(),
10955
+ tags: z11.string().optional(),
10759
10956
  featured: z11.boolean().optional(),
10760
10957
  visibility: VisibilitySchema.optional()
10761
10958
  }).refine((data) => Boolean(data.id || data.slug), {
@@ -10763,7 +10960,9 @@ var PageUpdateInputSchema = withSingleContentSource(
10763
10960
  path: ["id"]
10764
10961
  }).refine(
10765
10962
  (data) => Boolean(
10766
- data.title || data.status || data.publishAt || data.html || data.htmlFile || data.lexicalFile || data.featured !== void 0 || data.visibility
10963
+ data.title || // A positional id present alongside --slug is a rename, so the slug
10964
+ // is an update field rather than the lookup key.
10965
+ data.id && data.slug || data.status || data.publishAt || data.html || data.htmlFile || data.lexicalFile || data.markdownFile || data.markdownStdin || data.htmlRawFile || data.fromJson || data.tags || data.featured !== void 0 || data.visibility
10767
10966
  ),
10768
10967
  {
10769
10968
  message: "Provide at least one update field."
@@ -10804,12 +11003,6 @@ function throwValidationError8(error) {
10804
11003
  }
10805
11004
  );
10806
11005
  }
10807
- async function readOptionalFile(filePath) {
10808
- if (!filePath) {
10809
- return void 0;
10810
- }
10811
- return fs10.readFile(filePath, "utf8");
10812
- }
10813
11006
  function registerPageCommands(program) {
10814
11007
  const page = program.command("page").description("Page management");
10815
11008
  page.command("list").description("List pages").option("--limit <numberOrAll>", 'Number of pages per page or "all"').option("--page <number>", "Page number").option("--filter <nql>", "NQL filter").option("--status <status>", "Page status filter").option("--featured", "Only featured pages").option("--include <relations>", "Include relationships").option("--fields <fields>", "Select output fields").option("--order <order>", "Sort order").option("--formats <formats>", "Return requested content formats").action(async (options, command) => {
@@ -10878,46 +11071,61 @@ function registerPageCommands(program) {
10878
11071
  }
10879
11072
  printPageHuman(payload);
10880
11073
  });
10881
- page.command("create").description("Create a page").requiredOption("--title <title>", "Page title").option("--status <status>", "Page status", "draft").option("--publish-at <datetime>", "Publish date-time for scheduled pages").option("--html <html>", "Page HTML content").option("--html-file <path>", "Path to HTML file").option("--lexical-file <path>", "Path to Lexical JSON file").option("--featured", "Mark as featured").option("--visibility <visibility>", "public|members|paid|tiers").action(async (options, command) => {
11074
+ page.command("create").description("Create a page").option("--title <title>", "Page title").option("--slug <slug>", "Page slug").option("--status <status>", "Page status").option("--publish-at <datetime>", "Publish date-time for scheduled pages").option("--html <html>", "Page HTML content").option("--html-file <path>", "Path to HTML file").option("--lexical-file <path>", "Path to Lexical JSON file").option("--markdown-file <path>", "Path to Markdown file").option("--markdown-stdin", "Read Markdown content from stdin").option("--html-raw-file <path>", "Path to raw HTML file wrapped in an HTML card").option("--from-json <path>", "Read page payload from JSON file").option("--tags <tags>", "Comma separated tag names").option("--featured", "Mark as featured").option("--visibility <visibility>", "public|members|paid|tiers").action(async (options, command) => {
10882
11075
  const global = getGlobalOptions(command);
10883
11076
  const parsed = PageCreateInputSchema.safeParse({
10884
11077
  title: options.title,
11078
+ slug: options.slug,
10885
11079
  status: options.status,
10886
11080
  publishAt: options.publishAt,
10887
11081
  html: options.html,
10888
11082
  htmlFile: options.htmlFile,
10889
11083
  lexicalFile: options.lexicalFile,
10890
- featured: options.featured,
11084
+ markdownFile: options.markdownFile,
11085
+ markdownStdin: parseBooleanFlag(options.markdownStdin),
11086
+ htmlRawFile: options.htmlRawFile,
11087
+ fromJson: options.fromJson,
11088
+ tags: options.tags,
11089
+ featured: parseBooleanFlag(options.featured),
10891
11090
  visibility: options.visibility
10892
11091
  });
10893
11092
  if (!parsed.success) {
10894
11093
  throwValidationError8(parsed.error);
10895
11094
  }
11095
+ const fromJson = await readOptionalResourceJson(parsed.data.fromJson, "pages");
10896
11096
  const htmlFromFile = await readOptionalFile(parsed.data.htmlFile);
10897
11097
  const lexicalFromFile = await readOptionalFile(parsed.data.lexicalFile);
10898
- const html = parsed.data.html ?? htmlFromFile;
10899
- const lexical = lexicalFromFile;
11098
+ const markdownFromFile = await readOptionalFile(parsed.data.markdownFile);
11099
+ const markdownFromStdin = await readOptionalStdin(parsed.data.markdownStdin);
11100
+ const rawHtmlFromFile = await readOptionalFile(parsed.data.htmlRawFile);
11101
+ const markdown = markdownFromStdin ?? markdownFromFile;
11102
+ const renderedMarkdown = markdown ? renderMarkdown(markdown) : void 0;
11103
+ const wrappedRawHtml = rawHtmlFromFile ? wrapRawHtmlCard(rawHtmlFromFile) : void 0;
11104
+ const html = parsed.data.html ?? htmlFromFile ?? wrappedRawHtml ?? renderedMarkdown ?? (typeof fromJson.html === "string" ? fromJson.html : void 0);
11105
+ const lexical = lexicalFromFile ?? (typeof fromJson.lexical === "string" ? fromJson.lexical : void 0);
10900
11106
  const source = html ? "html" : void 0;
10901
- const payload = await createPage(
10902
- global,
11107
+ const createPayload = assignDefined(
11108
+ { ...fromJson },
10903
11109
  {
10904
11110
  title: parsed.data.title,
10905
- status: parsed.data.status,
11111
+ slug: parsed.data.slug,
11112
+ status: parsed.data.status ?? (typeof fromJson.status === "string" ? fromJson.status : void 0) ?? "draft",
10906
11113
  published_at: parsed.data.publishAt,
10907
11114
  html,
10908
11115
  lexical,
11116
+ tags: parseCsv(parsed.data.tags),
10909
11117
  featured: parsed.data.featured,
10910
11118
  visibility: parsed.data.visibility
10911
- },
10912
- source
11119
+ }
10913
11120
  );
11121
+ const payload = await createPage(global, createPayload, source);
10914
11122
  if (global.json) {
10915
11123
  printJson(payload, global.jq);
10916
11124
  return;
10917
11125
  }
10918
11126
  printPageHuman(payload);
10919
11127
  });
10920
- page.command("update [id]").description("Update a page by id or slug").option("--slug <slug>", "Page slug lookup").option("--title <title>", "Page title").option("--status <status>", "Page status").option("--publish-at <datetime>", "Publish date-time for scheduled pages").option("--html <html>", "Page HTML content").option("--html-file <path>", "Path to HTML file").option("--lexical-file <path>", "Path to Lexical JSON file").option("--featured <value>", "true|false").option("--visibility <visibility>", "public|members|paid|tiers").action(async (id, options, command) => {
11128
+ page.command("update [id]").description("Update a page by id or slug").option("--slug <slug>", "Page slug lookup, or new slug when a positional id is given").option("--title <title>", "Page title").option("--status <status>", "Page status").option("--publish-at <datetime>", "Publish date-time for scheduled pages").option("--html <html>", "Page HTML content").option("--html-file <path>", "Path to HTML file").option("--lexical-file <path>", "Path to Lexical JSON file").option("--markdown-file <path>", "Path to Markdown file").option("--markdown-stdin", "Read Markdown content from stdin").option("--html-raw-file <path>", "Path to raw HTML file wrapped in an HTML card").option("--from-json <path>", "Read page patch from JSON file").option("--tags <tags>", "Comma separated tag names").option("--featured <value>", "true|false").option("--visibility <visibility>", "public|members|paid|tiers").action(async (id, options, command) => {
10921
11129
  const global = getGlobalOptions(command);
10922
11130
  const parsed = PageUpdateInputSchema.safeParse({
10923
11131
  id,
@@ -10928,29 +11136,49 @@ function registerPageCommands(program) {
10928
11136
  html: options.html,
10929
11137
  htmlFile: options.htmlFile,
10930
11138
  lexicalFile: options.lexicalFile,
11139
+ markdownFile: options.markdownFile,
11140
+ markdownStdin: parseBooleanFlag(options.markdownStdin),
11141
+ htmlRawFile: options.htmlRawFile,
11142
+ fromJson: options.fromJson,
11143
+ tags: options.tags,
10931
11144
  featured: parseBooleanFlag(options.featured),
10932
11145
  visibility: options.visibility
10933
11146
  });
10934
11147
  if (!parsed.success) {
10935
11148
  throwValidationError8(parsed.error);
10936
11149
  }
11150
+ const fromJson = await readOptionalResourceJson(parsed.data.fromJson, "pages");
10937
11151
  const htmlFromFile = await readOptionalFile(parsed.data.htmlFile);
10938
11152
  const lexicalFromFile = await readOptionalFile(parsed.data.lexicalFile);
10939
- const html = parsed.data.html ?? htmlFromFile;
10940
- const lexical = lexicalFromFile;
11153
+ const markdownFromFile = await readOptionalFile(parsed.data.markdownFile);
11154
+ const markdownFromStdin = await readOptionalStdin(parsed.data.markdownStdin);
11155
+ const rawHtmlFromFile = await readOptionalFile(parsed.data.htmlRawFile);
11156
+ const markdown = markdownFromStdin ?? markdownFromFile;
11157
+ const renderedMarkdown = markdown ? renderMarkdown(markdown) : void 0;
11158
+ const wrappedRawHtml = rawHtmlFromFile ? wrapRawHtmlCard(rawHtmlFromFile) : void 0;
11159
+ const html = parsed.data.html ?? htmlFromFile ?? wrappedRawHtml ?? renderedMarkdown ?? (typeof fromJson.html === "string" ? fromJson.html : void 0);
11160
+ const lexical = lexicalFromFile ?? (typeof fromJson.lexical === "string" ? fromJson.lexical : void 0);
10941
11161
  const source = html ? "html" : void 0;
10942
- const payload = await updatePage(global, {
10943
- id: parsed.data.id,
10944
- slug: parsed.data.slug,
10945
- patch: {
11162
+ const lookupSlug = parsed.data.id ? void 0 : parsed.data.slug;
11163
+ const renameSlug = parsed.data.id ? parsed.data.slug : void 0;
11164
+ const patch = assignDefined(
11165
+ { ...fromJson },
11166
+ {
10946
11167
  title: parsed.data.title,
11168
+ slug: renameSlug,
10947
11169
  status: parsed.data.status,
10948
11170
  published_at: parsed.data.publishAt,
10949
11171
  html,
10950
11172
  lexical,
11173
+ tags: parseCsv(parsed.data.tags),
10951
11174
  featured: parsed.data.featured,
10952
11175
  visibility: parsed.data.visibility
10953
- },
11176
+ }
11177
+ );
11178
+ const payload = await updatePage(global, {
11179
+ id: parsed.data.id,
11180
+ slug: lookupSlug,
11181
+ patch,
10954
11182
  source
10955
11183
  });
10956
11184
  if (global.json) {
@@ -11039,10 +11267,6 @@ function registerPageCommands(program) {
11039
11267
  });
11040
11268
  }
11041
11269
 
11042
- // src/commands/post.ts
11043
- import fs11 from "fs/promises";
11044
- import MarkdownIt2 from "markdown-it";
11045
-
11046
11270
  // src/schemas/post.ts
11047
11271
  import { z as z12 } from "zod";
11048
11272
  var StatusSchema2 = z12.enum(["draft", "published", "scheduled"]);
@@ -11236,7 +11460,6 @@ var PostBulkInputSchema = z12.object({
11236
11460
  );
11237
11461
 
11238
11462
  // src/commands/post.ts
11239
- var markdownRenderer2 = new MarkdownIt2({ html: true, linkify: true, breaks: true });
11240
11463
  function throwValidationError9(error) {
11241
11464
  throw new GhstError(
11242
11465
  error.issues?.map((i) => i.message).join("; ") ?? "Validation failed",
@@ -11247,59 +11470,6 @@ function throwValidationError9(error) {
11247
11470
  }
11248
11471
  );
11249
11472
  }
11250
- async function readOptionalFile2(filePath) {
11251
- if (!filePath) {
11252
- return void 0;
11253
- }
11254
- return fs11.readFile(filePath, "utf8");
11255
- }
11256
- async function readOptionalStdin(enabled) {
11257
- if (!enabled) {
11258
- return void 0;
11259
- }
11260
- const chunks = [];
11261
- for await (const chunk of process.stdin) {
11262
- chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)));
11263
- }
11264
- const value = Buffer.concat(chunks).toString("utf8").trim();
11265
- return value.length > 0 ? value : void 0;
11266
- }
11267
- function wrapRawHtmlCard(html) {
11268
- return `<!--kg-card-begin: html-->
11269
- ${html}
11270
- <!--kg-card-end: html-->`;
11271
- }
11272
- function asPostPayload(value) {
11273
- if (!value || typeof value !== "object") {
11274
- throw new GhstError("Invalid --from-json payload: expected JSON object.", {
11275
- code: "VALIDATION_ERROR",
11276
- exitCode: 7 /* VALIDATION_ERROR */
11277
- });
11278
- }
11279
- const record = value;
11280
- if (Array.isArray(record.posts) && record.posts.length > 0) {
11281
- const first = record.posts[0];
11282
- if (first && typeof first === "object") {
11283
- return first;
11284
- }
11285
- }
11286
- return record;
11287
- }
11288
- async function readOptionalPostJson(filePath) {
11289
- if (!filePath) {
11290
- return {};
11291
- }
11292
- const payload = JSON.parse(await fs11.readFile(filePath, "utf8"));
11293
- return asPostPayload(payload);
11294
- }
11295
- function assignDefined(target, values) {
11296
- for (const [key, value] of Object.entries(values)) {
11297
- if (value !== void 0) {
11298
- target[key] = value;
11299
- }
11300
- }
11301
- return target;
11302
- }
11303
11473
  function registerPostCommands(program) {
11304
11474
  const post = program.command("post").description("Post management");
11305
11475
  post.command("list").description("List posts").option("--limit <numberOrAll>", 'Number of posts per page or "all"').option("--page <number>", "Page number").option("--filter <nql>", "NQL filter").option("--status <status>", "Post status filter").option("--featured", "Only featured posts").option("--include <relations>", "Include relationships").option("--fields <fields>", "Select output fields").option("--order <order>", "Sort order").option("--formats <formats>", "Return requested content formats").action(async (options, command) => {
@@ -11354,8 +11524,9 @@ function registerPostCommands(program) {
11354
11524
  code: "USAGE_ERROR"
11355
11525
  });
11356
11526
  }
11527
+ const bySlug = parsed.data.slug ? true : !looksLikeGhostId(lookup);
11357
11528
  const payload = await getPost(global, lookup, {
11358
- bySlug: Boolean(parsed.data.slug),
11529
+ bySlug,
11359
11530
  params: {
11360
11531
  include: parsed.data.include,
11361
11532
  fields: parsed.data.fields,
@@ -11397,14 +11568,14 @@ function registerPostCommands(program) {
11397
11568
  if (!parsed.success) {
11398
11569
  throwValidationError9(parsed.error);
11399
11570
  }
11400
- const fromJson = await readOptionalPostJson(parsed.data.fromJson);
11401
- const htmlFromFile = await readOptionalFile2(parsed.data.htmlFile);
11402
- const lexicalFromFile = await readOptionalFile2(parsed.data.lexicalFile);
11403
- const markdownFromFile = await readOptionalFile2(parsed.data.markdownFile);
11571
+ const fromJson = await readOptionalResourceJson(parsed.data.fromJson, "posts");
11572
+ const htmlFromFile = await readOptionalFile(parsed.data.htmlFile);
11573
+ const lexicalFromFile = await readOptionalFile(parsed.data.lexicalFile);
11574
+ const markdownFromFile = await readOptionalFile(parsed.data.markdownFile);
11404
11575
  const markdownFromStdin = await readOptionalStdin(parsed.data.markdownStdin);
11405
- const rawHtmlFromFile = await readOptionalFile2(parsed.data.htmlRawFile);
11576
+ const rawHtmlFromFile = await readOptionalFile(parsed.data.htmlRawFile);
11406
11577
  const markdown = markdownFromStdin ?? markdownFromFile;
11407
- const renderedMarkdown = markdown ? markdownRenderer2.render(markdown) : void 0;
11578
+ const renderedMarkdown = markdown ? renderMarkdown(markdown) : void 0;
11408
11579
  const wrappedRawHtml = rawHtmlFromFile ? wrapRawHtmlCard(rawHtmlFromFile) : void 0;
11409
11580
  const html = parsed.data.html ?? htmlFromFile ?? wrappedRawHtml ?? renderedMarkdown ?? (typeof fromJson.html === "string" ? fromJson.html : void 0);
11410
11581
  const lexical = lexicalFromFile ?? (typeof fromJson.lexical === "string" ? fromJson.lexical : void 0);
@@ -11472,14 +11643,14 @@ function registerPostCommands(program) {
11472
11643
  if (!parsed.success) {
11473
11644
  throwValidationError9(parsed.error);
11474
11645
  }
11475
- const fromJson = await readOptionalPostJson(parsed.data.fromJson);
11476
- const htmlFromFile = await readOptionalFile2(parsed.data.htmlFile);
11477
- const lexicalFromFile = await readOptionalFile2(parsed.data.lexicalFile);
11478
- const markdownFromFile = await readOptionalFile2(parsed.data.markdownFile);
11646
+ const fromJson = await readOptionalResourceJson(parsed.data.fromJson, "posts");
11647
+ const htmlFromFile = await readOptionalFile(parsed.data.htmlFile);
11648
+ const lexicalFromFile = await readOptionalFile(parsed.data.lexicalFile);
11649
+ const markdownFromFile = await readOptionalFile(parsed.data.markdownFile);
11479
11650
  const markdownFromStdin = await readOptionalStdin(parsed.data.markdownStdin);
11480
- const rawHtmlFromFile = await readOptionalFile2(parsed.data.htmlRawFile);
11651
+ const rawHtmlFromFile = await readOptionalFile(parsed.data.htmlRawFile);
11481
11652
  const markdown = markdownFromStdin ?? markdownFromFile;
11482
- const renderedMarkdown = markdown ? markdownRenderer2.render(markdown) : void 0;
11653
+ const renderedMarkdown = markdown ? renderMarkdown(markdown) : void 0;
11483
11654
  const wrappedRawHtml = rawHtmlFromFile ? wrapRawHtmlCard(rawHtmlFromFile) : void 0;
11484
11655
  const html = parsed.data.html ?? htmlFromFile ?? wrappedRawHtml ?? renderedMarkdown ?? (typeof fromJson.html === "string" ? fromJson.html : void 0);
11485
11656
  const lexical = lexicalFromFile ?? (typeof fromJson.lexical === "string" ? fromJson.lexical : void 0);
@@ -11798,7 +11969,7 @@ function registerSiteCommands(program) {
11798
11969
  }
11799
11970
 
11800
11971
  // src/commands/socialweb.ts
11801
- import fs12 from "fs/promises";
11972
+ import fs11 from "fs/promises";
11802
11973
 
11803
11974
  // src/schemas/socialweb.ts
11804
11975
  import { z as z14 } from "zod";
@@ -12348,7 +12519,7 @@ function registerSocialWebCommands(program) {
12348
12519
  throwValidationError11(parsed.error);
12349
12520
  }
12350
12521
  try {
12351
- await fs12.access(parsed.data.filePath);
12522
+ await fs11.access(parsed.data.filePath);
12352
12523
  } catch {
12353
12524
  throw new GhstError(`File not found: ${parsed.data.filePath}`, {
12354
12525
  code: "VALIDATION_ERROR",
@@ -12365,7 +12536,7 @@ function registerSocialWebCommands(program) {
12365
12536
  }
12366
12537
 
12367
12538
  // src/commands/stats.ts
12368
- import fs13 from "fs/promises";
12539
+ import fs12 from "fs/promises";
12369
12540
 
12370
12541
  // src/schemas/stats.ts
12371
12542
  import { z as z15 } from "zod";
@@ -12695,7 +12866,7 @@ function postReferrersCsv(payload) {
12695
12866
  async function emitCsv(csv, output) {
12696
12867
  if (output) {
12697
12868
  await assertFileDoesNotExist(output);
12698
- await fs13.writeFile(output, `${csv}
12869
+ await fs12.writeFile(output, `${csv}
12699
12870
  `, "utf8");
12700
12871
  return;
12701
12872
  }
@@ -13267,13 +13438,13 @@ function registerTagCommands(program) {
13267
13438
 
13268
13439
  // src/commands/theme.ts
13269
13440
  import { spawn as spawn4 } from "child_process";
13270
- import fs15 from "fs/promises";
13441
+ import fs14 from "fs/promises";
13271
13442
  import os4 from "os";
13272
13443
  import path8 from "path";
13273
13444
 
13274
13445
  // src/lib/theme-dev.ts
13275
13446
  import { spawn as spawn3 } from "child_process";
13276
- import fs14 from "fs";
13447
+ import fs13 from "fs";
13277
13448
  import fsPromises from "fs/promises";
13278
13449
  import os3 from "os";
13279
13450
  import path7 from "path";
@@ -13330,7 +13501,7 @@ async function runThemeDev(global, options) {
13330
13501
  if (!options.watch) {
13331
13502
  return initial.payload;
13332
13503
  }
13333
- const watcher = fs14.watch(options.path, { recursive: true });
13504
+ const watcher = fs13.watch(options.path, { recursive: true });
13334
13505
  let timer = null;
13335
13506
  let running = false;
13336
13507
  let queued = false;
@@ -13442,7 +13613,7 @@ function throwValidationError14(error) {
13442
13613
  );
13443
13614
  }
13444
13615
  async function zipDirectory2(directoryPath) {
13445
- const tempDir = await fs15.mkdtemp(path8.join(os4.tmpdir(), "ghst-theme-"));
13616
+ const tempDir = await fs14.mkdtemp(path8.join(os4.tmpdir(), "ghst-theme-"));
13446
13617
  const zipPath = path8.join(tempDir, `${path8.basename(directoryPath)}.zip`);
13447
13618
  await new Promise((resolve, reject) => {
13448
13619
  const child = spawn4("zip", ["-r", zipPath, "."], {
@@ -13463,7 +13634,7 @@ async function zipDirectory2(directoryPath) {
13463
13634
  async function validateTheme(targetPath) {
13464
13635
  const gscanModule = await import("gscan");
13465
13636
  const gscan = gscanModule.default ?? gscanModule;
13466
- const stat = await fs15.stat(targetPath);
13637
+ const stat = await fs14.stat(targetPath);
13467
13638
  if (stat.isDirectory()) {
13468
13639
  const result2 = await gscan.check?.(targetPath, {
13469
13640
  checkVersion: "v6"
@@ -13519,7 +13690,7 @@ function registerThemeCommands(program) {
13519
13690
  if (!parsed.success) {
13520
13691
  throwValidationError14(parsed.error);
13521
13692
  }
13522
- const stat = await fs15.stat(parsed.data.path);
13693
+ const stat = await fs14.stat(parsed.data.path);
13523
13694
  let uploadPath = parsed.data.path;
13524
13695
  if (stat.isDirectory()) {
13525
13696
  if (!parsed.data.zip) {
@@ -14522,7 +14693,10 @@ var PACKAGE_VERSION = packageJson.version ?? "0.0.0";
14522
14693
  function buildProgram() {
14523
14694
  const program = new Command();
14524
14695
  program.name("ghst").description(`A modern CLI for Ghost CMS
14525
- Version: ${PACKAGE_VERSION}`).version(PACKAGE_VERSION, "-v, --version", "Output version").showHelpAfterError().showSuggestionAfterError(true).option("--json", "Output JSON").option("--jq <filter>", "Apply jq-style field extraction to JSON output").option("--site <site>", "Configured site alias").option("--url <url>", "Ghost site URL override").option("--staff-token <token>", "Ghost staff access token override").option("--enable-destructive-actions", "Allow destructive operations such as deletes").option("--debug [level]", "Enable debug output").option("--no-color", "Disable color output");
14696
+ Version: ${PACKAGE_VERSION}`).version(PACKAGE_VERSION, "-v, --version", "Output version").showHelpAfterError().showSuggestionAfterError(true).option("--json", "Output JSON").option(
14697
+ "--jq <filter>",
14698
+ "Apply a jq filter to JSON output (runs against the full response, e.g. .posts[].slug)"
14699
+ ).option("--site <site>", "Configured site alias").option("--url <url>", "Ghost site URL override").option("--staff-token <token>", "Ghost staff access token override").option("--enable-destructive-actions", "Allow destructive operations such as deletes").option("--debug [level]", "Enable debug output").option("--no-color", "Disable color output");
14526
14700
  registerAuthCommands(program);
14527
14701
  registerCommentCommands(program);
14528
14702
  registerPostCommands(program);