@snap/valdi 1.0.7 → 1.0.8

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 (160) hide show
  1. package/README.md +12 -3
  2. package/bundled-skills/CONTRIBUTING_SKILLS.md +74 -0
  3. package/bundled-skills/registry.json +20 -0
  4. package/bundled-skills/skills/valdi-android/skill.md +89 -0
  5. package/bundled-skills/skills/valdi-async/skill.md +246 -0
  6. package/bundled-skills/skills/valdi-async/tests/BUILD.bazel +19 -0
  7. package/bundled-skills/skills/valdi-async/tests/README.md +25 -0
  8. package/bundled-skills/skills/valdi-async/tests/src/reference.tsx +210 -0
  9. package/bundled-skills/skills/valdi-async/tests/tsconfig.json +1 -0
  10. package/bundled-skills/skills/valdi-bazel/skill.md +122 -0
  11. package/bundled-skills/skills/valdi-compiler/skill.md +108 -0
  12. package/bundled-skills/skills/valdi-component-tests/skill.md +430 -0
  13. package/bundled-skills/skills/valdi-component-tests/tests/BUILD.bazel +24 -0
  14. package/bundled-skills/skills/valdi-component-tests/tests/README.md +35 -0
  15. package/bundled-skills/skills/valdi-component-tests/tests/src/ProfileCard.tsx +38 -0
  16. package/bundled-skills/skills/valdi-component-tests/tests/test/ProfileCardTest.spec.tsx +107 -0
  17. package/bundled-skills/skills/valdi-component-tests/tests/tsconfig.json +1 -0
  18. package/bundled-skills/skills/valdi-cpp-runtime/skill.md +103 -0
  19. package/bundled-skills/skills/valdi-custom-view/skill.md +62 -0
  20. package/bundled-skills/skills/valdi-ios/skill.md +93 -0
  21. package/bundled-skills/skills/valdi-migrate/skill.md +175 -0
  22. package/bundled-skills/skills/valdi-migrate/tests/BUILD.bazel +23 -0
  23. package/bundled-skills/skills/valdi-migrate/tests/README.md +70 -0
  24. package/bundled-skills/skills/valdi-migrate/tests/check_antipatterns.py +89 -0
  25. package/bundled-skills/skills/valdi-migrate/tests/compose_example.kt +94 -0
  26. package/bundled-skills/skills/valdi-migrate/tests/flutter_example.dart +129 -0
  27. package/bundled-skills/skills/valdi-migrate/tests/react_example.tsx +98 -0
  28. package/bundled-skills/skills/valdi-migrate/tests/src/expected_valdi.tsx +267 -0
  29. package/bundled-skills/skills/valdi-migrate/tests/tsconfig.json +3 -0
  30. package/bundled-skills/skills/valdi-overview/skill.md +63 -0
  31. package/bundled-skills/skills/valdi-perf/skill.md +197 -0
  32. package/bundled-skills/skills/valdi-perf/tests/BUILD.bazel +19 -0
  33. package/bundled-skills/skills/valdi-perf/tests/README.md +26 -0
  34. package/bundled-skills/skills/valdi-perf/tests/src/reference.tsx +202 -0
  35. package/bundled-skills/skills/valdi-perf/tests/tsconfig.json +1 -0
  36. package/bundled-skills/skills/valdi-polyglot-module/skill.md +85 -0
  37. package/bundled-skills/skills/valdi-setup/skill.md +129 -0
  38. package/bundled-skills/skills/valdi-testing/skill.md +65 -0
  39. package/bundled-skills/skills/valdi-tsx/skill.md +385 -0
  40. package/bundled-skills/skills/valdi-tsx/tests/BUILD.bazel +19 -0
  41. package/bundled-skills/skills/valdi-tsx/tests/README.md +29 -0
  42. package/bundled-skills/skills/valdi-tsx/tests/src/reference.tsx +173 -0
  43. package/bundled-skills/skills/valdi-tsx/tests/tsconfig.json +1 -0
  44. package/dist/commands/bootstrap.js +0 -7
  45. package/dist/commands/newModule.js +10 -14
  46. package/dist/commands/skills.js +16 -0
  47. package/dist/commands/skills_commands/create.js +125 -0
  48. package/dist/commands/skills_commands/install.js +96 -0
  49. package/dist/commands/skills_commands/list.js +83 -0
  50. package/dist/commands/skills_commands/remove.js +41 -0
  51. package/dist/commands/skills_commands/update.js +59 -0
  52. package/dist/core/constants.js +0 -1
  53. package/dist/setup/versions.js +1 -1
  54. package/dist/utils/skillsAdapters.js +140 -0
  55. package/dist/utils/skillsRegistry.js +40 -0
  56. package/package.json +6 -1
  57. package/.bazelignore +0 -2
  58. package/.bootstrap/apps/cli_application/BUILD.bazel.template +0 -7
  59. package/.bootstrap/apps/cli_application/modules/{{MODULE_NAME}}/BUILD.bazel.template +0 -11
  60. package/.bootstrap/apps/cli_application/modules/{{MODULE_NAME}}/src/index.ts +0 -1
  61. package/.bootstrap/apps/ui_application/.eslint.rc +0 -27
  62. package/.bootstrap/apps/ui_application/BUILD.bazel.template +0 -19
  63. package/.bootstrap/apps/ui_application/modules/{{MODULE_NAME}}/BUILD.bazel.template +0 -21
  64. package/.bootstrap/apps/ui_application/modules/{{MODULE_NAME}}/res/valdi@3x.png +0 -0
  65. package/.bootstrap/apps/ui_application/modules/{{MODULE_NAME}}/src/App.tsx +0 -133
  66. package/.bootstrap/apps/ui_application/package.json +0 -24
  67. package/.bootstrap/modules/cpp_bridge_module/BUILD.bazel.template +0 -21
  68. package/.bootstrap/modules/cpp_bridge_module/cpp/CalculatorModuleFactory.cpp.template +0 -28
  69. package/.bootstrap/modules/cpp_bridge_module/src/Calculator.d.ts +0 -4
  70. package/.bootstrap/modules/ios_android_bridge_module/BUILD.bazel.template +0 -39
  71. package/.bootstrap/modules/ios_android_bridge_module/android/CalculatorModuleFactory.kt.template +0 -18
  72. package/.bootstrap/modules/ios_android_bridge_module/ios/SCCCalculatorModuleFactory.m.template +0 -31
  73. package/.bootstrap/modules/ios_android_bridge_module/src/Calculator.d.ts +0 -4
  74. package/.bootstrap/modules/ios_android_view_module/BUILD.bazel.template +0 -41
  75. package/.bootstrap/modules/ios_android_view_module/android/CircleView.kt.template +0 -42
  76. package/.bootstrap/modules/ios_android_view_module/android/CircleViewAttributesBinder.kt.template +0 -60
  77. package/.bootstrap/modules/ios_android_view_module/ios/SCCCircleView.h +0 -6
  78. package/.bootstrap/modules/ios_android_view_module/ios/SCCCircleView.m +0 -82
  79. package/.bootstrap/modules/ios_android_view_module/src/Circle.tsx.template +0 -15
  80. package/.bootstrap/modules/ui_component/BUILD.bazel.template +0 -34
  81. package/.bootstrap/modules/ui_component/src/NewModuleComponent.tsx +0 -45
  82. package/.config/copyconfig.json +0 -10
  83. package/.editorconfig +0 -21
  84. package/.eslintignore +0 -1
  85. package/.eslintrc.js +0 -72
  86. package/.github/README.md +0 -164
  87. package/.metadata/.bazelrc.template +0 -91
  88. package/.metadata/.bazelversion.template +0 -1
  89. package/.metadata/.cursorrules.template +0 -60
  90. package/.metadata/.editorconfig.template +0 -37
  91. package/.metadata/.eslintrc.js.template +0 -27
  92. package/.metadata/.gitignore.template +0 -4
  93. package/.metadata/.prettierrc.json.template +0 -7
  94. package/.metadata/.watchmanconfig.template +0 -8
  95. package/.metadata/AGENTS.md.template +0 -282
  96. package/.metadata/README.md.template +0 -31
  97. package/.metadata/WORKSPACE.template +0 -57
  98. package/.metadata/config.yaml.template +0 -1
  99. package/.metadata/package.json.template +0 -23
  100. package/.prettierignore +0 -2
  101. package/.prettierrc.json +0 -7
  102. package/LINUX_COMPATIBILITY.md +0 -248
  103. package/prettier.config.js +0 -4
  104. package/scripts/sync-agents-md.sh +0 -44
  105. package/scripts/update-agents-templates.ts +0 -170
  106. package/spec/support/jasmine.json +0 -6
  107. package/src/commands/bootstrap.ts +0 -410
  108. package/src/commands/build.ts +0 -89
  109. package/src/commands/devSetup.ts +0 -17
  110. package/src/commands/doctor.ts +0 -1832
  111. package/src/commands/export.ts +0 -131
  112. package/src/commands/hotreload.ts +0 -108
  113. package/src/commands/install.ts +0 -93
  114. package/src/commands/lint.ts +0 -15
  115. package/src/commands/lint_commands/lintCheck.ts +0 -53
  116. package/src/commands/lint_commands/lintFormat.ts +0 -49
  117. package/src/commands/log.ts +0 -108
  118. package/src/commands/newModule.ts +0 -286
  119. package/src/commands/package.ts +0 -102
  120. package/src/commands/projectsync.ts +0 -488
  121. package/src/commands/test.ts +0 -68
  122. package/src/core/constants.ts +0 -98
  123. package/src/core/errors.ts +0 -10
  124. package/src/index.ts +0 -27
  125. package/src/setup/DevSetupHelper.ts +0 -290
  126. package/src/setup/linuxSetup.ts +0 -261
  127. package/src/setup/macOSSetup.ts +0 -156
  128. package/src/setup/setupEntryPoint.ts +0 -64
  129. package/src/setup/versions.ts +0 -8
  130. package/src/utils/ArgumentsResolver.ts +0 -23
  131. package/src/utils/BazelClient.ts +0 -285
  132. package/src/utils/Digraph.ts +0 -81
  133. package/src/utils/LoadingIndicator.ts +0 -43
  134. package/src/utils/applicationUtils.ts +0 -276
  135. package/src/utils/buildInfo.ts +0 -99
  136. package/src/utils/byString.ts +0 -3
  137. package/src/utils/cliUtils.ts +0 -112
  138. package/src/utils/copyBootstrapFiles.ts +0 -30
  139. package/src/utils/deviceUtils.ts +0 -76
  140. package/src/utils/errorUtils.ts +0 -63
  141. package/src/utils/fileUtils.ts +0 -257
  142. package/src/utils/githubUtils.ts +0 -102
  143. package/src/utils/jsonUtils.ts +0 -30
  144. package/src/utils/lintUtils.ts +0 -190
  145. package/src/utils/linuxDistro.spec.ts +0 -219
  146. package/src/utils/linuxDistro.ts +0 -326
  147. package/src/utils/logUtils.ts +0 -9
  148. package/src/utils/pathUtils.ts +0 -12
  149. package/src/utils/stringUtils.spec.ts +0 -95
  150. package/src/utils/stringUtils.ts +0 -103
  151. package/src/utils/tempDir.ts +0 -24
  152. package/src/utils/zipUtils.ts +0 -14
  153. package/test/ValdiSmokeTest.ts +0 -279
  154. package/test/helpers/AsyncHelpers.ts +0 -113
  155. package/test/helpers/CommandHelpers.ts +0 -37
  156. package/test/helpers/ProjectHelpers.ts +0 -153
  157. package/test/helpers/StreamHelpers.ts +0 -37
  158. package/test/helpers/TypeScriptClient.ts +0 -217
  159. package/tsconfig.dist.json +0 -8
  160. package/tsconfig.json +0 -42
