@intentius/chant-lexicon-gcp 0.0.22 → 0.1.0

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/src/plugin.ts CHANGED
@@ -6,14 +6,16 @@
6
6
  */
7
7
 
8
8
  import { createRequire } from "module";
9
- import type { LexiconPlugin, SkillDefinition, InitTemplateSet, ResourceMetadata } from "@intentius/chant/lexicon";
9
+ import type { LexiconPlugin, InitTemplateSet, ResourceMetadata } from "@intentius/chant/lexicon";
10
10
  const require = createRequire(import.meta.url);
11
11
  import type { LintRule } from "@intentius/chant/lint/rule";
12
- import type { PostSynthCheck } from "@intentius/chant/lint/post-synth";
13
12
  import type { TemplateParser } from "@intentius/chant/import/parser";
14
13
  import type { TypeScriptGenerator } from "@intentius/chant/import/generator";
15
14
  import type { CompletionContext, CompletionItem, HoverContext, HoverInfo } from "@intentius/chant/lsp/types";
16
- import type { McpToolContribution, McpResourceContribution } from "@intentius/chant/mcp/types";
15
+ import { discoverPostSynthChecks } from "@intentius/chant/lint/discover";
16
+ import { createSkillsLoader, createDiffTool, createCatalogResource } from "@intentius/chant/lexicon-plugin-helpers";
17
+ import { join, dirname } from "path";
18
+ import { fileURLToPath } from "url";
17
19
  import { gcpSerializer } from "./serializer";
18
20
 
