@howaboua/pi-gpt-switcher 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Igor Warzocha
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # @howaboua/pi-gpt-switcher
2
+
3
+ Pi extension adding quick model commands:
4
+
5
+ | Command | Model |
6
+ | --- | --- |
7
+ | `/sol [reasoning]` | `openai-codex/gpt-5.6-sol` |
8
+ | `/terra [reasoning]` | `openai-codex/gpt-5.6-terra` |
9
+ | `/luna [reasoning]` | `openai-codex/gpt-5.6-luna` |
10
+
11
+ Reasoning defaults to `high`. Valid arguments are `off`, `minimal`, `low`,
12
+ `medium`, `high`, `xhigh`, and `max`; for example, `/luna low`.
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ pi install npm:@howaboua/pi-gpt-switcher
18
+ ```
19
+
20
+ Try it for one session:
21
+
22
+ ```bash
23
+ pi -e npm:@howaboua/pi-gpt-switcher
24
+ ```
25
+
26
+ ## How it works
27
+
28
+ The commands use Pi's model registry and normal provider authentication. If a
29
+ model is unavailable or the OpenAI Codex credentials are missing, the command
30
+ reports that instead of changing the current model.
31
+
32
+ Reasoning defaults to `high`. Pi clamps the requested level automatically if
33
+ the selected model supports fewer levels.
34
+
35
+ ## Local development
36
+
37
+ Load the checkout directly:
38
+
39
+ ```sh
40
+ pi -e ./index.ts
41
+ ```
package/biome.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "$schema": "https://biomejs.dev/schemas/2.4.16/schema.json",
3
+ "vcs": {
4
+ "enabled": true,
5
+ "clientKind": "git",
6
+ "useIgnoreFile": true
7
+ },
8
+ "files": {
9
+ "includes": [
10
+ "**",
11
+ "!node_modules",
12
+ "!dist",
13
+ "!coverage",
14
+ "!package-lock.json"
15
+ ]
16
+ },
17
+ "formatter": {
18
+ "enabled": true,
19
+ "indentStyle": "tab"
20
+ },
21
+ "linter": {
22
+ "enabled": false
23
+ },
24
+ "javascript": {
25
+ "formatter": {
26
+ "quoteStyle": "double",
27
+ "semicolons": "always",
28
+ "trailingCommas": "all"
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Adds short slash commands for the three OpenAI Codex model variants.
3
+ * The commands use Pi's model registry, so normal provider authentication and
4
+ * model availability checks remain in charge.
5
+ */
6
+
7
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
8
+
9
+ const MODELS = {
10
+ sol: "gpt-5.6-sol",
11
+ terra: "gpt-5.6-terra",
12
+ luna: "gpt-5.6-luna",
13
+ } as const;
14
+
15
+ type Alias = keyof typeof MODELS;
16
+ type ThinkingLevel =
17
+ | "off"
18
+ | "minimal"
19
+ | "low"
20
+ | "medium"
21
+ | "high"
22
+ | "xhigh"
23
+ | "max";
24
+
25
+ const DEFAULT_THINKING_LEVEL: ThinkingLevel = "high";
26
+ const THINKING_LEVELS = new Set<ThinkingLevel>([
27
+ "off",
28
+ "minimal",
29
+ "low",
30
+ "medium",
31
+ "high",
32
+ "xhigh",
33
+ "max",
34
+ ]);
35
+
36
+ function parseThinkingLevel(args: string): ThinkingLevel | undefined {
37
+ const requested = args.trim().toLowerCase();
38
+ if (requested === "") return DEFAULT_THINKING_LEVEL;
39
+ return THINKING_LEVELS.has(requested as ThinkingLevel)
40
+ ? (requested as ThinkingLevel)
41
+ : undefined;
42
+ }
43
+
44
+ export default function (pi: ExtensionAPI) {
45
+ for (const alias of Object.keys(MODELS) as Alias[]) {
46
+ pi.registerCommand(alias, {
47
+ description: `Switch to GPT-5.6 ${alias.charAt(0).toUpperCase()}${alias.slice(1)}`,
48
+ handler: async (args, ctx) => {
49
+ const thinkingLevel = parseThinkingLevel(args);
50
+ if (!thinkingLevel) {
51
+ ctx.ui.notify(
52
+ `Usage: /${alias} [off|minimal|low|medium|high|xhigh|max]`,
53
+ "error",
54
+ );
55
+ return;
56
+ }
57
+
58
+ const modelId = MODELS[alias];
59
+ const model = ctx.modelRegistry.find("openai-codex", modelId);
60
+
61
+ if (!model) {
62
+ ctx.ui.notify(`Model unavailable: openai-codex/${modelId}`, "error");
63
+ return;
64
+ }
65
+
66
+ const alreadySelected =
67
+ ctx.model?.provider === "openai-codex" && ctx.model.id === modelId;
68
+ if (!alreadySelected) {
69
+ let switched: boolean;
70
+ try {
71
+ switched = await pi.setModel(model);
72
+ } catch (error) {
73
+ ctx.ui.notify(
74
+ `Could not switch to ${model.name}: ${error instanceof Error ? error.message : String(error)}`,
75
+ "error",
76
+ );
77
+ return;
78
+ }
79
+ if (!switched) {
80
+ ctx.ui.notify(
81
+ `Could not switch to ${model.name}: no OpenAI Codex credentials`,
82
+ "error",
83
+ );
84
+ return;
85
+ }
86
+ }
87
+
88
+ pi.setThinkingLevel(thinkingLevel);
89
+ ctx.ui.notify(
90
+ `${alreadySelected ? "Using" : "Switched to"} ${model.name} (${pi.getThinkingLevel()})`,
91
+ "info",
92
+ );
93
+ },
94
+ });
95
+ }
96
+ }
package/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ /** Pi package entry point for the Codex model shortcut extension. */
2
+
3
+ export { default } from "./codex-model-shortcuts.js";
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@howaboua/pi-gpt-switcher",
3
+ "version": "0.1.0",
4
+ "description": "Quick Pi commands for switching between GPT-5.6 Codex models and reasoning levels.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "Igor Warzocha",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/IgorWarzocha/howaboua-pi-stuff.git",
11
+ "directory": "packages/pi-gpt-switcher"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/IgorWarzocha/howaboua-pi-stuff/issues"
15
+ },
16
+ "homepage": "https://github.com/IgorWarzocha/howaboua-pi-stuff/tree/main/packages/pi-gpt-switcher#readme",
17
+ "keywords": [
18
+ "pi-package",
19
+ "pi-extension",
20
+ "pi-coding-agent",
21
+ "gpt-5.6",
22
+ "model-switching",
23
+ "reasoning-level"
24
+ ],
25
+ "engines": {
26
+ "node": ">=20.6.0"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "files": [
32
+ "index.ts",
33
+ "codex-model-shortcuts.ts",
34
+ "README.md",
35
+ "LICENSE",
36
+ "tsconfig.json",
37
+ "biome.json"
38
+ ],
39
+ "pi": {
40
+ "extensions": [
41
+ "./index.ts"
42
+ ]
43
+ },
44
+ "peerDependencies": {
45
+ "@earendil-works/pi-coding-agent": ">=0.80.6"
46
+ },
47
+ "devDependencies": {
48
+ "@biomejs/biome": "^2.4.16",
49
+ "@earendil-works/pi-coding-agent": "0.82.0",
50
+ "typescript": "^6.0.3"
51
+ },
52
+ "scripts": {
53
+ "check": "bun run lint && bun run typecheck && bun run test",
54
+ "prepack": "bun run check",
55
+ "test": "bun test",
56
+ "typecheck": "tsgo --noEmit",
57
+ "lint": "biome check .",
58
+ "format": "biome check --write .",
59
+ "pack:dry": "npm pack --dry-run"
60
+ },
61
+ "main": "index.ts",
62
+ "exports": "./index.ts"
63
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "include": ["index.ts", "codex-model-shortcuts.ts"]
4
+ }