refactor: merge /spark command into /roll

Consolidate the `/spark` command into `/roll` to simplify the CLI.
The `/roll` command now handles both dice notation and spark table
slugs.

- Update `parseInput` to treat `/roll` arguments as a generic string.
- Update `dispatchCommand` to check for spark table matches before
  evaluating dice notation or variable expressions.
- Update command completions to show both dice and spark table
  suggestions under `/roll`.
- Update documentation and UI placeholders to reflect the change.
This commit is contained in:
2026-07-13 14:43:55 +08:00
parent c4038a5213
commit d74ba69fdf
8 changed files with 118 additions and 77 deletions
+6 -12
View File
@@ -12,23 +12,17 @@ export interface CompletionItem {
}
export interface ParsedInput {
type: "chat" | "roll" | "spark" | "link" | "set" | "rolltag";
type: "chat" | "roll" | "link" | "set" | "rolltag";
payload: Record<string, unknown>;
error?: string;
}
export function parseInput(raw: string): ParsedInput {
if (raw.startsWith("/roll ")) {
const notation = raw.slice("/roll ".length).trim();
if (!notation)
return { type: "roll", payload: {}, error: "需要骰子表达式" };
return { type: "roll", payload: { notation, label: notation } };
}
if (raw.startsWith("/spark ")) {
const key = raw.slice("/spark ".length).trim();
if (!key) return { type: "spark", payload: {}, error: "需要种子表键名" };
return { type: "spark", payload: { key } };
const arg = raw.slice("/roll ".length).trim();
if (!arg)
return { type: "roll", payload: {}, error: "需要骰子表达式或种子表键名" };
return { type: "roll", payload: { arg } };
}
if (raw.startsWith("/link ")) {
@@ -69,7 +63,7 @@ export function parseInput(raw: string): ParsedInput {
return { type: "set", payload: { key, expr } };
}
if (raw === "/roll" || raw === "/spark" || raw === "/link" || raw === "/set") {
if (raw === "/roll" || raw === "/link" || raw === "/set") {
return { type: "chat", payload: {}, error: "请补全命令" };
}