Skip to content

Commit 0212631

Browse files
author
DavidQ
committed
Rewrite remaining engine utils references to shared utils - PR 11.78
1 parent 64d14fe commit 0212631

35 files changed

Lines changed: 421 additions & 117 deletions

docs/archive/pr/legacy-pr-history/BUILD_PR_REPO_CLEANUP_PHASE_1B_ENGINE_BOUNDARY_AND_DUPLICATE_HELPER_SCAN.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# BUILD_PR: REPO_CLEANUP_PHASE_1B_ENGINE_BOUNDARY_AND_DUPLICATE_HELPER_SCAN
22

33
## Execution Summary
4-
- Docs-first scan completed across `src/engine/utils/**`, `src/engine/ui/**`, `games/**`, `tools/**`, and `samples/**`.
4+
- Docs-first scan completed across `src/shared/utils/**`, `src/engine/ui/**`, `games/**`, `tools/**`, and `samples/**`.
55
- This phase made no runtime/helper consolidation changes.
66
- Classification produced candidate groups for immediate low-risk cleanup and deferred manual review.
77

88
## Findings: Already in engine, local duplicate
99
| path | responsibility | duplicate of | should be in engine | already in engine | canonical location | risk | recommendation |
1010
|---|---|---|---|---|---|---|---|
11-
| `games/Asteroids/utils/math.js` | wraps random/wrap helpers for Asteroids | `src/engine/utils/math.js` (`randomRange`, `wrap`) | no (wrapper can stay local) | yes | `src/engine/utils/math.js` | low | Keep only game-specific surface (`TAU`) or import engine helpers directly in consumers in a follow-up micro-PR. |
12-
| `games/*/game/*` local `function clamp(...)` cluster | scalar clamp utility repeated in multiple game modules | `src/engine/utils/math.js` (`clamp`) | no | yes | `src/engine/utils/math.js` | medium | Migrate in small batches (one game at a time) to reduce behavior/regression risk. |
11+
| `games/Asteroids/utils/math.js` | wraps random/wrap helpers for Asteroids | `src/shared/utils/math.js` (`randomRange`, `wrap`) | no (wrapper can stay local) | yes | `src/shared/utils/math.js` | low | Keep only game-specific surface (`TAU`) or import engine helpers directly in consumers in a follow-up micro-PR. |
12+
| `games/*/game/*` local `function clamp(...)` cluster | scalar clamp utility repeated in multiple game modules | `src/shared/utils/math.js` (`clamp`) | no | yes | `src/shared/utils/math.js` | medium | Migrate in small batches (one game at a time) to reduce behavior/regression risk. |
1313
| `tools/Vector Map Editor/editor/VectorMapFullscreenController.js` | fullscreen toggle + state sync | `src/engine/runtime/FullscreenService.js` | no | yes | `src/engine/runtime/FullscreenService.js` | low | Replace tool-local controller with engine runtime service adapter. |
1414
| `tools/Vector Map Editor/editor/VectorMapSerializer.js` + `tools/Vector Map Editor/editor/VectorMapRuntimeExporter.js` | blob download orchestration | `src/engine/runtime/BrowserDownloadService.js` | no | yes | `src/engine/runtime/BrowserDownloadService.js` | low | Route downloads through `BrowserDownloadService` and keep only payload-building logic local. |
1515
| `samples/_shared/platformerHelpers.js` (`overlap`) | AABB overlap predicate | `src/engine/collision/aabb.js` (`isColliding`) | no | yes | `src/engine/collision/index.js` | low | Import/alias `isColliding` in shared sample helper instead of redefining overlap math. |
@@ -39,9 +39,9 @@
3939
| path | responsibility | duplicate of | should be in engine | already in engine | canonical location | risk | recommendation |
4040
|---|---|---|---|---|---|---|---|
4141
| `games/SpaceInvaders/game/WaveController.js` naming | helper name implies simulation controller but currently HUD/banner presenter | `games/SpaceDuel/game/WaveController.js` (name only) | no | no | likely rename to `WaveHudPresenter`/`WaveStatusPresenter` | low | Rename in a doc-safe or tiny code-safe follow-up with import-site checks. |
42-
| `tools/SpriteEditor_old_keep/main.js` local `clamp` | overlaps engine clamp but file is a large patch/stabilization entrypoint | `src/engine/utils/math.js` (`clamp`) | uncertain | yes | evaluate per SpriteEditor stability plan | medium | Defer until SpriteEditor stabilization work is complete; avoid mixing concerns. |
43-
| `samples/sample003-mouse-input/MouseInputScene.js`, `samples/sample004-gamepad-input/GamepadScene.js` class-local clamp methods | duplicates engine clamp, but potentially intentional pedagogy | `src/engine/utils/math.js` (`clamp`) | uncertain | yes | sample-specific decision | low | Keep as-is unless sample docs explicitly prefer engine helper usage. |
44-
| Target path expectation: `src/engine/math/**` | scan target includes path that does not exist in repo (math lives under `src/engine/utils/math.js`) | N/A | N/A | N/A | `src/engine/utils/math.js` | low | Update future scan templates/docs to avoid path drift. |
42+
| `tools/SpriteEditor_old_keep/main.js` local `clamp` | overlaps engine clamp but file is a large patch/stabilization entrypoint | `src/shared/utils/math.js` (`clamp`) | uncertain | yes | evaluate per SpriteEditor stability plan | medium | Defer until SpriteEditor stabilization work is complete; avoid mixing concerns. |
43+
| `samples/sample003-mouse-input/MouseInputScene.js`, `samples/sample004-gamepad-input/GamepadScene.js` class-local clamp methods | duplicates engine clamp, but potentially intentional pedagogy | `src/shared/utils/math.js` (`clamp`) | uncertain | yes | sample-specific decision | low | Keep as-is unless sample docs explicitly prefer engine helper usage. |
44+
| Target path expectation: `src/engine/math/**` | scan target includes path that does not exist in repo (math lives under `src/shared/utils/math.js`) | N/A | N/A | N/A | `src/shared/utils/math.js` | low | Update future scan templates/docs to avoid path drift. |
4545

