@intentius/chant-lexicon-helm 0.0.16

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 (110) hide show
  1. package/README.md +22 -0
  2. package/dist/integrity.json +36 -0
  3. package/dist/manifest.json +37 -0
  4. package/dist/meta.json +208 -0
  5. package/dist/rules/chart-metadata.ts +64 -0
  6. package/dist/rules/helm-helpers.ts +64 -0
  7. package/dist/rules/no-hardcoded-image.ts +62 -0
  8. package/dist/rules/values-no-secrets.ts +82 -0
  9. package/dist/rules/whm101.ts +46 -0
  10. package/dist/rules/whm102.ts +33 -0
  11. package/dist/rules/whm103.ts +59 -0
  12. package/dist/rules/whm104.ts +35 -0
  13. package/dist/rules/whm105.ts +30 -0
  14. package/dist/rules/whm201.ts +36 -0
  15. package/dist/rules/whm202.ts +50 -0
  16. package/dist/rules/whm203.ts +39 -0
  17. package/dist/rules/whm204.ts +60 -0
  18. package/dist/rules/whm301.ts +41 -0
  19. package/dist/rules/whm302.ts +40 -0
  20. package/dist/rules/whm401.ts +57 -0
  21. package/dist/rules/whm402.ts +45 -0
  22. package/dist/rules/whm403.ts +45 -0
  23. package/dist/rules/whm404.ts +36 -0
  24. package/dist/rules/whm405.ts +53 -0
  25. package/dist/rules/whm406.ts +34 -0
  26. package/dist/rules/whm407.ts +83 -0
  27. package/dist/rules/whm501.ts +103 -0
  28. package/dist/rules/whm502.ts +94 -0
  29. package/dist/skills/chant-helm-chart-patterns.md +229 -0
  30. package/dist/skills/chant-helm-chart-security-patterns.md +192 -0
  31. package/dist/skills/chant-helm-create-chart.md +211 -0
  32. package/dist/types/index.d.ts +132 -0
  33. package/package.json +34 -0
  34. package/src/codegen/docs-cli.ts +4 -0
  35. package/src/codegen/docs.ts +483 -0
  36. package/src/codegen/generate-cli.ts +28 -0
  37. package/src/codegen/generate.ts +249 -0
  38. package/src/codegen/naming.ts +38 -0
  39. package/src/codegen/package.ts +64 -0
  40. package/src/composites/composites.test.ts +1050 -0
  41. package/src/composites/helm-batch-job.ts +209 -0
  42. package/src/composites/helm-crd-lifecycle.ts +184 -0
  43. package/src/composites/helm-cron-job.ts +177 -0
  44. package/src/composites/helm-daemon-set.ts +169 -0
  45. package/src/composites/helm-external-secret.ts +93 -0
  46. package/src/composites/helm-library.ts +51 -0
  47. package/src/composites/helm-microservice.ts +331 -0
  48. package/src/composites/helm-monitored-service.ts +252 -0
  49. package/src/composites/helm-namespace-env.ts +154 -0
  50. package/src/composites/helm-secure-ingress.ts +114 -0
  51. package/src/composites/helm-stateful-service.ts +213 -0
  52. package/src/composites/helm-web-app.ts +264 -0
  53. package/src/composites/helm-worker.ts +207 -0
  54. package/src/composites/index.ts +38 -0
  55. package/src/coverage.test.ts +21 -0
  56. package/src/coverage.ts +50 -0
  57. package/src/generated/index.d.ts +132 -0
  58. package/src/generated/index.ts +13 -0
  59. package/src/generated/lexicon-helm.json +208 -0
  60. package/src/helpers.test.ts +51 -0
  61. package/src/helpers.ts +100 -0
  62. package/src/import/generator.ts +285 -0
  63. package/src/import/import.test.ts +224 -0
  64. package/src/import/parser.ts +160 -0
  65. package/src/import/template-stripper.ts +123 -0
  66. package/src/index.ts +108 -0
  67. package/src/intrinsics.test.ts +380 -0
  68. package/src/intrinsics.ts +484 -0
  69. package/src/lint/post-synth/helm-helpers.ts +64 -0
  70. package/src/lint/post-synth/post-synth.test.ts +504 -0
  71. package/src/lint/post-synth/whm101.ts +46 -0
  72. package/src/lint/post-synth/whm102.ts +33 -0
  73. package/src/lint/post-synth/whm103.ts +59 -0
  74. package/src/lint/post-synth/whm104.ts +35 -0
  75. package/src/lint/post-synth/whm105.ts +30 -0
  76. package/src/lint/post-synth/whm201.ts +36 -0
  77. package/src/lint/post-synth/whm202.ts +50 -0
  78. package/src/lint/post-synth/whm203.ts +39 -0
  79. package/src/lint/post-synth/whm204.ts +60 -0
  80. package/src/lint/post-synth/whm301.ts +41 -0
  81. package/src/lint/post-synth/whm302.ts +40 -0
  82. package/src/lint/post-synth/whm401.ts +57 -0
  83. package/src/lint/post-synth/whm402.ts +45 -0
  84. package/src/lint/post-synth/whm403.ts +45 -0
  85. package/src/lint/post-synth/whm404.ts +36 -0
  86. package/src/lint/post-synth/whm405.ts +53 -0
  87. package/src/lint/post-synth/whm406.ts +34 -0
  88. package/src/lint/post-synth/whm407.ts +83 -0
  89. package/src/lint/post-synth/whm501.ts +103 -0
  90. package/src/lint/post-synth/whm502.ts +94 -0
  91. package/src/lint/rules/chart-metadata.ts +64 -0
  92. package/src/lint/rules/lint-rules.test.ts +97 -0
  93. package/src/lint/rules/no-hardcoded-image.ts +62 -0
  94. package/src/lint/rules/values-no-secrets.ts +82 -0
  95. package/src/lsp/completions.test.ts +72 -0
  96. package/src/lsp/completions.ts +20 -0
  97. package/src/lsp/hover.test.ts +46 -0
  98. package/src/lsp/hover.ts +46 -0
  99. package/src/package-cli.ts +28 -0
  100. package/src/plugin.test.ts +71 -0
  101. package/src/plugin.ts +206 -0
  102. package/src/resources.ts +77 -0
  103. package/src/serializer.test.ts +930 -0
  104. package/src/serializer.ts +835 -0
  105. package/src/skills/chart-patterns.md +229 -0
  106. package/src/skills/chart-security-patterns.md +192 -0
  107. package/src/skills/create-chart.md +211 -0
  108. package/src/validate-cli.ts +21 -0
  109. package/src/validate.test.ts +37 -0
  110. package/src/validate.ts +36 -0
