@henryqw/pi-auto-compact 1.0.2 → 1.0.4

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
@@ -35,7 +35,7 @@ Restart Pi after install or settings changes. Trusted project settings in `.pi/s
35
35
  | --- | --- | --- |
36
36
  | `/auto-compact` | command | Set the compaction threshold. |
37
37
 
38
- 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`. 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.
38
+ 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.
39
39
 
40
40
  ## Config
41
41
 
@@ -11,6 +11,7 @@ import type {
11
11
  ExtensionContext,
12
12
  } from "@earendil-works/pi-coding-agent";
13
13
  import {
14
+ DEFAULT_TASK_ASSIGNMENTS,
14
15
  orderedProfileRoutes,
15
16
  readTaskModelsConfig,
16
17
  resolveTaskModelRoute,
@@ -32,7 +33,7 @@ type AgentMessage = Parameters<typeof estimateTokens>[0];
32
33
  const DEFAULT_COMPACT_THRESHOLD_PERCENT = 50;
33
34
  const MIN_COMPACT_THRESHOLD_PERCENT = 25;
34
35
  const AUTO_COMPACT_TASK = "pi-auto-compact/autoCompact";
35
- const DEFAULT_AUTO_COMPACT_PROFILE = "balanced" as const;
36
+ const DEFAULT_AUTO_COMPACT_PROFILE = DEFAULT_TASK_ASSIGNMENTS[AUTO_COMPACT_TASK];
36
37
  const configPath = () => join(getAgentDir(), "config", "pi-auto-compact.json");
37
38
 
38
39
  type Config = {
@@ -69,13 +70,13 @@ function writeConfig(config: Config): void {
69
70
  writeFileSync(file, `${JSON.stringify(config, null, 2)}\n`);
70
71
  }
71
72
 
72
- function configuredTaskRoutes(ctx: ExtensionContext): ResolvedTaskRoute[] | undefined {
73
+ function configuredTaskRoutes(ctx: ExtensionContext): ResolvedTaskRoute[] {
73
74
  let config;
74
75
  try {
75
76
  config = readTaskModelsConfig();
76
77
  } catch {
77
78
  ctx.ui.notify("Couldn't read task model config; using current session model.", "error");
78
- return undefined;
79
+ return [];
79
80
  }
80
81
 
81
82
  const profileName = config.tasks[AUTO_COMPACT_TASK] ?? DEFAULT_AUTO_COMPACT_PROFILE;
@@ -340,7 +341,7 @@ export default function (pi: ExtensionAPI) {
340
341
  }
341
342
 
342
343
  const routes = configuredTaskRoutes(ctx);
343
- if (!routes?.length) return;
344
+ if (!routes.length) return;
344
345
 
345
346
  for (const route of routes) {
346
347
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@henryqw/pi-auto-compact",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Proactively compact Pi context at a configurable threshold and resume the current task.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -45,6 +45,6 @@
45
45
  ]
46
46
  },
47
47
  "dependencies": {
48
- "@henryqw/pi-task-models": "^0.1.0"
48
+ "@henryqw/pi-task-models": "^0.3.0"
49
49
  }
50
50
  }