@pi-unipi/unipi 3.0.0-alpha.2 → 3.0.0-alpha.21
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/CHANGELOG.md +292 -0
- package/README.md +8 -11
- package/docs/prefix-cache-architecture.md +14 -0
- package/package.json +22 -24
- package/packages/ask-user/README.md +55 -107
- package/packages/ask-user/ask-ui.ts +306 -732
- package/packages/ask-user/clipboard.ts +50 -0
- package/packages/ask-user/config.ts +74 -78
- package/packages/ask-user/package.json +2 -2
- package/packages/ask-user/questions.ts +151 -0
- package/packages/ask-user/skills/ask-user/SKILL.md +59 -133
- package/packages/ask-user/tools.ts +198 -432
- package/packages/autocomplete/package.json +1 -1
- package/packages/autocomplete/src/constants.ts +38 -43
- package/packages/autocomplete/src/sorting.ts +8 -0
- package/packages/background-tasks/package.json +2 -2
- package/packages/background-tasks/src/config.ts +0 -73
- package/packages/background-tasks/src/index.ts +20 -16
- package/packages/background-tasks/src/registry.ts +1 -171
- package/packages/background-tasks/src/types.ts +0 -32
- package/packages/btw/README.md +13 -56
- package/packages/btw/extensions/btw.ts +403 -1796
- package/packages/btw/package.json +5 -2
- package/packages/btw/skills/btw/SKILL.md +7 -143
- package/packages/compactor/README.md +56 -287
- package/packages/compactor/package.json +5 -9
- package/packages/compactor/skills/compactor/SKILL.md +13 -20
- package/packages/compactor/src/card.ts +90 -0
- package/packages/compactor/src/commands/index.ts +73 -130
- package/packages/compactor/src/compaction/compact-args.ts +5 -3
- package/packages/compactor/src/compaction/filter-noise.ts +1 -1
- package/packages/compactor/src/compaction/hooks.ts +487 -311
- package/packages/compactor/src/compaction/source.ts +178 -0
- package/packages/compactor/src/compaction/summarize.ts +586 -52
- package/packages/compactor/src/config/manager.ts +130 -127
- package/packages/compactor/src/config/schema.ts +32 -48
- package/packages/compactor/src/index.ts +40 -431
- package/packages/compactor/src/info-screen.ts +44 -190
- package/packages/compactor/src/session/recall-blocks.ts +1 -1
- package/packages/compactor/src/stats.ts +76 -0
- package/packages/compactor/src/tools/context-budget.ts +17 -34
- package/packages/compactor/src/tools/ctx-doctor.ts +45 -36
- package/packages/compactor/src/tools/register.ts +29 -269
- package/packages/compactor/src/types.ts +47 -186
- package/packages/core/README.md +25 -0
- package/packages/core/child-agent.ts +1 -0
- package/packages/core/command-echo.ts +63 -0
- package/packages/core/compaction-context.ts +41 -0
- package/packages/core/constants.ts +8 -38
- package/packages/core/events.ts +0 -53
- package/packages/core/fusion-status.ts +4 -0
- package/packages/core/global.d.ts +10 -0
- package/packages/core/harness-messages.ts +392 -0
- package/packages/core/index.ts +14 -0
- package/packages/core/kanboard-status.ts +49 -0
- package/packages/core/long-horizon-owner-status.ts +46 -0
- package/packages/core/model-cache.ts +81 -7
- package/packages/core/package.json +6 -3
- package/packages/core/src/attach/detect.ts +163 -0
- package/packages/core/src/child-agent/child-args.ts +31 -0
- package/packages/core/src/child-agent/delivery.ts +41 -0
- package/packages/core/src/child-agent/index.ts +5 -0
- package/packages/core/src/child-agent/readers.ts +203 -0
- package/packages/core/src/child-agent/runtime.ts +584 -0
- package/packages/core/src/evidence.ts +78 -0
- package/packages/core/src/hints/browser.ts +278 -0
- package/packages/core/src/hints/crab-data.ts +19 -0
- package/packages/core/src/hints/index.ts +865 -0
- package/packages/core/src/hints/lines.ts +607 -0
- package/packages/core/src/hints/store.ts +120 -0
- package/packages/core/src/jev/chatter.ts +24 -0
- package/packages/core/src/jev/settings.ts +177 -14
- package/packages/core/src/package-colors.ts +2 -0
- package/packages/core/src/settings/catalog.ts +39 -15
- package/packages/core/src/settings/engine.ts +48 -2
- package/packages/core/src/settings/hub.ts +83 -20
- package/packages/core/src/settings/open.ts +49 -0
- package/packages/core/src/settings/schema.ts +27 -7
- package/packages/core/src/tui/hub-kit.ts +18 -5
- package/packages/core/src/tui/kit.ts +198 -0
- package/packages/core/src/tui/progress.ts +73 -0
- package/packages/core/src/turn/arbiter.ts +290 -0
- package/packages/footer/README.md +4 -6
- package/packages/footer/package.json +3 -3
- package/packages/footer/src/glance-editor.ts +19 -11
- package/packages/footer/src/help.ts +1 -1
- package/packages/footer/src/index.ts +36 -3
- package/packages/footer/src/presets.ts +3 -4
- package/packages/footer/src/rendering/icons.ts +0 -20
- package/packages/footer/src/segments/compactor.ts +52 -142
- package/packages/footer/src/segments/status-ext.ts +0 -1
- package/packages/fusion/README.md +14 -4
- package/packages/fusion/package.json +4 -3
- package/packages/fusion/src/child-args.ts +1 -0
- package/packages/fusion/src/index.ts +161 -8
- package/packages/fusion/src/pi-settings.ts +57 -0
- package/packages/fusion/src/picker.ts +186 -51
- package/packages/fusion/src/preset.ts +56 -2
- package/packages/fusion/src/prompts.ts +1 -1
- package/packages/fusion/src/sidekick-runtime.ts +1 -420
- package/packages/fusion/src/tools.ts +107 -128
- package/packages/fusion/src/transcript.ts +27 -85
- package/packages/info-screen/package.json +2 -2
- package/packages/input-shortcuts/README.md +18 -30
- package/packages/input-shortcuts/package.json +2 -2
- package/packages/input-shortcuts/src/burst.ts +88 -0
- package/packages/input-shortcuts/src/chord-overlay.ts +20 -70
- package/packages/input-shortcuts/src/cleared-input.ts +97 -0
- package/packages/input-shortcuts/src/index.ts +99 -193
- package/packages/input-shortcuts/src/last-response.ts +40 -0
- package/packages/input-shortcuts/src/registers.ts +8 -23
- package/packages/input-shortcuts/src/types.ts +4 -16
- package/packages/input-shortcuts/src/undo-redo.ts +59 -47
- package/packages/kanboard/README.md +51 -47
- package/packages/kanboard/index.ts +293 -55
- package/packages/kanboard/package.json +8 -8
- package/packages/kanboard/skills/kanboard/SKILL.md +61 -27
- package/packages/kanboard/src/badges.ts +93 -0
- package/packages/kanboard/src/bin.ts +4 -2
- package/packages/kanboard/src/commands.ts +218 -84
- package/packages/kanboard/src/debug.ts +20 -0
- package/packages/kanboard/src/guard.ts +267 -109
- package/packages/kanboard/src/monitor.ts +330 -0
- package/packages/kanboard/src/notice-buffer.ts +74 -0
- package/packages/kanboard/src/progress.ts +27 -0
- package/packages/kanboard/src/reminders.ts +234 -0
- package/packages/kanboard/src/settings.ts +69 -15
- package/packages/kanboard/src/shapes.ts +5 -0
- package/packages/long-horizon/index.ts +190 -13
- package/packages/long-horizon/package.json +3 -3
- package/packages/long-horizon/src/commands.ts +103 -7
- package/packages/long-horizon/src/compaction-brief.ts +35 -0
- package/packages/long-horizon/src/engine/continuation.ts +84 -15
- package/packages/long-horizon/src/engine/goal-state.ts +64 -13
- package/packages/long-horizon/src/engine/nudge-stash.ts +71 -0
- package/packages/long-horizon/src/engine/ralph.ts +3 -2
- package/packages/long-horizon/src/engine/runaway.ts +68 -11
- package/packages/long-horizon/src/engine/verifier.ts +19 -0
- package/packages/long-horizon/src/gate.ts +37 -12
- package/packages/long-horizon/src/judge/resolve.ts +1 -0
- package/packages/long-horizon/src/owner.ts +35 -2
- package/packages/long-horizon/src/progress.ts +87 -0
- package/packages/long-horizon/src/prompts/goal.ts +1 -1
- package/packages/long-horizon/src/runtime.ts +172 -18
- package/packages/long-horizon/src/settings.ts +54 -39
- package/packages/long-horizon/src/tools/goal.ts +6 -0
- package/packages/long-horizon/src/tools/graph.ts +1 -1
- package/packages/long-horizon/src/tools/swarm.ts +3 -3
- package/packages/mcp/package.json +2 -2
- package/packages/memory/commands.ts +7 -2
- package/packages/memory/index.ts +210 -32
- package/packages/memory/package.json +3 -3
- package/packages/memory/save-session.ts +264 -0
- package/packages/memory/settings.ts +17 -0
- package/packages/memory/tools.ts +253 -203
- package/packages/notify/package.json +2 -2
- package/packages/skill-registry/README.md +53 -16
- package/packages/skill-registry/index.ts +230 -0
- package/packages/skill-registry/package.json +19 -8
- package/packages/skill-registry/src/editor.ts +206 -0
- package/packages/skill-registry/src/judge.ts +289 -0
- package/packages/skill-registry/src/registry.ts +87 -0
- package/packages/skill-registry/src/settings.ts +259 -0
- package/packages/skill-registry/src/vault.ts +80 -0
- package/packages/subagents/README.md +39 -119
- package/packages/subagents/package.json +6 -13
- package/packages/subagents/skills/subagents/SKILL.md +18 -42
- package/packages/subagents/src/agents.ts +213 -0
- package/packages/subagents/src/cards.ts +182 -0
- package/packages/subagents/src/index.ts +609 -1084
- package/packages/subagents/src/manager.ts +429 -0
- package/packages/subagents/src/profiles.ts +130 -0
- package/packages/subagents/src/transcript.ts +154 -0
- package/packages/subagents/src/ui.ts +389 -0
- package/packages/unipi/bundled.js +39756 -45569
- package/packages/unipi/index.ts +55 -10
- package/packages/updater/package.json +2 -2
- package/packages/utility/README.md +76 -69
- package/packages/utility/package.json +2 -2
- package/packages/utility/skills/image/SKILL.md +37 -0
- package/packages/utility/skills/utility/SKILL.md +17 -60
- package/packages/utility/src/answer/extract.ts +128 -0
- package/packages/utility/src/answer/index.ts +213 -0
- package/packages/utility/src/answer/reply.ts +133 -0
- package/packages/utility/src/answer/web.ts +167 -0
- package/packages/utility/src/attach/index.ts +205 -0
- package/packages/utility/src/commands.ts +38 -142
- package/packages/utility/src/diagnostics/engine.ts +50 -5
- package/packages/utility/src/image/index.ts +33 -0
- package/packages/utility/src/image/models.ts +221 -0
- package/packages/{image/src → utility/src/image}/recognize.ts +2 -2
- package/packages/utility/src/image/settings.ts +178 -0
- package/packages/{image/src/image-source.ts → utility/src/image/source.ts} +1 -1
- package/packages/utility/src/image/tools.ts +168 -0
- package/packages/utility/src/image/transports.ts +186 -0
- package/packages/utility/src/index.ts +68 -389
- package/packages/utility/src/lifecycle/cleanup.ts +116 -311
- package/packages/utility/src/rename/gate.ts +102 -0
- package/packages/utility/src/rename/index.ts +191 -0
- package/packages/utility/src/rename/session.ts +170 -0
- package/packages/utility/src/render/delegated.ts +285 -0
- package/packages/utility/src/render/harness.ts +683 -0
- package/packages/utility/src/render/parse.ts +156 -0
- package/packages/utility/src/render/pi-settings.ts +38 -0
- package/packages/utility/src/render/reply-bg.ts +307 -0
- package/packages/utility/src/render/simple.ts +724 -0
- package/packages/utility/src/render/spacing.ts +235 -0
- package/packages/utility/src/render/styled.ts +251 -0
- package/packages/utility/src/render/tools.ts +353 -0
- package/packages/utility/src/settings.ts +166 -233
- package/packages/utility/src/types.ts +1 -222
- package/packages/watchdog/index.ts +17 -6
- package/packages/watchdog/package.json +3 -3
- package/packages/watchdog/src/config.ts +3 -2
- package/packages/web-api/package.json +2 -2
- package/packages/workflow/README.md +3 -0
- package/packages/workflow/index.ts +0 -2
- package/packages/workflow/package.json +2 -2
- package/packages/workflow/src/permission/decide.ts +6 -4
- package/packages/workflow/src/permission/index.ts +17 -7
- package/packages/workflow/src/permission/settings.ts +39 -4
- package/packages/workflow/src/plan/index.ts +19 -4
- package/packages/background-tasks/extensions/delegate-child.ts +0 -1
- package/packages/background-tasks/src/context-parent-snapshot.ts +0 -142
- package/packages/background-tasks/src/context-token-budget.ts +0 -903
- package/packages/background-tasks/src/context-visible-conversation-v2.ts +0 -551
- package/packages/background-tasks/src/delegate/artifacts.ts +0 -487
- package/packages/background-tasks/src/delegate/budget.ts +0 -415
- package/packages/background-tasks/src/delegate/hook-contract-evidence.json +0 -18
- package/packages/background-tasks/src/delegate/hook-contract.ts +0 -154
- package/packages/background-tasks/src/delegate/launch.ts +0 -484
- package/packages/background-tasks/src/delegate/result-package.ts +0 -459
- package/packages/background-tasks/src/delegate/runner.ts +0 -430
- package/packages/background-tasks/src/delegate/seed.ts +0 -423
- package/packages/background-tasks/src/delegate/types.ts +0 -323
- package/packages/background-tasks/src/delegate-child-extension.ts +0 -978
- package/packages/background-tasks/src/delegate-extension.ts +0 -654
- package/packages/background-tasks/src/fixtures/delegate-context-incident.json +0 -17
- package/packages/compactor/skills/compactor-detail/SKILL.md +0 -116
- package/packages/compactor/skills/compactor-doctor/SKILL.md +0 -71
- package/packages/compactor/skills/compactor-stats/SKILL.md +0 -51
- package/packages/compactor/src/compaction/build-sections.ts +0 -76
- package/packages/compactor/src/compaction/extract/goals.ts +0 -36
- package/packages/compactor/src/compaction/extract/preferences.ts +0 -40
- package/packages/compactor/src/compaction/format.ts +0 -53
- package/packages/compactor/src/compaction/merge.ts +0 -143
- package/packages/compactor/src/config/presets.ts +0 -160
- package/packages/compactor/src/executor/executor.ts +0 -233
- package/packages/compactor/src/executor/runtime.ts +0 -115
- package/packages/compactor/src/security/evaluator.ts +0 -89
- package/packages/compactor/src/security/policy.ts +0 -96
- package/packages/compactor/src/security/scanner.ts +0 -65
- package/packages/compactor/src/session/auto-inject.ts +0 -60
- package/packages/compactor/src/session/db.ts +0 -325
- package/packages/compactor/src/session/extract.ts +0 -144
- package/packages/compactor/src/session/resume-inject.ts +0 -64
- package/packages/compactor/src/session/snapshot.ts +0 -327
- package/packages/compactor/src/tools/ctx-batch-execute.ts +0 -41
- package/packages/compactor/src/tools/ctx-execute-file.ts +0 -23
- package/packages/compactor/src/tools/ctx-execute.ts +0 -23
- package/packages/compactor/src/tools/ctx-stats.ts +0 -96
- package/packages/image/README.md +0 -99
- package/packages/image/package.json +0 -61
- package/packages/image/skills/image/SKILL.md +0 -76
- package/packages/image/src/generate.ts +0 -256
- package/packages/image/src/index.ts +0 -135
- package/packages/image/src/models.ts +0 -519
- package/packages/image/src/openai-images-api.ts +0 -282
- package/packages/image/src/register-providers.ts +0 -209
- package/packages/image/src/settings.ts +0 -173
- package/packages/image/src/tools.ts +0 -326
- package/packages/input-shortcuts/src/clipboard.ts +0 -119
- package/packages/kanboard/src/runner.ts +0 -817
- package/packages/skill-registry/skills/auto/SKILL.md +0 -465
- package/packages/skill-registry/skills/brainstorm/SKILL.md +0 -219
- package/packages/skill-registry/skills/chore-create/SKILL.md +0 -315
- package/packages/skill-registry/skills/chore-execute/SKILL.md +0 -314
- package/packages/skill-registry/skills/consolidate/SKILL.md +0 -142
- package/packages/skill-registry/skills/consultant/SKILL.md +0 -97
- package/packages/skill-registry/skills/debug/SKILL.md +0 -228
- package/packages/skill-registry/skills/document/SKILL.md +0 -120
- package/packages/skill-registry/skills/fix/SKILL.md +0 -212
- package/packages/skill-registry/skills/gather-context/SKILL.md +0 -145
- package/packages/skill-registry/skills/plan/SKILL.md +0 -231
- package/packages/skill-registry/skills/quick-fix/SKILL.md +0 -135
- package/packages/skill-registry/skills/quick-work/SKILL.md +0 -110
- package/packages/skill-registry/skills/research/SKILL.md +0 -251
- package/packages/skill-registry/skills/review-work/SKILL.md +0 -187
- package/packages/skill-registry/skills/scan-issues/SKILL.md +0 -195
- package/packages/skill-registry/skills/work/SKILL.md +0 -218
- package/packages/skill-registry/skills/worktree-create/SKILL.md +0 -69
- package/packages/skill-registry/skills/worktree-list/SKILL.md +0 -78
- package/packages/skill-registry/skills/worktree-merge/SKILL.md +0 -89
- package/packages/subagents/agents/delegate.md +0 -14
- package/packages/subagents/agents/oracle.md +0 -78
- package/packages/subagents/agents/researcher.md +0 -52
- package/packages/subagents/agents/reviewer.md +0 -80
- package/packages/subagents/agents/scout.md +0 -50
- package/packages/subagents/agents/worker.md +0 -59
- package/packages/subagents/prompts/council.md +0 -48
- package/packages/subagents/prompts/gather-context-and-clarify.md +0 -13
- package/packages/subagents/prompts/parallel-cleanup.md +0 -59
- package/packages/subagents/prompts/parallel-research.md +0 -50
- package/packages/subagents/prompts/parallel-review.md +0 -54
- package/packages/subagents/prompts/review-loop.md +0 -43
- package/packages/subagents/skills/council-mode/SKILL.md +0 -230
- package/packages/subagents/skills/subagents/references/constraints-and-recipes.md +0 -259
- package/packages/subagents/skills/subagents/references/execution-controls.md +0 -454
- package/packages/subagents/skills/subagents/references/management-authoring-rpc.md +0 -161
- package/packages/subagents/skills/subagents/references/multi-lane-orchestration.md +0 -39
- package/packages/subagents/skills/subagents/references/prompting-and-roles.md +0 -267
- package/packages/subagents/src/acceptance.ts +0 -331
- package/packages/subagents/src/agent-manager.ts +0 -405
- package/packages/subagents/src/agent-memory.ts +0 -300
- package/packages/subagents/src/agent-overrides.ts +0 -183
- package/packages/subagents/src/agent-runner.ts +0 -271
- package/packages/subagents/src/async-runner.ts +0 -422
- package/packages/subagents/src/authority-policy.ts +0 -47
- package/packages/subagents/src/budgets.ts +0 -285
- package/packages/subagents/src/child-safety.ts +0 -140
- package/packages/subagents/src/config.ts +0 -249
- package/packages/subagents/src/conversation-viewer.ts +0 -281
- package/packages/subagents/src/core-compat.ts +0 -94
- package/packages/subagents/src/custom-agents.ts +0 -343
- package/packages/subagents/src/file-system-retry.ts +0 -50
- package/packages/subagents/src/fleet-data.ts +0 -105
- package/packages/subagents/src/fleet-view.ts +0 -322
- package/packages/subagents/src/foreground-detach.ts +0 -59
- package/packages/subagents/src/fork-context.ts +0 -285
- package/packages/subagents/src/global.d.ts +0 -7
- package/packages/subagents/src/guide.ts +0 -129
- package/packages/subagents/src/mission-state.ts +0 -133
- package/packages/subagents/src/mission-store.ts +0 -436
- package/packages/subagents/src/output-limits.ts +0 -142
- package/packages/subagents/src/parity-types.ts +0 -315
- package/packages/subagents/src/pi-args.ts +0 -167
- package/packages/subagents/src/result-files.ts +0 -232
- package/packages/subagents/src/result-watcher.ts +0 -221
- package/packages/subagents/src/retained-children.ts +0 -176
- package/packages/subagents/src/run-fanout-budget.ts +0 -356
- package/packages/subagents/src/scheduled-runs.ts +0 -349
- package/packages/subagents/src/schemas.ts +0 -263
- package/packages/subagents/src/slash-commands.ts +0 -80
- package/packages/subagents/src/supervisor-channel.ts +0 -249
- package/packages/subagents/src/tool-handler.ts +0 -1144
- package/packages/subagents/src/types.ts +0 -238
- package/packages/subagents/src/widget.ts +0 -457
- package/packages/subagents/src/workflow-script.ts +0 -737
- package/packages/subagents/src/workflow-worker.ts +0 -384
- package/packages/subagents/src/worktree.ts +0 -614
- package/packages/utility/src/analytics/collector.ts +0 -293
- package/packages/utility/src/info-screen.ts +0 -80
- package/packages/utility/src/lifecycle/process.ts +0 -162
- package/packages/utility/src/prefix-cache.ts +0 -263
- package/packages/utility/src/skill-discovery.ts +0 -542
- package/packages/utility/src/tools/env.ts +0 -113
- package/packages/utility/src/tui/name-badge-state.ts +0 -315
- package/packages/utility/src/tui/name-badge.ts +0 -109
- /package/packages/{subagents/src → core/src/child-agent}/pi-spawn.ts +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-unipi/btw",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.21",
|
|
4
4
|
"description": "A pi extension for parallel side conversations with /unipi:btw — part of the Unipi suite",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "extensions/btw.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@earendil-works/pi-tui": "^0.87.1"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@pi-unipi/core": "3.0.0-alpha.
|
|
40
|
+
"@pi-unipi/core": "3.0.0-alpha.21"
|
|
41
41
|
},
|
|
42
42
|
"pi": {
|
|
43
43
|
"extensions": [
|
|
@@ -48,5 +48,8 @@
|
|
|
48
48
|
],
|
|
49
49
|
"prompts": [],
|
|
50
50
|
"themes": []
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"test": "npx tsx --test tests/*.test.ts"
|
|
51
54
|
}
|
|
52
55
|
}
|
|
@@ -1,151 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: btw
|
|
3
|
-
description:
|
|
3
|
+
description: Ask side questions in an inline panel without interrupting the main agent — read-only, one-shot, invisible to the main session.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# BTW
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
`/unipi:btw <question>` opens an inline panel and answers a side question from a fresh read-only session seeded with the main session's current context.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Rules the panel enforces:
|
|
11
|
+
- Read-only tools (`read`, `grep`, `find`, `ls`) — no commands or edits; changes belong in the main conversation.
|
|
12
|
+
- No memory between btw questions, and nothing reaches the main agent.
|
|
13
|
+
- Nothing is persisted — page history dies with the pi session.
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Prefer the BTW workflow when the user wants to:
|
|
15
|
-
|
|
16
|
-
- ask a side question while the main agent keeps working
|
|
17
|
-
- brainstorm or compare options without interrupting the current run
|
|
18
|
-
- prepare a plan or summary before handing it back to the main agent
|
|
19
|
-
- keep exploratory discussion out of the main transcript/context
|
|
20
|
-
|
|
21
|
-
## Commands
|
|
22
|
-
|
|
23
|
-
Use these commands in your guidance to the user:
|
|
24
|
-
|
|
25
|
-
```text
|
|
26
|
-
/unipi:btw <question>
|
|
27
|
-
/unipi:btw --save <question>
|
|
28
|
-
/unipi:btw-new [question]
|
|
29
|
-
/unipi:btw-tangent <question>
|
|
30
|
-
/unipi:btw-tangent --save <question>
|
|
31
|
-
/unipi:btw-clear
|
|
32
|
-
/unipi:btw-inject [instructions]
|
|
33
|
-
/unipi:btw-summarize [instructions]
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## How to guide the user
|
|
37
|
-
|
|
38
|
-
### For a quick side question
|
|
39
|
-
|
|
40
|
-
Recommend:
|
|
41
|
-
|
|
42
|
-
```text
|
|
43
|
-
/unipi:btw <question>
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Use this when the user wants an immediate aside and does not need a visible saved note.
|
|
47
|
-
|
|
48
|
-
### For a saved one-off note
|
|
49
|
-
|
|
50
|
-
Recommend:
|
|
51
|
-
|
|
52
|
-
```text
|
|
53
|
-
/unipi:btw --save <question>
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Use this when the user wants the exchange to appear as a visible BTW note in the session transcript.
|
|
57
|
-
|
|
58
|
-
### For a fresh side thread
|
|
59
|
-
|
|
60
|
-
Recommend:
|
|
61
|
-
|
|
62
|
-
```text
|
|
63
|
-
/unipi:btw-new
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
or
|
|
67
|
-
|
|
68
|
-
```text
|
|
69
|
-
/unipi:btw-new <question>
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
Use this when the previous BTW discussion is no longer relevant, but you still want the new side thread to inherit the current main-session context.
|
|
73
|
-
|
|
74
|
-
### For a contextless tangent thread
|
|
75
|
-
|
|
76
|
-
Recommend:
|
|
77
|
-
|
|
78
|
-
```text
|
|
79
|
-
/unipi:btw-tangent <question>
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
or
|
|
83
|
-
|
|
84
|
-
```text
|
|
85
|
-
/unipi:btw-tangent --save <question>
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
Use this when the user wants a side conversation that does not include the current main-session context.
|
|
89
|
-
|
|
90
|
-
### To hand the full thread back to the main agent
|
|
91
|
-
|
|
92
|
-
Recommend:
|
|
93
|
-
|
|
94
|
-
```text
|
|
95
|
-
/unipi:btw-inject <instructions>
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
Use this when the exact discussion matters and the user wants the main agent to act on it.
|
|
99
|
-
|
|
100
|
-
### To hand back a condensed version
|
|
101
|
-
|
|
102
|
-
Recommend:
|
|
103
|
-
|
|
104
|
-
```text
|
|
105
|
-
/unipi:btw-summarize <instructions>
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
Use this when the thread is long and only the distilled outcome should go back into the main agent.
|
|
109
|
-
|
|
110
|
-
## Recommendation rules
|
|
111
|
-
|
|
112
|
-
- Prefer `/unipi:btw` over normal chat when the user explicitly wants a side conversation.
|
|
113
|
-
- Prefer `/unipi:btw-tangent` when the user wants that side conversation to be contextless.
|
|
114
|
-
- Prefer `/unipi:btw-summarize` over `/unipi:btw-inject` for long exploratory threads.
|
|
115
|
-
- Prefer `/unipi:btw-inject` when precise wording, detailed tradeoffs, or a full plan matters.
|
|
116
|
-
- Suggest `/unipi:btw-new` before starting a totally unrelated side topic when main-session context is still useful.
|
|
117
|
-
- Suggest `/unipi:btw-clear` when the widget/thread should be dismissed.
|
|
118
|
-
|
|
119
|
-
## Response style
|
|
120
|
-
|
|
121
|
-
When helping the user use BTW:
|
|
122
|
-
|
|
123
|
-
- give the exact slash command to run
|
|
124
|
-
- explain briefly why that command fits
|
|
125
|
-
- keep the guidance short and operational
|
|
126
|
-
|
|
127
|
-
## Examples
|
|
128
|
-
|
|
129
|
-
### Example: brainstorm while coding continues
|
|
130
|
-
|
|
131
|
-
```text
|
|
132
|
-
/unipi:btw what are the risks of switching this to optimistic updates?
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### Example: create a clean new thread
|
|
136
|
-
|
|
137
|
-
```text
|
|
138
|
-
/unipi:btw-new sketch a safer migration plan
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
### Example: start a contextless tangent
|
|
142
|
-
|
|
143
|
-
```text
|
|
144
|
-
/unipi:btw-tangent think through this from first principles without using the current chat context
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
### Example: send the result back
|
|
148
|
-
|
|
149
|
-
```text
|
|
150
|
-
/unipi:btw-summarize implement the recommended migration plan
|
|
151
|
-
```
|
|
15
|
+
When to suggest it: quick clarifications, "what is X doing" checks, reading files, thinking out loud — anything that shouldn't derail or pollute the main turn.
|
|
@@ -1,318 +1,87 @@
|
|
|
1
1
|
# @pi-unipi/compactor
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Compaction for Pi that keeps work going. When the context fills up, the compactor replaces older messages with a summary. The full history stays in the session file, so nothing is lost and anything can be recalled.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Methods
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- **Session continuity:** important goals, changed files, commits, blockers, preferences, and a recent transcript survive compaction.
|
|
9
|
-
- **Optional percentage trigger:** UniPi can compact at a configured context percentage before Pi's fixed reserve-token safety net fires.
|
|
10
|
-
- **Recall:** agents can search the append-only session branch, including messages that no longer fit in live LLM context.
|
|
11
|
-
- **Runtime helpers:** sandbox execution, context budget checks, diagnostics, and stats.
|
|
12
|
-
- **Display guards:** tool output/diff rendering is clamped and summarized to avoid noisy or terminal-breaking output.
|
|
13
|
-
|
|
14
|
-
The compaction pipeline is deterministic and runs locally. It does not call an LLM during compaction.
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
## Quick start
|
|
19
|
-
|
|
20
|
-
```text
|
|
21
|
-
/unipi:settings (Compactor)
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
1. Choose a preset in **Presets**.
|
|
25
|
-
2. Optionally enable **Auto → Percentage Trigger**.
|
|
26
|
-
3. Press **Enter** to save.
|
|
27
|
-
4. Use `/unipi:lossless-compact` when you want to compact immediately.
|
|
28
|
-
|
|
29
|
-
Config files:
|
|
30
|
-
|
|
31
|
-
| Scope | Path | Notes |
|
|
32
|
-
|---|---|---|
|
|
33
|
-
| Global | `~/.unipi/config/compactor/config.json` | Used by default |
|
|
34
|
-
| Per project | `<project>/.unipi/config/compactor.json` | Enabled from settings with **Project Override** |
|
|
35
|
-
|
|
36
|
-
Per-project config is merged over global config when the current project directory is known.
|
|
37
|
-
|
|
38
|
-
---
|
|
39
|
-
|
|
40
|
-
## User-facing slash commands
|
|
41
|
-
|
|
42
|
-
| Command | What it does | Notes |
|
|
7
|
+
| Method | What it does | Cost |
|
|
43
8
|
|---|---|---|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
| `/unipi:session-recall <query>` | Searches current session history with BM25/regex recall. | Uses the append-only session branch when available, so pre-compaction messages can still be found. |
|
|
47
|
-
| `/unipi:compact-recall <query>` | Deprecated alias for `/unipi:session-recall`. | Kept for backward compatibility. |
|
|
48
|
-
| `/unipi:compact-stats` | Shows session events, compaction count, token savings, sandbox runs, and search counts. | Stats are DB-backed with runtime fallbacks. |
|
|
49
|
-
| `/unipi:compact-doctor` | Runs diagnostics for config, SQLite/session DB, and runtimes. | Useful when stats/recall/sandbox look broken. |
|
|
50
|
-
| `/unipi:settings (Compactor)` | Opens the TUI settings overlay. | Tabs: Presets, Strategies, Auto, Pipeline. |
|
|
51
|
-
| `/unipi:settings (Compactor › Presets) <name>` | Applies a preset globally. | Names: `precise`, `balanced`, `thorough`, `lean`. Old names map to new ones: `opencode→precise`, `verbose→thorough`, `minimal→lean`. |
|
|
52
|
-
| `/unipi:compact-help` | Shows compact help inside Pi. | Quick command reference. |
|
|
9
|
+
| **Lossless** (default) | Builds a structured summary without a model call, in milliseconds. | Free |
|
|
10
|
+
| **Model summary** | Pi's own model-written summary, with the active-work block added on top. | One model call |
|
|
53
11
|
|
|
54
|
-
|
|
12
|
+
### The lossless summary
|
|
55
13
|
|
|
56
|
-
|
|
14
|
+
It is rebuilt from the **full** session history on every compaction, never merged onto the previous summary, so it cannot drift or grow over time. Sections, in the order a resuming model needs them:
|
|
57
15
|
|
|
58
|
-
|
|
16
|
+
1. **Active Work**: the goal, ralph loop or kanboard task in flight, supplied by those modules from their own state.
|
|
17
|
+
2. **Your Requests**: the user's own messages and answers to agent questions (`ask_user`: "question → answer"). Text that extensions send with the user role (loop prompts, nudges, notifications) is excluded.
|
|
18
|
+
3. **Latest State**: the most recent step and the last full progress report.
|
|
19
|
+
4. **Decisions & Constraints**: the user's instructions ("keep the orange theme"), corrections ("I did not ask for this"), and answers to agent questions. Half the room goes to the most recent ones, the rest to standing rules from anywhere in the session ("always…", "never…", "by default…"). Bug reports, pasted text and code blocks are left out.
|
|
20
|
+
5. **Files**: modified, created and read files, as relative paths.
|
|
21
|
+
6. **Project Knowledge**: what the agent learned that no message states: project notes it wrote or read (SKILL.md, AGENTS.md, DESIGN.md, docs), build/test/deploy commands it ran more than once, and the hosts it worked against. Switched with the Files section.
|
|
22
|
+
7. **Commits**: hash and subject.
|
|
23
|
+
8. **Open Errors**: recent failures that were not followed by a success.
|
|
24
|
+
9. **Recent Transcript**: a ranked slice of recent work.
|
|
59
25
|
|
|
60
|
-
|
|
26
|
+
Each section has its own share of a hard budget (auto: 1.5k–4k tokens, scaling with session size). Credentials (typed passwords, API keys, bearer tokens) are redacted before anything is clipped; `session_recall` still has them. A closing line points the model to `session_recall`.
|
|
61
27
|
|
|
62
|
-
|
|
28
|
+
## In the TUI
|
|
63
29
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
| `↑/↓` | Move selection |
|
|
68
|
-
| `Space` | Cycle/toggle selected value |
|
|
69
|
-
| `/` | Search inside the Strategies tab |
|
|
70
|
-
| `Enter` | Save and close |
|
|
71
|
-
| `Esc` | Cancel |
|
|
72
|
-
|
|
73
|
-
### Presets tab
|
|
74
|
-
|
|
75
|
-
Presets are profiles that set strategies, the implemented Auto Injection pipeline behavior, and sandbox mode.
|
|
76
|
-
|
|
77
|
-
| Preset | Intended use | Important effects |
|
|
78
|
-
|---|---|---|
|
|
79
|
-
| `precise` | Code-heavy work, minimal waste | Full compaction sections, sandbox enabled, Auto Injection off. |
|
|
80
|
-
| `balanced` | Daily/default profile | Compact transcript, sandbox enabled, Auto Injection on. |
|
|
81
|
-
| `thorough` | Debug/audit sessions | Full transcript, sandbox enabled, Auto Injection on. |
|
|
82
|
-
| `lean` | Quick fixes or short sessions | Brief/minimal compaction sections, no sandbox, no session continuity, Auto Injection off. |
|
|
30
|
+
- **Compaction card:** one line under Pi's own `[compaction]` block, e.g. `▌ Compacted 7.9k → 2.2k tokens · lossless · at 3%`. ctrl+o expands it: method, trigger, what was kept verbatim, summary sections. It is a custom entry: shown, never sent to the model.
|
|
31
|
+
- **Footer strip** (under the input): `5 compactions · 47k→15k · just now`, hidden until the first compaction. With the glance frame off, the `compactions` segment shows the same (`cmp 5× 47k→15k · 1m`).
|
|
32
|
+
- **Info screen** (`/unipi:info` → Compactor): method and trigger settings, compactions by method, tokens before → after, the last compaction.
|
|
83
33
|
|
|
84
|
-
|
|
34
|
+
## When it compacts
|
|
85
35
|
|
|
86
|
-
- `
|
|
87
|
-
-
|
|
36
|
+
- **Pi's context limit** (default): Pi decides when, using its own compaction settings (`compaction.reserveTokens`, per-model overrides). The compactor decides what the summary contains. Pi continues the run after compacting.
|
|
37
|
+
- **At a percentage**: compacts once context use reaches the set percentage. This happens at a turn boundary, so running goal, ralph and kanboard loops are not interrupted.
|
|
88
38
|
|
|
89
|
-
|
|
39
|
+
## Settings
|
|
90
40
|
|
|
91
|
-
|
|
41
|
+
`/unipi:settings → Compactor`
|
|
92
42
|
|
|
93
|
-
| Setting |
|
|
43
|
+
| Setting | Default | |
|
|
94
44
|
|---|---|---|
|
|
95
|
-
|
|
|
96
|
-
|
|
|
97
|
-
|
|
|
98
|
-
|
|
|
99
|
-
|
|
|
100
|
-
| `User Preferences` | `all`, `recent-only`, `off` | Preserves user preferences learned during the session. |
|
|
101
|
-
| `Brief Transcript` | `full`, `compact`, `minimal`, `off` | Keeps a rolling recent transcript after the structured sections. |
|
|
102
|
-
| `Session Continuity` | `full`, `off` | Controls XML-style resume snapshots. Off prevents snapshot creation and injection; Pi’s normal compaction summary still remains. |
|
|
103
|
-
| `Sandbox Execution` | `all`, `off` | Controls sandbox tool registration. Changes require a session reload. Allowed languages and output limit are enforced from config. |
|
|
104
|
-
|
|
105
|
-
Config-only legacy field: `fts5Index` remains in the schema for compatibility. It is hidden from Compactor settings and presets. Legacy `sessionContinuity.mode: "essential-only"`, `eventCategories`, and `sandboxExecution.mode: "safe-only"` values remain loadable; essential-only behaves as full and safe-only behaves as enabled/all until explicit filtering/security policies are designed. Legacy `toolDisplay` and `showTruncationHints` fields also remain loadable but are deprecated and ignored; their profile names were never mapped to runtime renderer modes. Narrow-terminal diff clamping remains active as independent safety behavior.
|
|
106
|
-
|
|
107
|
-
### Auto tab
|
|
108
|
-
|
|
109
|
-
These settings control UniPi-managed percentage auto-compaction. They are separate from Pi core's own `compaction.reserveTokens` behavior.
|
|
110
|
-
|
|
111
|
-
**Prefix-cache policy:** every compaction replaces provider-visible history and starts a new cache epoch. UniPi therefore keeps this second percentage trigger **off by default** and does not compact repeatedly merely to shorten a cache-hit request. Pi core remains the default safety trigger: with its documented defaults it compacts when estimated context exceeds `contextWindow - 16,384` reserved response tokens, while keeping about 20,000 recent tokens. If you deliberately enable the UniPi percentage trigger, 80% is an earlier explicit boundary and the cooldown/growth guards prevent loops. UniPi's compiler is deterministic and zero-LLM; it does not issue a second summarizer request.
|
|
112
|
-
|
|
113
|
-
| Setting | Default | Meaning |
|
|
114
|
-
|---|---:|---|
|
|
115
|
-
| `Percentage Trigger` | `off` | When on, UniPi checks context usage at `agent_end` (after the agent run settles) and can call compaction when the threshold is reached. Disabled by default for backward compatibility. |
|
|
116
|
-
| `Threshold` | `80%` | Trigger point using Pi's live `ctx.getContextUsage().percent`. |
|
|
117
|
-
| `Cooldown` | `60s` | Minimum time between UniPi-triggered compaction attempts. Prevents loops. |
|
|
118
|
-
| `Repeat Growth` | `4k` | If usage is still above threshold after compaction, require this many new tokens before triggering again. |
|
|
119
|
-
| `Notifications` | `on` | Shows user-visible notifications for UniPi-triggered compaction attempts/results. |
|
|
120
|
-
|
|
121
|
-
Example config:
|
|
122
|
-
|
|
123
|
-
```json
|
|
124
|
-
{
|
|
125
|
-
"autoCompaction": {
|
|
126
|
-
"enabled": true,
|
|
127
|
-
"thresholdPercent": 80,
|
|
128
|
-
"cooldownMs": 60000,
|
|
129
|
-
"repeatMinGrowthTokens": 4000,
|
|
130
|
-
"notify": true
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### Pipeline tab
|
|
136
|
-
|
|
137
|
-
The Pipeline tab exposes only behavior implemented by the current runtime.
|
|
138
|
-
|
|
139
|
-
| Setting | Preset behavior | Current effect |
|
|
140
|
-
|---|---|---|
|
|
141
|
-
| `Auto Injection` | On in `balanced`, `thorough`; off in `precise`, `lean` | Adds behavioral/session state to the one-shot resume context after compaction. |
|
|
142
|
-
|
|
143
|
-
Deprecated config-only compatibility fields are still accepted so existing files load without migration failures, but they are ignored and no longer controlled or advertised by presets: `ttlCache`, `mmapPragma`, `proximityReranking`, `timelineSort`, and `progressiveThrottling`.
|
|
144
|
-
|
|
145
|
-
Other config-only pipeline field:
|
|
146
|
-
|
|
147
|
-
| Field | Meaning |
|
|
148
|
-
|---|---|
|
|
149
|
-
| `customNoisePatterns` | Extra regex/string patterns used by session recall filtering to remove noisy user blocks. |
|
|
150
|
-
|
|
151
|
-
---
|
|
45
|
+
| Method | lossless | lossless · model summary |
|
|
46
|
+
| Pi's /compact | same as Method | What Pi's built-in `/compact` does |
|
|
47
|
+
| When | Pi's context limit | Or: at a percentage |
|
|
48
|
+
| Percentage | 80 | Used when When = at a percentage |
|
|
49
|
+
| Notifications | on | The compaction card after automatic compactions (commands always show it); failures still notify |
|
|
152
50
|
|
|
153
|
-
|
|
51
|
+
**Advanced compaction** (collapsed): smart keep tail, summary budget, per-section toggles, percentage cooldown and repeat growth, extra instructions for model summaries, debug output.
|
|
154
52
|
|
|
155
|
-
|
|
53
|
+
Configs from before the rework are translated automatically: `overrideDefaultCompaction: false` becomes Method = model summary, and `autoCompaction.enabled` becomes When = at a percentage.
|
|
156
54
|
|
|
157
|
-
|
|
55
|
+
## Commands
|
|
158
56
|
|
|
159
|
-
|
|
|
57
|
+
| Command | |
|
|
160
58
|
|---|---|
|
|
161
|
-
|
|
|
162
|
-
| `
|
|
163
|
-
|
|
|
164
|
-
| `
|
|
165
|
-
| `
|
|
166
|
-
| `
|
|
167
|
-
| `ctx_execute` | Deprecated alias for `sandbox`. |
|
|
168
|
-
| `ctx_execute_file` | Deprecated alias for `sandbox_file`. |
|
|
169
|
-
| `ctx_batch_execute` | Deprecated alias for `sandbox_batch`. |
|
|
170
|
-
| `compactor_stats` | Agent-readable stats dashboard. |
|
|
171
|
-
| `ctx_stats` | Deprecated alias for `compactor_stats`. |
|
|
172
|
-
| `compactor_doctor` | Agent-readable diagnostics. |
|
|
173
|
-
| `ctx_doctor` | Deprecated alias for `compactor_doctor`. |
|
|
174
|
-
| `context_budget` | Uses live Pi context usage when available and returns compaction guidance. |
|
|
59
|
+
| `/unipi:compact-vcc [keep:N]` | Lossless compaction now; `keep:N` keeps the last N user turns |
|
|
60
|
+
| `/unipi:compact-by-llm [focus]` | Model-summary compaction now; optional text focuses the summary |
|
|
61
|
+
| `/unipi:session-recall <query>` | Search the full session history (`scope:all`, `page:N`) |
|
|
62
|
+
| `/unipi:compact-stats` | This session's compactions and savings |
|
|
63
|
+
| `/unipi:compact-doctor` | Check settings, Pi's compaction switch, leftovers |
|
|
64
|
+
| `/unipi:compact-help` | Command summary |
|
|
175
65
|
|
|
176
|
-
|
|
66
|
+
Removed: `/unipi:compact` and `/unipi:lossless-compact` (use `/unipi:compact-vcc`), `/unipi:compact-recall` (use `/unipi:session-recall`), `/unipi:compact-jev` and the jev method (a saved `method: "jev"` behaves as lossless).
|
|
177
67
|
|
|
178
|
-
|
|
179
|
-
|---|---|
|
|
180
|
-
| `compactor` | Small always-loadable routing skill: when to compact, recall, check budget, or use sandbox. |
|
|
181
|
-
| `compactor-detail` | On-demand full tool reference and workflow guidance. |
|
|
182
|
-
| `compactor-stats` | Help interpreting compactor stats. |
|
|
183
|
-
| `compactor-doctor` | Help diagnosing config/DB/runtime issues. |
|
|
184
|
-
|
|
185
|
-
---
|
|
186
|
-
|
|
187
|
-
## How the system works
|
|
188
|
-
|
|
189
|
-
### Chronological hook flow
|
|
190
|
-
|
|
191
|
-
Typical session order:
|
|
192
|
-
|
|
193
|
-
1. **Extension load**
|
|
194
|
-
- Registers compaction hooks immediately with lazy dependencies.
|
|
195
|
-
- Creates in-memory runtime counters/state.
|
|
196
|
-
|
|
197
|
-
2. **`session_start`**
|
|
198
|
-
- Scaffolds config if needed.
|
|
199
|
-
- Initializes `SessionDB` and sandbox executor.
|
|
200
|
-
- Computes the current session ID, including worktree suffix.
|
|
201
|
-
- Registers agent tools and slash commands.
|
|
202
|
-
- Registers the info-screen Compactor group.
|
|
203
|
-
- Emits UniPi `MODULE_READY`.
|
|
204
|
-
|
|
205
|
-
3. **`before_agent_start`**
|
|
206
|
-
- Reloads config for the active project.
|
|
207
|
-
- Applies runtime `autoDetect` behavior, such as disabling commit extraction outside git repos.
|
|
208
|
-
- Rebuilds cached recall blocks from Pi's append-only session branch.
|
|
209
|
-
- If a resume snapshot exists from a prior compaction, injects it into session context and marks it consumed.
|
|
210
|
-
|
|
211
|
-
4. **`input`**
|
|
212
|
-
- Performs advisory security checks for shell/network/file patterns.
|
|
213
|
-
- Can block some known-dangerous network shell commands.
|
|
214
|
-
|
|
215
|
-
5. **Tool execution → `tool_result`**
|
|
216
|
-
- Extracts file/change/search/sandbox events into the session DB.
|
|
217
|
-
- Updates runtime byte/tool counters.
|
|
218
|
-
- Applies display overrides and width-safe diff clamping before output reaches the TUI.
|
|
219
|
-
|
|
220
|
-
6. **`agent_end`**
|
|
221
|
-
- If percentage auto-compaction is enabled, reads `ctx.getContextUsage()`.
|
|
222
|
-
- Runs cooldown/repeat-growth safeguards.
|
|
223
|
-
- Calls `ctx.compact({ customInstructions: COMPACTOR_INSTRUCTION })` when eligible.
|
|
224
|
-
- Fires only after the agent run settles: `ctx.compact()` aborts any active operation first, so triggering mid-run (e.g. at `turn_end`) would kill the next provider request.
|
|
225
|
-
|
|
226
|
-
7. **Pi decides to compact**
|
|
227
|
-
- This can be from `/unipi:lossless-compact`, UniPi percentage auto-compaction, or Pi core's reserve-token fallback.
|
|
228
|
-
|
|
229
|
-
8. **`session_before_compact`**
|
|
230
|
-
- Pi provides `preparation`, `branchEntries`, and optional custom instructions.
|
|
231
|
-
- If compactor should handle it, UniPi:
|
|
232
|
-
1. chooses the safe cut point (`buildOwnCut`),
|
|
233
|
-
2. converts messages to LLM-like input,
|
|
234
|
-
3. runs the zero-LLM compile pipeline,
|
|
235
|
-
4. persists stats/snapshots,
|
|
236
|
-
5. returns `{ compaction: { summary, details, tokensBefore, firstKeptEntryId } }` to Pi.
|
|
237
|
-
|
|
238
|
-
9. **`session_compact`**
|
|
239
|
-
- Pi commits the compaction entry.
|
|
240
|
-
- UniPi increments compaction counters and persists token/character savings.
|
|
241
|
-
|
|
242
|
-
10. **Next `before_agent_start` after compaction**
|
|
243
|
-
- UniPi injects the resume snapshot so the agent gets continuity without needing the full old transcript in context.
|
|
244
|
-
|
|
245
|
-
11. **`session_shutdown`**
|
|
246
|
-
- Cleans old sessions.
|
|
247
|
-
- Cleans sandbox/background processes.
|
|
248
|
-
- Closes DB handles.
|
|
249
|
-
|
|
250
|
-
### Zero-LLM compile pipeline
|
|
251
|
-
|
|
252
|
-
When UniPi handles `session_before_compact`, it transforms old messages through these deterministic stages:
|
|
68
|
+
## Tools
|
|
253
69
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
3. **Build sections** — extract goals, files, commits, outstanding context, preferences, and transcript entries.
|
|
257
|
-
4. **Brief** — cap and condense transcript lines.
|
|
258
|
-
5. **Format** — emit a structured markdown summary.
|
|
259
|
-
6. **Merge** — merge with the previous summary when Pi provides one.
|
|
70
|
+
- `session_recall`: keyword/regex search over the session branch, including compacted-away messages. `expand` returns full entries by index (the `#N` refs in summaries); `mode: "touched"` lists files.
|
|
71
|
+
- `context_budget`: how full the context is.
|
|
260
72
|
|
|
261
|
-
|
|
73
|
+
## For other modules
|
|
262
74
|
|
|
263
|
-
|
|
75
|
+
Register an active-work provider so summaries lead with your state:
|
|
264
76
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
| Synthetic session | Input chars | Approx input tokens | Summary chars | Approx summary tokens | Reduction | Compile time |
|
|
270
|
-
|---:|---:|---:|---:|---:|---:|---:|
|
|
271
|
-
| 100 turns / 400 messages | 356,913 | 89,228 | 36,451 | 9,113 | 89.8% | 12.5 ms |
|
|
272
|
-
| 250 turns / 1,000 messages | 894,063 | 223,516 | 36,585 | 9,146 | 95.9% | 16.6 ms |
|
|
273
|
-
| 500 turns / 2,000 messages | 1,789,313 | 447,328 | 36,605 | 9,151 | 98.0% | 35.8 ms |
|
|
274
|
-
|
|
275
|
-
Practical interpretation:
|
|
276
|
-
|
|
277
|
-
- Larger sessions compress better because the structured summary has fixed caps.
|
|
278
|
-
- Runtime is local and usually small relative to model/tool latency.
|
|
279
|
-
- Actual savings reported to users should come from `/unipi:compact-stats`, because Pi supplies real `tokensBefore` during compaction when available.
|
|
280
|
-
|
|
281
|
-
---
|
|
282
|
-
|
|
283
|
-
## Troubleshooting
|
|
284
|
-
|
|
285
|
-
### "Whatever preset I choose, Pipeline is always off"
|
|
286
|
-
|
|
287
|
-
That means preset application is not updating `config.pipeline`. The intended behavior is:
|
|
288
|
-
|
|
289
|
-
- `precise`: Auto Injection off.
|
|
290
|
-
- `balanced`: Auto Injection on.
|
|
291
|
-
- `thorough`: Auto Injection on.
|
|
292
|
-
- `lean`: Auto Injection off.
|
|
293
|
-
|
|
294
|
-
The five deprecated compatibility fields remain off in every preset.
|
|
295
|
-
|
|
296
|
-
Make sure you are running a version with the preset pipeline fix, select the preset, and press **Enter** to save.
|
|
297
|
-
|
|
298
|
-
### "Compaction did not happen"
|
|
299
|
-
|
|
300
|
-
- For immediate user-triggered compaction, use `/unipi:lossless-compact`.
|
|
301
|
-
- For automatic percentage compaction, enable **Auto → Percentage Trigger**.
|
|
302
|
-
- Pi core still has its own reserve-token fallback; UniPi's percentage trigger is optional and disabled by default.
|
|
303
|
-
|
|
304
|
-
### "Stats show zero"
|
|
305
|
-
|
|
306
|
-
- Stats only increase after compaction or after tracked sandbox/search events.
|
|
307
|
-
- Run `/unipi:compact-doctor` to check DB/config health.
|
|
308
|
-
- Long sessions may show all-time DB fallbacks if current in-memory counters are zero.
|
|
309
|
-
|
|
310
|
-
### "Recall cannot find something"
|
|
77
|
+
```ts
|
|
78
|
+
import { registerCompactionContext } from "@pi-unipi/core";
|
|
79
|
+
registerCompactionContext("my-module", () => (running ? "Task X is in progress — …" : null));
|
|
80
|
+
```
|
|
311
81
|
|
|
312
|
-
|
|
313
|
-
- The recall path prefers Pi's append-only branch and falls back to cached normalized blocks.
|
|
314
|
-
- Extra noise filtering can be added with `pipeline.customNoisePatterns`.
|
|
82
|
+
Compactions applied at a turn boundary (percentage trigger) do not fire Pi's `session_compact`; listen to `UNIPI_EVENTS.COMPACTOR_COMPACTED` to react to every compaction.
|
|
315
83
|
|
|
316
|
-
##
|
|
84
|
+
## Removed in 3.0
|
|
317
85
|
|
|
318
|
-
|
|
86
|
+
- **Session continuity**: the SQLite event log and the hidden snapshot restored after compaction. It logged every session under one shared ID, so snapshots mixed projects and grew to ~60k tokens. The summary now derives files, errors and commits from the session itself. `/unipi:compact-doctor` reports the old `~/.unipi/db/compactor` directory, which can be deleted.
|
|
87
|
+
- **Sandbox tools** (`sandbox`, `sandbox_file`, `sandbox_batch`), the `compact` tool (it never compacted), `compactor_stats` / `compactor_doctor` tools (use the commands), presets, and the inert strategy modes.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-unipi/compactor",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "3.0.0-alpha.21",
|
|
4
|
+
"description": "Compaction for Pi — lossless zero-LLM or model summaries, rebuilt from full history, with session recall",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"license": "MIT",
|
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
"unipi",
|
|
19
19
|
"compactor",
|
|
20
20
|
"context",
|
|
21
|
-
"
|
|
22
|
-
"fts5"
|
|
21
|
+
"compaction"
|
|
23
22
|
],
|
|
24
23
|
"scripts": {
|
|
25
24
|
"test": "npx bun test tests"
|
|
@@ -34,8 +33,8 @@
|
|
|
34
33
|
"access": "public"
|
|
35
34
|
},
|
|
36
35
|
"dependencies": {
|
|
37
|
-
"@pi-unipi/core": "3.0.0-alpha.
|
|
38
|
-
"@pi-unipi/info-screen": "3.0.0-alpha.
|
|
36
|
+
"@pi-unipi/core": "3.0.0-alpha.21",
|
|
37
|
+
"@pi-unipi/info-screen": "3.0.0-alpha.21",
|
|
39
38
|
"@earendil-works/pi-agent-core": "^0.87.1"
|
|
40
39
|
},
|
|
41
40
|
"peerDependencies": {
|
|
@@ -47,9 +46,6 @@
|
|
|
47
46
|
"@types/node": "^25.6.0",
|
|
48
47
|
"typescript": "^6.0.0"
|
|
49
48
|
},
|
|
50
|
-
"optionalDependencies": {
|
|
51
|
-
"better-sqlite3": ">=11.0.0"
|
|
52
|
-
},
|
|
53
49
|
"pi": {
|
|
54
50
|
"extensions": [
|
|
55
51
|
"./index.ts"
|
|
@@ -1,29 +1,22 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: compactor
|
|
3
|
-
description:
|
|
3
|
+
description: Session recall and compaction — use when earlier parts of this session are missing from context, or after a compaction summary.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Compactor
|
|
6
|
+
# Compactor
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
- `context_budget` → check % full. `compact` → free tokens (zero-LLM, 98%+ reduction).
|
|
10
|
-
Compact BEFORE complex work. `compact(dryRun: true)` to preview without compacting.
|
|
11
|
-
- `compactor_stats` → check savings. `compactor_doctor` → diagnose.
|
|
8
|
+
Compaction is automatic: when the context fills, it is replaced by a summary and the work carries on. Keep working through it.
|
|
12
9
|
|
|
13
|
-
##
|
|
14
|
-
- `session_recall(query)` → search this session (BM25 or regex), including raw messages that may no longer be in live context after compaction.
|
|
15
|
-
- For project/file search, use `read`/`bash` (rg) directly; content indexing is not part of compactor.
|
|
10
|
+
## After a compaction
|
|
16
11
|
|
|
17
|
-
|
|
18
|
-
- `sandbox(lang, code)` → single script. `sandbox_batch(items)` → atomic.
|
|
19
|
-
`sandbox_file(lang, path)` → run file. Only stdout enters context.
|
|
12
|
+
The summary opens with **Active Work** (the goal, ralph loop or kanboard task in flight) — treat it as authoritative and continue that work. Then come the user's requests, the latest state, decisions, files, commits and open errors.
|
|
20
13
|
|
|
21
|
-
##
|
|
22
|
-
⚠ When the task spans many operations, PREFER Ralph loops
|
|
23
|
-
(`the implementation step`, `ralph_start`) if available — they manage
|
|
24
|
-
context pressure better than monolithic runs.
|
|
14
|
+
## Recall
|
|
25
15
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
- `session_recall`
|
|
29
|
-
-
|
|
16
|
+
The full session history is kept. Reach for `session_recall` whenever a detail is missing:
|
|
17
|
+
|
|
18
|
+
- `session_recall(query: "redis cache decision")` — plain keywords work best.
|
|
19
|
+
- `#123`-style refs in the summary are entry indices: `session_recall(expand: [123])` returns the full content.
|
|
20
|
+
- `mode: "touched"` lists the files worked on; `scope: "all"` also covers edited or retried turns.
|
|
21
|
+
|
|
22
|
+
`context_budget` reports how full the context is.
|