@henryqw/pi-auto-compact 1.1.6 → 1.1.8

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 CHANGED
@@ -40,11 +40,11 @@ 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 the `fast` profile. Tries the assigned 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.
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
 
47
- `~/.pi/agent/config/pi-auto-compact.json`
47
+ Package-owned: `~/.pi/agent/config/pi-auto-compact.json`
48
48
 
49
49
  ```json
50
50
  {
@@ -52,24 +52,10 @@ Refuses to activate unless effective `compaction.enabled` is `false`. Checks `tu
52
52
  }
53
53
  ```
54
54
 
55
- Threshold must be at least 25 and below 100. Missing config defaults to 50. Model routes live in `~/.pi/agent/config/pi-task-models.json`. Malformed shared task-model config is reported and left unchanged.
55
+ | Field | Required | Possible values | Default |
56
+ | --- | --- | --- | --- |
57
+ | `autoCompactThreshold` | No | Number, at least 25, below 100 | `50` |
56
58
 
57
- ## Remove
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.
58
60
 
59
- ```bash
60
- pi remove npm:@henryqw/pi-auto-compact
61
- ```
62
-
63
- ## Development
64
-
65
- ```bash
66
- npm test --workspace @henryqw/pi-auto-compact
67
- npm run typecheck --workspace @henryqw/pi-auto-compact
68
- npm run pack:check --workspace @henryqw/pi-auto-compact
69
- ```
70
-
71
- `test:live` needs real Pi plus authenticated model access. Set `PI_AUTO_COMPACT_AUTH_FILE` when auth is not at `~/.pi/agent/auth.json`.
72
-
73
- ```bash
74
- npm run test:live --workspace @henryqw/pi-auto-compact
75
- ```
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 = "pi-auto-compact/autoCompact";
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.6",
3
+ "version": "1.1.8",
4
4
  "description": "Proactively compact Pi context at a configurable threshold and resume the current task.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -44,6 +44,6 @@
44
44
  ]
45
45
  },
46
46
  "dependencies": {
47
- "@henryqw/pi-task-models": "^1.0.0"
47
+ "@henryqw/pi-task-models": "^3.0.0"
48
48
  }
49
49
  }