@intentius/chant 0.0.12 → 0.0.13

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.
Files changed (31) hide show
  1. package/package.json +1 -1
  2. package/src/cli/commands/__fixtures__/init-lexicon-output/docs/astro.config.mjs +3 -0
  3. package/src/cli/commands/__fixtures__/init-lexicon-output/docs/src/content/docs/getting-started.mdx +6 -0
  4. package/src/cli/commands/__fixtures__/init-lexicon-output/docs/src/content/docs/lint-rules.mdx +6 -0
  5. package/src/cli/commands/__fixtures__/init-lexicon-output/docs/src/content/docs/serialization.mdx +6 -0
  6. package/src/cli/commands/__fixtures__/init-lexicon-output/examples/getting-started/package.json +9 -0
  7. package/src/cli/commands/__fixtures__/init-lexicon-output/examples/getting-started/src/infra.ts +12 -0
  8. package/src/cli/commands/__fixtures__/init-lexicon-output/src/composites/.gitkeep +0 -0
  9. package/src/cli/commands/__fixtures__/init-lexicon-output/src/lint/post-synth/.gitkeep +0 -0
  10. package/src/cli/commands/__fixtures__/init-lexicon-output/src/plugin.ts +37 -42
  11. package/src/cli/commands/__snapshots__/init-lexicon.test.ts.snap +37 -42
  12. package/src/cli/commands/build.ts +12 -7
  13. package/src/cli/commands/check-lexicon.ts +385 -0
  14. package/src/cli/commands/import.ts +6 -3
  15. package/src/cli/commands/init-lexicon.test.ts +22 -1
  16. package/src/cli/commands/init-lexicon.ts +194 -43
  17. package/src/cli/commands/init.ts +3 -3
  18. package/src/cli/commands/onboard.test.ts +295 -0
  19. package/src/cli/commands/onboard.ts +313 -0
  20. package/src/cli/handlers/dev.ts +26 -1
  21. package/src/cli/main.ts +5 -1
  22. package/src/codegen/docs.ts +11 -5
  23. package/src/codegen/generate-registry.ts +3 -2
  24. package/src/codegen/typecheck.ts +44 -2
  25. package/src/detectLexicon.test.ts +24 -0
  26. package/src/detectLexicon.ts +4 -2
  27. package/src/runtime.ts +4 -0
  28. package/src/serializer-walker.test.ts +8 -0
  29. package/src/toml.test.ts +388 -0
  30. package/src/toml.ts +606 -0
  31. /package/src/cli/commands/__fixtures__/init-lexicon-output/{examples/getting-started → src/actions}/.gitkeep +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "files": ["src/", "bin/"],
@@ -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
  ],
@@ -0,0 +1,6 @@
1
+ ---
2
+ title: Getting Started
3
+ description: Get started with the Fixture lexicon
4
+ ---
5
+
6
+ TODO: Document how to set up a project using the Fixture lexicon.
@@ -0,0 +1,6 @@
1
+ ---
2
+ title: Lint Rules
3
+ description: Fixture lint rules reference
4
+ ---
5
+
6
+ TODO: Document the lint rules provided by the Fixture lexicon.
@@ -0,0 +1,6 @@
1
+ ---
2
+ title: Serialization
3
+ description: Fixture output format
4
+ ---
5
+
6
+ TODO: Document the Fixture serialization format and output structure.
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "@intentius/chant-lexicon-fixture-example-getting-started",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "dependencies": {
6
+ "@intentius/chant-lexicon-fixture": "workspace:*",
7
+ "@intentius/chant": "workspace:*"
8
+ }
9
+ }
@@ -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
+ // });
@@ -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 (uncomment and implement as needed) ───
49
+ // ── Optional extensions ────────────────────────────────────
46
50
 
47
- // lintRules(): LintRule[] {
48
- // return [];
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
- // pseudoParameters(): string[] {
64
- // return [];
65
- // },
56
+ postSynthChecks() {
57
+ return []; // TODO: Add post-synth checks
58
+ },
66
59
 