@@ -0,0 +1,210 @@
1
+ // valdi-async skill reference — compile check for async lifecycle safety patterns.
2
+ // This file must compile cleanly against the Valdi TypeScript compiler.
3
+ // Run: bzl build //ai-skills/skills/valdi-async/tests:tests
4
+
5
+ import { StatefulComponent } from 'valdi_core/src/Component';
6
+ import { CancelablePromise, promiseToCancelablePromise } from 'valdi_core/src/CancelablePromise';
7
+ import { setTimeoutInterruptible } from 'valdi_core/src/SetTimeout';
8
+ import { HTTPClient } from 'valdi_http/src/HTTPClient';
9
+ import { HTTPResponse } from 'valdi_http/src/HTTPTypes';
10
+
11
+ // ─── HTTPClient: store, cancel in onDestroy, cancel before restart ────────────
12
+
13
+ interface UserProfileViewModel {
14
+ userId: string;
15
+ }
16
+
17
+ interface UserProfileState {
18
+ user: { name: string } | null;
19
+ loading: boolean;
20
+ }
21
+
22
+ class UserProfile extends StatefulComponent<UserProfileViewModel, UserProfileState> {
23
+ state: UserProfileState = { user: null, loading: true };
24
+
25
+ private client = new HTTPClient('https://api.example.com');
26
+ private request?: CancelablePromise<HTTPResponse>;
27
+
28
+ onCreate(): void {
29
+ this.fetchUser(this.viewModel.userId);
30
+ }
31
+
32
+ onViewModelUpdate(previous?: UserProfileViewModel): void {
33
+ if (this.viewModel.userId !== previous?.userId) {
34
+ this.request?.cancel?.(); // Cancel in-flight before starting new one
35
+ this.fetchUser(this.viewModel.userId);
36
+ }
37
+ }
38
+
39
+ onDestroy(): void {
40
+ this.request?.cancel?.(); // Always clean up
41
+ }
42
+
43
+ private fetchUser(id: string): void {
44
+ this.request = this.client.get(`/users/${id}`);
45
+ this.request.then(response => {
46
+ const user = JSON.parse(new TextDecoder().decode(response.body)) as { name: string };
47
+ this.setState({ user, loading: false });
48
+ });
49
+ }
50
+
51
+ onRender(): void {
52
+ if (this.state.loading) {
53
+ <spinner />;
54
+ return;
55
+ }
56
+ <label value={this.state.user?.name ?? ''} />;
57
+ }
58
+ }
59
+
60
+ // ─── registerDisposable: timers and subscriptions ────────────────────────────
61
+
62
+ interface ClockViewModel {
63
+ format: string;
64
+ }
65
+
66
+ interface ClockState {
67
+ ticks: number;
68
+ }
69
+
70
+ class LiveClock extends StatefulComponent<ClockViewModel, ClockState> {
71
+ state: ClockState = { ticks: 0 };
72
+
73
+ onCreate(): void {
74
+ // ✅ Automatically cancelled on destroy — no onDestroy() needed
75
+ const id = setInterval(() => this.tick(), 1000);
76
+ this.registerDisposable({ cancel: () => clearInterval(id) });
77
+ }
78
+
79
+ private tick = (): void => {
80
+ this.setState({ ticks: this.state.ticks + 1 });
81
+ };
82
+
83
+ onRender(): void {
84
+ <label value={String(this.state.ticks)} />;
85
+ }
86
+ }
87
+
88
+ // ─── isDestroyed() guard for plain Promises ──────────────────────────────────
89
+
90
+ declare function expensiveOperation(): Promise<string>;
91
+
92
+ interface DataState {
93
+ data: string | null;
94
+ }
95
+
96
+ interface DataViewModel {
97
+ query: string;
98
+ }
99
+
100
+ class DataLoader extends StatefulComponent<DataViewModel, DataState> {
101
+ state: DataState = { data: null };
102
+
103
+ onCreate(): void {
104
+ this.loadData().catch(() => {});
105
+ }
106
+
107
+ private async loadData(): Promise<void> {
108
+ const result = await expensiveOperation();
109
+
110
+ if (this.isDestroyed()) return; // Guard before setState
111
+
112
+ this.setState({ data: result });
113
+ }
114
+
115
+ onRender(): void {
116
+ <label value={this.state.data ?? 'Loading…'} />;
117
+ }
118
+ }
119
+
120
+ // ─── setTimeoutInterruptible for debounce ────────────────────────────────────
121
+ // setTimeoutInterruptible returns number (timer ID) — cancel with clearTimeout
122
+
123
+ interface SearchViewModel {
124
+ query: string;
125
+ }
126
+
127
+ interface SearchState {
128
+ results: string[];
129
+ }
130
+
131
+ class SearchBar extends StatefulComponent<SearchViewModel, SearchState> {
132
+ state: SearchState = { results: [] };
133
+
134
+ private debounceId?: number;
135
+ private searchRequest?: CancelablePromise<HTTPResponse>;
136
+ private client = new HTTPClient('https://api.example.com');
137
+
138
+ onViewModelUpdate(previous?: SearchViewModel): void {
139
+ if (this.viewModel.query !== previous?.query) {
140
+ clearTimeout(this.debounceId); // Cancel pending debounce
141
+ this.debounceId = setTimeoutInterruptible(() => {
142
+ this.fetchResults(this.viewModel.query);
143
+ }, 300);
144
+ }
145
+ }
146
+
147
+ onDestroy(): void {
148
+ this.searchRequest?.cancel?.();
149
+ }
150
+
151
+ private fetchResults(query: string): void {
152
+ this.searchRequest?.cancel?.();
153
+ this.searchRequest = this.client.get(`/search?q=${encodeURIComponent(query)}`);
154
+ this.searchRequest.then(response => {
155
+ const data = JSON.parse(new TextDecoder().decode(response.body)) as { results: string[] };
156
+ this.setState({ results: data.results });
157
+ });
158
+ }
159
+
160
+ onRender(): void {
161
+ <scroll>
162
+ {this.state.results.forEach(result => {
163
+ <label key={result} value={result} />;
164
+ })}
165
+ </scroll>;
166
+ }
167
+ }
168
+
169
+ // ─── promiseToCancelablePromise ──────────────────────────────────────────────
170
+
171
+ declare function thirdPartyFetch(url: string): Promise<string>;
172
+
173
+ interface FetchState {
174
+ content: string | null;
175
+ }
176
+
177
+ interface FetchViewModel {
178
+ url: string;
179
+ }
180
+
181
+ class ThirdPartyFetcher extends StatefulComponent<FetchViewModel, FetchState> {
182
+ state: FetchState = { content: null };
183
+
184
+ private request?: CancelablePromise<string>;
185
+
186
+ onCreate(): void {
187
+ const rawPromise = thirdPartyFetch(this.viewModel.url);
188
+ this.request = promiseToCancelablePromise(rawPromise, () => {
189
+ // optional cleanup on cancel
190
+ });
191
+ this.request.then(content => {
192
+ if (this.isDestroyed()) return;
193
+ this.setState({ content });
194
+ });
195
+ }
196
+
197
+ onDestroy(): void {
198
+ this.request?.cancel?.();
199
+ }
200
+
201
+ onRender(): void {
202
+ <label value={this.state.content ?? ''} />;
203
+ }
204
+ }
205
+
206
+ void UserProfile;
207
+ void LiveClock;
208
+ void DataLoader;
209
+ void SearchBar;
210
+ void ThirdPartyFetcher;
@@ -0,0 +1 @@
1
+ {"extends": "../../../../src/valdi_modules/src/valdi/_configs/base.tsconfig.json"}
@@ -0,0 +1,122 @@
1
+ # Bazel Build System Rules
2
+
3
+ **Applies to**: `BUILD.bazel`, `*.bzl` files in `/bzl/`, `WORKSPACE`, `MODULE.bazel`
4
+
5
+ ## Overview
6
+
7
+ Valdi uses Bazel as its build system. Bazel provides reproducible, incremental builds across all platforms.
8
+
9
+ ## Key Commands
10
+
11
+ ```bash
12
+ # Build everything
13
+ bazel build //...
14
+
15
+ # Build specific target
16
+ bazel build //apps/helloworld:helloworld
17
+
18
+ # Run tests
19
+ bazel test //...
20
+
21
+ # Clean (use sparingly - cache is valuable!)
22
+ bazel clean
23
+ ```
24
+
25
+ ## Important Notes
26
+
27
+ 1. **Use `bazel`** for all build commands
28
+ 2. **The CLI wraps Bazel** - `valdi` commands use bazel under the hood
29
+ 3. **Cache is important** - Don't suggest `bazel clean` unless necessary
30
+
31
+ ## Build Rules
32
+
33
+ ### Valdi-Specific Rules
34
+
35
+ - `/bzl/valdi/` - Valdi build rules and macros
36
+ - Custom rules for compiling .tsx to .valdimodule
37
+ - Platform-specific build transitions
38
+
39
+ ### Common Targets
40
+
41
+ ```python
42
+ # Valdi application
43
+ valdi_application(
44
+ name = "my_app",
45
+ root_component_path = "App@my_app/src/MyApp",
46
+ title = "My App",
47
+ version = "1.0.0",
48
+ deps = ["//apps/my_app/src/valdi/my_app"],
49
+ )
50
+
51
+ # Valdi module
52
+ valdi_module(
53
+ name = "my_module",
54
+ srcs = glob(["src/**/*.ts", "src/**/*.tsx"]),
55
+ deps = [
56
+ "//src/valdi_modules/src/valdi/valdi_core",
57
+ ],
58
+ )
59
+ ```
60
+
61
+ ## Conventions
62
+
63
+ ### File Naming
64
+
65
+ - `BUILD.bazel` not `BUILD` (explicit extension)
66
+ - `.bzl` for Starlark macros and rules
67
+
68
+ ### Targets
69
+
70
+ - Use descriptive target names
71
+ - One main target per BUILD file usually matches directory name
72
+
73
+ ### Dependencies
74
+
75
+ - Be explicit about dependencies
76
+ - Don't rely on transitive deps implicitly
77
+ - Use visibility to control access
78
+
79
+ ## Platform Builds
80
+
81
+ ```bash
82
+ # Build and install iOS app
83
+ valdi install ios
84
+
85
+ # Build and install Android app
86
+ valdi install android
87
+
88
+ # Or use bazel directly with configs
89
+ bazel build //apps/helloworld:hello_world --config=ios
90
+ bazel build //apps/helloworld:hello_world --config=android
91
+ ```
92
+
93
+ ## Configuration
94
+
95
+ - `.bazelrc` - Build flags and configurations
96
+ - `MODULE.bazel` - Bazel module dependencies
97
+ - `WORKSPACE` - Legacy workspace configuration (being migrated to MODULE.bazel)
98
+
99
+ ## Common Issues
100
+
101
+ 1. **Missing dependencies** - Add to `deps` in BUILD.bazel
102
+ 2. **Cache issues** - Try `bazel clean --expunge` (last resort)
103
+ 3. **Platform transitions** - Use correct config flags
104
+
105
+ ## Testing
106
+
107
+ ```bash
108
+ # Run all tests
109
+ bazel test //...
110
+
111
+ # Run specific test
112
+ bazel test //valdi/test:renderer_test
113
+
114
+ # Run with coverage
115
+ bazel coverage //...
116
+ ```
117
+
118
+ ## More Information
119
+
120
+ - Bazel docs: https://bazel.build
121
+ - Valdi build rules: `/bzl/valdi/README.md`
122
+ - Framework docs: `/AGENTS.md`
@@ -0,0 +1,108 @@
1
+ # Valdi Compiler Rules
2
+
3
+ **Applies to**: Swift files in `/compiler/compiler/`
4
+
5
+ ## Overview
6
+
7
+ The Valdi compiler consists of two parts:
8
+
9
+ 1. **Compiler (Swift)**: Transforms TypeScript/TSX into `.valdimodule` files
10
+ 2. **Companion (TypeScript/Node.js)**: Handles TypeScript compilation, type checking, and provides debugging support
11
+
12
+ ## Key Conventions
13
+
14
+ ### Code Style
15
+
16
+ - **4-space indentation** for Swift
17
+ - Follow Swift naming conventions (camelCase for methods, PascalCase for types)
18
+ - Use Swift type inference where appropriate
19
+ - Prefer `let` over `var` when possible
20
+
21
+ ### Architecture
22
+
23
+ - Compiler is a multi-pass system
24
+ - AST transformation pipeline
25
+ - Type checking and validation
26
+ - Code generation for each platform
27
+
28
+ ### Important Files
29
+
30
+ - `/compiler/compiler/` - Main Swift compiler implementation
31
+ - Output: `.valdimodule` files (binary format read by runtime)
32
+
33
+ ## Common Patterns
34
+
35
+ ### AST Traversal
36
+
37
+ ```swift
38
+ // Follow existing visitor patterns
39
+ class MyASTVisitor: ASTVisitor {
40
+ func visit(_ node: Node) -> Result {
41
+ // Visit logic
42
+ }
43
+ }
44
+ ```
45
+
46
+ ### Error Handling
47
+
48
+ ```swift
49
+ // Use proper error types
50
+ enum CompilerError: Error {
51
+ case invalidSyntax(String)
52
+ case typeError(String)
53
+ }
54
+ ```
55
+
56
+ ## Testing
57
+
58
+ Tests are critical - add tests for new features and error cases. The `update_compiler.sh` script runs tests automatically.
59
+
60
+ ## Build
61
+
62
+ ### Using the update script (recommended):
63
+
64
+ ```bash
65
+ cd compiler/compiler
66
+ ./scripts/update_compiler.sh ../../bin/compiler
67
+ ```
68
+
69
+ This script:
70
+ - Runs `swift test` automatically
71
+ - Builds the compiler for the correct architecture
72
+ - Copies the binary to `bin/compiler/macos/valdi_compiler` (or `linux/valdi_compiler`)
73
+ - Handles platform differences (macOS vs Linux)
74
+
75
+ ### Alternative: Using Xcode
76
+
77
+ Open `compiler/compiler/Compiler/Package.swift` in Xcode, let it resolve dependencies, then build.
78
+
79
+ ## Companion (TypeScript)
80
+
81
+ The companion is a TypeScript service that works alongside the Swift compiler. It handles TypeScript compilation, type checking, and provides debugging support.
82
+
83
+ ### Build the companion:
84
+
85
+ ```bash
86
+ cd compiler/companion
87
+ ./scripts/update_companion.sh ../../bin/compiler_companion
88
+ ```
89
+
90
+ This script:
91
+ - Runs `npm install`
92
+ - Runs `npm run test`
93
+ - Builds with `bazel build //compiler/companion:bundle`
94
+ - Copies output to `bin/compiler_companion`
95
+
96
+ **Note**: Once built, the companion is automatically invoked by the compiler during compilation. You don't need to run it manually - it's part of the compiler process.
97
+
98
+ ## Important Notes
99
+
100
+ 1. **Performance matters** - Compiler speed affects developer experience
101
+ 2. **Error messages** - Make them helpful and actionable
102
+ 3. **Backward compatibility** - Don't break existing .valdimodule files
103
+ 4. **Cross-platform** - Consider iOS, Android, macOS targets
104
+
105
+ ## More Information
106
+
107
+ - Compiler architecture: `/compiler/compiler/README.md`
108
+ - Framework docs: `/AGENTS.md`