Skip to content

Commit 3c08e0c

Browse files
BenBen
authored andcommitted
fix(patches): adapt regexes to CC 2.1.113 minified shapes
verboseProperty: spinner props moved from createElement object literal to destructured function parameter, and spinnerTip is no longer adjacent. Add fallback anchor on overrideMessage + verbose. thinkerFormat: same shape change — the approxAreaPattern can no longer rely on spinnerTip preceding overrideMessage. Add a new-shape fallback using overrideMessage,spinnerSuffix,verbose. opusplan1m: CC 2.1.113 dropped model version numbers from the description string ('Opus 4.6 in plan mode' -> 'Opus in plan mode'); make the version-suffix pieces optional. patchesAppliedIndication: PATCH 3's 'skipped' message duplicates the specific cause already printed by findPatchesListLocation. Downgrade from console.error to console.log to stop flagging it as a failure.
1 parent 207b57c commit 3c08e0c

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

src/patches/opusplan1m.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,11 @@ const patchModelAliasesList = (oldFile: string): string | null => {
109109
* if (A === "opusplan[1m]") return "Opus 4.6 in plan mode, else Sonnet 4.6 (1M context)";
110110
*/
111111
const patchDescriptionFunction = (oldFile: string): string | null => {
112-
// Pattern matches: if (VAR === "opusplan") return "Opus 4.6 in plan mode, else Sonnet 4.6";
112+
// Pattern matches: if (VAR === "opusplan") return "Opus[ 4.6] in plan mode, else Sonnet[ 4.6]";
113+
// CC >= 2.1.113 dropped the model version numbers from this string, so the
114+
// " 4.6" fragments must be optional.
113115
const pattern =
114-
/(if\s*\(\s*([$\w]+)\s*===\s*"opusplan"\s*\)\s*return\s*"Opus .{0,20} in plan mode, else Sonnet .{0,20}";)/;
116+
/(if\s*\(\s*([$\w]+)\s*===\s*"opusplan"\s*\)\s*return\s*"Opus(?: .{0,20})? in plan mode, else Sonnet(?: .{0,20})?";)/;
115117

116118
const match = oldFile.match(pattern);
117119
if (!match || match.index === undefined) {

src/patches/patchesAppliedIndication.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,11 @@ export const writePatchesAppliedIndication = (
553553
if (showPatchesApplied) {
554554
const patchesListLoc = findPatchesListLocation(content);
555555
if (!patchesListLoc) {
556-
console.error(
557-
'patch: patchesAppliedIndication: patch 3 skipped (version display pattern changed by PATCH 2)'
556+
// findPatchesListLocation already logged the specific cause (e.g. header
557+
// component function not found on CC >= 2.1.86). Don't duplicate as an
558+
// error — this is a cascade from the underlying shape change.
559+
console.log(
560+
'patch: patchesAppliedIndication: patch 3 skipped (see prior message)'
558561
);
559562
} else {
560563
const lines = [];

src/patches/thinkerFormat.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33
import { LocationResult, showDiff } from './index';
44

55
const getThinkerFormatLocation = (oldFile: string): LocationResult | null => {
6-
const approxAreaPattern =
6+
// Older CC shape: spinnerTip + overrideMessage adjacent in one destructure.
7+
const approxAreaPatternOld =
78
/spinnerTip:[$\w]+,(?:[$\w]+:[$\w]+,)*overrideMessage:[$\w]+,.{300}/;
8-
const approxAreaMatch = oldFile.match(approxAreaPattern);
9+
// CC >= 2.1.113: spinnerTip moved out; anchor on the spinner's destructured
10+
// signature containing overrideMessage, spinnerSuffix, and verbose.
11+
const approxAreaPatternNew =
12+
/overrideMessage:[$\w]+,spinnerSuffix:[$\w]+,verbose:[$\w]+,.{300}/;
13+
const approxAreaMatch =
14+
oldFile.match(approxAreaPatternOld) || oldFile.match(approxAreaPatternNew);
915

1016
if (!approxAreaMatch || approxAreaMatch.index == undefined) {
1117
console.error('patch: thinker format: failed to find approxAreaMatch');

src/patches/verboseProperty.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,22 @@
33
import { LocationResult, showDiff } from './index';
44

55
const getVerbosePropertyLocation = (oldFile: string): LocationResult | null => {
6+
// Older CC shape: createElement(X, {...spinnerTip...overrideMessage...})
67
const createElementPattern =
78
/createElement\([$\w]+,\{[^}]+spinnerTip[^}]+overrideMessage[^}]+\}/;
8-
const createElementMatch = oldFile.match(createElementPattern);
9+
// CC >= 2.1.113: the spinner component receives its props as a destructured
10+
// function parameter rather than a createElement object literal, and
11+
// spinnerTip is no longer on the same object (it's pulled from state
12+
// separately). Anchor on overrideMessage + verbose instead.
13+
const destructurePattern =
14+
/\{[^{}]{0,400}overrideMessage:[$\w]+,[^{}]{0,200}verbose:[^,}]+[^{}]{0,200}\}/;
15+
16+
const createElementMatch =
17+
oldFile.match(createElementPattern) || oldFile.match(destructurePattern);
918

1019
if (!createElementMatch || createElementMatch.index === undefined) {
1120
console.error(
12-
'patch: verbose: failed to find createElement with spinnerTip and overrideMessage'
21+
'patch: verbose: failed to find spinner props containing overrideMessage and verbose'
1322
);
1423
return null;
1524
}

0 commit comments

Comments
 (0)