@sureshsankaran/ralph-wiggum 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +11 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -67,7 +67,8 @@ export const RalphWiggumPlugin = async ({ client }) => {
|
|
|
67
67
|
const stateFilePath = getStateFilePath();
|
|
68
68
|
// In-memory state to prevent double-processing
|
|
69
69
|
let completionDetected = false;
|
|
70
|
-
let
|
|
70
|
+
let pendingIteration = -1; // Track iteration we're currently processing/waiting for
|
|
71
|
+
let lastAssistantId = ""; // Track last assistant message to detect new responses
|
|
71
72
|
// Cast to extended hooks type that includes experimental.session.stop
|
|
72
73
|
const hooks = {
|
|
73
74
|
// Stop hook: called when main session loop is about to exit
|
|
@@ -89,6 +90,14 @@ export const RalphWiggumPlugin = async ({ client }) => {
|
|
|
89
90
|
.find((m) => m.info.role === "assistant" && m.parts.some((p) => p.type === "text"));
|
|
90
91
|
if (!lastAssistant)
|
|
91
92
|
return;
|
|
93
|
+
// Prevent double-triggering: if we already sent a prompt for this iteration
|
|
94
|
+
// and haven't seen a new assistant message, skip
|
|
95
|
+
if (pendingIteration === state.iteration && lastAssistant.info.id === lastAssistantId) {
|
|
96
|
+
output.decision = "block"; // Still block, we're waiting for AI to respond
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
// Update tracking
|
|
100
|
+
lastAssistantId = lastAssistant.info.id;
|
|
92
101
|
const textParts = lastAssistant.parts.filter((p) => p.type === "text");
|
|
93
102
|
const fullText = textParts.map((p) => p.text).join("\n");
|
|
94
103
|
// Check completion promise
|
|
@@ -113,11 +122,8 @@ export const RalphWiggumPlugin = async ({ client }) => {
|
|
|
113
122
|
catch { }
|
|
114
123
|
return;
|
|
115
124
|
}
|
|
116
|
-
// Check if we've already advanced this iteration
|
|
117
|
-
if (state.iteration <= lastProcessedIteration)
|
|
118
|
-
return;
|
|
119
125
|
const nextIteration = state.iteration + 1;
|
|
120
|
-
|
|
126
|
+
pendingIteration = nextIteration;
|
|
121
127
|
// Update state file with new iteration
|
|
122
128
|
const updated = content.replace(/^iteration: \d+$/m, `iteration: ${nextIteration}`);
|
|
123
129
|
writeFileSync(stateFilePath, updated);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sureshsankaran/ralph-wiggum",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Ralph Wiggum iterative AI development plugin for OpenCode - continuously loops the same prompt until task completion",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|