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
+8 -8
View File
@@ -690,16 +690,16 @@ describe("var-reactivity", () => {
// ---------------------------------------------------------------------------
describe("parseInput", () => {
test("parses /roll command", () => {
const result = parseInput("/roll 3d6+5");
test("parses /roll command with spark table slug", () => {
const result = parseInput("/roll my-table");
expect(result.type).toBe("roll");
expect(result.payload).toEqual({ notation: "3d6+5", label: "3d6+5" });
expect(result.payload).toEqual({ arg: "my-table" });
});
test("parses /spark command", () => {
const result = parseInput("/spark my-table");
expect(result.type).toBe("spark");
expect(result.payload).toEqual({ key: "my-table" });
test("parses /roll command with dice notation", () => {
const result = parseInput("/roll 3d6+5");
expect(result.type).toBe("roll");
expect(result.payload).toEqual({ arg: "3d6+5" });
});
test("parses /link command", () => {
@@ -743,7 +743,7 @@ describe("parseInput", () => {
test("returns error for empty /roll", () => {
const result = parseInput("/roll ");
expect(result.error).toBe("需要骰子表达式");
expect(result.error).toBe("需要骰子表达式或种子表键名");
});
test("returns error for empty /set", () => {