19
21
  export const gcpPlugin: LexiconPlugin = {
@@ -27,37 +29,9 @@ export const gcpPlugin: LexiconPlugin = {
27
29
  return [hardcodedProjectRule, hardcodedRegionRule, publicIamRule];
28
30
  },
29
31
 
30
- postSynthChecks(): PostSynthCheck[] {
31
- const { wgc101 } = require("./lint/post-synth/wgc101");
32
- const { wgc102 } = require("./lint/post-synth/wgc102");
33
- const { wgc103 } = require("./lint/post-synth/wgc103");
34
- const { wgc104 } = require("./lint/post-synth/wgc104");
35
- const { wgc105 } = require("./lint/post-synth/wgc105");
36
- const { wgc106 } = require("./lint/post-synth/wgc106");
37
- const { wgc107 } = require("./lint/post-synth/wgc107");
38
- const { wgc108 } = require("./lint/post-synth/wgc108");
39
- const { wgc109 } = require("./lint/post-synth/wgc109");
40
- const { wgc110 } = require("./lint/post-synth/wgc110");
41
- const { wgc201 } = require("./lint/post-synth/wgc201");
42
- const { wgc202 } = require("./lint/post-synth/wgc202");
43
- const { wgc203 } = require("./lint/post-synth/wgc203");
44
- const { wgc204 } = require("./lint/post-synth/wgc204");
45
- const { wgc301 } = require("./lint/post-synth/wgc301");
46
- const { wgc302 } = require("./lint/post-synth/wgc302");
47
- const { wgc303 } = require("./lint/post-synth/wgc303");
48
- const { wgc111 } = require("./lint/post-synth/wgc111");
49
- const { wgc112 } = require("./lint/post-synth/wgc112");
50
- const { wgc113 } = require("./lint/post-synth/wgc113");
51
- const { wgc401 } = require("./lint/post-synth/wgc401");
52
- const { wgc402 } = require("./lint/post-synth/wgc402");
53
- const { wgc403 } = require("./lint/post-synth/wgc403");
54
- return [
55
- wgc101, wgc102, wgc103, wgc104, wgc105, wgc106, wgc107, wgc108, wgc109, wgc110,
56
- wgc111, wgc112, wgc113,
57
- wgc201, wgc202, wgc203, wgc204,
58
- wgc301, wgc302, wgc303,
59
- wgc401, wgc402, wgc403,
60
- ];
32
+ postSynthChecks() {
33
+ const postSynthDir = join(dirname(fileURLToPath(import.meta.url)), "lint", "post-synth");
34
+ return discoverPostSynthChecks(postSynthDir, import.meta.url);
61
35
  },
62
36
 
63
37
  intrinsics() {
@@ -353,50 +327,13 @@ export const bucketReader = new IAMPolicyMember({
353
327
  return resources;
354
328
  },
355
329
 
356
- mcpTools(): McpToolContribution[] {
357
- return [
358
- {
359
- name: "diff",
360
- description: "Compare current build output against previous output for GCP Config Connector manifests",
361
- inputSchema: {
362
- type: "object" as const,
363
- properties: {
364
- path: {
365
- type: "string",
366
- description: "Path to the infrastructure project directory",
367
- },
368
- },
369
- required: ["path"],
370
- },
371
- async handler(params: Record<string, unknown>): Promise<unknown> {
372
- const { diffCommand } = await import("@intentius/chant/cli/commands/diff");
373
- const result = await diffCommand({
374
- path: (params.path as string) ?? ".",
375
- serializers: [gcpSerializer],
376
- });
377
- return result;
378
- },
379
- },
380
- ];
330
+ mcpTools() {
331
+ return [createDiffTool(gcpSerializer, "Compare current build output against previous output for GCP Config Connector manifests")];
381
332
  },
382
333
 
383
- mcpResources(): McpResourceContribution[] {
334
+ mcpResources() {
384
335
  return [
385
- {
386
- uri: "resource-catalog",
387
- name: "GCP Config Connector Resource Catalog",
388
- description: "JSON list of all supported GCP Config Connector resource types",
389
- mimeType: "application/json",
390
- async handler(): Promise<string> {
391
- const lexicon = require("./generated/lexicon-gcp.json") as Record<string, { resourceType: string; kind: string }>;
392
- const entries = Object.entries(lexicon).map(([className, entry]) => ({
393
- className,
394
- resourceType: entry.resourceType,
395
- kind: entry.kind,
396
- }));
397
- return JSON.stringify(entries);
398
- },
399
- },
336
+ createCatalogResource(import.meta.url, "GCP Config Connector Resource Catalog", "JSON list of all supported GCP Config Connector resource types", "lexicon-gcp.json"),
400
337
  {
401
338
  uri: "examples/basic-bucket",
402
339
  name: "Basic GCS Bucket Example",
@@ -422,111 +359,86 @@ export const bucket = new StorageBucket({
422
359
  ];
423
360
  },
424
361
 
425
- skills(): SkillDefinition[] {
426
- const { readFileSync } = require("fs");
427
- const { join, dirname } = require("path");
428
- const { fileURLToPath } = require("url");
429
- const dir = dirname(fileURLToPath(import.meta.url));
430
-
431
- const skills: SkillDefinition[] = [];
432
-
433
- const skillFiles = [
434
- {
435
- file: "chant-gcp.md",
436
- name: "chant-gcp",
437
- description: "GCP Config Connector lifecycle — build, lint, apply, and troubleshoot from a chant project",
438
- triggers: [
439
- { type: "file-pattern" as const, value: "*.gcp.ts" },
440
- { type: "context" as const, value: "gcp" },
441
- ],
442
- parameters: [
443
- {
444
- name: "resourceType",
445
- type: "string",
446
- description: "GCP Config Connector resource type to work with",
447
- },
448
- ],
449
- examples: [
450
- {
451
- title: "Create a Storage Bucket",
452
- output: "new StorageBucket({ location: \"US\", storageClass: \"STANDARD\" })",
453
- },
454
- {
455
- title: "Create a GKE Cluster",
456
- output: "new GKECluster({ location: GCP.Region, releaseChannel: { channel: \"REGULAR\" } })",
457
- },
458
- ],
459
- },
460
- {
461
- file: "chant-gcp-security.md",
462
- name: "chant-gcp-security",
463
- description: "GCP security best practices for infrastructure",
464
- triggers: [
465
- { type: "context" as const, value: "gcp security" },
466
- { type: "context" as const, value: "gcp iam" },
467
- ],
468
- parameters: [],
469
- examples: [
470
- {
471
- title: "Secure Storage Bucket",
472
- input: "Create a storage bucket with encryption and uniform access",
473
- output: "import { GcsBucket } from \"@intentius/chant-lexicon-gcp\";\n\nconst { bucket } = GcsBucket({ name: \"my-bucket\", kmsKeyName: \"...\" });",
474
- },
475
- ],
476
- },
477
- {
478
- file: "chant-gcp-patterns.md",
479
- name: "chant-gcp-patterns",
480
- description: "Advanced GCP Config Connector patterns",
481
- triggers: [
482
- { type: "context" as const, value: "gcp patterns" },
483
- { type: "context" as const, value: "gcp composites" },
484
- ],
485
- parameters: [],
486
- examples: [
487
- {
488
- title: "VPC with Subnets",
489
- input: "Create a VPC network with private subnets",
490
- output: "import { VpcNetwork } from \"@intentius/chant-lexicon-gcp\";\n\nconst { network, subnets } = VpcNetwork({ name: \"my-vpc\", subnets: [...] });",
491
- },
492
- ],
493
- },
494
- {
495
- file: "chant-gke.md",
496
- name: "chant-gke",
497
- description: "GKE end-to-end workflow — bootstrap cluster, deploy Config Connector resources, deploy K8s workloads",
498
- triggers: [
499
- { type: "context" as const, value: "gke" },
500
- { type: "context" as const, value: "gcp kubernetes" },
501
- { type: "context" as const, value: "config connector" },
502
- ],
503
- parameters: [],
504
- examples: [
505
- {
506
- title: "Deploy GKE microservice",
507
- input: "Deploy a GKE project end-to-end",
508
- output: "npm run bootstrap && npm run deploy",
509
- },
510
- ],
511
- },
512
- ];
513
-
514
- for (const skill of skillFiles) {
515
- try {
516
- const content = readFileSync(join(dir, "skills", skill.file), "utf-8");
517
- skills.push({
518
- name: skill.name,
519
- description: skill.description,
520
- content,
521
- triggers: skill.triggers,
522
- parameters: skill.parameters,
523
- examples: skill.examples,
524
- });
525
- } catch { /* skip missing skills */ }
526
- }
527
-
528
- return skills;
529
- },
362
+ skills: createSkillsLoader(import.meta.url, [
363
+ {
364
+ file: "chant-gcp.md",
365
+ name: "chant-gcp",
366
+ description: "Build, validate, and deploy GCP Config Connector manifests from a chant project",
367
+ triggers: [
368
+ { type: "file-pattern" as const, value: "*.gcp.ts" },
369
+ { type: "context" as const, value: "gcp" },
370
+ ],
371
+ parameters: [
372
+ {
373
+ name: "resourceType",
374
+ type: "string",
375
+ description: "GCP Config Connector resource type to work with",
376
+ },
377
+ ],
378
+ examples: [
379
+ {
380
+ title: "Create a Storage Bucket",
381
+ output: "new StorageBucket({ location: \"US\", storageClass: \"STANDARD\" })",
382
+ },
383
+ {
384
+ title: "Create a GKE Cluster",
385
+ output: "new GKECluster({ location: GCP.Region, releaseChannel: { channel: \"REGULAR\" } })",
386
+ },
387
+ ],
388
+ },
389
+ {
390
+ file: "chant-gcp-security.md",
391
+ name: "chant-gcp-security",
392
+ description: "GCP security best practices for infrastructure",
393
+ triggers: [
394
+ { type: "context" as const, value: "gcp security" },
395
+ { type: "context" as const, value: "gcp iam" },
396
+ ],
397
+ parameters: [],
398
+ examples: [
399
+ {
400
+ title: "Secure Storage Bucket",
401
+ input: "Create a storage bucket with encryption and uniform access",
402
+ output: "import { GcsBucket } from \"@intentius/chant-lexicon-gcp\";\n\nconst { bucket } = GcsBucket({ name: \"my-bucket\", kmsKeyName: \"...\" });",
403
+ },
404
+ ],
405
+ },
406
+ {
407
+ file: "chant-gcp-patterns.md",
408
+ name: "chant-gcp-patterns",
409
+ description: "Advanced GCP Config Connector patterns",
410
+ triggers: [
411
+ { type: "context" as const, value: "gcp patterns" },
412
+ { type: "context" as const, value: "gcp composites" },
413
+ ],
414
+ parameters: [],
415
+ examples: [
416
+ {
417
+ title: "VPC with Subnets",
418
+ input: "Create a VPC network with private subnets",
419
+ output: "import { VpcNetwork } from \"@intentius/chant-lexicon-gcp\";\n\nconst { network, subnets } = VpcNetwork({ name: \"my-vpc\", subnets: [...] });",
420
+ },
421
+ ],
422
+ },
423
+ {
424
+ file: "chant-gcp-gke.md",
425
+ name: "chant-gcp-gke",
426
+ description: "End-to-end GKE workflow bridging GCP infrastructure and Kubernetes workloads",
427
+ triggers: [
428
+ { type: "context" as const, value: "gke" },
429
+ { type: "context" as const, value: "gcp kubernetes" },
430
+ { type: "context" as const, value: "config connector" },
431
+ ],
432
+ parameters: [],
433
+ examples: [
434
+ {
435
+ title: "Deploy GKE microservice",
436
+ input: "Deploy a GKE project end-to-end",
437
+ output: "npm run bootstrap && npm run deploy",
438
+ },
439
+ ],
440
+ },
441
+ ]),
530
442
 
531
443
  async generate(options?: { verbose?: boolean }): Promise<void> {
532
444
  const { generate, writeGeneratedFiles } = await import("./codegen/generate");
@@ -1,5 +1,5 @@
1
1
  ---
2
- skill: chant-gke
2
+ skill: chant-gcp-gke
3
3
  description: End-to-end GKE workflow bridging GCP infrastructure and Kubernetes workloads
4
4
  user-invocable: true
5
5
  ---
@@ -1,6 +1,7 @@
1
1
  ---
2
- source: chant-lexicon
3
- lexicon: gcp
2
+ skill: chant-gcp-patterns
3
+ description: Advanced GCP Config Connector patterns
4
+ user-invocable: true
4
5
  ---
5
6
 
6
7
  # Advanced GCP Config Connector Patterns with Chant
@@ -1,6 +1,7 @@
1
1
  ---
2
- source: chant-lexicon
3
- lexicon: gcp
2
+ skill: chant-gcp-security
3
+ description: GCP security best practices for infrastructure
4
+ user-invocable: true
4
5
  ---
5
6
 
6
7
  # GCP Security Best Practices for Chant