spawnpack 0.1.9 → 0.1.10
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/package.json +1 -1
- package/templates/AGENTS.md +32 -22
- package/templates/CLAUDE.md +32 -22
package/package.json
CHANGED
package/templates/AGENTS.md
CHANGED
|
@@ -246,27 +246,37 @@ PLAN:
|
|
|
246
246
|
ALWAYS use Exa to search the latest Minecraft Script API documentation before implementing. APIs change every major update — never trust memory.
|
|
247
247
|
</guideline>
|
|
248
248
|
|
|
249
|
-
<guideline name="
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
249
|
+
<guideline name="guard_first_error_handling" priority="critical">
|
|
250
|
+
Prefer **guard clauses** for predictable invalid state: missing values, unloaded or invalid entities, optional components, permissions, and known preconditions. `throw`, `try`, and `catch` are allowed when they are truly necessary: APIs can fail despite correct guards, you are crossing IO/persistence/parsing/async boundaries, or you need cleanup, recovery, or clearer error context.
|
|
251
|
+
|
|
252
|
+
Keep `catch` blocks narrow and purposeful. Do not use `try-catch` as normal control flow, to hide mistakes, or where a simple guard makes the failure impossible.
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
// ✅ CORRECT: Use guard clauses
|
|
256
|
+
function processBlock(block: Block | undefined): void {
|
|
255
257
|
if (!block) return;
|
|
256
258
|
if (!block.isValid) return;
|
|
257
259
|
const permutation = block.permutation;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
//
|
|
261
|
-
function
|
|
262
|
-
try {
|
|
263
|
-
|
|
264
|
-
} catch (
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// ✅ CORRECT: Use try-catch only at a real failure boundary
|
|
263
|
+
function loadSavedConfig(rawConfig: string): AddonConfig {
|
|
264
|
+
try {
|
|
265
|
+
return JSON.parse(rawConfig) as AddonConfig;
|
|
266
|
+
} catch (error) {
|
|
267
|
+
throw new Error("Saved addon config is not valid JSON", { cause: error });
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// ❌ WRONG: Catching instead of checking known state
|
|
272
|
+
function processBlockBad(block: Block | undefined): void {
|
|
273
|
+
try {
|
|
274
|
+
const permutation = block!.permutation;
|
|
275
|
+
} catch {
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
</guideline>
|
|
270
280
|
|
|
271
281
|
<guideline name="typescript_verification" priority="critical">
|
|
272
282
|
ALWAYS run `tsc --noEmit` after implementing. Ensure **zero warnings, zero errors, and no unused variables/imports**.
|
|
@@ -395,7 +405,7 @@ ALWAYS use Minecraft Bedrock Edition JSON Schemas for validation of BP/RP JSON f
|
|
|
395
405
|
- Use explicit return types on functions
|
|
396
406
|
- Use `readonly` for immutable properties
|
|
397
407
|
- Prefer interfaces over type aliases for object shapes
|
|
398
|
-
- Use `undefined` checks
|
|
408
|
+
- Use `undefined` checks and guard clauses before reaching for try-catch
|
|
399
409
|
</best_practices>
|
|
400
410
|
|
|
401
411
|
<best_practices name="script_api">
|
|
@@ -598,7 +608,7 @@ POTENTIAL CONCERNS:
|
|
|
598
608
|
13. Editing files from stale context without re-reading first
|
|
599
609
|
14. Duplicating state instead of fixing the real problem
|
|
600
610
|
15. Writing library/framework code from memory without searching Exa for current docs first
|
|
601
|
-
16. Using try-catch in Minecraft Script API code
|
|
611
|
+
16. Using broad try-catch in Minecraft Script API code where guard clauses would be clearer
|
|
602
612
|
17. Creating custom math functions when @minecraft/math has them available
|
|
603
613
|
18. Using raw strings instead of @minecraft/vanilla-data typed identifiers
|
|
604
614
|
19. Writing BP/RP JSON files without schema validation
|
|
@@ -614,7 +624,7 @@ You have unlimited stamina. The human does not. Use your persistence wisely —
|
|
|
614
624
|
1. **EXA FOR DOCS** — Always search library/framework docs via Exa before implementing
|
|
615
625
|
2. **VERIFY BEFORE DONE** — Type-check, lint, test before claiming success
|
|
616
626
|
3. **PLAN BEFORE BUILD** — Spec and approval before implementation
|
|
617
|
-
4. **GUARD CLAUSES** —
|
|
627
|
+
4. **GUARD CLAUSES FIRST** — Prefer guards; use throw/try-catch only at real failure boundaries
|
|
618
628
|
5. **VANILLA-DATA** — Use typed identifiers from @minecraft/vanilla-data
|
|
619
629
|
6. **MINECRAFT-MATH** — Use @minecraft/math library for math operations
|
|
620
630
|
7. **JSON SCHEMAS** — Validate BP/RP JSONs with Rockide/schemas
|
|
@@ -625,7 +635,7 @@ You have unlimited stamina. The human does not. Use your persistence wisely —
|
|
|
625
635
|
- ❌ Said "Done!" without running type-check/lint/tests? → Violated forced verification rule
|
|
626
636
|
- ❌ Edited a file from memory after 10+ messages without re-reading? → Violated context decay rule
|
|
627
637
|
- ❌ Started building without plan approval on a non-trivial task? → Violated plan-build separation
|
|
628
|
-
- ❌ Used try-catch
|
|
638
|
+
- ❌ Used broad try-catch where guards would work? → Violated guard-first error handling
|
|
629
639
|
- ❌ Made changes without running `tsc --noEmit`? → Violated TypeScript verification
|
|
630
640
|
- ❌ Created custom math function without checking @minecraft/math? → Violated library-first rule
|
|
631
641
|
- ❌ Used raw string like `"inventory"` or `"minecraft:wolf"`? → Violated vanilla-data rule
|
package/templates/CLAUDE.md
CHANGED
|
@@ -246,27 +246,37 @@ PLAN:
|
|
|
246
246
|
ALWAYS use Exa to search the latest Minecraft Script API documentation before implementing. APIs change every major update — never trust memory.
|
|
247
247
|
</guideline>
|
|
248
248
|
|
|
249
|
-
<guideline name="
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
249
|
+
<guideline name="guard_first_error_handling" priority="critical">
|
|
250
|
+
Prefer **guard clauses** for predictable invalid state: missing values, unloaded or invalid entities, optional components, permissions, and known preconditions. `throw`, `try`, and `catch` are allowed when they are truly necessary: APIs can fail despite correct guards, you are crossing IO/persistence/parsing/async boundaries, or you need cleanup, recovery, or clearer error context.
|
|
251
|
+
|
|
252
|
+
Keep `catch` blocks narrow and purposeful. Do not use `try-catch` as normal control flow, to hide mistakes, or where a simple guard makes the failure impossible.
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
// ✅ CORRECT: Use guard clauses
|
|
256
|
+
function processBlock(block: Block | undefined): void {
|
|
255
257
|
if (!block) return;
|
|
256
258
|
if (!block.isValid) return;
|
|
257
259
|
const permutation = block.permutation;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
//
|
|
261
|
-
function
|
|
262
|
-
try {
|
|
263
|
-
|
|
264
|
-
} catch (
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// ✅ CORRECT: Use try-catch only at a real failure boundary
|
|
263
|
+
function loadSavedConfig(rawConfig: string): AddonConfig {
|
|
264
|
+
try {
|
|
265
|
+
return JSON.parse(rawConfig) as AddonConfig;
|
|
266
|
+
} catch (error) {
|
|
267
|
+
throw new Error("Saved addon config is not valid JSON", { cause: error });
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// ❌ WRONG: Catching instead of checking known state
|
|
272
|
+
function processBlockBad(block: Block | undefined): void {
|
|
273
|
+
try {
|
|
274
|
+
const permutation = block!.permutation;
|
|
275
|
+
} catch {
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
</guideline>
|
|
270
280
|
|
|
271
281
|
<guideline name="typescript_verification" priority="critical">
|
|
272
282
|
ALWAYS run `tsc --noEmit` after implementing. Ensure **zero warnings, zero errors, and no unused variables/imports**.
|
|
@@ -395,7 +405,7 @@ ALWAYS use Minecraft Bedrock Edition JSON Schemas for validation of BP/RP JSON f
|
|
|
395
405
|
- Use explicit return types on functions
|
|
396
406
|
- Use `readonly` for immutable properties
|
|
397
407
|
- Prefer interfaces over type aliases for object shapes
|
|
398
|
-
- Use `undefined` checks
|
|
408
|
+
- Use `undefined` checks and guard clauses before reaching for try-catch
|
|
399
409
|
</best_practices>
|
|
400
410
|
|
|
401
411
|
<best_practices name="script_api">
|
|
@@ -598,7 +608,7 @@ POTENTIAL CONCERNS:
|
|
|
598
608
|
13. Editing files from stale context without re-reading first
|
|
599
609
|
14. Duplicating state instead of fixing the real problem
|
|
600
610
|
15. Writing library/framework code from memory without searching Exa for current docs first
|
|
601
|
-
16. Using try-catch in Minecraft Script API code
|
|
611
|
+
16. Using broad try-catch in Minecraft Script API code where guard clauses would be clearer
|
|
602
612
|
17. Creating custom math functions when @minecraft/math has them available
|
|
603
613
|
18. Using raw strings instead of @minecraft/vanilla-data typed identifiers
|
|
604
614
|
19. Writing BP/RP JSON files without schema validation
|
|
@@ -614,7 +624,7 @@ You have unlimited stamina. The human does not. Use your persistence wisely —
|
|
|
614
624
|
1. **EXA FOR DOCS** — Always search library/framework docs via Exa before implementing
|
|
615
625
|
2. **VERIFY BEFORE DONE** — Type-check, lint, test before claiming success
|
|
616
626
|
3. **PLAN BEFORE BUILD** — Spec and approval before implementation
|
|
617
|
-
4. **GUARD CLAUSES** —
|
|
627
|
+
4. **GUARD CLAUSES FIRST** — Prefer guards; use throw/try-catch only at real failure boundaries
|
|
618
628
|
5. **VANILLA-DATA** — Use typed identifiers from @minecraft/vanilla-data
|
|
619
629
|
6. **MINECRAFT-MATH** — Use @minecraft/math library for math operations
|
|
620
630
|
7. **JSON SCHEMAS** — Validate BP/RP JSONs with Rockide/schemas
|
|
@@ -625,7 +635,7 @@ You have unlimited stamina. The human does not. Use your persistence wisely —
|
|
|
625
635
|
- ❌ Said "Done!" without running type-check/lint/tests? → Violated forced verification rule
|
|
626
636
|
- ❌ Edited a file from memory after 10+ messages without re-reading? → Violated context decay rule
|
|
627
637
|
- ❌ Started building without plan approval on a non-trivial task? → Violated plan-build separation
|
|
628
|
-
- ❌ Used try-catch
|
|
638
|
+
- ❌ Used broad try-catch where guards would work? → Violated guard-first error handling
|
|
629
639
|
- ❌ Made changes without running `tsc --noEmit`? → Violated TypeScript verification
|
|
630
640
|
- ❌ Created custom math function without checking @minecraft/math? → Violated library-first rule
|
|
631
641
|
- ❌ Used raw string like `"inventory"` or `"minecraft:wolf"`? → Violated vanilla-data rule
|