4646
## Explicit File Lists
4747

@@ -114,7 +114,7 @@
114114
- Migrate `Asteroids`, `SpaceDuel`, `SpaceInvaders` services to thin adapters.
115115
4. `BUILD_PR: REPO_CLEANUP_PHASE_1F_NAMING_AND_TEMPLATE_ALIGNMENT`
116116
- Resolve `WaveController` naming ambiguity in Space Invaders.
117-
- Update cleanup template path expectation from `src/engine/math/**` to `src/engine/utils/math.js`.
117+
- Update cleanup template path expectation from `src/engine/math/**` to `src/shared/utils/math.js`.
118118

119119
## Phase Status
120120
- Classification and planning complete.

docs/archive/pr/legacy-pr-history/BUILD_PR_REPO_CLEANUP_PHASE_1G_ENGINE_PROMOTION_FROM_STRONG_CANDIDATES.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Repo Cleanup Phase 1G - Engine Promotion From Strong Candidates
2222
- unrelated files outside this BUILD scope
2323

2424
## Full Repo-Relative Paths (Touched for This BUILD)
25-
- `src/engine/utils/fuzzyMatchScore.js`
25+
- `src/shared/utils/fuzzyMatchScore.js`
2626
- `tools/SpriteEditor_old_keep/shared/scoreCommandItem.js`
2727
- `tools/SpriteEditor_old_keep/shared/fuzzyMatchScore.js` (removed)
2828
- `docs/pr/PLAN_PR_REPO_CLEANUP_PHASE_1G_ENGINE_PROMOTION_FROM_STRONG_CANDIDATES.md`
@@ -35,19 +35,19 @@ Repo Cleanup Phase 1G - Engine Promotion From Strong Candidates
3535
## Helper Ownership Before/After
3636
| helper | before owner | after owner | placement justification | behavior change |
3737
|---|---|---|---|---|
38-
| `fuzzyMatchScore(text, query)` | `tools/SpriteEditor_old_keep/shared/fuzzyMatchScore.js` | `src/engine/utils/fuzzyMatchScore.js` | Pure text scoring utility with zero UI/state coupling; best fit in engine utilities | none |
38+
| `fuzzyMatchScore(text, query)` | `tools/SpriteEditor_old_keep/shared/fuzzyMatchScore.js` | `src/shared/utils/fuzzyMatchScore.js` | Pure text scoring utility with zero UI/state coupling; best fit in engine utilities | none |
3939

4040
## Engine Placement Justification
4141
- The helper is deterministic and stateless.
4242
- It has no Sprite Editor data dependency and no UI coupling.
43-
- `src/engine/utils/` is the appropriate reusable utility domain.
43+
- `src/shared/utils/` is the appropriate reusable utility domain.
4444

