@letterstory/cli 0.29.0 → 0.29.2
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/README.md +2 -1
- package/lib/cli.mjs +10 -2
- package/lib/commands/feedback.mjs +57 -0
- package/lib/commands/posts.mjs +22 -3
- package/lib/commands.mjs +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -142,9 +142,10 @@ letterstory phantom domain connect <phantom-id> myblog.com # attach one you
|
|
|
142
142
|
```bash
|
|
143
143
|
letterstory posts list [--limit <n>] [--collection <uuid>]
|
|
144
144
|
letterstory posts show <article-id>
|
|
145
|
-
letterstory posts new --title "…" --collection <uuid> --body "…"
|
|
145
|
+
letterstory posts new --title "…" --collection <uuid> --body "…" [--article-id <uuid>] # or --file <path|->; --article-id updates that article instead of creating one
|
|
146
146
|
letterstory posts publish <article-id>
|
|
147
147
|
letterstory posts unpublish <article-id>
|
|
148
|
+
letterstory posts delete --id <uuid> [--id <uuid> ...] # permanent; content, history, and any published copy are all removed
|
|
148
149
|
|
|
149
150
|
letterstory published list [--limit <n>] [--collection <uuid>] [--format html|md]
|
|
150
151
|
letterstory published show --slug my-post-slug [--format html|md] # or --id <uuid>
|
package/lib/cli.mjs
CHANGED
|
@@ -40,10 +40,11 @@ import {
|
|
|
40
40
|
cmdLede,
|
|
41
41
|
cmdLandings,
|
|
42
42
|
cmdAdmin,
|
|
43
|
+
cmdFeedback,
|
|
43
44
|
} from "./commands.mjs";
|
|
44
45
|
|
|
45
46
|
// Keep in sync with cli/package.json.
|
|
46
|
-
export const VERSION = "0.29.
|
|
47
|
+
export const VERSION = "0.29.2";
|
|
47
48
|
|
|
48
49
|
// Flags that never take a value. Listing them explicitly means `deploy get --json <id>`
|
|
49
50
|
// can't accidentally swallow the id as --json's value.
|
|
@@ -205,9 +206,10 @@ Phantomstory (a collection Letterstory hosts as an independent publication):
|
|
|
205
206
|
Content:
|
|
206
207
|
posts list [--limit <n>] [--collection <uuid>] List your articles
|
|
207
208
|
posts show <article-id> Show one article
|
|
208
|
-
posts new --title <t> --collection <uuid> (--body <text> | --file <path|->)
|
|
209
|
+
posts new --title <t> --collection <uuid> (--body <text> | --file <path|->) [--article-id <uuid>]
|
|
209
210
|
posts publish <article-id> Publish an article
|
|
210
211
|
posts unpublish <article-id> Unpublish an article
|
|
212
|
+
posts delete --id <uuid> [--id <uuid> ...] Permanently delete article(s)
|
|
211
213
|
published list [--limit <n>] [--collection <uuid>] [--format html|md]
|
|
212
214
|
published show (--id <uuid> | --slug <slug>) [--format html|md]
|
|
213
215
|
|
|
@@ -580,6 +582,11 @@ Insights:
|
|
|
580
582
|
insights post <article-id> [--period 14d|30d|90d]
|
|
581
583
|
insights top [--period 14d|30d|90d] [--collection <uuid>] [--limit <n>] [--sort clicks|impressions]
|
|
582
584
|
|
|
585
|
+
Feedback (tell us what's broken, missing, unclear, or wanted):
|
|
586
|
+
feedback submit --category bug|missing_feature|unclear|feature_request|praise|other
|
|
587
|
+
[--message <text>|--body <text>|--file <path>|--file -] [--rating 1-5]
|
|
588
|
+
[--context '<json>']
|
|
589
|
+
|
|
583
590
|
Anything else:
|
|
584
591
|
tools list List every tool this server exposes, by name
|
|
585
592
|
tools show <name> Show one tool's capability, argument schema, and return shape
|
|
@@ -644,6 +651,7 @@ const CLIENT_COMMANDS = {
|
|
|
644
651
|
lede: cmdLede,
|
|
645
652
|
ledes: cmdLede,
|
|
646
653
|
landings: cmdLandings,
|
|
654
|
+
feedback: cmdFeedback,
|
|
647
655
|
// Platform-scoped (staff key) — the only commands that act BEFORE an org exists.
|
|
648
656
|
admin: cmdAdmin,
|
|
649
657
|
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// `feedback` — submit product feedback about Letterstory itself: a bug, something
|
|
2
|
+
// missing, something unclear, a feature request, or praise. One subcommand, one tool
|
|
3
|
+
// (submit_feedback) — there is no read/list surface yet, staff triage this table directly.
|
|
4
|
+
|
|
5
|
+
import { CliError } from "../client.mjs";
|
|
6
|
+
import { flagStr, readBodyInput, printResult, ok, argsFromFlags } from "./shared.mjs";
|
|
7
|
+
|
|
8
|
+
function readJsonObjectFlag(flags, name) {
|
|
9
|
+
const inline = flagStr(flags[name]);
|
|
10
|
+
if (inline === undefined) return undefined;
|
|
11
|
+
let parsed;
|
|
12
|
+
try {
|
|
13
|
+
parsed = JSON.parse(inline);
|
|
14
|
+
} catch (err) {
|
|
15
|
+
throw new CliError(`--${name} is not valid JSON: ${err.message}`);
|
|
16
|
+
}
|
|
17
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
|
|
18
|
+
throw new CliError(`--${name} must be a JSON object`);
|
|
19
|
+
return parsed;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const ARGS = {
|
|
23
|
+
submit_feedback: {
|
|
24
|
+
category: { flag: "category", required: true },
|
|
25
|
+
// --message, or the larger-blob trio --body/--file/stdin (same convention as
|
|
26
|
+
// `landings create`'s --context).
|
|
27
|
+
message: { value: (flags) => flagStr(flags.message) ?? readBodyInput(flags) },
|
|
28
|
+
rating: { flag: "rating", type: "num" },
|
|
29
|
+
context: { value: (flags) => readJsonObjectFlag(flags, "context") },
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export async function cmdFeedback(ctx) {
|
|
34
|
+
const sub = ctx.positionals[0];
|
|
35
|
+
const rest = { ...ctx, positionals: ctx.positionals.slice(1) };
|
|
36
|
+
switch (sub) {
|
|
37
|
+
case "submit":
|
|
38
|
+
return feedbackSubmit(rest);
|
|
39
|
+
default:
|
|
40
|
+
throw new CliError(`Unknown feedback subcommand: ${sub ?? "(none)"}. Try: submit`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function feedbackSubmit(ctx) {
|
|
45
|
+
const { client, flags, io } = ctx;
|
|
46
|
+
// ARGS.category has required: true, so a missing --category throws before we get here.
|
|
47
|
+
const args = argsFromFlags(ARGS.submit_feedback, flags, ctx.positionals);
|
|
48
|
+
if (!args.message) {
|
|
49
|
+
throw new CliError("Missing feedback message — pass --message, --body, --file <path>, or pipe it on stdin.");
|
|
50
|
+
}
|
|
51
|
+
const result = await client.callTool("submit_feedback", args);
|
|
52
|
+
ok(ctx, `Submitted ${args.category} feedback.`);
|
|
53
|
+
printResult(io, flags, result);
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { ARGS };
|
package/lib/commands/posts.mjs
CHANGED
|
@@ -20,6 +20,9 @@ export const ARGS = {
|
|
|
20
20
|
publish_article: {
|
|
21
21
|
article_id: { positional: 0, label: "article-id", required: true },
|
|
22
22
|
},
|
|
23
|
+
delete_article: {
|
|
24
|
+
article_ids: { flag: "id", type: "list", required: true, label: "id" },
|
|
25
|
+
},
|
|
23
26
|
};
|
|
24
27
|
|
|
25
28
|
export async function cmdPosts(ctx) {
|
|
@@ -37,9 +40,12 @@ export async function cmdPosts(ctx) {
|
|
|
37
40
|
return postsPublish(rest);
|
|
38
41
|
case "unpublish":
|
|
39
42
|
return postsUnpublish(rest);
|
|
43
|
+
case "delete":
|
|
44
|
+
case "rm":
|
|
45
|
+
return postsDelete(rest);
|
|
40
46
|
default:
|
|
41
47
|
throw new CliError(
|
|
42
|
-
`Unknown posts subcommand: ${sub ?? "(none)"}. Try: list, show, new, publish, unpublish`
|
|
48
|
+
`Unknown posts subcommand: ${sub ?? "(none)"}. Try: list, show, new, publish, unpublish, delete`
|
|
43
49
|
);
|
|
44
50
|
}
|
|
45
51
|
}
|
|
@@ -66,8 +72,10 @@ async function postsNew(ctx) {
|
|
|
66
72
|
const collection = requireFlag(flags, "collection");
|
|
67
73
|
const body = readBodyInput(flags);
|
|
68
74
|
if (!body) throw new CliError("Provide --body or --file <path>.");
|
|
69
|
-
const
|
|
70
|
-
|
|
75
|
+
const articleId = flagStr(flags["article-id"]);
|
|
76
|
+
const args = compact({ title, body, collection_id: collection, article_id: articleId });
|
|
77
|
+
const result = await client.callTool("ingest_article", args);
|
|
78
|
+
ok(ctx, articleId ? `Updated "${title}".` : `Created draft "${title}".`);
|
|
71
79
|
printResult(io, flags, result);
|
|
72
80
|
return 0;
|
|
73
81
|
}
|
|
@@ -89,6 +97,17 @@ async function postsUnpublish(ctx) {
|
|
|
89
97
|
return 0;
|
|
90
98
|
}
|
|
91
99
|
|
|
100
|
+
// Permanent: no confirmation prompt here — the CLI is a scripting surface, and the
|
|
101
|
+
// tool result reports exactly which ids were deleted vs not found.
|
|
102
|
+
async function postsDelete(ctx) {
|
|
103
|
+
const { client, flags, io, positionals } = ctx;
|
|
104
|
+
const args = argsFromFlags(ARGS.delete_article, flags, positionals);
|
|
105
|
+
const result = await client.callTool("delete_article", args);
|
|
106
|
+
ok(ctx, `Deleted ${result?.deleted_ids?.length ?? 0} article(s).`);
|
|
107
|
+
printResult(io, flags, result);
|
|
108
|
+
return 0;
|
|
109
|
+
}
|
|
110
|
+
|
|
92
111
|
// --- published (frozen public view) -----------------------------------------
|
|
93
112
|
|
|
94
113
|
export async function cmdPublished(ctx) {
|
package/lib/commands.mjs
CHANGED