opencode-immune 1.0.10 → 1.0.12
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 +30 -11
- package/package.json +1 -1
package/dist/plugin.js
CHANGED
|
@@ -531,17 +531,25 @@ function createSessionRecoveryEvent(state) {
|
|
|
531
531
|
*/
|
|
532
532
|
function createSystemTransform(state) {
|
|
533
533
|
return async (input, output) => {
|
|
534
|
-
// Session Recovery injection
|
|
535
|
-
if
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
534
|
+
// Session Recovery injection:
|
|
535
|
+
// Inject if recoveryContext exists AND either:
|
|
536
|
+
// - session is already registered as managed root ultrawork, OR
|
|
537
|
+
// - session is not yet registered (plugin just restarted, map is empty)
|
|
538
|
+
// but agent field matches ultrawork (checked via input metadata if available)
|
|
539
|
+
if (state.recoveryContext) {
|
|
540
|
+
const isManaged = isManagedRootUltraworkSession(state, input.sessionID);
|
|
541
|
+
const mapIsEmpty = state.managedUltraworkSessions.size === 0;
|
|
542
|
+
if (isManaged || mapIsEmpty) {
|
|
543
|
+
const ctx = state.recoveryContext;
|
|
544
|
+
const intentInfo = ctx.intent ? `, Intent: ${ctx.intent}` : "";
|
|
545
|
+
const categoryInfo = ctx.category ? `, Category: ${ctx.category}` : "";
|
|
546
|
+
output.system.push(`[Session Recovery] Active Memory Bank task detected:\n` +
|
|
547
|
+
`- Task: ${ctx.task}\n` +
|
|
548
|
+
`- Level: ${ctx.level}${intentInfo}${categoryInfo}\n` +
|
|
549
|
+
`- Current Phase: ${ctx.phase}\n` +
|
|
550
|
+
`- Phase Status:\n${ctx.phaseStatus}\n` +
|
|
551
|
+
`Read memory-bank/tasks.md and memory-bank/activeContext.md to resume work.`);
|
|
552
|
+
}
|
|
545
553
|
}
|
|
546
554
|
// Ralph Loop injection
|
|
547
555
|
if (state.lastEditAttempt) {
|
|
@@ -960,6 +968,17 @@ function createMultiCycleHandler(state) {
|
|
|
960
968
|
// ═══════════════════════════════════════════════════════════════════════════════
|
|
961
969
|
async function server(input) {
|
|
962
970
|
const state = createState(input);
|
|
971
|
+
// Eagerly load recovery context at plugin init so it's available
|
|
972
|
+
// for the very first system.transform call (before chat.params fires).
|
|
973
|
+
const markerActive = await isUltraworkMarkerActive(state);
|
|
974
|
+
if (markerActive) {
|
|
975
|
+
const recovery = await parseTasksFile(state.input.directory);
|
|
976
|
+
if (recovery && recovery.phase !== "ARCHIVE: DONE") {
|
|
977
|
+
state.recoveryContext = recovery;
|
|
978
|
+
console.log(`[opencode-immune] Plugin init: ultrawork marker active, recovery context loaded: ` +
|
|
979
|
+
`task="${recovery.task}", level=${recovery.level}, phase=${recovery.phase}`);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
963
982
|
console.log(`[opencode-immune] Plugin initialized. Directory: ${input.directory}`);
|
|
964
983
|
// Compose tool.execute.after handlers:
|
|
965
984
|
// Todo Enforcer (counter) + Ralph Loop (edit error) + Comment Checker
|