@aetherwing/fcp-core 0.1.0 → 0.1.1

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.
@@ -1,144 +0,0 @@
1
- import { describe, it, expect } from "vitest";
2
- import { tokenize, isKeyValue, parseKeyValue, isArrow, isSelector } from "../src/tokenizer.js";
3
-
4
- describe("tokenize", () => {
5
- it("splits simple tokens", () => {
6
- expect(tokenize("add svc AuthService")).toEqual(["add", "svc", "AuthService"]);
7
- });
8
-
9
- it("handles quoted strings", () => {
10
- expect(tokenize('add svc "Auth Service" theme:blue')).toEqual([
11
- "add", "svc", "Auth Service", "theme:blue",
12
- ]);
13
- });
14
-
15
- it("handles escaped quotes inside quoted strings", () => {
16
- expect(tokenize('label A "say \\"hello\\""')).toEqual([
17
- "label", "A", 'say "hello"',
18
- ]);
19
- });
20
-
21
- it("handles empty input", () => {
22
- expect(tokenize("")).toEqual([]);
23
- });
24
-
25
- it("handles whitespace-only input", () => {
26
- expect(tokenize(" ")).toEqual([]);
27
- });
28
-
29
- it("handles multiple spaces between tokens", () => {
30
- expect(tokenize("add svc A")).toEqual(["add", "svc", "A"]);
31
- });
32
-
33
- it("converts literal \\n to newline in unquoted tokens", () => {
34
- expect(tokenize("add svc Container\\nRegistry")).toEqual([
35
- "add", "svc", "Container\nRegistry",
36
- ]);
37
- });
38
-
39
- it("converts literal \\n to newline in quoted strings", () => {
40
- expect(tokenize('add svc "Container\\nRegistry"')).toEqual([
41
- "add", "svc", "Container\nRegistry",
42
- ]);
43
- });
44
-
45
- it("handles embedded quoted values (key:\"value\")", () => {
46
- expect(tokenize('label:"Line1\\nLine2"')).toEqual(["label:Line1\nLine2"]);
47
- });
48
-
49
- it("converts multiple \\n sequences", () => {
50
- expect(tokenize("add svc A\\nB\\nC")).toEqual(["add", "svc", "A\nB\nC"]);
51
- });
52
-
53
- it("handles single token", () => {
54
- expect(tokenize("add")).toEqual(["add"]);
55
- });
56
-
57
- it("handles empty quoted string", () => {
58
- expect(tokenize('""')).toEqual([""]);
59
- });
60
-
61
- it("handles unclosed quote (takes rest as token)", () => {
62
- expect(tokenize('"hello world')).toEqual(["hello world"]);
63
- });
64
-
65
- it("handles escaped backslash in quotes", () => {
66
- expect(tokenize('"path\\\\dir"')).toEqual(["path\\dir"]);
67
- });
68
-
69
- it("handles key:value with colons in value", () => {
70
- expect(tokenize("url:http://example.com")).toEqual(["url:http://example.com"]);
71
- });
72
- });
73
-
74
- describe("isKeyValue", () => {
75
- it("returns true for key:value", () => {
76
- expect(isKeyValue("theme:blue")).toBe(true);
77
- });
78
-
79
- it("returns true for key:value with colons in value", () => {
80
- expect(isKeyValue("url:http://x")).toBe(true);
81
- });
82
-
83
- it("returns false for selectors", () => {
84
- expect(isKeyValue("@type:db")).toBe(false);
85
- });
86
-
87
- it("returns false for arrows", () => {
88
- expect(isKeyValue("->")).toBe(false);
89
- });
90
-
91
- it("returns false for plain words", () => {
92
- expect(isKeyValue("hello")).toBe(false);
93
- });
94
-
95
- it("returns false for trailing colon", () => {
96
- expect(isKeyValue("key:")).toBe(false);
97
- });
98
-
99
- it("returns false for leading colon", () => {
100
- expect(isKeyValue(":value")).toBe(false);
101
- });
102
- });
103
-
104
- describe("parseKeyValue", () => {
105
- it("parses simple key:value", () => {
106
- expect(parseKeyValue("theme:blue")).toEqual({ key: "theme", value: "blue" });
107
- });
108
-
109
- it("parses value with colons", () => {
110
- expect(parseKeyValue("url:http://x:8080")).toEqual({ key: "url", value: "http://x:8080" });
111
- });
112
- });
113
-
114
- describe("isArrow", () => {
115
- it("recognizes ->", () => {
116
- expect(isArrow("->")).toBe(true);
117
- });
118
-
119
- it("recognizes <->", () => {
120
- expect(isArrow("<->")).toBe(true);
121
- });
122
-
123
- it("recognizes --", () => {
124
- expect(isArrow("--")).toBe(true);
125
- });
126
-
127
- it("rejects other tokens", () => {
128
- expect(isArrow("=>")).toBe(false);
129
- expect(isArrow("add")).toBe(false);
130
- });
131
- });
132
-
133
- describe("isSelector", () => {
134
- it("recognizes @-prefixed tokens", () => {
135
- expect(isSelector("@type:db")).toBe(true);
136
- expect(isSelector("@all")).toBe(true);
137
- expect(isSelector("@recent:5")).toBe(true);
138
- });
139
-
140
- it("rejects non-@ tokens", () => {
141
- expect(isSelector("type:db")).toBe(false);
142
- expect(isSelector("add")).toBe(false);
143
- });
144
- });
@@ -1,76 +0,0 @@
1
- import { describe, it, expect } from "vitest";
2
- import { VerbRegistry, type VerbSpec } from "../src/verb-registry.js";
3
-
4
- describe("VerbRegistry", () => {
5
- function createTestRegistry(): VerbRegistry {
6
- const reg = new VerbRegistry();
7
- reg.registerMany([
8
- { verb: "add", syntax: "add TYPE LABEL [key:value]", category: "create" },
9
- { verb: "remove", syntax: "remove SELECTOR", category: "modify" },
10
- { verb: "connect", syntax: "connect SRC -> TGT", category: "create", description: "Create an edge" },
11
- { verb: "style", syntax: "style REF [fill:#HEX]", category: "modify", params: ["fill", "stroke"] },
12
- ]);
13
- return reg;
14
- }
15
-
16
- describe("register/lookup", () => {
17
- it("registers and looks up a verb", () => {
18
- const reg = new VerbRegistry();
19
- const spec: VerbSpec = { verb: "add", syntax: "add TYPE LABEL", category: "create" };
20
- reg.register(spec);
21
- expect(reg.lookup("add")).toEqual(spec);
22
- });
23
-
24
- it("returns undefined for unknown verbs", () => {
25
- const reg = new VerbRegistry();
26
- expect(reg.lookup("nonexistent")).toBeUndefined();
27
- });
28
-
29
- it("registers many at once", () => {
30
- const reg = createTestRegistry();
31
- expect(reg.lookup("add")).toBeDefined();
32
- expect(reg.lookup("remove")).toBeDefined();
33
- expect(reg.lookup("connect")).toBeDefined();
34
- expect(reg.lookup("style")).toBeDefined();
35
- });
36
- });
37
-
38
- describe("verbs", () => {
39
- it("returns all registered specs", () => {
40
- const reg = createTestRegistry();
41
- expect(reg.verbs).toHaveLength(4);
42
- const verbs = reg.verbs.map((v) => v.verb);
43
- expect(verbs).toContain("add");
44
- expect(verbs).toContain("remove");
45
- expect(verbs).toContain("connect");
46
- expect(verbs).toContain("style");
47
- });
48
- });
49
-
50
- describe("generateReferenceCard", () => {
51
- it("groups verbs by category", () => {
52
- const reg = createTestRegistry();
53
- const card = reg.generateReferenceCard();
54
- expect(card).toContain("CREATE:");
55
- expect(card).toContain("MODIFY:");
56
- expect(card).toContain(" add TYPE LABEL [key:value]");
57
- expect(card).toContain(" connect SRC -> TGT");
58
- expect(card).toContain(" remove SELECTOR");
59
- expect(card).toContain(" style REF [fill:#HEX]");
60
- });
61
-
62
- it("appends additional sections", () => {
63
- const reg = createTestRegistry();
64
- const card = reg.generateReferenceCard({
65
- "Themes": " blue #dae8fc\n red #f8cecc",
66
- });
67
- expect(card).toContain("THEMES:");
68
- expect(card).toContain(" blue #dae8fc");
69
- });
70
-
71
- it("returns empty string for empty registry", () => {
72
- const reg = new VerbRegistry();
73
- expect(reg.generateReferenceCard()).toBe("");
74
- });
75
- });
76
- });
package/tsconfig.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "NodeNext",
5
- "moduleResolution": "NodeNext",
6
- "declaration": true,
7
- "declarationMap": true,
8
- "sourceMap": true,
9
- "outDir": "dist",
10
- "rootDir": "src",
11
- "strict": true,
12
- "esModuleInterop": true,
13
- "skipLibCheck": true,
14
- "forceConsistentCasingInFileNames": true,
15
- "resolveJsonModule": true
16
- },
17
- "include": ["src/**/*.ts"],
18
- "exclude": ["node_modules", "dist", "tests"]
19
- }
package/vitest.config.ts DELETED
@@ -1,7 +0,0 @@
1
- import { defineConfig } from "vitest/config";
2
-
3
- export default defineConfig({
4
- test: {
5
- include: ["tests/**/*.test.ts"],
6
- },
7
- });