67
- // detectTemplate(data: unknown): boolean {
68
- // return false;
69
- // },
60
+ skills() {
61
+ return []; // TODO: Add skills
62
+ },
70
63
 
71
- // templateParser(): TemplateParser {
72
- // // return new MyParser();
73
- // },
64
+ mcpTools() {
65
+ return []; // TODO: Implement MCP tools
66
+ },
74
67
 
75
- // templateGenerator(): TypeScriptGenerator {
76
- // // return new MyGenerator();
77
- // },
68
+ mcpResources() {
69
+ return []; // TODO: Implement MCP resources
70
+ },
78
71
 
79
- // skills(): SkillDefinition[] {
80
- // return [];
81
- // },
72
+ detectTemplate(data: unknown) {
73
+ return false; // TODO: Detect if a template belongs to this lexicon
74
+ },
82
75
 
83
- // completionProvider(ctx: CompletionContext): CompletionItem[] {
84
- // return [];
85
- // },
76
+ completionProvider(ctx: CompletionContext) {
77
+ const { completions } = require("./lsp/completions");
78
+ return completions(ctx);
79
+ },
86
80
 
87
- // hoverProvider(ctx: HoverContext): HoverInfo | undefined {
88
- // return undefined;
89
- // },
81
+ hoverProvider(ctx: HoverContext) {
82
+ const { hover } = require("./lsp/hover");
83
+ return hover(ctx);
84
+ },
90
85
 
91
- // docs(options?: { verbose?: boolean }): Promise<void> {
92
- // const { generateDocs } = await import("./codegen/docs");
93
- // return generateDocs(options);
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 (uncomment and implement as needed) ───
159
+ // ── Optional extensions ────────────────────────────────────
156
160
 
157
- // lintRules(): LintRule[] {
158
- // return [];
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
- // pseudoParameters(): string[] {
174
- // return [];
175
- // },
166
+ postSynthChecks() {
167
+ return []; // TODO: Add post-synth checks
168
+ },
176
169
 
177
- // detectTemplate(data: unknown): boolean {
178
- // return false;
179
- // },
170
+ skills() {
171
+ return []; // TODO: Add skills
172
+ },
180
173
 
181
- // templateParser(): TemplateParser {
182
- // // return new MyParser();
183
- // },
174
+ mcpTools() {
175
+ return []; // TODO: Implement MCP tools
176
+ },
184
177
 
185
- // templateGenerator(): TypeScriptGenerator {
186
- // // return new MyGenerator();
187
- // },
178
+ mcpResources() {
179
+ return []; // TODO: Implement MCP resources
180
+ },
188
181
 
189
- // skills(): SkillDefinition[] {
190
- // return [];
191
- // },
182
+ detectTemplate(data: unknown) {
183
+ return false; // TODO: Detect if a template belongs to this lexicon
184
+ },
192
185
 
193
- // completionProvider(ctx: CompletionContext): CompletionItem[] {
194
- // return [];
195
- // },
186
+ completionProvider(ctx: CompletionContext) {
187
+ const { completions } = require("./lsp/completions");
188
+ return completions(ctx);
189
+ },
196
190
 
197
- // hoverProvider(ctx: HoverContext): HoverInfo | undefined {
198
- // return undefined;
199
- // },
191
+ hoverProvider(ctx: HoverContext) {
192
+ const { hover } = require("./lsp/hover");
193
+ return hover(ctx);
194
+ },
200
195
 
201
- // docs(options?: { verbose?: boolean }): Promise<void> {
202
- // const { generateDocs } = await import("./codegen/docs");
203
- // return generateDocs(options);
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
- postSynthChecks.push(...plugin.postSynthChecks());
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
- if (postSynthChecks.length > 0) {
85
- const postDiags = runPostSynthChecks(postSynthChecks, result);
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})` : "";