@henryqw/pi-auto-compact 1.1.7 → 1.1.9
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/README.md +3 -3
- package/extensions/auto-compact.ts +9 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ pi install npm:@henryqw/pi-task-models
|
|
|
14
14
|
pi install npm:@henryqw/pi-auto-compact
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
Requires Pi Coding Agent 0.84.
|
|
17
|
+
Requires Pi Coding Agent 0.84.4+.
|
|
18
18
|
|
|
19
19
|
## With
|
|
20
20
|
|
|
@@ -40,7 +40,7 @@ Restart Pi after install or settings changes. Trusted project settings in `.pi/s
|
|
|
40
40
|
| --- | --- | --- |
|
|
41
41
|
| `/auto-compact` | command | Set the compaction threshold. |
|
|
42
42
|
|
|
43
|
-
Refuses to activate unless effective `compaction.enabled` is `false`. Checks `turn_start`, tool-call `turn_end`, `agent_end`, `context`, and resumed or forked `session_start`. `pi-auto-compact/autoCompact` defaults to
|
|
43
|
+
Refuses to activate unless effective `compaction.enabled` is `false`. Checks `turn_start`, tool-call `turn_end`, `agent_end`, `context`, and resumed or forked `session_start`. Its consumer-owned `pi-auto-compact/autoCompact` task defaults to `fast`. Tries the effective profile primary, then fallback; if neither route works, the current session model still compacts. After mid-task compaction, a follow-up message continues the current task.
|
|
44
44
|
|
|
45
45
|
## Config
|
|
46
46
|
|
|
@@ -58,4 +58,4 @@ Package-owned: `~/.pi/agent/config/pi-auto-compact.json`
|
|
|
58
58
|
|
|
59
59
|
Unknown fields are ignored (legacy model fields are obsolete). `/auto-compact` writes this file. A missing file uses the default; a malformed or invalid file fails visibly at session start, falls back to 50%, and stays unchanged.
|
|
60
60
|
|
|
61
|
-
Shared: `~/.pi/agent/config/pi-task-models.json`, owned by `@henryqw/pi-task-models`.
|
|
61
|
+
Shared: `~/.pi/agent/config/pi-task-models.json`, owned by `@henryqw/pi-task-models`. The local `pi-auto-compact/autoCompact` declaration defaults to `fast`; a task entry is an explicit user override. Malformed shared task-model config is reported and left unchanged; compaction then uses the current session model.
|
|
@@ -11,7 +11,9 @@ import type {
|
|
|
11
11
|
ExtensionContext,
|
|
12
12
|
} from "@earendil-works/pi-coding-agent";
|
|
13
13
|
import {
|
|
14
|
+
registerModelTask,
|
|
14
15
|
resolveConfiguredTaskRoutes,
|
|
16
|
+
type ModelTask,
|
|
15
17
|
type ResolvedTaskRoute,
|
|
16
18
|
type TaskRouteError,
|
|
17
19
|
} from "@henryqw/pi-task-models";
|
|
@@ -30,7 +32,12 @@ type AgentMessage = Parameters<typeof estimateTokens>[0];
|
|
|
30
32
|
*/
|
|
31
33
|
const DEFAULT_COMPACT_THRESHOLD_PERCENT = 50;
|
|
32
34
|
const MIN_COMPACT_THRESHOLD_PERCENT = 25;
|
|
33
|
-
const AUTO_COMPACT_TASK =
|
|
35
|
+
export const AUTO_COMPACT_TASK = {
|
|
36
|
+
id: "pi-auto-compact/autoCompact",
|
|
37
|
+
label: "Auto compaction",
|
|
38
|
+
purpose: "Compact session context before it is exhausted.",
|
|
39
|
+
defaultProfile: "fast",
|
|
40
|
+
} as const satisfies ModelTask;
|
|
34
41
|
const configPath = () => join(getAgentDir(), "config", "pi-auto-compact.json");
|
|
35
42
|
|
|
36
43
|
function isValidThreshold(value: unknown): value is number {
|
|
@@ -147,6 +154,7 @@ function hasToolCall(message: AgentMessage): boolean {
|
|
|
147
154
|
}
|
|
148
155
|
|
|
149
156
|
export default function (pi: ExtensionAPI) {
|
|
157
|
+
registerModelTask(pi, AUTO_COMPACT_TASK);
|
|
150
158
|
let active = false;
|
|
151
159
|
let autoCompactThreshold = DEFAULT_COMPACT_THRESHOLD_PERCENT;
|
|
152
160
|
// Prevent lifecycle hooks from starting duplicate summaries.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@henryqw/pi-auto-compact",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"description": "Proactively compact Pi context at a configurable threshold and resume the current task.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"pack:check": "npm pack --dry-run"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@earendil-works/pi-coding-agent": "^0.84.
|
|
28
|
+
"@earendil-works/pi-coding-agent": "^0.84.4"
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
|
31
31
|
"type": "git",
|
|
@@ -44,6 +44,6 @@
|
|
|
44
44
|
]
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@henryqw/pi-task-models": "^
|
|
47
|
+
"@henryqw/pi-task-models": "^3.0.0"
|
|
48
48
|
}
|
|
49
49
|
}
|