4545
## Import Update
4646
- Updated `tools/SpriteEditor_old_keep/shared/scoreCommandItem.js` to import from:
47-
- `../../../src/src/engine/utils/fuzzyMatchScore.js`
47+
- `../../../src/src/shared/utils/fuzzyMatchScore.js`
4848

4949
## Validation
50-
- `node -c src/engine/utils/fuzzyMatchScore.js`
50+
- `node -c src/shared/utils/fuzzyMatchScore.js`
5151
- `node -c tools/SpriteEditor_old_keep/shared/scoreCommandItem.js`
5252
- `node -c tools/SpriteEditor_old_keep/shared/normalizeCommandText.js`
5353
- `node -c tools/SpriteEditor_old_keep/modules/appCommands.js`

docs/archive/pr/legacy-pr-history/BUILD_PR_REPO_CLEANUP_PHASE_1H_ENGINE_CONSOLIDATION_AND_EXPANSION.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Repo Cleanup Phase 1H - Engine Consolidation and Controlled Expansion
2222
- unrelated files outside this BUILD scope
2323

2424
## Full Repo-Relative Paths (Touched for This BUILD)
25-
- `src/engine/utils/normalizeCommandText.js`
25+
- `src/shared/utils/normalizeCommandText.js`
2626
- `tools/SpriteEditor_old_keep/modules/appCommands.js`
2727
- `tools/SpriteEditor_old_keep/shared/scoreCommandItem.js`
2828
- `tools/SpriteEditor_old_keep/shared/normalizeCommandText.js` (removed)
@@ -36,11 +36,11 @@ Repo Cleanup Phase 1H - Engine Consolidation and Controlled Expansion
3636
## Promoted Helpers (This Phase)
3737
| helper | before owner | after owner | engine domain | behavior change |
3838
|---|---|---|---|---|
39-
| `normalizeCommandText(input)` | `tools/SpriteEditor_old_keep/shared/normalizeCommandText.js` | `src/engine/utils/normalizeCommandText.js` | `src/engine/utils` (generic text normalization) | none |
39+
| `normalizeCommandText(input)` | `tools/SpriteEditor_old_keep/shared/normalizeCommandText.js` | `src/shared/utils/normalizeCommandText.js` | `src/engine/utils` (generic text normalization) | none |
4040

4141
## Consolidation Notes
4242
- Existing Phase 1G promotion remains in place:
43-
- `src/engine/utils/fuzzyMatchScore.js`
43+
- `src/shared/utils/fuzzyMatchScore.js`
4444
- Command ranking shared helper now depends on engine-owned generic helpers.
4545
- Sprite Editor module import updated to consume engine utility directly where used.
4646

@@ -50,18 +50,18 @@ Repo Cleanup Phase 1H - Engine Consolidation and Controlled Expansion
5050
## Updated Helper Inventory Snapshot
5151
| helper | owner after Phase 1H |
5252
|---|---|
53-
| `fuzzyMatchScore` | `src/engine/utils/fuzzyMatchScore.js` |
54-
| `normalizeCommandText` | `src/engine/utils/normalizeCommandText.js` |
53+
| `fuzzyMatchScore` | `src/shared/utils/fuzzyMatchScore.js` |
54+
| `normalizeCommandText` | `src/shared/utils/normalizeCommandText.js` |
5555
| `scoreCommandItem` | `tools/SpriteEditor_old_keep/shared/scoreCommandItem.js` |
5656

5757
## Import Updates
5858
- `tools/SpriteEditor_old_keep/shared/scoreCommandItem.js`
59-
- `normalizeCommandText` import -> `../../../src/src/engine/utils/normalizeCommandText.js`
59+
- `normalizeCommandText` import -> `../../../src/src/shared/utils/normalizeCommandText.js`
6060
- `tools/SpriteEditor_old_keep/modules/appCommands.js`
61-
- `normalizeCommandText` import -> `../../../src/src/engine/utils/normalizeCommandText.js`
61+
- `normalizeCommandText` import -> `../../../src/src/shared/utils/normalizeCommandText.js`
6262

6363
## Validation
64-
- `node -c src/engine/utils/normalizeCommandText.js`
64+
- `node -c src/shared/utils/normalizeCommandText.js`
6565
- `node -c tools/SpriteEditor_old_keep/shared/scoreCommandItem.js`
6666
- `node -c tools/SpriteEditor_old_keep/modules/appCommands.js`
6767

