Skip to content

Commit c58d3e8

Browse files
author
DavidQ
committed
BUILD PR: optional npm prehook for shared extraction guard.
1 parent 32af67a commit c58d3e8

7 files changed

Lines changed: 64 additions & 9 deletions

docs/dev/CODEX_COMMANDS.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
MODEL: GPT-5.3-codex
22
REASONING: high
33
COMMAND:
4-
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_20_GUARD_SCRIPT_WIRING_PACKAGE_JSON.md exactly.
5-
Edit only:
6-
- package.json (only if it exists and has scripts)
7-
Fail fast if conditions are not met.
8-
Package delta to <project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_20_GUARD_SCRIPT_WIRING_PACKAGE_JSON_delta.zip
4+
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_21_OPTIONAL_NPM_PREHOOK_GUARD.md exactly.
5+
Edit only package.json under defined rules.
6+
Fail fast if conditions not met.
7+
Package delta to <project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_21_OPTIONAL_NPM_PREHOOK_GUARD_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: wire shared extraction guard into package.json script.
1+
BUILD PR: optional npm prehook for shared extraction guard.

docs/dev/NEXT_COMMAND.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Next: continue executable BUILD chain.
1+
Next: continue BUILD chain.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Add npm script for guard execution.
1+
Optional guard auto-run via npm prehooks.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
package.json script added correctly
1+
prehook added correctly
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# BUILD_PR_SHARED_EXTRACTION_21_OPTIONAL_NPM_PREHOOK_GUARD
2+
3+
## Purpose
4+
Optionally enforce the shared-extraction guard automatically before existing npm workflows (test or start), without introducing CI or new tooling.
5+
6+
## Single PR Purpose
7+
Add guard execution as a pre-hook ONLY IF matching scripts already exist.
8+
9+
## Exact Files Allowed
10+
1. package.json (only if it exists AND already has scripts)
11+
12+
## Fail-Fast Gate
13+
Before editing:
14+
1. package.json exists
15+
2. has scripts section
16+
3. already contains at least one of:
17+
- "test"
18+
- "start"
19+
20+
If not:
21+
- stop
22+
- no changes
23+
- no ZIP
24+
25+
## Exact Change
26+
27+
If "test" exists and "pretest" does NOT exist:
28+
add:
29+
"pretest": "node tools/dev/checkSharedExtractionGuard.mjs"
30+
31+
If "start" exists and "prestart" does NOT exist:
32+
add:
33+
"prestart": "node tools/dev/checkSharedExtractionGuard.mjs"
34+
35+
Rules:
36+
- do not override existing pretest/prestart
37+
- do not modify existing scripts
38+
- minimal insertion only
39+
40+
## Hard Constraints
41+
- only package.json
42+
- no new files
43+
- no logic changes
44+
- no CI
45+
- no lint
46+
47+
## Validation Checklist
48+
1. Only package.json changed
49+
2. pretest/prestart added only if valid
50+
3. guard script path correct
51+
4. existing scripts unchanged
52+
53+
## Non-Goals
54+
- no CI integration
55+
- no repo-wide changes

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"type": "module",
33
"scripts": {
4+
"pretest": "node tools/dev/checkSharedExtractionGuard.mjs",
45
"test": "node ./scripts/run-node-tests.mjs",
56
"build:manifest": "node ./scripts/generate-sample-manifest.mjs",
67
"check:shared-extraction-guard": "node tools/dev/checkSharedExtractionGuard.mjs"

0 commit comments

Comments
 (0)