opencode-immune 1.0.22 → 1.0.23
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/plugin.js +43 -17
- package/package.json +1 -1
package/dist/plugin.js
CHANGED
|
@@ -1183,13 +1183,46 @@ const PRE_COMMIT_MARKER = "0-ULTRAWORK: PRE_COMMIT";
|
|
|
1183
1183
|
const CYCLE_COMPLETE_MARKER = "0-ULTRAWORK: CYCLE_COMPLETE";
|
|
1184
1184
|
const NEXT_TASK_PATTERN = /Next task:\s*(.+)/;
|
|
1185
1185
|
const ALL_CYCLES_COMPLETE_MARKER = "0-ULTRAWORK: ALL_CYCLES_COMPLETE";
|
|
1186
|
+
/**
|
|
1187
|
+
* Helper: run git commit in the project directory.
|
|
1188
|
+
* Uses execFile for safety (no shell injection).
|
|
1189
|
+
* Returns true if commit succeeded, false otherwise.
|
|
1190
|
+
*/
|
|
1191
|
+
function runGitCommit(directory, message) {
|
|
1192
|
+
return new Promise((resolve) => {
|
|
1193
|
+
// Stage all changes first
|
|
1194
|
+
(0, child_process_1.execFile)("git", ["add", "-A"], { cwd: directory }, (addErr) => {
|
|
1195
|
+
if (addErr) {
|
|
1196
|
+
console.error("[opencode-immune] git add failed:", addErr.message);
|
|
1197
|
+
resolve(false);
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
// Then commit
|
|
1201
|
+
(0, child_process_1.execFile)("git", ["commit", "-m", message], { cwd: directory }, (commitErr, stdout, stderr) => {
|
|
1202
|
+
if (commitErr) {
|
|
1203
|
+
// "nothing to commit" is not a real error
|
|
1204
|
+
if (stderr?.includes("nothing to commit") || stdout?.includes("nothing to commit")) {
|
|
1205
|
+
console.log("[opencode-immune] git commit: nothing to commit (clean tree).");
|
|
1206
|
+
resolve(true);
|
|
1207
|
+
return;
|
|
1208
|
+
}
|
|
1209
|
+
console.error("[opencode-immune] git commit failed:", commitErr.message, stderr);
|
|
1210
|
+
resolve(false);
|
|
1211
|
+
return;
|
|
1212
|
+
}
|
|
1213
|
+
console.log("[opencode-immune] git commit succeeded:", stdout?.trim());
|
|
1214
|
+
resolve(true);
|
|
1215
|
+
});
|
|
1216
|
+
});
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1186
1219
|
/**
|
|
1187
1220
|
* experimental.text.complete: scans completed assistant text for signal markers.
|
|
1188
1221
|
*
|
|
1189
1222
|
* KEY INSIGHT: text.complete fires per text-part, not per message.
|
|
1190
1223
|
* PRE_COMMIT and CYCLE_COMPLETE are in DIFFERENT text parts.
|
|
1191
1224
|
* Therefore CYCLE_COMPLETE handler must be self-contained:
|
|
1192
|
-
* it always runs
|
|
1225
|
+
* it always runs git commit first, then creates a new session.
|
|
1193
1226
|
*
|
|
1194
1227
|
* ALL_CYCLES_COMPLETE → clears ultrawork marker, no new session.
|
|
1195
1228
|
*/
|
|
@@ -1207,18 +1240,14 @@ function createTextCompleteHandler(state) {
|
|
|
1207
1240
|
}
|
|
1208
1241
|
// ── PRE_COMMIT only (without CYCLE_COMPLETE in same part): run commit ──
|
|
1209
1242
|
if (text.includes(PRE_COMMIT_MARKER) && !text.includes(CYCLE_COMPLETE_MARKER)) {
|
|
1210
|
-
if (!state.commitPending
|
|
1243
|
+
if (!state.commitPending) {
|
|
1211
1244
|
state.commitPending = true;
|
|
1212
|
-
console.log("[opencode-immune] Multi-Cycle: PRE_COMMIT detected (standalone),
|
|
1245
|
+
console.log("[opencode-immune] Multi-Cycle: PRE_COMMIT detected (standalone), running git commit...");
|
|
1213
1246
|
try {
|
|
1214
|
-
await state.input.
|
|
1215
|
-
body: { command: "/commit", arguments: "" },
|
|
1216
|
-
path: { id: sessionID },
|
|
1217
|
-
});
|
|
1218
|
-
console.log("[opencode-immune] Multi-Cycle: /commit completed (standalone).");
|
|
1247
|
+
await runGitCommit(state.input.directory, "chore: ultrawork cycle auto-commit");
|
|
1219
1248
|
}
|
|
1220
1249
|
catch (err) {
|
|
1221
|
-
console.error("[opencode-immune] Multi-Cycle:
|
|
1250
|
+
console.error("[opencode-immune] Multi-Cycle: git commit failed (standalone):", err);
|
|
1222
1251
|
}
|
|
1223
1252
|
finally {
|
|
1224
1253
|
state.commitPending = false;
|
|
@@ -1229,18 +1258,15 @@ function createTextCompleteHandler(state) {
|
|
|
1229
1258
|
// ── CYCLE_COMPLETE: self-contained sequence: commit → new session ──
|
|
1230
1259
|
if (text.includes(CYCLE_COMPLETE_MARKER)) {
|
|
1231
1260
|
// Step 1: Always commit first (CYCLE_COMPLETE implies end of cycle)
|
|
1232
|
-
if (
|
|
1261
|
+
if (!state.commitPending) {
|
|
1233
1262
|
state.commitPending = true;
|
|
1234
|
-
console.log("[opencode-immune] Multi-Cycle: CYCLE_COMPLETE detected, running
|
|
1263
|
+
console.log("[opencode-immune] Multi-Cycle: CYCLE_COMPLETE detected, running git commit first...");
|
|
1235
1264
|
try {
|
|
1236
|
-
await state.input.
|
|
1237
|
-
|
|
1238
|
-
path: { id: sessionID },
|
|
1239
|
-
});
|
|
1240
|
-
console.log("[opencode-immune] Multi-Cycle: /commit completed before new cycle.");
|
|
1265
|
+
await runGitCommit(state.input.directory, "chore: ultrawork cycle auto-commit");
|
|
1266
|
+
console.log("[opencode-immune] Multi-Cycle: git commit completed before new cycle.");
|
|
1241
1267
|
}
|
|
1242
1268
|
catch (err) {
|
|
1243
|
-
console.error("[opencode-immune] Multi-Cycle:
|
|
1269
|
+
console.error("[opencode-immune] Multi-Cycle: git commit failed (continuing anyway):", err);
|
|
1244
1270
|
}
|
|
1245
1271
|
finally {
|
|
1246
1272
|
state.commitPending = false;
|