@@ -0,0 +1,211 @@
1
+ ---
2
+ skill: chant-helm
3
+ description: Build, validate, and deploy Helm charts from a chant project
4
+ user-invocable: true
5
+ ---
6
+
7
+ # Helm Chart Operational Playbook
8
+
9
+ ## How chant and Helm relate
10
+
11
+ chant is a **synthesis-only** tool — it compiles TypeScript source files into a complete Helm chart directory (Chart.yaml, values.yaml, templates/, etc.). chant does NOT call Helm CLI. Your job as an agent is to bridge the two:
12
+
13
+ - Use **chant** for: build, lint, diff (local chart comparison)
14
+ - Use **helm** for: install, upgrade, rollback, test, dependency update
15
+
16
+ The source of truth is the TypeScript in `src/`. The generated chart directory is an intermediate artifact — never edit it by hand.
17
+
18
+ ## Scaffolding a new project
19
+
20
+ ### Initialize with a template
21
+
22
+ ```bash
23
+ chant init --lexicon helm # default: Deployment + Service chart
24
+ ```
25
+
26
+ ### Project structure after init
27
+
28
+ ```
29
+ my-chart/
30
+ src/
31
+ chart.ts ← Chart metadata, Values, K8s resources with Helm intrinsics
32
+ chant.json ← project configuration
33
+ package.json
34
+ ```
35
+
36
+ ## Key concepts
37
+
38
+ ### Values proxy
39
+
40
+ The `values` proxy creates `{{ .Values.x }}` template directives:
41
+
42
+ ```typescript
43
+ import { values } from "@intentius/chant-lexicon-helm";
44
+
45
+ // values.replicaCount → {{ .Values.replicaCount }}
46
+ // values.image.repository → {{ .Values.image.repository }}
47
+ ```
48
+
49
+ ### Template functions
50
+
51
+ ```typescript
52
+ import { include, printf, toYaml, quote, required, helmDefault } from "@intentius/chant-lexicon-helm";
53
+
54
+ include("my-app.fullname") // {{ include "my-app.fullname" . }}
55
+ printf("%s:%s", values.image.repo, values.image.tag) // {{ printf "%s:%s" ... }}
56
+ toYaml(values.resources, 12) // {{ toYaml .Values.resources | nindent 12 }}
57
+ ```
58
+
59
+ ### Conditional resources
60
+
61
+ ```typescript
62
+ import { If, values } from "@intentius/chant-lexicon-helm";
63
+
64
+ // Wrap an entire resource in {{- if .Values.ingress.enabled }}
65
+ export const ingress = If(values.ingress.enabled, new Ingress({ ... }));
66
+ ```
67
+
68
+ ### Built-in objects
69
+
70
+ ```typescript
71
+ import { Release, ChartRef } from "@intentius/chant-lexicon-helm";
72
+
73
+ Release.Name // {{ .Release.Name }}
74
+ Release.Namespace // {{ .Release.Namespace }}
75
+ ChartRef.Version // {{ .Chart.Version }}
76
+ ```
77
+
78
+ ## Build and validate workflow
79
+
80
+ ```bash
81
+ # Build the chart
82
+ chant build
83
+
84
+ # Lint the TypeScript (pre-synth rules)
85
+ chant lint
86
+
87
+ # Validate the generated chart (post-synth checks)
88
+ chant check
89
+
90
+ # Validate with helm CLI
91
+ helm lint dist/
92
+ helm template test dist/
93
+ ```
94
+
95
+ ## Common patterns
96
+
97
+ ### Deployment with parameterized image
98
+
99
+ ```typescript
100
+ export const deployment = new Deployment({
101
+ metadata: {
102
+ name: include("my-app.fullname"),
103
+ labels: include("my-app.labels"),
104
+ },
105
+ spec: {
106
+ replicas: values.replicaCount,
107
+ template: {
108
+ spec: {
109
+ containers: [{
110
+ name: "my-app",
111
+ image: printf("%s:%s", values.image.repository, values.image.tag),
112
+ resources: toYaml(values.resources),
113
+ }],
114
+ },
115
+ },
116
+ },
117
+ });
118
+ ```
119
+
120
+ ### Composites for common patterns
121
+
122
+ ```typescript
123
+ import { HelmWebApp, HelmMicroservice, HelmDaemonSet, HelmWorker } from "@intentius/chant-lexicon-helm";
124
+
125
+ // Quick scaffold: Deployment + Service + Ingress + HPA + ServiceAccount
126
+ const result = HelmWebApp({ name: "my-app", port: 3000, replicas: 3 });
127
+
128
+ // Full microservice: + PDB + ConfigMap + health probes + resource limits
129
+ const msvc = HelmMicroservice({ name: "api", port: 8080 });
130
+
131
+ // DaemonSet for node-level agents (logging, monitoring)
132
+ const agent = HelmDaemonSet({ name: "log-agent", imageRepository: "fluent/fluent-bit" });
133
+
134
+ // Worker for background processors (no Service, exec probes, queue config)
135
+ const worker = HelmWorker({ name: "job-processor", replicas: 4 });
136
+ ```
137
+
138
+ ### Secret management with ExternalSecret
139
+
140
+ ```typescript
141
+ import { HelmExternalSecret } from "@intentius/chant-lexicon-helm";
142
+
143
+ const secrets = HelmExternalSecret({
144
+ name: "app-secrets",
145
+ secretStoreName: "vault",
146
+ data: {
147
+ DB_PASSWORD: "secret/data/db-password",
148
+ API_KEY: "secret/data/api-key",
149
+ },
150
+ });
151
+ ```
152
+
153
+ ### Resource ordering
154
+
155
+ ```typescript
156
+ import { withOrder, argoWave } from "@intentius/chant-lexicon-helm";
157
+
158
+ // Helm hook ordering (lower weight = runs first)
159
+ metadata: { annotations: { ...withOrder(-5) } }
160
+
161
+ // Argo CD sync waves
162
+ metadata: { annotations: { ...argoWave(2) } }
163
+ ```
164
+
165
+ ### CRD lifecycle management
166
+
167
+ ```typescript
168
+ import { HelmCRDLifecycle } from "@intentius/chant-lexicon-helm";
169
+
170
+ // Managed CRD lifecycle via Helm hooks (solves Helm's CRD limitation)
171
+ const lifecycle = HelmCRDLifecycle({
172
+ name: "my-operator",
173
+ crdContent: crdYaml,
174
+ });
175
+ ```
176
+
177
+ ## Lint rules
178
+
179
+ | Rule | Description |
180
+ |------|-------------|
181
+ | WHM001 | Chart must have name, version, apiVersion |
182
+ | WHM002 | Values should not contain bare secrets |
183
+ | WHM003 | Container images should use values references |
184
+ | WHM101 | Chart.yaml has valid apiVersion (v2) |
185
+ | WHM102 | values.schema.json present when Values used |
186
+ | WHM103 | Go template syntax valid (balanced braces) |
187
+ | WHM104 | NOTES.txt exists for application charts |
188
+ | WHM105 | _helpers.tpl exists |
189
+ | WHM201 | Resources have standard Helm labels |
190
+ | WHM301 | At least one test for application charts |
191
+ | WHM302 | Resource limits set |
192
+ | WHM401 | Image uses :latest tag or no tag |
193
+ | WHM402 | runAsNonRoot not set |
194
+ | WHM403 | readOnlyRootFilesystem not set |
195
+ | WHM404 | privileged: true detected |
196
+ | WHM405 | Resource spec missing cpu/memory |
197
+ | WHM406 | CRD lifecycle limitation |
198
+ | WHM407 | Secret with inline data |
199
+ | WHM501 | Unused values keys |
200
+ | WHM502 | Deprecated K8s API versions |
201
+
202
+ ## Troubleshooting
203
+
204
+ ### "apiVersion must be v2"
205
+ Helm 3 requires `apiVersion: v2` in Chart.yaml. Update your Chart metadata.
206
+
207
+ ### "unbalanced template braces"
208
+ A Go template expression has mismatched `{{` / `}}`. Check your intrinsic usage.
209
+
210
+ ### "hardcoded image tag"
211
+ Use `printf("%s:%s", values.image.repository, values.image.tag)` instead of literal strings for container images.
@@ -0,0 +1,132 @@
1
+ // Auto-generated Helm lexicon type declarations
2
+ // Do not edit manually
3
+
4
+ /** Minimal Declarable interface for generated types. */
5
+ interface Declarable { [key: string]: unknown; }
6
+
7
+ /** Chart.yaml metadata — defines the chart identity, version, and type. */
8
+ export interface ChartProps {
9
+ /** Chart API version (v2) */
10
+ apiVersion: string;
11
+ /** Chart name */
12
+ name: string;
13
+ /** Chart version (SemVer) */
14
+ version: string;
15
+ /** Version of the app deployed by this chart */
16
+ appVersion?: string;
17
+ /** A single-sentence description of this chart */
18
+ description?: string;
19
+ /** Chart type: application or library */
20
+ type?: string;
21
+ /** Keywords for chart search */
22
+ keywords?: string[];
23
+ /** URL of the project home page */
24
+ home?: string;
25
+ /** URL to an SVG or PNG image for the chart */
26
+ icon?: string;
27
+ /** Whether this chart is deprecated */
28
+ deprecated?: boolean;
29
+ /** URLs to source code for this chart */
30
+ sources?: string[];
31
+ /** List of chart maintainers */
32
+ maintainers?: HelmMaintainerProps[];
33
+ /** Arbitrary key-value annotations */
34
+ annotations?: Record<string, string>;
35
+ /** SemVer range of compatible Kubernetes versions */
36
+ kubeVersion?: string;
37
+ /** YAML path for chart enablement (subcharts) */
38
+ condition?: string;
39
+ /** Tags for grouping charts for enabling/disabling */
40
+ tags?: string;
41
+ }
42
+
43
+ /** Chart.yaml metadata — defines the chart identity, version, and type. */
44
+ export declare const Chart: new (props: ChartProps) => Declarable;
45
+
46
+ /** Typed values definition — emits values.yaml and values.schema.json. */
47
+ export interface ValuesProps {
48
+ [key: string]: unknown;
49
+ }
50
+
51
+ /** Typed values definition — emits values.yaml and values.schema.json. */
52
+ export declare const Values: new (props: ValuesProps) => Declarable;
53
+
54
+ /** Helm test pod — annotated with helm.sh/hook: test. */
55
+ export interface HelmTestProps {
56
+ /** K8s Pod resource to use as the test */
57
+ resource?: object;
58
+ }
59
+
60
+ /** Helm test pod — annotated with helm.sh/hook: test. */
61
+ export declare const HelmTest: new (props: HelmTestProps) => Declarable;
62
+
63
+ /** NOTES.txt template content — displayed after helm install. */
64
+ export interface HelmNotesProps {
65
+ /** NOTES.txt content (may contain Go template expressions) */
66
+ content: string;
67
+ }
68
+
69
+ /** NOTES.txt template content — displayed after helm install. */
70
+ export declare const HelmNotes: new (props: HelmNotesProps) => Declarable;
71
+
72
+ /** Lifecycle hook annotation — wraps a K8s resource with helm.sh/hook annotations. */
73
+ export interface HelmHookProps {
74
+ /** Hook type: pre-install, post-install, pre-upgrade, post-upgrade, pre-delete, post-delete, pre-rollback, post-rollback, test */
75
+ hook: string;
76
+ /** Hook execution order weight */
77
+ weight?: number;
78
+ /** Hook delete policy: before-hook-creation, hook-succeeded, hook-failed */
79
+ deletePolicy?: string;
80
+ /** K8s resource to annotate with the hook */
81
+ resource: object;
82
+ }
83
+
84
+ /** Lifecycle hook annotation — wraps a K8s resource with helm.sh/hook annotations. */
85
+ export declare const HelmHook: new (props: HelmHookProps) => Declarable;
86
+
87
+ /** Chart dependency entry for Chart.yaml dependencies. */
88
+ export interface HelmDependencyProps {
89
+ /** Dependency chart name */
90
+ name: string;
91
+ /** Dependency version range (SemVer) */
92
+ version: string;
93
+ /** Repository URL */
94
+ repository: string;
95
+ /** YAML path that enables/disables this dependency */
96
+ condition?: string;
97
+ /** Tags for grouping dependencies */
98
+ tags?: string[];
99
+ /** Whether this dependency is enabled */
100
+ enabled?: boolean;
101
+ /** Values to import from dependency (import-values in Chart.yaml) */
102
+ importValues?: unknown[];
103
+ /** Alias for the dependency */
104
+ alias?: string;
105
+ }
106
+
107
+ /** Chart dependency entry for Chart.yaml dependencies. */
108
+ export declare const HelmDependency: new (props: HelmDependencyProps) => Declarable;
109
+
110
+ /** Chart maintainer entry for Chart.yaml maintainers. */
111
+ export interface HelmMaintainerProps {
112
+ /** Maintainer name */
113
+ name: string;
114
+ /** Maintainer email */
115
+ email?: string;
116
+ /** Maintainer URL */
117
+ url?: string;
118
+ }
119
+
120
+ /** Chart maintainer entry for Chart.yaml maintainers. */
121
+ export declare const HelmMaintainer: new (props: HelmMaintainerProps) => Declarable;
122
+
123
+ /** Custom Resource Definition — placed in the crds/ directory. */
124
+ export interface HelmCRDProps {
125
+ /** CRD YAML content */
126
+ content: string;
127
+ /** CRD filename (e.g. mycrd.yaml) */
128
+ filename?: string;
129
+ }
130
+
131
+ /** Custom Resource Definition — placed in the crds/ directory. */
132
+ export declare const HelmCRD: new (props: HelmCRDProps) => Declarable;
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@intentius/chant-lexicon-helm",
3
+ "version": "0.0.16",
4
+ "license": "Apache-2.0",
5
+ "type": "module",
6
+ "files": [
7
+ "src/",
8
+ "dist/"
9
+ ],
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "exports": {
14
+ ".": "./src/index.ts",
15
+ "./*": "./src/*.ts",
16
+ "./manifest": "./dist/manifest.json",
17
+ "./meta": "./dist/meta.json",
18
+ "./types": "./dist/types/index.d.ts"
19
+ },
20
+ "scripts": {
21
+ "generate": "bun run src/codegen/generate-cli.ts",
22
+ "bundle": "bun run src/package-cli.ts",
23
+ "validate": "bun run src/validate-cli.ts",
24
+ "docs": "bun run src/codegen/docs-cli.ts",
25
+ "prepack": "bun run generate && bun run bundle && bun run validate"
26
+ },
27
+ "dependencies": {
28
+ "@intentius/chant": "0.0.15",
29
+ "@intentius/chant-lexicon-k8s": "0.0.15"
30
+ },
31
+ "devDependencies": {
32
+ "typescript": "^5.9.3"
33
+ }
34
+ }
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env bun
2
+ import { generateDocs } from "./docs";
3
+
4
+ await generateDocs({ verbose: true });