dsh-manual-compact-plugin 0.2.2 → 0.2.3

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.
Files changed (2) hide show
  1. package/lib/index.js +10 -6
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -129,13 +129,15 @@ function resolveAgent(agents, sessionId) {
129
129
  * Supports cancellation through `signal` and reports progress through
130
130
  * `onProgress`. Returns the outcome including a readable file path.
131
131
  */
132
- async function executeCompact(ctx, agents, request, signal, onProgress) {
132
+ async function executeCompact(ctx, agents, request, signal, onProgress, resolvedCompaction) {
133
133
  const resolved = resolveAgent(agents, request.sessionId)
134
134
  const agent = resolved.agent
135
- // The compaction provider may be mounted on the host-registrant context
136
- // (near the root) and take the agent as its target, or directly on the
137
- // agent's own context. Try both and report exactly which is available.
138
- const rootCompaction = ctx && typeof ctx.get === 'function' ? ctx.get('compaction') : undefined
135
+ // Prefer the compaction reference captured at plugin activation (the same
136
+ // seam `/compact` uses). Fall back to the agent's own context, then to a
137
+ // request-time lookup, and report exactly which source is available.
138
+ const rootCompaction = resolvedCompaction !== undefined
139
+ ? resolvedCompaction
140
+ : (ctx && typeof ctx.get === 'function' ? ctx.get('compaction') : undefined)
139
141
  const agentCompaction = agent && agent.ctx && typeof agent.ctx.get === 'function' ? agent.ctx.get('compaction') : undefined
140
142
  const compaction = rootCompaction || agentCompaction
141
143
  if (!agent || !compaction) {
@@ -190,6 +192,8 @@ function apply(ctx, config) {
190
192
  let lastHandledNonce = null
191
193
  let handling = null
192
194
  const controllers = new Map() // sessionId -> AbortController
195
+ // Capture the compaction seam at activation, like `/compact` does.
196
+ const compactionAtApply = (typeof ctx.get === 'function') ? ctx.get('compaction') : undefined
193
197
 
194
198
  const handle = () => {
195
199
  const current = getter()
@@ -217,7 +221,7 @@ function apply(ctx, config) {
217
221
  const onProgress = async (p) => {
218
222
  try { await ctx.settings.update(NS, { progress: p }) } catch {}
219
223
  }
220
- const result = await executeCompact(ctx, ctx.agents, request, controller.signal, onProgress)
224
+ const result = await executeCompact(ctx, ctx.agents, request, controller.signal, onProgress, compactionAtApply)
221
225
  await ctx.settings.update(NS, {
222
226
  request: null,
223
227
  progress: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-manual-compact-plugin",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Manual context compaction for DeepSeek Harness: keep the latest N conversation items with stop or batch mode and a per-session compaction archive — embedded in the context meter popup when the meter panel slot exists, or a composer button otherwise.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",