@intentius/chant 0.0.12 → 0.0.14
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/__fixtures__/init-lexicon-output/docs/astro.config.mjs +3 -0
- package/src/cli/commands/__fixtures__/init-lexicon-output/docs/src/content/docs/getting-started.mdx +6 -0
- package/src/cli/commands/__fixtures__/init-lexicon-output/docs/src/content/docs/lint-rules.mdx +6 -0
- package/src/cli/commands/__fixtures__/init-lexicon-output/docs/src/content/docs/serialization.mdx +6 -0
- package/src/cli/commands/__fixtures__/init-lexicon-output/examples/getting-started/package.json +9 -0
- package/src/cli/commands/__fixtures__/init-lexicon-output/examples/getting-started/src/infra.ts +12 -0
- package/src/cli/commands/__fixtures__/init-lexicon-output/src/composites/.gitkeep +0 -0
- package/src/cli/commands/__fixtures__/init-lexicon-output/src/lint/post-synth/.gitkeep +0 -0
- package/src/cli/commands/__fixtures__/init-lexicon-output/src/plugin.ts +37 -42
- package/src/cli/commands/__snapshots__/init-lexicon.test.ts.snap +37 -42
- package/src/cli/commands/build.ts +12 -7
- package/src/cli/commands/check-lexicon.ts +385 -0
- package/src/cli/commands/import.ts +6 -3
- package/src/cli/commands/init-lexicon.test.ts +22 -1
- package/src/cli/commands/init-lexicon.ts +194 -43
- package/src/cli/commands/init.ts +3 -3
- package/src/cli/commands/onboard.test.ts +295 -0
- package/src/cli/commands/onboard.ts +313 -0
- package/src/cli/handlers/dev.ts +26 -1
- package/src/cli/main.ts +5 -1
- package/src/codegen/docs.ts +11 -5
- package/src/codegen/generate-registry.ts +3 -2
- package/src/codegen/typecheck.ts +44 -2
- package/src/detectLexicon.test.ts +24 -0
- package/src/detectLexicon.ts +4 -2
- package/src/runtime.ts +4 -0
- package/src/serializer-walker.test.ts +8 -0
- package/src/toml.test.ts +388 -0
- package/src/toml.ts +606 -0
- /package/src/cli/commands/__fixtures__/init-lexicon-output/{examples/getting-started → src/actions}/.gitkeep +0 -0
package/package.json
CHANGED
|
@@ -8,6 +8,9 @@ export default defineConfig({
|
|
|
8
8
|
title: 'Fixture',
|
|
9
9
|
sidebar: [
|
|
10
10
|
{ label: 'Overview', slug: '' },
|
|
11
|
+
{ label: 'Getting Started', slug: 'getting-started' },
|
|
12
|
+
{ label: 'Serialization', slug: 'serialization' },
|
|
13
|
+
{ label: 'Lint Rules', slug: 'lint-rules' },
|
|
11
14
|
],
|
|
12
15
|
}),
|
|
13
16
|
],
|
package/src/cli/commands/__fixtures__/init-lexicon-output/examples/getting-started/src/infra.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Getting-started example for the fixture lexicon.
|
|
3
|
+
*
|
|
4
|
+
* TODO: Replace with a real infrastructure definition
|
|
5
|
+
* that uses resources from the fixture lexicon.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// import { SomeResource } from "@intentius/chant-lexicon-fixture";
|
|
9
|
+
//
|
|
10
|
+
// export const myResource = SomeResource("example", {
|
|
11
|
+
// // properties...
|
|
12
|
+
// });
|
|
File without changes
|
|
File without changes
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type { LexiconPlugin } from "@intentius/chant/lexicon";
|
|
1
|
+
import type { LexiconPlugin, SkillDefinition, IntrinsicDef } from "@intentius/chant/lexicon";
|
|
2
|
+
import type { LintRule } from "@intentius/chant/lint/rule";
|
|
3
|
+
import type { PostSynthCheck } from "@intentius/chant/lint/post-synth";
|
|
4
|
+
import type { CompletionContext, CompletionItem, HoverContext, HoverInfo } from "@intentius/chant/lsp/types";
|
|
5
|
+
import type { McpToolContribution, McpResourceContribution } from "@intentius/chant/mcp/types";
|
|
2
6
|
import { fixtureSerializer } from "./serializer";
|
|
3
7
|
|
|
4
8
|
/**
|
|
@@ -42,54 +46,45 @@ export const fixturePlugin: LexiconPlugin = {
|
|
|
42
46
|
console.error(`Packaged ${stats.resources} resources, ${stats.ruleCount} rules, ${stats.skillCount} skills`);
|
|
43
47
|
},
|
|
44
48
|
|
|
45
|
-
// ── Optional extensions
|
|
49
|
+
// ── Optional extensions ────────────────────────────────────
|
|
46
50
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// declarativeRules(): RuleSpec[] {
|
|
52
|
-
// return [];
|
|
53
|
-
// },
|
|
54
|
-
|
|
55
|
-
// postSynthChecks(): PostSynthCheck[] {
|
|
56
|
-
// return [];
|
|
57
|
-
// },
|
|
58
|
-
|
|
59
|
-
// intrinsics(): IntrinsicDef[] {
|
|
60
|
-
// return [];
|
|
61
|
-
// },
|
|
51
|
+
lintRules() {
|
|
52
|
+
const { rules } = require("./lint/rules");
|
|
53
|
+
return rules;
|
|
54
|
+
},
|
|
62
55
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
56
|
+
postSynthChecks() {
|
|
57
|
+
return []; // TODO: Add post-synth checks
|
|
58
|
+
},
|
|
66
59
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
60
|
+
skills() {
|
|
61
|
+
return []; // TODO: Add skills
|
|
62
|
+
},
|
|
70
63
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
mcpTools() {
|
|
65
|
+
return []; // TODO: Implement MCP tools
|
|
66
|
+
},
|
|
74
67
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
68
|
+
mcpResources() {
|
|
69
|
+
return []; // TODO: Implement MCP resources
|
|
70
|
+
},
|
|
78
71
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
72
|
+
detectTemplate(data: unknown) {
|
|
73
|
+
return false; // TODO: Detect if a template belongs to this lexicon
|
|
74
|
+
},
|
|
82
75
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
76
|
+
completionProvider(ctx: CompletionContext) {
|
|
77
|
+
const { completions } = require("./lsp/completions");
|
|
78
|
+
return completions(ctx);
|
|
79
|
+
},
|
|
86
80
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
81
|
+
hoverProvider(ctx: HoverContext) {
|
|
82
|
+
const { hover } = require("./lsp/hover");
|
|
83
|
+
return hover(ctx);
|
|
84
|
+
},
|
|
90
85
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
86
|
+
async docs(options?) {
|
|
87
|
+
const { generateDocs } = await import("./codegen/docs");
|
|
88
|
+
return generateDocs(options);
|
|
89
|
+
},
|
|
95
90
|
};
|
|
@@ -108,7 +108,11 @@ export async function packageLexicon(options?: { verbose?: boolean; force?: bool
|
|
|
108
108
|
`;
|
|
109
109
|
|
|
110
110
|
exports[`init-lexicon fixture snapshot fixture plugin.ts matches snapshot 1`] = `
|
|
111
|
-
"import type { LexiconPlugin } from "@intentius/chant/lexicon";
|
|
111
|
+
"import type { LexiconPlugin, SkillDefinition, IntrinsicDef } from "@intentius/chant/lexicon";
|
|
112
|
+
import type { LintRule } from "@intentius/chant/lint/rule";
|
|
113
|
+
import type { PostSynthCheck } from "@intentius/chant/lint/post-synth";
|
|
114
|
+
import type { CompletionContext, CompletionItem, HoverContext, HoverInfo } from "@intentius/chant/lsp/types";
|
|
115
|
+
import type { McpToolContribution, McpResourceContribution } from "@intentius/chant/mcp/types";
|
|
112
116
|
import { fixtureSerializer } from "./serializer";
|
|
113
117
|
|
|
114
118
|
/**
|
|
@@ -152,56 +156,47 @@ export const fixturePlugin: LexiconPlugin = {
|
|
|
152
156
|
console.error(\`Packaged \${stats.resources} resources, \${stats.ruleCount} rules, \${stats.skillCount} skills\`);
|
|
153
157
|
},
|
|
154
158
|
|
|
155
|
-
// ── Optional extensions
|
|
159
|
+
// ── Optional extensions ────────────────────────────────────
|
|
156
160
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
// declarativeRules(): RuleSpec[] {
|
|
162
|
-
// return [];
|
|
163
|
-
// },
|
|
164
|
-
|
|
165
|
-
// postSynthChecks(): PostSynthCheck[] {
|
|
166
|
-
// return [];
|
|
167
|
-
// },
|
|
168
|
-
|
|
169
|
-
// intrinsics(): IntrinsicDef[] {
|
|
170
|
-
// return [];
|
|
171
|
-
// },
|
|
161
|
+
lintRules() {
|
|
162
|
+
const { rules } = require("./lint/rules");
|
|
163
|
+
return rules;
|
|
164
|
+
},
|
|
172
165
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
166
|
+
postSynthChecks() {
|
|
167
|
+
return []; // TODO: Add post-synth checks
|
|
168
|
+
},
|
|
176
169
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
170
|
+
skills() {
|
|
171
|
+
return []; // TODO: Add skills
|
|
172
|
+
},
|
|
180
173
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
174
|
+
mcpTools() {
|
|
175
|
+
return []; // TODO: Implement MCP tools
|
|
176
|
+
},
|
|
184
177
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
178
|
+
mcpResources() {
|
|
179
|
+
return []; // TODO: Implement MCP resources
|
|
180
|
+
},
|
|
188
181
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
182
|
+
detectTemplate(data: unknown) {
|
|
183
|
+
return false; // TODO: Detect if a template belongs to this lexicon
|
|
184
|
+
},
|
|
192
185
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
186
|
+
completionProvider(ctx: CompletionContext) {
|
|
187
|
+
const { completions } = require("./lsp/completions");
|
|
188
|
+
return completions(ctx);
|
|
189
|
+
},
|
|
196
190
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
191
|
+
hoverProvider(ctx: HoverContext) {
|
|
192
|
+
const { hover } = require("./lsp/hover");
|
|
193
|
+
return hover(ctx);
|
|
194
|
+
},
|
|
200
195
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
196
|
+
async docs(options?) {
|
|
197
|
+
const { generateDocs } = await import("./codegen/docs");
|
|
198
|
+
return generateDocs(options);
|
|
199
|
+
},
|
|
205
200
|
};
|
|
206
201
|
"
|
|
207
202
|
`;
|
|
@@ -72,17 +72,22 @@ export async function buildCommand(options: BuildOptions): Promise<BuildResult>
|
|
|
72
72
|
warnings.push(formatWarning({ message: warning }));
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
// Run post-synth checks from plugins
|
|
75
|
+
// Run post-synth checks from plugins — each plugin only sees its own lexicon's output
|
|
76
76
|
if (result.errors.length === 0 && options.plugins) {
|
|
77
|
-
const postSynthChecks: PostSynthCheck[] = [];
|
|
78
77
|
for (const plugin of options.plugins) {
|
|
79
|
-
if (plugin.postSynthChecks)
|
|
80
|
-
|
|
78
|
+
if (!plugin.postSynthChecks) continue;
|
|
79
|
+
const checks = plugin.postSynthChecks();
|
|
80
|
+
if (checks.length === 0) continue;
|
|
81
|
+
|
|
82
|
+
// Scope outputs to this plugin's lexicon so cross-lexicon outputs don't interfere
|
|
83
|
+
const scopedOutputs = new Map<string, string | SerializerResult>();
|
|
84
|
+
const pluginOutput = result.outputs.get(plugin.name);
|
|
85
|
+
if (pluginOutput !== undefined) {
|
|
86
|
+
scopedOutputs.set(plugin.name, pluginOutput);
|
|
81
87
|
}
|
|
82
|
-
}
|
|
83
88
|
|
|
84
|
-
|
|
85
|
-
const postDiags = runPostSynthChecks(
|
|
89
|
+
const scopedResult = { ...result, outputs: scopedOutputs };
|
|
90
|
+
const postDiags = runPostSynthChecks(checks, scopedResult);
|
|
86
91
|
for (const diag of postDiags) {
|
|
87
92
|
const prefix = diag.entity ? `[${diag.entity}] ` : "";
|
|
88
93
|
const lexiconSuffix = diag.lexicon ? ` (${diag.lexicon})` : "";
|