@snap/valdi 1.0.1 → 1.0.6
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/.bootstrap/apps/cli_application/AGENTS.md.template +76 -0
- package/.bootstrap/apps/ui_application/AGENTS.md.template +79 -3
- package/.bootstrap/modules/cpp_bridge_module/BUILD.bazel.template +3 -3
- package/.bootstrap/modules/cpp_bridge_module/cpp/CalculatorModuleFactory.cpp.template +18 -19
- package/.bootstrap/modules/cpp_bridge_module/src/Calculator.d.ts +3 -0
- package/.github/README.md +164 -0
- package/.metadata/.cursorrules.template +53 -0
- package/.metadata/.editorconfig.template +37 -0
- package/LINUX_COMPATIBILITY.md +248 -0
- package/README.md +99 -15
- package/dist/commands/bootstrap.js +79 -19
- package/dist/commands/doctor.js +361 -54
- package/dist/commands/newModule.js +15 -12
- package/dist/core/constants.js +2 -0
- package/dist/setup/DevSetupHelper.js +81 -6
- package/dist/setup/linuxSetup.js +149 -11
- package/dist/setup/macOSSetup.js +96 -8
- package/dist/utils/githubUtils.js +74 -2
- package/dist/utils/linuxDistro.js +255 -0
- package/dist/utils/linuxDistro.spec.js +170 -0
- package/dist/utils/stringUtils.js +60 -0
- package/dist/utils/stringUtils.spec.js +63 -0
- package/package.json +11 -3
- package/scripts/sync-agents-md.sh +44 -0
- package/scripts/update-agents-templates.ts +170 -0
- package/src/commands/bootstrap.ts +117 -25
- package/src/commands/doctor.ts +469 -59
- package/src/commands/newModule.ts +18 -19
- package/src/core/constants.ts +2 -0
- package/src/setup/DevSetupHelper.ts +108 -6
- package/src/setup/linuxSetup.ts +235 -12
- package/src/setup/macOSSetup.ts +122 -8
- package/src/utils/githubUtils.ts +98 -2
- package/src/utils/linuxDistro.spec.ts +219 -0
- package/src/utils/linuxDistro.ts +326 -0
- package/src/utils/stringUtils.spec.ts +77 -1
- package/src/utils/stringUtils.ts +88 -0
- package/test/ValdiSmokeTest.ts +5 -4
- package/test/helpers/TypeScriptClient.ts +2 -2
|
@@ -6,6 +6,82 @@ This document provides context and guidelines for AI coding assistants working o
|
|
|
6
6
|
|
|
7
7
|
This is a Valdi command-line application that runs in a terminal. Valdi compiles TypeScript to native code, enabling you to write performant CLI tools in TypeScript with access to native platform APIs.
|
|
8
8
|
|
|
9
|
+
|
|
10
|
+
## 🚨 CRITICAL: Valdi is NOT React!
|
|
11
|
+
|
|
12
|
+
**AI assistants often suggest React patterns that DON'T EXIST in Valdi.** This is because TSX/JSX syntax looks like React, but Valdi compiles to native code.
|
|
13
|
+
|
|
14
|
+
### ❌ FORBIDDEN Patterns (Don't exist in Valdi)
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
// ❌ WRONG - React hooks don't exist
|
|
18
|
+
const [count, setCount] = useState(0);
|
|
19
|
+
useEffect(() => { ... }, []);
|
|
20
|
+
|
|
21
|
+
// ❌ WRONG - Functional components don't exist
|
|
22
|
+
const MyComponent = () => <view />;
|
|
23
|
+
|
|
24
|
+
// ❌ WRONG - Common AI mistakes
|
|
25
|
+
this.markNeedsRender(); // Doesn't exist!
|
|
26
|
+
this.props.title; // Should be: this.viewModel.title
|
|
27
|
+
onMount() { } // Should be: onCreate()
|
|
28
|
+
onUpdate() { } // Should be: onViewModelUpdate()
|
|
29
|
+
onUnmount() { } // Should be: onDestroy()
|
|
30
|
+
this.context.get(Service); // Wrong pattern, use withProviders()
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### ✅ CORRECT Valdi Patterns
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
// ✅ Stateful component with state
|
|
37
|
+
import { StatefulComponent } from 'valdi_core/src/Component';
|
|
38
|
+
|
|
39
|
+
class MyComponent extends StatefulComponent<ViewModel, State> {
|
|
40
|
+
state = { count: 0 };
|
|
41
|
+
|
|
42
|
+
// Lifecycle methods
|
|
43
|
+
onCreate() { } // Component created
|
|
44
|
+
onViewModelUpdate(prev: ViewModel) { } // Props changed
|
|
45
|
+
onDestroy() { } // Before removal
|
|
46
|
+
|
|
47
|
+
// State updates
|
|
48
|
+
handleClick() {
|
|
49
|
+
this.setState({ count: this.state.count + 1 }); // Auto re-renders
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Render (returns void, JSX is statement)
|
|
53
|
+
onRender() {
|
|
54
|
+
<button
|
|
55
|
+
title={`Count: ${this.state.count}`}
|
|
56
|
+
onPress={this.handleClick}
|
|
57
|
+
/>;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// ✅ Stateless component (props only)
|
|
62
|
+
import { Component } from 'valdi_core/src/Component';
|
|
63
|
+
|
|
64
|
+
class SimpleComponent extends Component<ViewModel> {
|
|
65
|
+
onRender() {
|
|
66
|
+
<label value={this.viewModel.title} />; // viewModel, not props!
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Key Differences from React
|
|
72
|
+
|
|
73
|
+
| Concept | React | Valdi |
|
|
74
|
+
|---------|-------|-------|
|
|
75
|
+
| **Components** | Functions or classes | Classes only (Component or StatefulComponent) |
|
|
76
|
+
| **State** | `useState` hook | `state = { }` + `setState()` |
|
|
77
|
+
| **Props** | `this.props` | `this.viewModel` |
|
|
78
|
+
| **Lifecycle** | `useEffect` | `onCreate`, `onViewModelUpdate`, `onDestroy` |
|
|
79
|
+
| **Re-render** | `setCount(...)` | `this.setState(...)` |
|
|
80
|
+
| **Return** | `return <view />` | `<view />;` (statement, returns void) |
|
|
81
|
+
|
|
82
|
+
For complete framework documentation, see: https://github.com/Snapchat/Valdi
|
|
83
|
+
|
|
84
|
+
|
|
9
85
|
## Project Structure
|
|
10
86
|
|
|
11
87
|
- **`modules/`** - Your application modules
|
|
@@ -6,6 +6,82 @@ This document provides context and guidelines for AI coding assistants working o
|
|
|
6
6
|
|
|
7
7
|
This is a Valdi application that runs natively on iOS, Android, and macOS. Valdi is a cross-platform UI framework that compiles declarative TypeScript components to native views - no web views, no JavaScript bridges.
|
|
8
8
|
|
|
9
|
+
|
|
10
|
+
## 🚨 CRITICAL: Valdi is NOT React!
|
|
11
|
+
|
|
12
|
+
**AI assistants often suggest React patterns that DON'T EXIST in Valdi.** This is because TSX/JSX syntax looks like React, but Valdi compiles to native code.
|
|
13
|
+
|
|
14
|
+
### ❌ FORBIDDEN Patterns (Don't exist in Valdi)
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
// ❌ WRONG - React hooks don't exist
|
|
18
|
+
const [count, setCount] = useState(0);
|
|
19
|
+
useEffect(() => { ... }, []);
|
|
20
|
+
|
|
21
|
+
// ❌ WRONG - Functional components don't exist
|
|
22
|
+
const MyComponent = () => <view />;
|
|
23
|
+
|
|
24
|
+
// ❌ WRONG - Common AI mistakes
|
|
25
|
+
this.markNeedsRender(); // Doesn't exist!
|
|
26
|
+
this.props.title; // Should be: this.viewModel.title
|
|
27
|
+
onMount() { } // Should be: onCreate()
|
|
28
|
+
onUpdate() { } // Should be: onViewModelUpdate()
|
|
29
|
+
onUnmount() { } // Should be: onDestroy()
|
|
30
|
+
this.context.get(Service); // Wrong pattern, use withProviders()
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### ✅ CORRECT Valdi Patterns
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
// ✅ Stateful component with state
|
|
37
|
+
import { StatefulComponent } from 'valdi_core/src/Component';
|
|
38
|
+
|
|
39
|
+
class MyComponent extends StatefulComponent<ViewModel, State> {
|
|
40
|
+
state = { count: 0 };
|
|
41
|
+
|
|
42
|
+
// Lifecycle methods
|
|
43
|
+
onCreate() { } // Component created
|
|
44
|
+
onViewModelUpdate(prev: ViewModel) { } // Props changed
|
|
45
|
+
onDestroy() { } // Before removal
|
|
46
|
+
|
|
47
|
+
// State updates
|
|
48
|
+
handleClick() {
|
|
49
|
+
this.setState({ count: this.state.count + 1 }); // Auto re-renders
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Render (returns void, JSX is statement)
|
|
53
|
+
onRender() {
|
|
54
|
+
<button
|
|
55
|
+
title={`Count: ${this.state.count}`}
|
|
56
|
+
onPress={this.handleClick}
|
|
57
|
+
/>;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// ✅ Stateless component (props only)
|
|
62
|
+
import { Component } from 'valdi_core/src/Component';
|
|
63
|
+
|
|
64
|
+
class SimpleComponent extends Component<ViewModel> {
|
|
65
|
+
onRender() {
|
|
66
|
+
<label value={this.viewModel.title} />; // viewModel, not props!
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Key Differences from React
|
|
72
|
+
|
|
73
|
+
| Concept | React | Valdi |
|
|
74
|
+
|---------|-------|-------|
|
|
75
|
+
| **Components** | Functions or classes | Classes only (Component or StatefulComponent) |
|
|
76
|
+
| **State** | `useState` hook | `state = { }` + `setState()` |
|
|
77
|
+
| **Props** | `this.props` | `this.viewModel` |
|
|
78
|
+
| **Lifecycle** | `useEffect` | `onCreate`, `onViewModelUpdate`, `onDestroy` |
|
|
79
|
+
| **Re-render** | `setCount(...)` | `this.setState(...)` |
|
|
80
|
+
| **Return** | `return <view />` | `<view />;` (statement, returns void) |
|
|
81
|
+
|
|
82
|
+
For complete framework documentation, see: https://github.com/Snapchat/Valdi
|
|
83
|
+
|
|
84
|
+
|
|
9
85
|
## Project Structure
|
|
10
86
|
|
|
11
87
|
- **`modules/`** - Your application modules
|
|
@@ -84,9 +160,9 @@ class MyComponent extends Component {
|
|
|
84
160
|
}
|
|
85
161
|
|
|
86
162
|
// Optional lifecycle methods:
|
|
87
|
-
//
|
|
88
|
-
//
|
|
89
|
-
//
|
|
163
|
+
// onCreate() - Called when component is first created
|
|
164
|
+
// onDestroy() - Called before component is removed
|
|
165
|
+
// onViewModelUpdate(previousViewModel) - Called when viewModel updates
|
|
90
166
|
}
|
|
91
167
|
```
|
|
92
168
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
load("@valdi//bzl/valdi:valdi_module.bzl", "valdi_module")
|
|
2
2
|
|
|
3
3
|
cc_library(
|
|
4
|
-
name = "{{MODULE_NAME}}
|
|
4
|
+
name = "{{MODULE_NAME}}_cpp_impl",
|
|
5
5
|
srcs = glob(["cpp/**/*.cpp"]),
|
|
6
6
|
hdrs = glob(["cpp/**/*.hpp"]),
|
|
7
7
|
includes = [],
|
|
8
|
-
deps = ["
|
|
8
|
+
deps = [":{{MODULE_NAME}}_cpp"],
|
|
9
9
|
alwayslink = 1,
|
|
10
10
|
)
|
|
11
11
|
|
|
@@ -15,7 +15,7 @@ valdi_module(
|
|
|
15
15
|
"src/**/*.ts",
|
|
16
16
|
"src/**/*.tsx",
|
|
17
17
|
]),
|
|
18
|
-
native_deps = [":{{MODULE_NAME}}
|
|
18
|
+
native_deps = [":{{MODULE_NAME}}_cpp_impl"],
|
|
19
19
|
visibility = ["//visibility:public"],
|
|
20
20
|
deps = [],
|
|
21
21
|
)
|
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
#include "
|
|
2
|
-
#include "valdi_core/cpp/Utils/ValueFunctionWithCallable.hpp"
|
|
1
|
+
#include "valdi_modules/{{MODULE_NAME}}/{{MODULE_NAME}}.hpp"
|
|
3
2
|
|
|
4
|
-
namespace
|
|
3
|
+
using namespace Valdi;
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
namespace snap::valdi_modules::{{MODULE_NAME}} {
|
|
6
|
+
|
|
7
|
+
class CalculatorModuleFactoryImpl : public CalculatorModuleFactory {
|
|
7
8
|
public:
|
|
8
|
-
|
|
9
|
-
~CalculatorModuleFactory() override = default;
|
|
9
|
+
CalculatorModuleFactoryImpl() = default;
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
Ref<CalculatorModule> onLoadModule() final {
|
|
12
|
+
class CalculatorModuleImpl : public CalculatorModule {
|
|
13
|
+
public:
|
|
14
|
+
CalculatorModuleImpl() = default;
|
|
15
|
+
~CalculatorModuleImpl() override = default;
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
auto left = callContext.getParameterAsDouble(0);
|
|
20
|
-
auto right = callContext.getParameterAsDouble(1);
|
|
17
|
+
double multiply(double left, double right) final {
|
|
18
|
+
return left * right;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
})));
|
|
22
|
+
return makeShared<CalculatorModuleImpl>();
|
|
24
23
|
}
|
|
25
24
|
};
|
|
26
25
|
|
|
27
|
-
|
|
26
|
+
static auto registerCalculatorModuleFactory = RegisterModuleFactory::registerTyped<CalculatorModuleFactoryImpl>();
|
|
28
27
|
|
|
29
|
-
} // namespace snap::
|
|
28
|
+
} // namespace snap::valdi_modules::{{MODULE_NAME}}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# GitHub Actions CI for Valdi CLI
|
|
2
|
+
|
|
3
|
+
## Workflows
|
|
4
|
+
|
|
5
|
+
### 1. `test-cli-linux.yml` - Linux Distribution Testing
|
|
6
|
+
|
|
7
|
+
Tests the CLI on multiple Linux distributions to ensure proper distribution detection and package management.
|
|
8
|
+
|
|
9
|
+
**Triggers:**
|
|
10
|
+
- Pull requests touching CLI source files
|
|
11
|
+
- Pushes to main branch
|
|
12
|
+
- Manual workflow dispatch
|
|
13
|
+
|
|
14
|
+
**Test Matrix:**
|
|
15
|
+
- Ubuntu 22.04
|
|
16
|
+
- Ubuntu 24.04
|
|
17
|
+
- Fedora 39
|
|
18
|
+
- Fedora 40
|
|
19
|
+
|
|
20
|
+
**Tests:**
|
|
21
|
+
1. **Distribution Detection**
|
|
22
|
+
- Verifies correct detection of distribution type (Debian, RedHat)
|
|
23
|
+
- Validates package manager identification (apt, dnf)
|
|
24
|
+
- Checks distribution name parsing
|
|
25
|
+
|
|
26
|
+
2. **Package Name Mappings**
|
|
27
|
+
- Tests all common package mappings (git, npm, Java, etc.)
|
|
28
|
+
- Ensures correct package names for each distribution
|
|
29
|
+
- Validates fallback behavior
|
|
30
|
+
|
|
31
|
+
3. **Install Command Generation**
|
|
32
|
+
- Tests single and multiple package installation commands
|
|
33
|
+
- Verifies correct package manager usage
|
|
34
|
+
- Validates sudo requirement handling
|
|
35
|
+
|
|
36
|
+
4. **Git-LFS Setup Detection**
|
|
37
|
+
- Tests whether repository setup is needed
|
|
38
|
+
- Validates setup command generation
|
|
39
|
+
- Checks Debian vs RPM script selection
|
|
40
|
+
|
|
41
|
+
5. **`valdi doctor` Integration**
|
|
42
|
+
- Runs the doctor command on each distribution
|
|
43
|
+
- Verifies it executes without errors
|
|
44
|
+
- Checks distribution-specific fix commands
|
|
45
|
+
|
|
46
|
+
6. **Unit Tests**
|
|
47
|
+
- Runs Jasmine unit tests for `linuxDistro` utilities
|
|
48
|
+
- Validates ESLint compliance
|
|
49
|
+
|
|
50
|
+
**Example Run:**
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Locally test distribution detection (requires Docker)
|
|
54
|
+
docker run -it ubuntu:22.04 bash
|
|
55
|
+
# Install Node.js, clone repo, run tests
|
|
56
|
+
|
|
57
|
+
# Or use act to run GitHub Actions locally
|
|
58
|
+
act -j test-distribution-detection -P ubuntu-22.04=ubuntu:22.04
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 2. `bzl-changes.yml` - Main CI Pipeline (Updated)
|
|
62
|
+
|
|
63
|
+
**Changes:**
|
|
64
|
+
- Added `test-cli-linux` job to test CLI on Linux containers
|
|
65
|
+
- Updated path triggers to include `npm_modules/cli/src/**`
|
|
66
|
+
- Tests run alongside existing Bazel validation
|
|
67
|
+
|
|
68
|
+
**Linux Job:**
|
|
69
|
+
- Tests CLI on Ubuntu and Fedora
|
|
70
|
+
- Validates distribution detection
|
|
71
|
+
- Ensures package mappings work correctly
|
|
72
|
+
|
|
73
|
+
### 3. `publish-npm.yml` - NPM Publishing
|
|
74
|
+
|
|
75
|
+
**No changes needed** - builds and publishes on Ubuntu, which now benefits from the improved Linux support.
|
|
76
|
+
|
|
77
|
+
## Running Tests Locally
|
|
78
|
+
|
|
79
|
+
### Test Distribution Detection
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# On your Linux machine
|
|
83
|
+
cd npm_modules/cli
|
|
84
|
+
npm install
|
|
85
|
+
npm run build
|
|
86
|
+
|
|
87
|
+
# Test distribution detection
|
|
88
|
+
node -e "
|
|
89
|
+
const distro = require('./dist/utils/linuxDistro');
|
|
90
|
+
const detected = distro.detectLinuxDistro();
|
|
91
|
+
console.log('Detected:', detected);
|
|
92
|
+
"
|
|
93
|
+
|
|
94
|
+
# Run unit tests
|
|
95
|
+
npx jasmine dist/utils/linuxDistro.spec.js
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Test on Multiple Distributions (Docker)
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Ubuntu 22.04
|
|
102
|
+
docker run --rm -v $(pwd):/workspace -w /workspace node:22-slim bash -c "
|
|
103
|
+
apt-get update && apt-get install -y git
|
|
104
|
+
cd npm_modules/cli
|
|
105
|
+
npm install && npm run build
|
|
106
|
+
node -e \"const d = require('./dist/utils/linuxDistro'); console.log(d.detectLinuxDistro())\"
|
|
107
|
+
"
|
|
108
|
+
|
|
109
|
+
# Fedora 39
|
|
110
|
+
docker run --rm -v $(pwd):/workspace -w /workspace node:22-slim bash -c "
|
|
111
|
+
dnf install -y git
|
|
112
|
+
cd npm_modules/cli
|
|
113
|
+
npm install && npm run build
|
|
114
|
+
node -e \"const d = require('./dist/utils/linuxDistro'); console.log(d.detectLinuxDistro())\"
|
|
115
|
+
"
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## CI Badge
|
|
119
|
+
|
|
120
|
+
Add this to your README to show CI status:
|
|
121
|
+
|
|
122
|
+
```markdown
|
|
123
|
+

|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Troubleshooting CI Failures
|
|
127
|
+
|
|
128
|
+
### Distribution detection fails
|
|
129
|
+
- Check `/etc/os-release` file exists in container
|
|
130
|
+
- Verify `ID` and `ID_LIKE` fields are present
|
|
131
|
+
- Check package manager is in PATH
|
|
132
|
+
|
|
133
|
+
### Package mappings incorrect
|
|
134
|
+
- Update `getCommonPackageMappings()` in `src/utils/linuxDistro.ts`
|
|
135
|
+
- Add distribution-specific package names
|
|
136
|
+
- Update unit tests to match
|
|
137
|
+
|
|
138
|
+
### `valdi doctor` fails
|
|
139
|
+
- Check if missing dependencies are expected for CI
|
|
140
|
+
- Verify error handling works correctly
|
|
141
|
+
- Ensure fix commands use correct distribution detection
|
|
142
|
+
|
|
143
|
+
## Adding New Distributions to CI
|
|
144
|
+
|
|
145
|
+
To add a new distribution to the test matrix:
|
|
146
|
+
|
|
147
|
+
1. Edit `.github/workflows/test-cli-linux.yml`
|
|
148
|
+
2. Add to the matrix:
|
|
149
|
+
```yaml
|
|
150
|
+
- distro: new-distro-name
|
|
151
|
+
container: distro:version
|
|
152
|
+
expected_type: debian|redhat|arch|suse
|
|
153
|
+
expected_pm: apt|dnf|pacman|zypper
|
|
154
|
+
expected_name_pattern: "Distro Name"
|
|
155
|
+
```
|
|
156
|
+
3. Ensure the distribution has Node.js 22+ support
|
|
157
|
+
4. Test locally with Docker first
|
|
158
|
+
|
|
159
|
+
## Notes
|
|
160
|
+
|
|
161
|
+
- **Arch Linux** and **openSUSE** are not in CI due to container availability/complexity
|
|
162
|
+
- CI uses Docker containers for isolation
|
|
163
|
+
- Tests are read-only - we don't actually install packages in CI
|
|
164
|
+
- Manual testing on physical distributions is still recommended for full coverage
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Valdi Open Source - Cursor Rules
|
|
2
|
+
|
|
3
|
+
## ⚠️ Open Source Project
|
|
4
|
+
|
|
5
|
+
This is an open source project. Never commit secrets, API keys, or proprietary information.
|
|
6
|
+
|
|
7
|
+
## 🚨 CRITICAL: This is NOT React!
|
|
8
|
+
|
|
9
|
+
Valdi uses TSX/JSX syntax but is **fundamentally different from React**.
|
|
10
|
+
|
|
11
|
+
**Common AI mistakes:**
|
|
12
|
+
- ❌ Suggesting `useState`, `useEffect`, `useContext` (don't exist!)
|
|
13
|
+
- ❌ Functional components (don't exist!)
|
|
14
|
+
- ❌ `this.props` (should be `this.viewModel`)
|
|
15
|
+
- ❌ `markNeedsRender()`, `onMount()`, `onUpdate()` (wrong names/don't exist!)
|
|
16
|
+
|
|
17
|
+
**Correct Valdi:**
|
|
18
|
+
- ✅ `class MyComponent extends StatefulComponent`
|
|
19
|
+
- ✅ `state = {}` + `this.setState()`
|
|
20
|
+
- ✅ `this.viewModel` for props
|
|
21
|
+
- ✅ `onCreate()`, `onViewModelUpdate()`, `onDestroy()` lifecycle
|
|
22
|
+
|
|
23
|
+
## 📁 Context-Specific Rules
|
|
24
|
+
|
|
25
|
+
Cursor automatically loads additional rules based on where you're working:
|
|
26
|
+
|
|
27
|
+
| Working In | See |
|
|
28
|
+
|-----------|-----|
|
|
29
|
+
| TypeScript/TSX components | `.cursor/rules/typescript-tsx.md` |
|
|
30
|
+
| Swift compiler | `.cursor/rules/compiler.md` |
|
|
31
|
+
| C++ runtime | `.cursor/rules/cpp-runtime.md` |
|
|
32
|
+
| Android (Kotlin) | `.cursor/rules/android.md` |
|
|
33
|
+
| iOS (Objective-C) | `.cursor/rules/ios.md` |
|
|
34
|
+
| Bazel files | `.cursor/rules/bazel.md` |
|
|
35
|
+
| Tests | `.cursor/rules/testing.md` |
|
|
36
|
+
|
|
37
|
+
**→ Check `.cursor/rules/README.md` for the full list**
|
|
38
|
+
|
|
39
|
+
## Quick Commands
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
bazel build //... # Build everything
|
|
43
|
+
bazel test //... # Run all tests
|
|
44
|
+
valdi install ios # Build & install iOS app
|
|
45
|
+
valdi hotreload # Start hot reload
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## More Information
|
|
49
|
+
|
|
50
|
+
- **Comprehensive guide**: `/AGENTS.md` (621 lines)
|
|
51
|
+
- **AI tooling**: `/docs/docs/ai-tooling.md`
|
|
52
|
+
- **Support**: `/SUPPORT.md`
|
|
53
|
+
- **Discord**: https://discord.gg/uJyNEeYX2U
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
root = true
|
|
2
|
+
|
|
3
|
+
[*]
|
|
4
|
+
charset = utf-8
|
|
5
|
+
end_of_line = lf
|
|
6
|
+
insert_final_newline = true
|
|
7
|
+
trim_trailing_whitespace = true
|
|
8
|
+
|
|
9
|
+
[*.{ts,tsx,js,jsx}]
|
|
10
|
+
indent_style = space
|
|
11
|
+
indent_size = 2
|
|
12
|
+
|
|
13
|
+
[*.{cpp,hpp,h,cc}]
|
|
14
|
+
indent_style = space
|
|
15
|
+
indent_size = 4
|
|
16
|
+
|
|
17
|
+
[*.{swift,kt,java}]
|
|
18
|
+
indent_style = space
|
|
19
|
+
indent_size = 4
|
|
20
|
+
|
|
21
|
+
[*.{yml,yaml,json}]
|
|
22
|
+
indent_style = space
|
|
23
|
+
indent_size = 2
|
|
24
|
+
|
|
25
|
+
[*.{bzl,bazel,BUILD}]
|
|
26
|
+
indent_style = space
|
|
27
|
+
indent_size = 4
|
|
28
|
+
|
|
29
|
+
[*.md]
|
|
30
|
+
trim_trailing_whitespace = false
|
|
31
|
+
|
|
32
|
+
[*.{mm,m}]
|
|
33
|
+
indent_style = space
|
|
34
|
+
indent_size = 4
|
|
35
|
+
|
|
36
|
+
[Makefile]
|
|
37
|
+
indent_style = tab
|