@ryan_nookpi/pi-extension-codex-large-context 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/README.md +23 -0
- package/index.ts +39 -0
- package/package.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# @ryan_nookpi/pi-extension-codex-large-context
|
|
2
|
+
|
|
3
|
+
This extension raises the pi context window metadata for newer OpenAI Codex models.
|
|
4
|
+
|
|
5
|
+
It is intended for `gpt-5.4` and `gpt-5.5` model IDs when pi reports a smaller context window than the model can actually handle.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pi install npm:@ryan_nookpi/pi-extension-codex-large-context
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## What it does
|
|
14
|
+
|
|
15
|
+
- Watches `session_start` and `model_select` events.
|
|
16
|
+
- If the active model ID starts with `gpt-5.4` or `gpt-5.5`, sets its context window to `922000` tokens.
|
|
17
|
+
- Shows a small notification when the context window is updated in the interactive UI.
|
|
18
|
+
|
|
19
|
+
## Notes
|
|
20
|
+
|
|
21
|
+
- This only changes pi's local model metadata for the active session/model selection.
|
|
22
|
+
- It does not change API limits on the provider side.
|
|
23
|
+
- If pi already reports a context window of `922000` tokens or more, it leaves the model unchanged.
|
package/index.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent";
|
|
2
|
+
|
|
3
|
+
export const TARGET_CONTEXT_WINDOW = 922_000;
|
|
4
|
+
export const TARGET_MODEL_PREFIXES = ["gpt-5.4", "gpt-5.5"] as const;
|
|
5
|
+
|
|
6
|
+
export function isTargetModelId(modelId: string | undefined): boolean {
|
|
7
|
+
if (!modelId) return false;
|
|
8
|
+
return TARGET_MODEL_PREFIXES.some((prefix) => modelId.startsWith(prefix));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function applyLargeContext(pi: ExtensionAPI, ctx: ExtensionContext): Promise<boolean> {
|
|
12
|
+
const model = ctx.model;
|
|
13
|
+
if (!model) return false;
|
|
14
|
+
if (!isTargetModelId(model.id)) return false;
|
|
15
|
+
if (model.contextWindow >= TARGET_CONTEXT_WINDOW) return false;
|
|
16
|
+
|
|
17
|
+
const previousContextWindow = model.contextWindow;
|
|
18
|
+
const updated = { ...model, contextWindow: TARGET_CONTEXT_WINDOW };
|
|
19
|
+
const ok = await pi.setModel(updated);
|
|
20
|
+
|
|
21
|
+
if (ok && ctx.hasUI) {
|
|
22
|
+
ctx.ui.notify(
|
|
23
|
+
`${model.id} context window: ${(previousContextWindow / 1000).toFixed(0)}K → ${(TARGET_CONTEXT_WINDOW / 1000).toFixed(0)}K`,
|
|
24
|
+
"info",
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return ok;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default function codexLargeContext(pi: ExtensionAPI) {
|
|
32
|
+
pi.on("model_select", async (_event, ctx) => {
|
|
33
|
+
await applyLargeContext(pi, ctx);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
37
|
+
await applyLargeContext(pi, ctx);
|
|
38
|
+
});
|
|
39
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ryan_nookpi/pi-extension-codex-large-context",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Codex large context window extension for pi.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/Jonghakseo/pi-extension.git",
|
|
9
|
+
"directory": "packages/codex-large-context"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/Jonghakseo/pi-extension/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/Jonghakseo/pi-extension/tree/main/packages/codex-large-context#readme",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"pi-package"
|
|
18
|
+
],
|
|
19
|
+
"files": [
|
|
20
|
+
"index.ts",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"pi": {
|
|
24
|
+
"extensions": [
|
|
25
|
+
"./index.ts"
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@mariozechner/pi-coding-agent": "*"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
}
|
|
34
|
+
}
|