pi-model-control 0.1.0 → 0.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/shared.ts +26 -0
- package/extensions/thinking.ts +1 -21
- package/extensions/variants.ts +3 -19
- package/package.json +1 -8
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
|
|
3
|
+
export const DISPLAY_LEVELS = [NULL_LEVELS, "minimal", "low", "medium", "high", "max"];
|
|
4
|
+
const NULL_LEVELS = "none"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export function getSupportedLevels(m: any): string[] {
|
|
8
|
+
if (!m.reasoning) return [NULL_LEVELS];
|
|
9
|
+
|
|
10
|
+
const map = m.thinkingLevelMap;
|
|
11
|
+
if (!map) return [NULL_LEVELS];
|
|
12
|
+
|
|
13
|
+
return DISPLAY_LEVELS.filter((level) => {
|
|
14
|
+
const piLevel = level === NULL_LEVELS ? "off" : level;
|
|
15
|
+
|
|
16
|
+
return map.hasOwnProperty(piLevel) && map[piLevel] !== null;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function displayToPi(display: string): string {
|
|
21
|
+
return display === NULL_LEVELS ? "off" : display;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function piToDisplay(pi: string): string {
|
|
25
|
+
return pi === "off" ? NULL_LEVELS : pi;
|
|
26
|
+
}
|
package/extensions/thinking.ts
CHANGED
|
@@ -1,25 +1,5 @@
|
|
|
1
1
|
import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
|
|
3
|
-
const DISPLAY_LEVELS = ["default", "minimal", "low", "medium", "high", "max"];
|
|
4
|
-
|
|
5
|
-
function getSupportedLevels(m: any): string[] {
|
|
6
|
-
if (!m.reasoning) return ["default"];
|
|
7
|
-
return DISPLAY_LEVELS.filter((level) => {
|
|
8
|
-
const piLevel = level === "default" ? "off" : level;
|
|
9
|
-
const mapped = m.thinkingLevelMap?.[piLevel];
|
|
10
|
-
if (mapped === null) return false;
|
|
11
|
-
if (level === "max") return mapped !== undefined;
|
|
12
|
-
return true;
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function displayToPi(display: string): string {
|
|
17
|
-
return display === "default" ? "off" : display;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function piToDisplay(pi: string): string {
|
|
21
|
-
return pi === "off" ? "default" : pi;
|
|
22
|
-
}
|
|
2
|
+
import { DISPLAY_LEVELS, getSupportedLevels, displayToPi, piToDisplay } from "./shared.js";
|
|
23
3
|
|
|
24
4
|
export default function (pi: ExtensionAPI) {
|
|
25
5
|
pi.registerCommand("thinking", {
|
package/extensions/variants.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { Focusable } from "@earendil-works/pi-tui";
|
|
|
5
5
|
import { readFileSync, existsSync } from "node:fs";
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
import { homedir } from "node:os";
|
|
8
|
+
import { DISPLAY_LEVELS, getSupportedLevels, displayToPi, piToDisplay } from "./shared.js";
|
|
8
9
|
|
|
9
10
|
interface VariantEntry {
|
|
10
11
|
provider: string;
|
|
@@ -12,23 +13,6 @@ interface VariantEntry {
|
|
|
12
13
|
thinking: string;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
const DISPLAY_LEVELS = ["default", "minimal", "low", "medium", "high", "max"];
|
|
16
|
-
|
|
17
|
-
function getSupportedLevels(m: any): string[] {
|
|
18
|
-
if (!m.reasoning) return ["default"];
|
|
19
|
-
return DISPLAY_LEVELS.filter((level) => {
|
|
20
|
-
const piLevel = level === "default" ? "off" : level;
|
|
21
|
-
const mapped = m.thinkingLevelMap?.[piLevel];
|
|
22
|
-
if (mapped === null) return false;
|
|
23
|
-
if (level === "max") return mapped !== undefined;
|
|
24
|
-
return true;
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function displayToPi(display: string): string {
|
|
29
|
-
return display === "default" ? "off" : display;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
16
|
function loadEnabledModels(): Set<string> | null {
|
|
33
17
|
const dir = process.env.PI_CODING_AGENT_DIR || join(homedir(), ".pi", "agent");
|
|
34
18
|
const path = join(dir, "settings.json");
|
|
@@ -246,9 +230,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
246
230
|
variants,
|
|
247
231
|
(v) => {
|
|
248
232
|
selected = v;
|
|
249
|
-
done();
|
|
233
|
+
done(v);
|
|
250
234
|
},
|
|
251
|
-
() => done(),
|
|
235
|
+
() => done(null),
|
|
252
236
|
);
|
|
253
237
|
|
|
254
238
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-model-control",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Model and thinking level controls for pi — /variants and /thinking commands",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -27,12 +27,5 @@
|
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@earendil-works/pi-coding-agent": "*",
|
|
29
29
|
"@earendil-works/pi-tui": "*"
|
|
30
|
-
},
|
|
31
|
-
"devDependencies": {
|
|
32
|
-
"sigstore": "^5.0.0"
|
|
33
|
-
},
|
|
34
|
-
"dependencies": {
|
|
35
|
-
"libnpmpublish": "^12.0.0",
|
|
36
|
-
"node-fetch": "^3.3.2"
|
|
37
30
|
}
|
|
38
31
|
}
|