opencodekit 0.16.10 → 0.16.13

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.
@@ -1,20 +1,21 @@
1
1
  /**
2
- * Memory & Compaction Plugin (Codex-Inspired Continuity)
2
+ * Session Continuity Plugin (Compaction-Time Context Injection)
3
3
  *
4
- * Injects continuity context into session compaction:
5
- * 1. Load session-context.md (CONTINUITY.md pattern)
6
- * 2. Load project memory files
7
- * 3. Inject beads in-progress state
4
+ * Complements DCP plugin (which handles context management rules via
5
+ * experimental.chat.system.transform). This plugin fires ONLY during
6
+ * compaction events (experimental.session.compacting) and handles:
7
+ *
8
+ * 1. Load session-context.md (CONTINUITY.md pattern) — highest priority
9
+ * 2. Load project memory files (user prefs, tech stack, gotchas)
10
+ * 3. Inject beads in-progress state (active task IDs)
8
11
  * 4. Load most recent handoff file for session resumption
9
- * 5. Append workflow-specific compaction rules
12
+ * 5. Append post-compaction recovery protocol
10
13
  *
11
- * Session context format (agent-maintained via memory-update):
12
- * - Goal: What we're trying to achieve + success criteria
13
- * - Constraints: User-specified limits, discovered guardrails
14
- * - Decisions: Key choices made this session
15
- * - State: Done/Now/Next
16
- * - Open Questions: Uncertainties marked UNCONFIRMED
17
- * - Working Set: Files, bead IDs, branch
14
+ * Division of responsibility:
15
+ * - DCP plugin: context budget zones, distill/compress/prune rules,
16
+ * prunable-tools list, nudge system (always-on via system.transform)
17
+ * - This plugin: session state preservation, post-compaction recovery,
18
+ * memory persistence reminders (compaction-time only)
18
19
  */
19
20
 
20
21
  import type { Plugin } from "@opencode-ai/plugin";
@@ -101,51 +102,51 @@ export const CompactionPlugin: Plugin = async ({ $, directory }) => {
101
102
  output.context.push(`## Session Context\n${allContext}\n`);
102
103
  }
103
104
 
104
- // Append workflow-specific rules to OpenCode's default prompt
105
+ // Append post-compaction recovery protocol
106
+ // NOTE: Context management rules (distill/compress/prune, tool guidance)
107
+ // are handled by DCP plugin via experimental.chat.system.transform (always present).
108
+ // This plugin ONLY handles session continuity and post-compaction recovery.
105
109
  output.prompt = `${output.prompt}
106
110
 
107
- ## Additional Rules for This Workflow
111
+ ## Post-Compaction Recovery Protocol
112
+
113
+ ### IMMEDIATE: Restore Session State (Do This First)
114
+ 1. Read session-context.md via \`memory-read({ file: "session-context" })\`
115
+ 2. If missing or stale, reconstruct from the compaction summary above
116
+ 3. Resume work from the "Now" item — do NOT restart from scratch
117
+ 4. Ask 1-3 targeted questions ONLY if critical gaps remain (don't interrogate)
118
+
119
+ ### Session Continuity Document
120
+ Maintain session-context.md via memory-update tool. This is your lifeline after compaction.
108
121
 
109
- ### Session Continuity
110
- Maintain session-context.md via memory-update tool. Format:
111
122
  \`\`\`
112
- Goal: [What + success criteria]
113
- Constraints: [Limits, mark UNCONFIRMED if inferred]
114
- Decisions: [Key choices this session]
123
+ Goal: [What + measurable success criteria]
124
+ Constraints: [Hard limits. Mark UNCONFIRMED if inferred, never assume]
125
+ Decisions: [Key choices made this session + WHY]
115
126
  State:
116
- Done: [Completed]
117
- Now: [Current focus - ONE thing]
118
- Next: [Queued]
119
- Open Questions: [Uncertainties - mark UNCONFIRMED]
120
- Working Set: [Files, bead ID, branch]
127
+ Done: [Completed items with verification status]
128
+ Now: [Current focus - ONE thing only]
129
+ Next: [Queued items in priority order]
130
+ Open Questions: [Uncertainties - mark UNCONFIRMED, note what would resolve each]
131
+ Working Set: [Exact file paths, bead IDs, branch name, worktree path if applicable]
121
132
  \`\`\`
122
133
 
123
- Update session-context.md when:
124
- - Goal changes or clarifies
125
- - Key decision made
126
- - State shifts (Done/Now/Next)
127
- - Uncertainty discovered
128
-
129
- After compaction: Check session-context.md, ask 1-3 targeted questions if gaps exist.
130
-
131
- ### Beads Workflow
132
- - PRESERVE: Bead IDs (br-xxx format), bead states, in-progress task IDs
133
- - DROP: Closed/completed beads (already tracked in git)
134
-
135
- ### TodoWrite Items
136
- - PRESERVE: Todo items with exact IDs, statuses (pending/in_progress/completed), priorities
137
- - DROP: Cancelled todos
138
-
139
- ### Memory System
140
- If you discover:
141
- - Gotchas/edge cases → Save to .opencode/memory/project/gotchas.md
142
- - Build/test commands → Save to .opencode/memory/project/commands.md
143
- - Code patterns/conventions → Save to .opencode/memory/project/conventions.md
144
- - Architecture insights → Save to .opencode/memory/project/architecture.md
145
-
146
- ### Preservation Priorities
147
- - PRESERVE: File paths (file:line_number), user constraints, decisions, UNCONFIRMED items
148
- - DROP: Failed attempts, superseded info, verbose tool outputs, exploration dead-ends
134
+ Update session-context.md when: goal changes, key decision made, state shifts, or uncertainty discovered.
135
+
136
+ ### Preservation Priorities (Compaction-Specific)
137
+ These items MUST survive compaction — if they appeared in conversation, include in summary:
138
+ - **Bead state**: IDs (br-xxx), status, in-progress tasks, dependencies
139
+ - **Todo items**: Exact IDs, statuses, priorities, content
140
+ - **File paths**: Exact paths with line numbers where relevant
141
+ - **User constraints**: Verbatim. Never paraphrase.
142
+ - **Decisions + rationale**: Both WHAT and WHY
143
+ - **UNCONFIRMED items**: Keep uncertainty markers intact
144
+
145
+ ### Memory Persistence (Before Compaction Loses It)
146
+ Save discoveries to persistent memory so they survive:
147
+ - Gotchas/edge cases observation({ type: "warning", ... })
148
+ - Architecture insights → observation({ type: "pattern", ... })
149
+ - Key decisions → observation({ type: "decision", ... })
149
150
  `;
150
151
  },
151
152
  };