picocode-core 0.9.201 → 0.9.202

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/package.json +1 -1
  2. package/src/controller.js +11 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "picocode-core",
3
- "version": "0.9.201",
3
+ "version": "0.9.202",
4
4
  "description": "The agent runtime behind pico: sessions, tools, subagents, MCP, memory, and model access",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/controller.js CHANGED
@@ -105,7 +105,7 @@ function errorText(err, limit) {
105
105
  return String(err?.message || err).slice(0, limit)
106
106
  }
107
107
 
108
- export function createController({ boot, run = runTurn, peerDirectory } = {}) {
108
+ export function createController({ boot, run = runTurn, compactRun = compactHistory, peerDirectory } = {}) {
109
109
  if (!Object.hasOwn(boot, 'participantAModel')) boot.participantAModel = boot.proposerModel ?? null
110
110
  if (!Object.hasOwn(boot, 'participantBModel')) boot.participantBModel = boot.reviewerModel ?? null
111
111
  const { on, emit } = createEmitter()
@@ -599,7 +599,7 @@ export function createController({ boot, run = runTurn, peerDirectory } = {}) {
599
599
  return next
600
600
  }
601
601
 
602
- async function compact(instructions = '') {
602
+ async function compact(instructions = '', { automatic = false } = {}) {
603
603
  if (state.busy || state.compacting || peerTransition) return flash('finish or interrupt the current turn first')
604
604
  const current = state.derived
605
605
  if (current.providerHistory.length < 4) return flash('nothing to compact yet')
@@ -618,7 +618,7 @@ export function createController({ boot, run = runTurn, peerDirectory } = {}) {
618
618
  const keepFrom = compactionKeepFrom(current, state.model.context)
619
619
  let streamed = ''
620
620
  try {
621
- const raw = await compactHistory({
621
+ const raw = await compactRun({
622
622
  history: current.providerHistory,
623
623
  modelName: state.model.name,
624
624
  ...(state.model.provider === 'codex' && { speed: speedApplies() ? state.speed : 'standard' }),
@@ -631,6 +631,7 @@ export function createController({ boot, run = runTurn, peerDirectory } = {}) {
631
631
  set({ compactStatus: compactProgress(streamed) })
632
632
  },
633
633
  })
634
+ controller.signal.throwIfAborted()
634
635
  const summary = formatCompactSummary(raw)
635
636
  if (!summary) throw new Error('empty summary')
636
637
  if (summarySections(summary) < 5) throw new Error('malformed summary, conversation left untouched')
@@ -638,6 +639,12 @@ export function createController({ boot, run = runTurn, peerDirectory } = {}) {
638
639
  reDerive()
639
640
  set({ compactOutcome: 'done' })
640
641
  flash('compacted · recent messages kept verbatim')
642
+ if (automatic) {
643
+ noteSystem(
644
+ '[system notification] this conversation was automatically compacted to free context. Continue any unfinished work from where you left off. If the task is already complete or you are waiting for user input, stop. Do not recap or acknowledge the compaction.',
645
+ { wake: true },
646
+ )
647
+ }
641
648
  } catch (err) {
642
649
  set({ compactOutcome: controller.signal.aborted ? 'cancelled' : 'failed' })
643
650
  if (controller.signal.aborted) flash('compaction cancelled')
@@ -667,7 +674,7 @@ export function createController({ boot, run = runTurn, peerDirectory } = {}) {
667
674
  const ratio = used / limit
668
675
  if (ratio >= 0.85) {
669
676
  flash(`context ${Math.round(ratio * 100)}% full · auto-compacting`)
670
- compact()
677
+ compact('', { automatic: true })
671
678
  }
672
679
  }
673
680