scratch-blocks 2.1.6 → 2.1.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.
- package/AGENTS.md +33 -20
- package/dist/main.mjs +1 -1
- package/dist/types/src/renderer/render_info.d.ts +1 -1
- package/dist/types/src/renderer/render_info.d.ts.map +1 -1
- package/eslint.config.mjs +0 -16
- package/package.json +5 -5
- package/src/blocks/data.ts +1 -1
- package/src/renderer/render_info.ts +14 -4
package/AGENTS.md
CHANGED
|
@@ -1,16 +1,36 @@
|
|
|
1
1
|
# Agent Guide: scratch-blocks
|
|
2
2
|
|
|
3
|
+
## AI-assisted development policy
|
|
4
|
+
|
|
5
|
+
See [CONTRIBUTING.AI.md](https://github.com/scratchfoundation/.github/blob/main/CONTRIBUTING.AI.md) for Scratch's
|
|
6
|
+
org-wide policy on AI-assisted contributions. The short version: human developers remain responsible for all code
|
|
7
|
+
they submit. Do not submit code you cannot explain and defend in a review.
|
|
8
|
+
|
|
3
9
|
## Agent defaults
|
|
4
10
|
|
|
5
11
|
Use these defaults unless the user asks otherwise:
|
|
6
12
|
|
|
7
|
-
1. Keep changes minimal and scoped to the user request.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
1. Keep changes minimal and scoped to the user request. Do not refactor surrounding code, add features, or clean up
|
|
14
|
+
style in areas you weren't asked to touch.
|
|
15
|
+
2. Do not preserve backward compatibility when it isn't required. When all callers are internal to the repo, rename
|
|
16
|
+
or restructure freely rather than adding shims or aliases. scratch-blocks is published to npm and consumed
|
|
17
|
+
externally, so treat its public exports as a contract and preserve compatibility unless explicitly told otherwise.
|
|
18
|
+
3. Write comments that explain the current code, not its history. Do not reference prior implementations,
|
|
19
|
+
intermediate states, or what the code "used to do." If an approach seems counterintuitive, explain why it is
|
|
20
|
+
correct now — not why it changed.
|
|
21
|
+
4. Never edit `node_modules/blockly/`; extend or override from `src/` instead.
|
|
22
|
+
5. Prefer fixing root causes over adding surface-level workarounds or assertions.
|
|
23
|
+
6. When fixing a bug, start by adding one or more failing tests that reproduce it, then implement the fix. Iterate
|
|
24
|
+
until all tests pass, including but not limited to the new tests.
|
|
25
|
+
7. When adding runtime guards for states that should never happen, log actionable context (function name, relevant
|
|
26
|
+
IDs, key flags) rather than failing silently. Use `console.warn` for recoverable states and `console.error` for
|
|
27
|
+
invalid required data.
|
|
28
|
+
8. Preserve failure semantics when refactoring. An implicit crash (null dereference, `!` assertion) should become
|
|
29
|
+
an explicit `throw` with a useful message — not silent failure. Code that previously wouldn't crash still
|
|
30
|
+
shouldn't, but consider whether a warning is warranted. Replacing a potential null dereference with
|
|
31
|
+
`if (!foo) return` could make a bug harder to find; `if (!foo) throw new Error(...)` surfaces it.
|
|
32
|
+
9. Do not add error handling, fallbacks, or validation for scenarios that cannot happen. Trust internal code and
|
|
33
|
+
framework guarantees. Only validate at system boundaries (user input, external APIs).
|
|
14
34
|
|
|
15
35
|
## What this repository is
|
|
16
36
|
|
|
@@ -32,6 +52,8 @@ npm run test:unit # Run unit tests only
|
|
|
32
52
|
npm run test:browser # Run browser tests only
|
|
33
53
|
```
|
|
34
54
|
|
|
55
|
+
Run `npm run test:lint` first when iterating — it is fast. Run `npm run test` before declaring work done.
|
|
56
|
+
|
|
35
57
|
## Repository layout
|
|
36
58
|
|
|
37
59
|
```text
|
|
@@ -70,10 +92,9 @@ Blocks, so here are some definitions to clarify:
|
|
|
70
92
|
- Scratch's "block palette" is called the "toolbox" in Blockly, and is implemented with the flyout, which hosts a
|
|
71
93
|
secondary Blockly workspace (a concept that Scratch glosses over).
|
|
72
94
|
|
|
73
|
-
##
|
|
95
|
+
## npm workflow
|
|
74
96
|
|
|
75
|
-
|
|
76
|
-
specified in `package-lock.json`.
|
|
97
|
+
Use `npm ci` to install existing dependencies so you get the exact versions in `package-lock.json`.
|
|
77
98
|
|
|
78
99
|
When installing a new dependency or updating an existing one, run `npm install some-package@new-version` to update
|
|
79
100
|
both `package.json` and `package-lock.json` in one step.
|
|
@@ -81,15 +102,6 @@ both `package.json` and `package-lock.json` in one step.
|
|
|
81
102
|
Keep `package.json` in canonical order. In particular, make sure to alphabetize each dependency block (e.g.,
|
|
82
103
|
`dependencies`, `devDependencies`) and the `scripts` block.
|
|
83
104
|
|
|
84
|
-
## When adding runtime safety checks
|
|
85
|
-
|
|
86
|
-
When adding runtime checks for states that should never happen (including guard-driven early returns), avoid silent failure:
|
|
87
|
-
|
|
88
|
-
- Log a warning or error with enough context to debug (function path, block/event id, key flags).
|
|
89
|
-
- Use `console.warn` for recoverable states and `console.error` for invalid required data.
|
|
90
|
-
- Keep logs specific and consistent (e.g., include function or class context in the message).
|
|
91
|
-
- Do not add noisy logs for expected control flow (e.g., optional constructor args used by `fromJson`).
|
|
92
|
-
|
|
93
105
|
## TypeScript guidelines
|
|
94
106
|
|
|
95
107
|
### Avoid `any`
|
|
@@ -185,8 +197,9 @@ Review all changes and confirm:
|
|
|
185
197
|
- **Correctness**: Changes make sense and edge cases were considered.
|
|
186
198
|
- **Comments**: Comments are necessary, short, and clear; self-explanatory code has no comment.
|
|
187
199
|
- **Simplicity**: Implementation is as simple as possible; no unnecessary code remains.
|
|
200
|
+
- **Documentation**: Update `AGENTS.md` and any other documentation files whose content is affected by the change
|
|
201
|
+
(commands, repo structure, conventions, etc.).
|
|
188
202
|
- **`node_modules/`**: No changes within this directory. In particular, no direct edits to Blockly source files.
|
|
189
|
-
- **Runtime checks**: Any new guards for states that should never happen include diagnostic logging.
|
|
190
203
|
- **Build passes**: `npm run build` completes successfully.
|
|
191
204
|
- **Tests pass**: `npm run test` completes with no failures.
|
|
192
205
|
- **No lint errors**: `npm run test:lint` passes. Iterate with `npm run format` and/or manual changes as needed.
|