Skip to content

Commit d0fe1e0

Browse files
author
DavidQ
committed
BUILD PR: centralize toResult across exact debug-command batch.
1 parent 81adac0 commit d0fe1e0

9 files changed

Lines changed: 117 additions & 31 deletions

File tree

docs/dev/CODEX_COMMANDS.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
MODEL: GPT-5.3-codex
22
REASONING: high
33
COMMAND:
4-
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_38_CODE_TO_LETTER_HIGHSCORE_BATCH.md exactly.
4+
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_44_TO_RESULT_DEBUG_COMMAND_BATCH.md exactly.
55
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
6+
- src/engine/debug/shared/debugCommandResultUtils.js (new file)
7+
- src/engine/debug/inspectors/commands/registerInspectorCommands.js
8+
- tools/dev/presets/debugPresetApplier.js
109
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
10+
Package the delta output to <project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_44_TO_RESULT_DEBUG_COMMAND_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: centralize codeToLetter across exact initials-entry batch.
1+
BUILD PR: centralize toResult across exact debug-command batch.

docs/dev/NEXT_COMMAND.txt

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

src/engine/debug/inspectors/commands/registerInspectorCommands.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,7 @@ import {
1010
asObject,
1111
sanitizeText
1212
} from "../shared/inspectorUtils.js";
13-
14-
function toResult(status, title, code, lines, details = {}) {
15-
return {
16-
status: status === "failed" ? "failed" : "ready",
17-
title,
18-
code,
19-
lines: asArray(lines).map((line) => String(line)),
20-
details: asObject(details)
21-
};
22-
}
13+
import { toResult } from "../../shared/debugCommandResultUtils.js";
2314

2415
function readHostStatus(host) {
2516
return host && typeof host.getStatus === "function"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {
2+
asArray,
3+
asObject
4+
} from "../inspectors/shared/inspectorUtils.js";
5+
6+
export function toResult(status, title, code, lines, details = {}) {
7+
return {
8+
status: status === "failed" ? "failed" : "ready",
9+
title,
10+
code,
11+
lines: asArray(lines).map((line) => String(line)),
12+
details: asObject(details)
13+
};
14+
}

tools/dev/presets/debugPresetApplier.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ debugPresetApplier.js
66
*/
77

88
import { sanitizeText } from "../../../src/engine/debug/inspectors/shared/inspectorUtils.js";
9-
import { isObject } from "../../../src/shared/utils/objectUtils.js";
109
import { cloneJson } from "../../../src/shared/utils/jsonUtils.js";
1110
import { getRuntimeAndRegistry } from "../shared/runtimeRegistryUtils.js";
11+
import { toResult } from "../../../src/engine/debug/shared/debugCommandResultUtils.js";
1212

1313
function getAllPanels(panelRegistry) {
1414
const panels = panelRegistry.getOrderedPanels(true);
@@ -38,16 +38,6 @@ function toPanelMap(panelRegistry) {
3838
return map;
3939
}
4040

41-
function toResult(status, title, code, lines, details = {}) {
42-
return {
43-
status: status === "failed" ? "failed" : "ready",
44-
title,
45-
code,
46-
lines: Array.isArray(lines) ? lines : [],
47-
details: isObject(details) ? details : {}
48-
};
49-
}
50-
5141
export class DebugPresetApplier {
5242
constructor(options = {}) {
5343
this.presetRegistry = options.presetRegistry || null;

0 commit comments

Comments
 (0)