docs/archive/tools/SpriteEditor_old_keep/modules/appCommands.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { normalizeCommandText } from "/src/engine/utils/normalizeCommandText.js";
1+
import { normalizeCommandText } from "/src/shared/utils/normalizeCommandText.js";
22
import { scoreCommandItem } from "../shared/scoreCommandItem.js";
33

44
function installSpriteEditorCommandMethods(SpriteEditorApp) {

docs/archive/tools/SpriteEditor_old_keep/modules/appPopups.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getCenteredRect } from "/src/engine/utils/index.js";
1+
import { getCenteredRect } from "/src/shared/utils/index.js";
22
import {
33
createCanvasPopupState,
44
dismissCanvasPopup,

docs/archive/tools/SpriteEditor_old_keep/modules/appShell.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
MACRO_DEFINITIONS_KEY,
44
RECENT_ACTIONS_KEY,
55
} from "./constants.js";
6-
import { pointInRect } from "/src/engine/utils/index.js";
6+
import { pointInRect } from "/src/shared/utils/index.js";
77

88
function installSpriteEditorShellMethods(SpriteEditorApp) {
99
Object.assign(SpriteEditorApp.prototype, {

docs/archive/tools/SpriteEditor_old_keep/modules/controlSurfaceCommandPalette.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { LOGICAL_H, LOGICAL_W } from "./constants.js";
2-
import { xyInRect } from "/src/engine/utils/index.js";
2+
import { xyInRect } from "/src/shared/utils/index.js";
33

44
function installControlSurfaceCommandPalette(SpriteEditorCanvasControlSurface) {
55
SpriteEditorCanvasControlSurface.prototype.toggleFavoriteAt = function toggleFavoriteAt(x, y) {

docs/archive/tools/SpriteEditor_old_keep/modules/controlSurfaceInput.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { xyInRect } from "/src/engine/utils/index.js";
1+
import { xyInRect } from "/src/shared/utils/index.js";
22

33
function installControlSurfaceInput(SpriteEditorCanvasControlSurface) {
44
SpriteEditorCanvasControlSurface.prototype.getControlAt = function getControlAt(x, y) {

docs/archive/tools/SpriteEditor_old_keep/shared/scoreCommandItem.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { fuzzyMatchScore } from "/src/engine/utils/fuzzyMatchScore.js";
2-
import { normalizeCommandText } from "/src/engine/utils/normalizeCommandText.js";
1+
import { fuzzyMatchScore } from "/src/shared/utils/fuzzyMatchScore.js";
2+
import { normalizeCommandText } from "/src/shared/utils/normalizeCommandText.js";
33

44
function scoreCommandItem(item, normalizedQuery) {
55
if (!normalizedQuery) return 0;

docs/dev/codex_commands.md

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
1-
# Codex Commands — PR 11.76
1+
# Codex command - PR 11.78
22

33
Model: GPT-5.4
4-
Reasoning: high
4+
Reasoning: medium
55

6-
```powershell
7-
codex exec --model gpt-5.4 --reasoning high "Apply PR 11.76. Move all utility files from src/engine/utils to src/shared/utils unless a file is proven to be engine-runtime code. Do not cherry-pick only duplicates. Update all imports. Do not create aliases or wrappers. Remove old duplicate files. Produce reports under docs/dev/reports and a ZIP artifact at tmp/PR_11_76_ENGINE_UTILS_TO_SHARED_UTILS.zip. Run targeted validation only."
8-
```
9-
10-
## Required validation commands
11-
12-
```powershell
13-
# find remaining old imports
14-
Select-String -Path .\src\*.js, .\src\**\*.js, .\samples\**\*.js, .\tools\**\*.js -Pattern "src/engine/utils|engine/utils|../engine/utils|../../engine/utils|../../../engine/utils" -ErrorAction SilentlyContinue
15-
16-
# list remaining engine utils files
17-
Get-ChildItem .\src\engine\utils -Recurse -File -ErrorAction SilentlyContinue
6+
```text
7+
Run BUILD_PR_LEVEL_11_78_ENGINE_UTILS_REFERENCE_CLOSURE. Rewrite every remaining literal reference from src/engine/utils/ to src/shared/utils/, including leading-slash forms. Do not create aliases or shims. Fail the PR if any runtime/source references remain after verification.
188
```

0 commit comments

Comments
 (0)