@intentius/chant 0.0.22 → 0.0.24
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/package.json +1 -1
- package/src/cli/commands/init-lexicon/templates/codegen.ts +188 -0
- package/src/cli/commands/init-lexicon/templates/docs.ts +81 -0
- package/src/cli/commands/init-lexicon/templates/examples.ts +35 -0
- package/src/cli/commands/init-lexicon/templates/lint.ts +30 -0
- package/src/cli/commands/init-lexicon/templates/lsp.ts +39 -0
- package/src/cli/commands/init-lexicon/templates/plugin.ts +110 -0
- package/src/cli/commands/init-lexicon/templates/project.ts +182 -0
- package/src/cli/commands/init-lexicon/templates/spec.ts +57 -0
- package/src/cli/commands/init-lexicon/templates/tests.ts +70 -0
- package/src/cli/commands/init-lexicon.ts +12 -774
- package/src/cli/conflict-check.test.ts +43 -0
- package/src/cli/main.ts +1 -1
- package/src/cli/mcp/resource-handlers.ts +227 -0
- package/src/cli/mcp/server.ts +20 -409
- package/src/cli/mcp/state-tools.ts +138 -0
- package/src/cli/mcp/types.ts +45 -0
- package/src/codegen/docs-file-markers.ts +69 -0
- package/src/codegen/docs-rule-scanning.ts +159 -0
- package/src/codegen/docs-sections.ts +159 -0
- package/src/codegen/docs-sidebar.ts +56 -0
- package/src/codegen/docs-types.ts +79 -0
- package/src/codegen/docs.ts +9 -495
- package/src/composite.test.ts +75 -0
- package/src/composite.ts +37 -0
- package/src/discovery/collect.test.ts +34 -0
- package/src/discovery/collect.ts +12 -0
- package/src/lexicon-plugin-helpers.ts +130 -0
- package/src/toml-emit.ts +182 -0
- package/src/toml-parse.ts +370 -0
- package/src/toml-utils.ts +60 -0
- package/src/toml.ts +5 -602
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spec template generators for init-lexicon scaffold.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export function generateSpecFetchTs(): string {
|
|
6
|
+
return `import { fetchWithCache, extractFromZip } from "@intentius/chant/codegen/fetch";
|
|
7
|
+
|
|
8
|
+
// TODO: Set this to your upstream schema source URL
|
|
9
|
+
const SCHEMA_URL = "https://example.com/schemas.zip";
|
|
10
|
+
const CACHE_FILE = ".cache/schemas.zip";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Fetch upstream schemas with caching.
|
|
14
|
+
*
|
|
15
|
+
* TODO: Point SCHEMA_URL at your real upstream schema source.
|
|
16
|
+
*/
|
|
17
|
+
export async function fetchSchemas(options?: { force?: boolean }): Promise<Map<string, string>> {
|
|
18
|
+
const zipData = await fetchWithCache({
|
|
19
|
+
url: SCHEMA_URL,
|
|
20
|
+
cacheFile: CACHE_FILE,
|
|
21
|
+
force: options?.force,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// TODO: Adjust the filter to match your schema file names
|
|
25
|
+
return extractFromZip(zipData, (name) => name.endsWith(".json"));
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function generateSpecParseTs(): string {
|
|
31
|
+
return `/**
|
|
32
|
+
* Parsed schema result for a single schema file.
|
|
33
|
+
*/
|
|
34
|
+
export interface ParseResult {
|
|
35
|
+
typeName: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
properties: Map<string, ParsedProperty>;
|
|
38
|
+
attributes: string[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface ParsedProperty {
|
|
42
|
+
name: string;
|
|
43
|
+
type: string;
|
|
44
|
+
required: boolean;
|
|
45
|
+
description?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Parse a single schema file into a ParseResult.
|
|
50
|
+
*
|
|
51
|
+
* TODO: Implement parsing for your schema format.
|
|
52
|
+
*/
|
|
53
|
+
export function parseSchema(name: string, content: string): ParseResult {
|
|
54
|
+
throw new Error(\`TODO: implement parseSchema for \${name}\`);
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test file template generators for init-lexicon scaffold.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export function generatePluginTestTs(name: string, names: { pluginVarName: string }): string {
|
|
6
|
+
return `import { describe, expect, it } from "bun:test";
|
|
7
|
+
import { ${names.pluginVarName} } from "./plugin";
|
|
8
|
+
import { isLexiconPlugin } from "@intentius/chant/lexicon";
|
|
9
|
+
|
|
10
|
+
describe("${name} plugin", () => {
|
|
11
|
+
it("is a valid LexiconPlugin", () => {
|
|
12
|
+
expect(isLexiconPlugin(${names.pluginVarName})).toBe(true);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("has the correct name", () => {
|
|
16
|
+
expect(${names.pluginVarName}.name).toBe("${name}");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("has a serializer", () => {
|
|
20
|
+
expect(${names.pluginVarName}.serializer).toBeDefined();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function generateSerializerTestTs(name: string, names: { serializerVarName: string }): string {
|
|
27
|
+
return `import { describe, expect, it } from "bun:test";
|
|
28
|
+
import { ${names.serializerVarName} } from "./serializer";
|
|
29
|
+
|
|
30
|
+
describe("${name} serializer", () => {
|
|
31
|
+
it("serializes an empty map to valid JSON", () => {
|
|
32
|
+
const result = ${names.serializerVarName}.serialize(new Map());
|
|
33
|
+
expect(typeof result).toBe("string");
|
|
34
|
+
expect(() => JSON.parse(result)).not.toThrow();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("has the correct name", () => {
|
|
38
|
+
expect(${names.serializerVarName}.name).toBe("${name}");
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function generateCompletionsTestTs(): string {
|
|
45
|
+
return `import { describe, expect, it } from "bun:test";
|
|
46
|
+
import { completions } from "./completions";
|
|
47
|
+
|
|
48
|
+
describe("LSP completions", () => {
|
|
49
|
+
it("returns an array", () => {
|
|
50
|
+
// TODO: Replace with a real CompletionContext
|
|
51
|
+
const result = completions({} as any);
|
|
52
|
+
expect(Array.isArray(result)).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function generateHoverTestTs(): string {
|
|
59
|
+
return `import { describe, expect, it } from "bun:test";
|
|
60
|
+
import { hover } from "./hover";
|
|
61
|
+
|
|
62
|
+
describe("LSP hover", () => {
|
|
63
|
+
it("returns undefined for unknown context", () => {
|
|
64
|
+
// TODO: Replace with a real HoverContext
|
|
65
|
+
const result = hover({} as any);
|
|
66
|
+
expect(result).toBeUndefined();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
`;
|
|
70
|
+
}
|