Skip to content

Commit 0febf94

Browse files
jsvdclaude
andcommitted
Fix cheatsheet type-check errors in scaffolded projects
Rename cheatsheet.d.ts to cheatsheet.txt so it's never type-checked. Fix multi-line signature collapsing (track brace depth in awk). Add scaffolded-project type-check step to release process. Bump version to 0.12.1. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 082cd3d commit 0febf94

11 files changed

Lines changed: 173 additions & 137 deletions

File tree

.claude/skills/release/SKILL.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@ cargo check --no-default-features 2>&1 | tail -3 # Headless check
4747

4848
All must pass before proceeding. Record the test counts (e.g., "2028 Node + 2125 V8 + 292 Rust").
4949

50+
Also verify that generated declaration files type-check correctly in a scaffolded project:
51+
52+
```bash
53+
# Regenerate declarations (ensures cheatsheet is fresh)
54+
scripts/generate-declarations.sh
55+
56+
# Create a temp project and type-check it
57+
TMPDIR=$(mktemp -d)
58+
cargo run -- new "$TMPDIR/release-check" 2>&1
59+
cd "$TMPDIR/release-check" && npx -p typescript tsc --noEmit 2>&1
60+
cd - && rm -rf "$TMPDIR"
61+
```
62+
63+
If type-checking fails, fix the generated files before proceeding.
64+
5065
### 4. Update status docs with fresh test counts
5166

5267
#### a. `README.md`

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
All notable changes to Arcane are documented here.
44

5+
## [0.12.1] - 2026-02-18
6+
7+
### Fixed
8+
- **Cheatsheet breaks type-checking** — renamed `cheatsheet.d.ts` to `cheatsheet.txt` so it's never type-checked. Fixed multi-line signature collapsing in the generator script. Added scaffolded-project type-check verification to the release process.
9+
510
## [0.12.0] - 2026-02-18
611

712
### Added

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Arcane is a code-first, test-native, agent-native 2D game engine. Rust core for performance, TypeScript scripting for game logic.
66

7-
**Current status: v0.12.0 — DX improvements. Unified Color API, particle presets, knockback, palette. 2082 TS (Node) + 2179 (V8) + 292 Rust tests passing. Next: Phase 26 (Atmosphere).**
7+
**Current status: v0.12.1 — DX improvements. Unified Color API, particle presets, knockback, palette. 2082 TS (Node) + 2206 (V8) + 292 Rust tests passing. Next: Phase 26 (Atmosphere).**
88

99
## Repository Structure
1010

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Rails for games. Rails didn't beat Java by being more powerful — it beat it by
9696

9797
## Status
9898

99-
**v0.12.0 — DX improvements: color API, particle presets, knockback, palette!**
99+
**v0.12.1 — DX improvements: color API, particle presets, knockback, palette!**
100100

