Skip to content

Commit a0caf72

Browse files
author
DavidQ
committed
BUILD PR: centralize stringifyValue across exact inspector/command-pack batch.
1 parent efef29d commit a0caf72

8 files changed

Lines changed: 109 additions & 26 deletions

File tree

docs/dev/CODEX_COMMANDS.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
MODEL: GPT-5.3-codex
22
REASONING: high
33
COMMAND:
4-
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_45_READ_HOST_STATUS_SNAPSHOT_BATCH.md exactly.
4+
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_46_STRINGIFY_VALUE_INSPECTOR_BATCH.md exactly.
55
Edit only these files:
6-
- src/engine/debug/network/shared/hostReadUtils.js (new file)
7-
- src/engine/debug/inspectors/commands/registerInspectorCommands.js
8-
- src/engine/debug/network/dashboard/registerDashboardCommands.js
6+
- tools/dev/shared/stringifyValueUtils.js (new file)
7+
- src/engine/debug/inspectors/viewModels/stateDiffInspectorViewModel.js
8+
- tools/dev/commandPacks/inspectorCommandPack.js
99
Do not expand scope.
10-
Package the delta output to <project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_45_READ_HOST_STATUS_SNAPSHOT_BATCH_delta.zip
10+
Package the delta output to <project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_46_STRINGIFY_VALUE_INSPECTOR_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 readHostStatus/readHostSnapshot across exact engine batch.
1+
BUILD PR: centralize stringifyValue across exact inspector/command-pack batch.

docs/dev/NEXT_COMMAND.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Next: run BUILD_PR_SHARED_EXTRACTION_46_STRINGIFY_VALUE_INSPECTOR_BATCH after this 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-
Execution-grade batch for host reader helpers using the exact duplicate-report file list.
1+
Execution-grade batch for stringifyValue using the exact duplicate-report file list.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# BUILD_PR_SHARED_EXTRACTION_46_STRINGIFY_VALUE_INSPECTOR_BATCH
2+
3+
## Purpose
4+
Centralize duplicated `stringifyValue(value)` implementations across the exact inspector/command-pack batch identified in the duplicate report.
5+
6+
## Single PR Purpose
7+
Normalize ONLY this helper:
8+
9+
- `stringifyValue(value)`
10+
11+
## Exact Files Allowed
12+
13+
### New shared file
14+
1. `tools/dev/shared/stringifyValueUtils.js`
15+
16+
### Consumer files
17+
2. `src/engine/debug/inspectors/viewModels/stateDiffInspectorViewModel.js`
18+
3. `tools/dev/commandPacks/inspectorCommandPack.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 stringifyValue(value)`
26+
27+
Only the 2 listed consumer files are in scope.
28+
29+
## Exact Shared Helper Creation
30+
Create:
31+
32+
`tools/dev/shared/stringifyValueUtils.js`
33+
34+
Export exactly:
35+
36+
```js
37+
export function stringifyValue(value) {
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+
- `stringifyValue(value)`
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 stringifyValue(value)
55+
```
56+
then:
57+
- remove the local `stringifyValue(value)` function definition
58+
- import `stringifyValue` from the correct relative path to:
59+
- `tools/dev/shared/stringifyValueUtils.js`
60+
- if the file already imports from that module, add `stringifyValue` 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 `stringifyValue`, leave it unchanged.
66+
67+
## Relative Import Rule
68+
Use the correct relative path from each consumer file to:
69+
70+
`tools/dev/shared/stringifyValueUtils.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 stringify 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 `tools/dev/shared/stringifyValueUtils.js` exists and exports `stringifyValue`
84+
3. Confirm local `function stringifyValue(value)` definitions no longer exist in changed listed consumer files
85+
4. Confirm changed consumer files import `stringifyValue` from the correct relative path to `tools/dev/shared/stringifyValueUtils.js`
86+
5. Confirm no unrelated files changed
87+
6. Confirm no behavior changes were made
88+
89+
## Non-Goals
90+
- no cleanup outside the 2 listed consumer files
91+
- no refactor beyond this exact duplicate-removal batch

src/engine/debug/inspectors/viewModels/stateDiffInspectorViewModel.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,7 @@ import {
99
asObject
1010
} from "../shared/inspectorUtils.js";
1111
import { asPositiveInteger } from "../../../../shared/utils/numberUtils.js";
12-
13-
function stringifyValue(value) {
14-
try {
15-
const encoded = JSON.stringify(value);
16-
return typeof encoded === "string" ? encoded : String(value);
17-
} catch (_error) {
18-
return String(value);
19-
}
20-
}
12+
import { stringifyValue } from "../../../../../tools/dev/shared/stringifyValueUtils.js";
2113

2214
export function createStateDiffInspectorViewModel(options = {}) {
2315
const source = asObject(options);

tools/dev/commandPacks/inspectorCommandPack.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
standardDetails,
1414
toLinePair
1515
} from "./packUtils.js";
16+
import { stringifyValue } from "../shared/stringifyValueUtils.js";
1617

1718
import { sanitizeText } from "../../../src/engine/debug/inspectors/shared/inspectorUtils.js";
1819

@@ -40,15 +41,6 @@ function findEntity(inspectors, entityId) {
4041
return entities.find((entry) => entry.id === id) || null;
4142
}
4243

43-
function stringifyValue(value) {
44-
try {
45-
const json = JSON.stringify(value);
46-
return typeof json === "string" ? json : String(value);
47-
} catch (_error) {
48-
return String(value);
49-
}
50-
}
51-
5244
function formatTime(timestamp) {
5345
return Number.isFinite(timestamp)
5446
? new Date(timestamp).toISOString()
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export function stringifyValue(value) {
2+
try {
3+
const encoded = JSON.stringify(value);
4+
return typeof encoded === "string" ? encoded : String(value);
5+
} catch (_error) {
6+
return String(value);
7+
}
8+
}

0 commit comments

Comments
 (0)