Skip to content

Commit 4ba9b2f

Browse files
author
DavidQ
committed
BUILD PR: centralize codeToLetter across exact initials-entry batch.
1 parent 7b098ef commit 4ba9b2f

11 files changed

Lines changed: 125 additions & 33 deletions

docs/dev/CODEX_COMMANDS.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
Execute exactly. No expansion.
1+
MODEL: GPT-5.3-codex
2+
REASONING: high
3+
COMMAND:
4+
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_38_CODE_TO_LETTER_HIGHSCORE_BATCH.md exactly.
5+
Edit only these files:
6+
- src/shared/utils/initialsEntryUtils.js (new file)
7+
- games/Asteroids/systems/AsteroidsInitialsEntry.js
8+
- games/SpaceDuel/game/SpaceDuelInitialsEntry.js
9+
- games/SpaceInvaders/game/SpaceInvadersInitialsEntry.js
10+
Do not expand scope.
11+
Package the delta output to <project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_38_CODE_TO_LETTER_HIGHSCORE_BATCH_delta.zip

docs/dev/COMMIT_COMMENT.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
BUILD_PR_SHARED_EXTRACTION_38_ID_UTILS_BATCH
1+
BUILD PR: centralize codeToLetter across exact initials-entry batch.

docs/dev/NEXT_COMMAND.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Next batch
1+
Next: continue duplicate-family extraction from the provided duplicate report.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
batch
1+
Execution-grade batch for codeToLetter using the exact duplicate-report file list.

docs/dev/reports/file_tree.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
docs
1+
docs only
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
validate
1+
Exact file list present; one PR purpose only; no guessing.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# BUILD_PR_SHARED_EXTRACTION_38_CODE_TO_LETTER_HIGHSCORE_BATCH
2+
3+
## Purpose
4+
Centralize duplicated `codeToLetter(code)` implementations across the exact initials-entry batch identified in the duplicate report.
5+
6+
## Single PR Purpose
7+
Normalize ONLY this helper:
8+
9+
- `codeToLetter(code)`
10+
11+
## Exact Files Allowed
12+
13+
### New shared file
14+
1. `src/shared/utils/initialsEntryUtils.js`
15+
16+
### Consumer files
17+
2. `games/Asteroids/systems/AsteroidsInitialsEntry.js`
18+
3. `games/SpaceDuel/game/SpaceDuelInitialsEntry.js`
19+
4. `games/SpaceInvaders/game/SpaceInvadersInitialsEntry.js`
20+
21+
Do not edit any other file.
22+
23+
## Source of Truth
24+
This exact scope comes from the provided duplicate report entry for:
25+
26+
`function codeToLetter(code)`
27+
28+
Only the 3 listed consumer files are in scope. fileciteturn8file0
29+
30+
## Exact Shared Helper Creation
31+
Create:
32+
33+
`src/shared/utils/initialsEntryUtils.js`
34+
35+
Export exactly:
36+
37+
```js
38+
export function codeToLetter(code) {
39+
// copy one existing implementation exactly
40+
}
41+
```
42+
43+
Implementation rules:
44+
- use ONE existing local implementation as source-of-truth
45+
- do NOT merge logic
46+
- do NOT generalize behavior
47+
- preserve the function signature exactly:
48+
- `codeToLetter(code)`
49+
50+
## Exact Consumer Changes
51+
For each of the 3 listed consumer files:
52+
53+
If the file contains a local function definition matching:
54+
```js
55+
function codeToLetter(code)
56+
```
57+
then:
58+
- remove the local `codeToLetter(code)` function definition
59+
- import `codeToLetter` from the correct relative path to:
60+
- `src/shared/utils/initialsEntryUtils.js`
61+
- if the file already imports from that module, add `codeToLetter` with the minimum safe edit
62+
- do not duplicate imports
63+
- do not touch unrelated helpers
64+
- do not change logic
65+
66+
If a listed file already imports and uses shared `codeToLetter`, leave it unchanged.
67+
68+
## Relative Import Rule
69+
Use the correct relative path from each consumer file to:
70+
71+
`src/shared/utils/initialsEntryUtils.js`
72+
73+
Do not use aliases.
74+
Do not change `.js` extension usage.
75+
76+
## Hard Constraints
77+
- no engine changes
78+
- no game files outside the 3 listed consumers
79+
- no sample files
80+
- no repo-wide initials helper cleanup
81+
- no behavior changes
82+
- keep one PR purpose only
83+
84+
## Validation Checklist
85+
1. Confirm no more than the 4 listed files changed
86+
2. Confirm `src/shared/utils/initialsEntryUtils.js` exists and exports `codeToLetter`
87+
3. Confirm local `function codeToLetter(code)` definitions no longer exist in changed listed consumer files
88+
4. Confirm changed consumer files import `codeToLetter` from the correct relative path to `src/shared/utils/initialsEntryUtils.js`
89+
5. Confirm no unrelated engine, game, or sample files changed
90+
6. Confirm no behavior changes were made
91+
92+
## Non-Goals
93+
- no cleanup of high score service helpers in this PR
94+
- no cleanup outside the 3 listed consumer files
95+
- no refactor beyond this exact duplicate-removal batch