101101
Install: [`cargo install arcane-engine`](https://crates.io/crates/arcane-engine)
102102

cli/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "arcane-engine"
3-
version = "0.12.0"
3+
version = "0.12.1"
44
edition.workspace = true
55
license.workspace = true
66
description = "Arcane game engine — agent-native 2D engine with embedded TypeScript runtime"
@@ -17,7 +17,7 @@ name = "arcane"
1717
path = "src/main.rs"
1818

1919
[dependencies]
20-
arcane-core = { version = "0.12.0", path = "../core", features = ["renderer"] }
20+
arcane-core = { version = "0.12.1", path = "../core", features = ["renderer"] }
2121
clap = { version = "4", features = ["derive"] }
2222
tokio = { version = "1", features = ["full"] }
2323
anyhow = "1"

core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "arcane-core"
3-
version = "0.12.0"
3+
version = "0.12.1"
44
edition.workspace = true
55
license.workspace = true
66
description = "Core library for Arcane - agent-native 2D game engine (TypeScript runtime, renderer, platform layer)"

scripts/generate-declarations.sh

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,16 @@ for entry in "${MODULES[@]}"; do
125125
done
126126

127127
# Step 3: Generate cheatsheet (compact one-liner signatures from all modules)
128+
# Output is .txt (not .d.ts) so it never gets type-checked — it's a reference doc.
128129
echo "Generating cheatsheet..."
129-
CHEATSHEET="$OUT_DIR/cheatsheet.d.ts"
130+
CHEATSHEET="$OUT_DIR/cheatsheet.txt"
130131
{
131-
echo "// Arcane Engine — API Cheatsheet"
132-
echo "// Generated from runtime source. Do not edit manually."
133-
echo "// Regenerate with: ./scripts/generate-declarations.sh"
134-
echo "//"
135-
echo "// One-liner signatures for every exported function, grouped by module."
136-
echo "// For full JSDoc, argument types, and examples, see the per-module files in types/."
132+
echo "Arcane Engine — API Cheatsheet"
133+
echo "Generated from runtime source. Do not edit manually."
134+
echo "Regenerate with: ./scripts/generate-declarations.sh"
135+
echo ""
136+
echo "One-liner signatures for every exported function, grouped by module."
137+
echo "For full JSDoc, argument types, and examples, see the per-module .d.ts files in types/."
137138
echo ""
138139

139140
for entry in "${MODULES[@]}"; do
@@ -144,34 +145,49 @@ CHEATSHEET="$OUT_DIR/cheatsheet.d.ts"
144145
continue
145146
fi
146147

147-
echo "// --- $dir (@arcane/runtime/$dir) ---"
148+
echo "=== $dir (@arcane/runtime/$dir) ==="
148149

149150
# Extract type names (one-liner summary)
150151
type_names=$(grep -E '^\s+export type \w+ ' "$module_file" 2>/dev/null | sed 's/.*export type \([A-Za-z_][A-Za-z0-9_]*\).*/\1/' | sort -u | tr '\n' ', ' | sed 's/, $//') || true
151152
if [ -n "$type_names" ]; then
152-
echo "// Types: $type_names"
153+
echo "Types: $type_names"
153154
fi
154155

155-
# Extract function declarations (just the signature line)
156-
grep -E '^\s+export declare function ' "$module_file" 2>/dev/null | while IFS= read -r line; do
157-
# Strip leading whitespace and "export " prefix
158-
trimmed="${line#"${line%%[! ]*}"}"
159-
trimmed="${trimmed#export }"
160-
echo "$trimmed"
161-
done || true
162-
163-
# Extract const declarations (just name and type)
164-
grep -E '^\s+export declare const ' "$module_file" 2>/dev/null | while IFS= read -r line; do
165-
trimmed="${line#"${line%%[! ]*}"}"
166-
trimmed="${trimmed#export }"
167-
echo "$trimmed"
168-
done || true
156+
# Extract function and const signatures, collapsing multi-line ones.
157+
# Tracks brace depth so "loop?: boolean;" inside {…} doesn't end the sig.
158+
awk '
159+
BEGIN { buf = ""; depth = 0 }
160+
/^[[:space:]]+export declare (function|const) / {
161+
sub(/^[[:space:]]+/, "")
162+
sub(/^export /, "")
163+
buf = $0
164+
depth = 0
165+
for (i = 1; i <= length($0); i++) {
166+
c = substr($0, i, 1)
167+
if (c == "{") depth++
168+
else if (c == "}") depth--
169+
}
170+
if (depth <= 0 && buf ~ /;[[:space:]]*$/) { print buf; buf = ""; depth = 0 }
171+
next
172+
}
173+
{ if (buf != "") {
174+
sub(/^[[:space:]]+/, "")
175+
buf = buf " " $0
176+
for (i = 1; i <= length($0); i++) {
177+
c = substr($0, i, 1)
178+
if (c == "{") depth++
179+
else if (c == "}") depth--
180+
}
181+
if (depth <= 0 && buf ~ /;[[:space:]]*$/) { print buf; buf = ""; depth = 0 }
182+
}
183+
}
184+
' "$module_file" || true
169185

170186
echo ""
171187
done
172188
} > "$CHEATSHEET"
173189
cheatsheet_lines=$(wc -l < "$CHEATSHEET")
174-
echo " cheatsheet.d.ts ($cheatsheet_lines lines)"
190+
echo " cheatsheet.txt ($cheatsheet_lines lines)"
175191

176192
# Step 4: Clean up
177193
rm -rf "$DIST_DIR"

templates/default/AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ Read the **Essential** guides first, then the genre-specific guides for your gam
231231

232232
## API Quick Reference
233233

234-
See [`types/cheatsheet.d.ts`](types/cheatsheet.d.ts) for every exported function as a one-liner, grouped by module. The 20 most common functions:
234+
See [`types/cheatsheet.txt`](types/cheatsheet.txt) for every exported function as a one-liner, grouped by module. The 20 most common functions:
235235

236236
| Function | Module | What it does |
237237
|----------|--------|-------------|
@@ -262,7 +262,7 @@ Per-module type files with JSDoc documentation. Check these before using unfamil
262262

263263
| File | Module |
264264
|------|--------|
265-
| `types/cheatsheet.d.ts` | **All modules** — compact one-liner signatures |
265+
| `types/cheatsheet.txt` | **All modules** — compact one-liner signatures |
266266
| `types/rendering.d.ts` | `@arcane/runtime/rendering` |
267267
| `types/ui.d.ts` | `@arcane/runtime/ui` |
268268
| `types/physics.d.ts` | `@arcane/runtime/physics` |

templates/default/CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
Read [AGENTS.md](AGENTS.md) for the full guide on building this game with Arcane.
44

5-
API declarations are in `types/*.d.ts` (one file per module: rendering, physics, game, ui, etc.). Start with [`types/cheatsheet.d.ts`](types/cheatsheet.d.ts) for a compact overview of every function. Use `/api` to look up specific functions.
5+
API declarations are in `types/*.d.ts` (one file per module: rendering, physics, game, ui, etc.). Start with [`types/cheatsheet.txt`](types/cheatsheet.txt) for a compact overview of every function. Use `/api` to look up specific functions.
66

77
**Essential topic guides** (read before coding): rendering, coordinates, tweening, particles, juice, transitions, input, entities. See the full list and genre-specific reading order in AGENTS.md.

0 commit comments

Comments
 (0)