-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtmp_break_diagnostic_loop.py
More file actions
92 lines (90 loc) · 3.76 KB
/
Copy pathtmp_break_diagnostic_loop.py
File metadata and controls
92 lines (90 loc) · 3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
from pathlib import Path
path = Path(r'C:\Users\acer\.pi\agent\git\github.com\adi805\pi-minimax-pack\extensions\global-contract.ts')
text = path.read_text(encoding='utf-8')
text = text.replace('''const GRIND_MESSAGE_PREFIXES = [
"Run verification now and report results.",
"Run verification commands now and report results.",
];
function isVirtualValidationCommand(cmd: string): boolean {
return cmd === VIRTUAL_READBACK_VALIDATION;
}
function isGrindMessageText(text: string): boolean {
return GRIND_MESSAGE_PREFIXES.some((prefix) => text.includes(prefix));
}
''','''const GRIND_MESSAGE_PREFIXES = [
"Run verification now and report results.",
"Run verification commands now and report results.",
];
const DIAGNOSTIC_MESSAGE_PREFIXES = [
"Selidiki kegagalan ",
"Investigate the ",
];
function isVirtualValidationCommand(cmd: string): boolean {
return cmd === VIRTUAL_READBACK_VALIDATION;
}
function isGrindMessageText(text: string): boolean {
return GRIND_MESSAGE_PREFIXES.some((prefix) => text.includes(prefix));
}
function isDiagnosticMessageText(text: string): boolean {
return DIAGNOSTIC_MESSAGE_PREFIXES.some((prefix) => text.includes(prefix));
}
''')
text = text.replace(''' let notified = false;
let grindFiredThisSession = false;
let currentGoal: GoalState | null = null;
let preferredLanguage: PreferredLanguage = "id";
''',''' let notified = false;
let grindFiredThisSession = false;
let currentGoal: GoalState | null = null;
let preferredLanguage: PreferredLanguage = "id";
let activeDiagnosticTurn = false;
''')
text = text.replace(''' if (isGrindMessageText(inputMsg) || inputMsg.includes("Continue the active MiniMax goal.")) {
return;
}
preferredLanguage = detectPreferredLanguage(inputMsg);
''',''' activeDiagnosticTurn = isDiagnosticMessageText(inputMsg);
if (isGrindMessageText(inputMsg) || inputMsg.includes("Continue the active MiniMax goal.")) {
return;
}
preferredLanguage = detectPreferredLanguage(inputMsg);
''')
text = text.replace('${contract}\n${ENFORCEMENT}${goalDirective}${reliabilityDirective}${skillDirective}${validationDirective}`','${contract}\n${ENFORCEMENT}${languageDirective}${goalDirective}${reliabilityDirective}${skillDirective}${validationDirective}`')
text = text.replace(''' const messageError = classifyErrorText(messageText);
if (updateRecentError(state, messageError)) {
await flushState();
} else if (messageText.trim() && clearRecentError(state, ["provider_error", "extension_error"])) {
await flushState();
}
if (shouldQueueDiagnostic(state, state.recentError)) {
await flushState();
const diagnosticMsg = buildDiagnosticMessage(state.recentError!, state.sessionChangedPaths.slice(), preferredLanguage);
setTimeout(async () => {
try {
await pi.sendUserMessage(diagnosticMsg, { triggerTurn: true });
} catch (_e) {
await pi.sendUserMessage(diagnosticMsg, { deliverAs: "steer" });
}
}, 250);
}
''',''' const messageError = activeDiagnosticTurn ? null : classifyErrorText(messageText);
if (updateRecentError(state, messageError)) {
await flushState();
} else if (messageText.trim() && clearRecentError(state, ["provider_error", "extension_error"])) {
await flushState();
}
if (!activeDiagnosticTurn && shouldQueueDiagnostic(state, state.recentError)) {
await flushState();
const diagnosticMsg = buildDiagnosticMessage(state.recentError!, state.sessionChangedPaths.slice(), preferredLanguage);
setTimeout(async () => {
try {
await pi.sendUserMessage(diagnosticMsg, { triggerTurn: true });
} catch (_e) {
await pi.sendUserMessage(diagnosticMsg, { deliverAs: "steer" });
}
}, 250);
}
activeDiagnosticTurn = false;
''')
path.write_bytes(text.replace('\r\n','\n').replace('\r','\n').encode('utf-8'))
print('added diagnostic loop breaker and language directive fix')