@shd101wyy/yo 0.1.17 → 0.1.19

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.
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: yo-project-workflow
3
+ description: Build, test, scaffold, and manage Yo projects. Use this when working with yo init, build.yo, yo build, yo compile, yo test, yo install, yo fetch, yo version, or cross-platform Yo project setup.
4
+ argument-hint: "[project task or command]"
5
+ ---
6
+
7
+ # Yo Project Workflow
8
+
9
+ Use this skill for repository setup, build and test execution, and authoring `build.yo` in normal Yo projects.
10
+
11
+ If a repository wraps the Yo CLI in scripts, verify the wrapper first but keep the underlying `yo` workflow in mind.
12
+
13
+ ## When to use this skill
14
+
15
+ Use this skill when you need to:
16
+
17
+ - scaffold a new Yo project
18
+ - understand or edit `build.yo`
19
+ - choose between `yo build`, `yo compile`, and `yo test`
20
+ - manage dependencies with `yo install` or `yo fetch`
21
+ - pin or manage Yo versions with `yo version`
22
+ - install AI agent skill files with `yo skills install`
23
+ - generate API documentation with `yo doc` or `build.doc()`
24
+ - reason about targets, compilers, or cross-platform setup
25
+
26
+ ## Workflow
27
+
28
+ 1. If the repository has `build.yo`, prefer `yo build` and named steps for whole-project work.
29
+ 2. For single-file experiments or reproductions, use `yo compile`.
30
+ 3. For tests, use `yo test [path]` and narrow to a file or pattern before broad runs.
31
+ 4. To pin the project to a specific Yo version, use `yo version pin`.
32
+ 5. Consult the [workflow cheatsheet](./workflow-cheatsheet.md) for command shapes, project layout, and a minimal `build.yo`.
33
+
34
+ ## High-signal rules
35
+
36
+ - `yo init` scaffolds `build.yo`, `deps.yo`, `src/`, and `tests/`.
37
+ - `build.yo` is Yo code that imports `std/build`; build functions register compile-time steps.
38
+ - `yo build run` and `yo build test` are the standard project entry points.
39
+ - `yo test ./tests/some.test.yo --parallel 1` is the focused single-file test pattern.
40
+ - Use `yo install` and `yo fetch` for git or path dependencies.
41
+ - Use `yo version pin` to create a `.yo-version` file for reproducible builds.
42
+ - Use `yo skills install` to copy Yo skill files into all agent config directories in the project.
43
+ - Prefer symbolic build APIs and target constants in `build.yo` instead of ad-hoc shell logic.
44
+
45
+ ## Resource
46
+
47
+ - [Yo project workflow cheatsheet](./workflow-cheatsheet.md)
@@ -0,0 +1,255 @@
1
+ # Yo Project Workflow Cheatsheet
2
+
3
+ These commands and patterns are aimed at normal Yo projects that use the public `yo` CLI.
4
+
5
+ ## CLI quick reference
6
+
7
+ | Goal | Command |
8
+ | ------------------------- | --------------------------------------------------------- |
9
+ | Scaffold a project | `yo init my-project` |
10
+ | Pin Yo version | `yo version pin` |
11
+ | Pin specific version | `yo version pin 0.1.12` |
12
+ | Show current/pinned ver | `yo version` |
13
+ | Build default step | `yo build` |
14
+ | Build and run | `yo build run` |
15
+ | Run project test step | `yo build test` |
16
+ | List build steps | `yo build --list-steps` |
17
+ | Compile one file | `yo compile main.yo --release -o app` |
18
+ | Inspect generated C | `yo compile main.yo --emit-c --skip-c-compiler` |
19
+ | Run tests in one file | `yo test ./tests/main.test.yo --parallel 1` |
20
+ | Filter tests by name | `yo test ./tests/main.test.yo --test-name-pattern "Name"` |
21
+ | Generate docs for project | `yo doc ./src` |
22
+ | Generate docs (custom) | `yo doc ./src -o docs --title "My Project"` |
23
+ | Install AI agent skills | `yo skills install` |
24
+ | Install dependency | `yo install user/repo` |
25
+ | Install pinned dependency | `yo install user/repo@v1.2.3` |
26
+ | Fetch dependency graph | `yo fetch` |
27
+
28
+ ## Project layout
29
+
30
+ `yo init` produces a structure like this:
31
+
32
+ ```text
33
+ my-project/
34
+ ├── build.yo
35
+ ├── deps.yo
36
+ ├── src/
37
+ │ ├── main.yo
38
+ │ └── lib.yo
39
+ └── tests/
40
+ └── main.test.yo
41
+ ```
42
+
43
+ - `build.yo` defines artifacts, named steps, and doc generation
44
+ - `deps.yo` tracks installed dependencies
45
+ - `src/main.yo` is the executable entry point
46
+ - `src/lib.yo` is the library module root
47
+
48
+ ## Minimal `build.yo`
49
+
50
+ ```rust
51
+ build :: import "std/build";
52
+
53
+ mod :: build.module({ name: "my-project", root: "./src/lib.yo" });
54
+
55
+ exe :: build.executable({
56
+ name: "my-project",
57
+ root: "./src/main.yo"
58
+ });
59
+
60
+ tests :: build.test({
61
+ name: "tests",
62
+ root: "./tests/"
63
+ });
64
+
65
+ run_exe :: build.run(exe);
66
+
67
+ install :: build.step("install", "Build the default artifacts");
68
+ install.depend_on(exe);
69
+
70
+ run_step :: build.step("run", "Run the application");
71
+ run_step.depend_on(run_exe);
72
+
73
+ test_step :: build.step("test", "Run the tests");
74
+ test_step.depend_on(tests);
75
+
76
+ docs :: build.doc({ name: "my-project", root: "./src" });
77
+ doc_step :: build.step("doc", "Generate documentation");
78
+ doc_step.depend_on(docs);
79
+ ```
80
+
81
+ - `build.yo` is ordinary Yo code evaluated at compile time
82
+ - Build functions return `Step` values that can be wired with `depend_on(...)`
83
+ - Prefer named steps like `install`, `run`, and `test` for common workflows
84
+
85
+ ## Choosing the right entry point
86
+
87
+ | Situation | Preferred command |
88
+ | ------------------------------- | ------------------------------------------ |
89
+ | Whole project with `build.yo` | `yo build ...` |
90
+ | One standalone file | `yo compile ...` |
91
+ | One test file or test directory | `yo test ...` |
92
+ | Dependency changes | `yo install ...` then `yo fetch` if needed |
93
+
94
+ ## Testing patterns
95
+
96
+ ```bash
97
+ yo test ./tests
98
+ yo test ./tests/main.test.yo --parallel 1
99
+ yo test ./tests/main.test.yo --bail --verbose --parallel 1
100
+ ```
101
+
102
+ - Use `--parallel 1` for focused, readable single-file runs
103
+ - Use `--test-name-pattern` when a file contains many tests
104
+ - Use `yo build test` when the repository's main test workflow is defined in `build.yo`
105
+
106
+ ### Writing tests in Yo
107
+
108
+ ```rust
109
+ test "Basic assertion", {
110
+ assert(((i32(1) + i32(1)) == i32(2)), "1+1 should be 2");
111
+ };
112
+
113
+ test "Compile-time check", {
114
+ comptime_assert((2 + 2) == 4);
115
+ comptime_expect_error({ x :: (1 / 0); });
116
+ };
117
+
118
+ test "Async test", {
119
+ { yield } :: import "std/async";
120
+ io.await(yield());
121
+ };
122
+ ```
123
+
124
+ - `test "name", { body }` defines a test — `io : IO` is automatically available
125
+ - All tests can use `io.async(...)`, `io.await(...)`, etc. without a `using` clause
126
+ - `assert(condition, "message")` — always include a message string
127
+ - `comptime_assert(expr)` — verified at compile time
128
+ - `comptime_expect_error(expr)` — verify code produces a compile error
129
+ - Test files use `.test.yo` extension
130
+
131
+ ## Targets and compilers
132
+
133
+ ```bash
134
+ yo compile main.yo --cc clang -o app
135
+ yo compile main.yo --cc zig -o app
136
+ yo compile main.yo --cc emcc --release -o app
137
+ yo test ./tests/main.test.yo --target wasm-wasi
138
+ ```
139
+
140
+ - Common C compilers: `clang`, `gcc`, `zig`, `cl`, `emcc`
141
+ - `--cc emcc` targets Emscripten-based WebAssembly
142
+ - `--target wasm-wasi` targets standalone WASI
143
+ - Prefer the host target for routine development unless the task is explicitly cross-platform
144
+
145
+ ### WASM library targets in build.yo
146
+
147
+ For projects that compile to WASM npm packages, use `target: build.CompilationTarget.Wasm32_Emscripten` and `add_c_flags(...)` for Emscripten settings:
148
+
149
+ ```rust
150
+ build :: import "std/build";
151
+
152
+ wasm_api :: build.executable({
153
+ name: "my_lib_wasm_api",
154
+ root: "./src/wasm_api.yo",
155
+ target: build.CompilationTarget.Wasm32_Emscripten,
156
+ optimize: build.Optimize.ReleaseSmall,
157
+ allocator: build.Allocator.Libc
158
+ });
159
+ wasm_api.add_c_flags("-O3 -flto -mbulk-memory -sALLOW_MEMORY_GROWTH -sENVIRONMENT=web,node -sMODULARIZE=1 -sEXPORT_NAME=createModule -sEXPORTED_FUNCTIONS=_my_func,_wasm_alloc,_wasm_free -sEXPORTED_RUNTIME_METHODS=HEAPU8");
160
+
161
+ wasm_step :: build.step("wasm_api", "Build WASM module");
162
+ wasm_step.depend_on(wasm_api);
163
+ ```
164
+
165
+ Key API:
166
+
167
+ - `build.executable({...})` — `Executable` struct fields: `name`, `root`, `target`, `optimize`, `allocator`, `sanitize`
168
+ - `step.add_c_flags("...")` — append compiler/linker flags (Emscripten `-s` options go here)
169
+ - `step.add_import_list(imports)` — add module dependencies
170
+ - `build.CompilationTarget.Wasm32_Emscripten` — Emscripten target
171
+ - `build.CompilationTarget.Wasm32_Wasi` — WASI target
172
+
173
+ See the [yo-wasm-integration](../yo-wasm-integration/SKILL.md) skill for full npm packaging patterns.
174
+
175
+ ## Documentation
176
+
177
+ ### `yo doc` — Generate API documentation
178
+
179
+ ```bash
180
+ yo doc ./src # Document all .yo files in directory
181
+ yo doc ./src/main.yo # Document single file
182
+ yo doc -o ./docs # Custom output directory
183
+ yo doc --title "My Project" # Set doc site title
184
+ yo doc --format markdown # Output as Markdown (default: html)
185
+ yo doc --format json # Output as JSON
186
+ yo doc --document-private # Include non-exported items
187
+ ```
188
+
189
+ ### `build.doc()` — Documentation build step
190
+
191
+ In `build.yo`:
192
+
193
+ ```rust
194
+ build :: import "std/build";
195
+
196
+ docs :: build.doc({ name: "docs", root: "./src" });
197
+ doc_step :: build.step("doc", "Generate documentation");
198
+ doc_step.depend_on(docs);
199
+ ```
200
+
201
+ Then run: `yo build doc`
202
+
203
+ ### Doc comments
204
+
205
+ ````rust
206
+ /// Brief description of the function.
207
+ ///
208
+ /// ## Examples
209
+ /// ```rust
210
+ /// add(i32(1), i32(2))
211
+ /// ```
212
+ add :: (fn(a: i32, b: i32) -> i32)((a + b));
213
+ ````
214
+
215
+ Use `///` for item documentation and `//!` at the top of a file for module-level docs.
216
+
217
+ ## Version management
218
+
219
+ ```bash
220
+ yo version # Show current version and pinned version
221
+ yo version pin # Pin project to current Yo version
222
+ yo version pin 0.1.12 # Pin to specific version
223
+ yo version install 0.1.13 # Pre-download a version
224
+ yo version list # List locally cached versions
225
+ yo version list --remote # List all available versions on npm
226
+ yo version clean # Remove all cached versions
227
+ yo version clean 0.1.12 # Remove specific cached version
228
+ ```
229
+
230
+ - `.yo-version` file pins a project to a specific Yo version (similar to `.nvmrc`)
231
+ - When `.yo-version` exists with a different version, `yo` auto-dispatches to the cached version
232
+ - The LSP also reads `.yo-version` to resolve the correct `std/` library for go-to-definition
233
+ - Commit `.yo-version` to version control for reproducible builds across the team
234
+
235
+ ## Skills for AI agents
236
+
237
+ ```bash
238
+ yo skills install # Copy bundled skill files into the current project
239
+ ```
240
+
241
+ `yo skills install` detects which agent config directories exist in the current project (`.github`, `.agents`, `.claude`, `.opencode`, `.openai`, `.cursor`) and copies all Yo skill files into each. Falls back to creating `.agents/skills/` if none exist.
242
+
243
+ ## Dependency management
244
+
245
+ ```bash
246
+ yo install user/repo
247
+ yo install user/repo@v1.0.0
248
+ yo install ./relative/path
249
+ yo fetch
250
+ yo fetch --update
251
+ ```
252
+
253
+ - Use `yo install` to add dependencies from GitHub or a local path
254
+ - Use `yo fetch` to populate or refresh fetched dependencies
255
+ - Keep dependency management in Yo tooling instead of hand-editing generated cache state
@@ -0,0 +1,57 @@
1
+ ---
2
+ name: yo-syntax
3
+ description: Write and repair Yo source code. Use this when authoring, reviewing, or debugging .yo files, especially around declarations, begin blocks, cond/match, imports, recursion, function calls, and parser-facing errors.
4
+ argument-hint: "[task, file, or error]"
5
+ ---
6
+
7
+ # Yo Syntax
8
+
9
+ Use this skill for source-level Yo authoring. It focuses on portable Yo syntax rules that apply across repositories.
10
+
11
+ If the repository adds stricter local conventions, follow those after the baseline rules in this skill.
12
+
13
+ ## When to use this skill
14
+
15
+ Use this skill when you need to:
16
+
17
+ - write new `.yo` files
18
+ - fix parse errors or syntax-shaped type errors
19
+ - review whether Yo code uses the correct expression form
20
+ - choose between begin blocks, imports, pattern matching, or recursion forms
21
+
22
+ ## Workflow
23
+
24
+ 1. Read the target code and decide whether the problem is declarations, control flow, imports, calls, or pattern matching.
25
+ 2. Apply the rules in the [syntax cheatsheet](./syntax-cheatsheet.md) before editing.
26
+ 3. Prefer the simplest expression form that fits Yo parsing rules.
27
+ 4. Re-check the common traps below before finishing.
28
+
29
+ ## High-signal rules
30
+
31
+ - `cond(...)` and `match(...)` always require parentheses.
32
+ - `{ expr }` is a struct literal; `{ expr; }` is a begin block.
33
+ - Yo has no operator precedence. Parenthesize every binary operation.
34
+ - Use `func(arg)` with no space before `(` for normal calls.
35
+ - Use `recur(...)` for self-recursion instead of the function name.
36
+ - Use `forall(T : Type)` for generic type parameters, `comptime(x) : T` for compile-time parameters.
37
+ - Use `where(T <: Trait)` to constrain type parameters.
38
+ - Use `using(name : Type)` for implicit/effect parameters and `given(name) := Type(...)` to install handlers.
39
+ - Use `(params) => expr` for closures; `Impl(Fn(...) -> T)` for the closure type.
40
+ - Every executable needs `export main;`.
41
+ - Import sibling modules with relative paths like `./file.yo`.
42
+ - Do not import `std/prelude`; it is loaded automatically.
43
+ - Use `snake_case` for names, `PascalCase` for types/traits, 2-space indentation.
44
+
45
+ ## Common traps
46
+
47
+ - `return expr1, expr2` is parsed as one call; use a begin block or return an expression directly.
48
+ - Nested patterns like `.Ok(.Some(x))` are not supported; match in stages.
49
+ - Unary operators need parenthesized operands: `!(ready)`.
50
+ - `while true` is compile-time. Use `while runtime(true), { ... }` for infinite runtime loops.
51
+ - A single-expression lambda body should not be wrapped in `{ ... }` unless semicolons make it a begin block.
52
+ - `"hello"` is `comptime_string` inside `comptime` functions, not `str`. In runtime code, `"hello"` is always `str`.
53
+ - Functions called without `()` in match/cond branches consume trailing commas. Always add `()` or use begin blocks.
54
+
55
+ ## Resource
56
+
57
+ - [Yo syntax cheatsheet](./syntax-cheatsheet.md)