@henryqw/pi-auto-compact 1.1.0 → 1.1.2
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/extensions/auto-compact.ts +11 -24
- package/package.json +2 -2
|
@@ -11,11 +11,9 @@ import type {
|
|
|
11
11
|
ExtensionContext,
|
|
12
12
|
} from "@earendil-works/pi-coding-agent";
|
|
13
13
|
import {
|
|
14
|
-
|
|
15
|
-
orderedProfileRoutes,
|
|
16
|
-
readTaskModelsConfig,
|
|
17
|
-
resolveTaskModelRoute,
|
|
14
|
+
resolveConfiguredTaskRoutes,
|
|
18
15
|
type ResolvedTaskRoute,
|
|
16
|
+
type TaskRouteError,
|
|
19
17
|
} from "@henryqw/pi-task-models";
|
|
20
18
|
|
|
21
19
|
type AgentMessage = Parameters<typeof estimateTokens>[0];
|
|
@@ -33,7 +31,6 @@ type AgentMessage = Parameters<typeof estimateTokens>[0];
|
|
|
33
31
|
const DEFAULT_COMPACT_THRESHOLD_PERCENT = 50;
|
|
34
32
|
const MIN_COMPACT_THRESHOLD_PERCENT = 25;
|
|
35
33
|
const AUTO_COMPACT_TASK = "pi-auto-compact/autoCompact";
|
|
36
|
-
const DEFAULT_AUTO_COMPACT_PROFILE = DEFAULT_TASK_ASSIGNMENTS[AUTO_COMPACT_TASK];
|
|
37
34
|
const configPath = () => join(getAgentDir(), "config", "pi-auto-compact.json");
|
|
38
35
|
|
|
39
36
|
type Config = {
|
|
@@ -71,28 +68,18 @@ function writeConfig(config: Config): void {
|
|
|
71
68
|
}
|
|
72
69
|
|
|
73
70
|
function configuredTaskRoutes(ctx: ExtensionContext): ResolvedTaskRoute[] {
|
|
74
|
-
let config;
|
|
75
71
|
try {
|
|
76
|
-
|
|
77
|
-
} catch {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
ctx.ui.notify(`Task model profile ${profileName} is not configured; using current session model.`, "error");
|
|
72
|
+
return resolveConfiguredTaskRoutes(ctx, AUTO_COMPACT_TASK);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
const { taskRouteCode, profileName } = error as TaskRouteError;
|
|
75
|
+
const cause = taskRouteCode === "profile-missing"
|
|
76
|
+
? `Task model profile ${profileName} is not configured`
|
|
77
|
+
: taskRouteCode === "no-route"
|
|
78
|
+
? `No usable ${profileName} task model route`
|
|
79
|
+
: "Couldn't read task model config";
|
|
80
|
+
ctx.ui.notify(`${cause}; using current session model.`, "error");
|
|
86
81
|
return [];
|
|
87
82
|
}
|
|
88
|
-
|
|
89
|
-
const routes = orderedProfileRoutes(profile)
|
|
90
|
-
.map((route) => resolveTaskModelRoute(ctx, route))
|
|
91
|
-
.filter((route): route is ResolvedTaskRoute => route !== undefined);
|
|
92
|
-
if (!routes.length) {
|
|
93
|
-
ctx.ui.notify(`No usable ${profileName} task model route; using current session model.`, "error");
|
|
94
|
-
}
|
|
95
|
-
return routes;
|
|
96
83
|
}
|
|
97
84
|
|
|
98
85
|
function withoutDeletedHeaders(headers: Record<string, string | null> | undefined): Record<string, string> | undefined {
|
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.2",
|
|
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.
|
|
48
|
+
"@henryqw/pi-task-models": "^0.7.0"
|
|
49
49
|
}
|
|
50
50
|
}
|