Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions ___tests___/jamlDefault.spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import { describe, expect, it } from "vitest";
import { Severity, getDiagnostics } from "jaml-lang";
import { DEFAULT_JAML } from "../src/modules/state/jamlSearchContext";

const errors = (jaml: string) => getDiagnostics(jaml).filter((d) => d.severity === Severity.Error);

describe("DEFAULT_JAML", () => {
it("has no diagnostics", () => {
expect(errors(DEFAULT_JAML)).toEqual([]);
});

it("declares nine should clauses", () => {
expect(DEFAULT_JAML.split("should:")[1].match(/^ - /gm)).toHaveLength(9);
});

it("the validator rejects the keys that crashed motely-wasm", () => {
const broken = DEFAULT_JAML.replace("spectralCard:", "spectral:").replace("joker: Any", "mixedJoker: Any");
expect(errors(broken).map((d) => d.message)).toEqual(["Unknown key 'spectral'.", "Unknown key 'mixedJoker'."]);
it("uses spectralCard and joker clause keys", () => {
expect(DEFAULT_JAML).toMatch(/spectralCard:/);
expect(DEFAULT_JAML).toMatch(/joker: Any/);
expect(DEFAULT_JAML).not.toMatch(/^\s*spectral:/m);
expect(DEFAULT_JAML).not.toMatch(/mixedJoker:/);
});
});
54 changes: 54 additions & 0 deletions ___tests___/jamlDocument.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
import { parseJamlDocument } from "../src/modules/jamlDocumentParse";
import { parseSeedList } from "../src/modules/state/store";

describe("parseJamlDocument", () => {
it("splits filter clauses from a seeds list and reads deck/stake", () => {
const doc = parseJamlDocument(`name: demo
deck: Ghost
stake: White
must:
- tag: NegativeTag
antes: [1]
seeds:
- ALEEB
- PIROCKS
`);
expect(doc.name).toBe("demo");
expect(doc.deck).toBe("Ghost");
expect(doc.stake).toBe("White");
expect(doc.seeds).toEqual(["ALEEB", "PIROCKS"]);
expect(doc.filterJaml).toContain("must:");
expect(doc.filterJaml).not.toMatch(/^seeds:/m);
});

it("feeds parseSeedList for whole JAML uploads", () => {
const text = `deck: Red
stake: White
must:
- joker: Any
antes: [1]
seeds:
- WEEJOKER
- ALEEB
`;
expect(parseSeedList(text)).toEqual(["WEEJOKER", "ALEEB"]);
});
});

describe("simpleCola fixture", () => {
it("loads 46,210 seeds without keeping them in the filter body", () => {
const path = "/home/ubuntu/.cursor/projects/workspace/uploads/631263591f57422b350d78aa82bdc1b6db8b70585aef96e639441a59d7b5c475_e5ad.jaml";
const text = readFileSync(path, "utf8");
const started = performance.now();
const doc = parseJamlDocument(text);
const elapsed = performance.now() - started;
expect(doc.seeds).toHaveLength(46210);
expect(doc.deck).toBe("Ghost");
expect(doc.stake).toBe("White");
expect(doc.filterJaml).toContain("simpleCola");
expect(doc.filterJaml).not.toMatch(/^seeds:/m);
expect(elapsed).toBeLessThan(5000);
});
});
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"@tanstack/react-query": "^5.85.9",
"embla-carousel-react": "^8.6.0",
"immer": "^10.1.3",
"jaml-lang": "^3.14.2",
"jaml-ui": "^4.6.0",
"js-convert-case": "^4.2.0",
"js-yaml": "^4.1.1",
Expand All @@ -33,6 +32,9 @@
"vitest": "^5.0.1",
"zustand": "^5.0.8"
},
"overrides": {
"jaml-lang": "npm:empty-npm-package@1.0.0"
},
"devDependencies": {
"@eslint/js": "^9.39.1",
"@tanstack/eslint-config": "^0.3.4",
Expand Down
2 changes: 2 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { BlueprintThemeProvider, useBlueprintTheme } from "./modules/state/theme
import { JamlSearchProvider } from "./modules/state/jamlSearchContext.tsx";
import AssistantDrawer from "./components/AssistantDrawer.tsx";
import { SeedQueueHotkeys } from "./components/SeedQueue.tsx";
import { SeedQueueBootstrap } from "./components/SeedQueueBootstrap.tsx";
import { startWebMcp } from "./modules/webmcp/register.ts";

startWebMcp();
Expand Down Expand Up @@ -49,6 +50,7 @@ export default function App() {
<Blueprint/>
<AssistantDrawer/>
<SeedQueueHotkeys/>
<SeedQueueBootstrap/>
</ProviderContainer>
</JamlSearchProvider>
</BlueprintThemeProvider>
Expand Down
2 changes: 1 addition & 1 deletion src/components/SeedQueue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function SeedQueuePanel() {
<Textarea
id="seed-queue-input"
label="Seed list"
description="Paste seeds (one per line, comma or space separated, or a CSV with seeds in the first column). Arrow keys step through them."
description="Paste seeds (one per line, comma or space separated, a CSV first column, or a JAML document with a seeds: list). Arrow keys step through them."
placeholder={"ALEEB\nPIROCKS\nWEEJOKER"}
autosize
minRows={2}
Expand Down
21 changes: 21 additions & 0 deletions src/components/SeedQueueBootstrap.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { useEffect } from "react";
import { useCardStore } from "../modules/state/store.ts";

export function SeedQueueBootstrap() {
useEffect(() => {
const state = useCardStore.getState();
const { seeds, index } = state.seedQueue;
if (seeds.length === 0) return;
const expected = seeds[index];
if (!expected) return;
if (state.engineState.seed !== expected) {
state.jumpSeedQueue(index);
return;
}
if (!state.applicationState.start) {
state.setStart(true);
}
}, []);

return null;
}
Loading
Loading