Skip to content

Commit 64d14fe

Browse files
author
DavidQ
committed
Move engine utilities into shared utils and update imports - PR 11.76. Rewire moved utility imports from engine utils to shared utils - PR 11.77
1 parent fc0562c commit 64d14fe

11 files changed

Lines changed: 108 additions & 10 deletions

docs/dev/codex_commands.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
# Codex Commands — PR 11.75
1+
# Codex Commands — PR 11.76
22

33
Model: GPT-5.4
44
Reasoning: high
55

66
```powershell
7-
codex --model gpt-5.4 --reasoning high "Run PR 11.75 utils consolidation. Read docs/pr/PR_11_75_UTILS_CONSOLIDATION.md. Inventory src/engine/utils and src/shared/utils at file and exported-method level. Consolidate only true shared-safe duplicates into src/shared/utils, keep engine-bound utilities in src/engine/utils, update imports, remove duplicate implementation files only after imports are updated, and write reports under docs/dev/reports. Do not create wrappers, alias files, bridge exports, pass-through variables, or broad refactors. Run targeted syntax/import validation only."
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
818
```

docs/dev/commit_comment.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Consolidate shared utilities and remove duplicate engine utility implementations - PR 11.75
1+
Move engine utilities into shared utils and update imports - PR 11.76
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# PR 11.76 Acceptance Checklist
2+
3+
- [ ] All files under `src/engine/utils/*` inventoried.
4+
- [ ] All utility files moved to `src/shared/utils/*`.
5+
- [ ] Any remaining `src/engine/utils/*` file has a documented engine-runtime dependency.
6+
- [ ] No wrapper or alias files created.
7+
- [ ] No duplicate utility implementations remain.
8+
- [ ] All repo imports updated to new shared utility paths.
9+
- [ ] Search for old engine utility imports returns zero, except documented exceptions.
10+
- [ ] Workspace Manager opens.
11+
- [ ] Affected tools open without console import errors.
12+
- [ ] Full samples test skipped because this is targeted utility/import consolidation; run only if broad loader/runtime issues appear.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# PR 11.76 — Engine Utils to Shared Utils
2+
3+
## Scope Executed
4+
- Moved all files from `src/engine/utils/` into `src/shared/utils/`.
5+
- Removed old `src/engine/utils/index.js`.
6+
- Updated `src/shared/utils/index.js` exports for moved utilities.
7+
- No engine-runtime exceptions were found.
8+
9+
## Files Moved
10+
- `src/engine/utils/fuzzyMatchScore.js` -> `src/shared/utils/fuzzyMatchScore.js`
11+
- `src/engine/utils/geometry.js` -> `src/shared/utils/geometryUtils.js`
12+
- `src/engine/utils/invariant.js` -> `src/shared/utils/invariantUtils.js`
13+
- `src/engine/utils/normalizeCommandText.js` -> `src/shared/utils/normalizeCommandTextUtils.js`
14+
15+
## Files Updated
16+
- `src/shared/utils/index.js`
17+
18+
## Files Removed
19+
- `src/engine/utils/index.js`
20+
21+
## Validation
22+
- Required import scan command:
23+
- `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`
24+
- Result: no matches
25+
- Required engine utils directory check:
26+
- `Get-ChildItem .\src\engine\utils -Recurse -File -ErrorAction SilentlyContinue`
27+
- Result: no files
28+
- Targeted syntax checks:
29+
- `node --check src/shared/utils/index.js`
30+
- `node --check src/shared/utils/geometryUtils.js`
31+
- `node --check src/shared/utils/invariantUtils.js`
32+
- `node --check src/shared/utils/normalizeCommandTextUtils.js`
33+
- `node --check src/shared/utils/fuzzyMatchScore.js`
34+
- Result: all passed
35+
36+
## Acceptance Summary
37+
- `src/engine/utils/*` now contains no files.
38+
- Moved utilities are under `src/shared/utils/*`.
39+
- No active imports remain in `src/`, `samples/`, or `tools/` for `engine/utils` paths.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# PR 11.76 — Engine Utils to Shared Utils Consolidation
2+
3+
## Purpose
4+
Move the complete utility layer currently under `src/engine/utils/*` into `src/shared/utils/*` because these files are utilities, not engine runtime code.
5+
6+
## Scope
7+
- Inventory every file under `src/engine/utils/*`.
8+
- Move all utility files to `src/shared/utils/*`.
9+
- Preserve folder structure where it helps clarity.
10+
- Merge only when the target shared file is the same utility contract.
11+
- Update all imports across the repo.
12+
- Remove emptied `src/engine/utils` files/folders after import updates.
13+
14+
## Important Correction
15+
Do not cherry-pick only exact duplicates. The default action is move to shared.
16+
17+
Only keep a file under `src/engine/utils/*` if it is proven to be engine runtime code, meaning it directly depends on engine runtime systems such as:
18+
- render loop ownership
19+
- engine state lifecycle
20+
- engine-specific service registry
21+
- runtime scene/game object orchestration
22+
- engine-only loader internals
23+
24+
Canvas helpers, math helpers, path helpers, DOM helpers, JSON helpers, color helpers, id helpers, validation helpers, formatting helpers, and similar utilities belong in `src/shared/utils/*`.
25+
26+
## Rules
27+
- No pass-through aliases.
28+
- No wrapper files that re-export moved utilities from the old path.
29+
- No duplicate utility implementations left behind.
30+
- No broad refactor beyond import path updates required by the move.
31+
- No unrelated changes.
32+
- If two files conflict, keep the shared destination as source of truth and merge useful exported functions into one shared file.
33+
- If a file must remain in engine, document the exact engine runtime dependency in the report.
34+
35+
## Acceptance
36+
- `src/engine/utils/*` is empty or contains only documented engine-runtime exceptions.
37+
- All moved utilities live under `src/shared/utils/*`.
38+
- All imports resolve to the new shared paths.
39+
- No old `src/engine/utils/*` imports remain except documented exceptions.
40+
- Workspace Manager and affected tools load without import errors.

src/engine/utils/index.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/shared/utils/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ export { stringifyValue } from "./stringifyValueUtils.js";
2828
export { oppositeCardinalDirection } from "./directionUtils.js";
2929
export { wrapTextByCharacterCount } from "./textWrapUtils.js";
3030
export { clamp, distance, wrap, randomRange } from "./mathUtils.js";
31+
export { pointInRect, xyInRect, getCenteredRect } from "./geometryUtils.js";
32+
export { invariant } from "./invariantUtils.js";
33+
export { normalizeCommandText } from "./normalizeCommandTextUtils.js";
34+
export { fuzzyMatchScore } from "./fuzzyMatchScore.js";

0 commit comments

Comments
 (0)