games/Asteroids/systems/AsteroidsInitialsEntry.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,9 @@ David Quesenberry
44
03/25/2026
55
AsteroidsInitialsEntry.js
66
*/
7-
const KEY_CODES = Array.from({ length: 26 }).map((_, index) => `Key${String.fromCharCode(65 + index)}`);
8-
9-
function codeToLetter(code) {
10-
if (!code || !code.startsWith('Key')) {
11-
return null;
12-
}
7+
import { codeToLetter } from '../../../src/shared/utils/initialsEntryUtils.js';
138

14-
const letter = code.slice(3, 4).toUpperCase();
15-
return /^[A-Z]$/.test(letter) ? letter : null;
16-
}
9+
const KEY_CODES = Array.from({ length: 26 }).map((_, index) => `Key${String.fromCharCode(65 + index)}`);
1710

1811
export default class AsteroidsInitialsEntry {
1912
constructor() {

games/SpaceDuel/game/SpaceDuelInitialsEntry.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,9 @@ David Quesenberry
44
03/25/2026
55
SpaceDuelInitialsEntry.js
66
*/
7-
const KEY_CODES = Array.from({ length: 26 }).map((_, index) => `Key${String.fromCharCode(65 + index)}`);
8-
9-
function codeToLetter(code) {
10-
if (!code || !code.startsWith('Key')) {
11-
return null;
12-
}
7+
import { codeToLetter } from '../../../src/shared/utils/initialsEntryUtils.js';
138

14-
const letter = code.slice(3, 4).toUpperCase();
15-
return /^[A-Z]$/.test(letter) ? letter : null;
16-
}
9+
const KEY_CODES = Array.from({ length: 26 }).map((_, index) => `Key${String.fromCharCode(65 + index)}`);
1710

1811
export default class SpaceDuelInitialsEntry {
1912
constructor() {

games/SpaceInvaders/game/SpaceInvadersInitialsEntry.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,9 @@ David Quesenberry
44
03/25/2026
55
SpaceInvadersInitialsEntry.js
66
*/
7-
const KEY_CODES = Array.from({ length: 26 }).map((_, index) => `Key${String.fromCharCode(65 + index)}`);
8-
9-
function codeToLetter(code) {
10-
if (!code || !code.startsWith('Key')) {
11-
return null;
12-
}
7+
import { codeToLetter } from '../../../src/shared/utils/initialsEntryUtils.js';
138

14-
const letter = code.slice(3, 4).toUpperCase();
15-
return /^[A-Z]$/.test(letter) ? letter : null;
16-
}
9+
const KEY_CODES = Array.from({ length: 26 }).map((_, index) => `Key${String.fromCharCode(65 + index)}`);
1710

1811
export default class SpaceInvadersInitialsEntry {
1912
constructor() {

0 commit comments

Comments
 (0)