@howaboua/pi-codex-conversion 1.0.17 → 1.0.18

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
@@ -8,6 +8,7 @@ This package replaces Pi's default Codex/GPT experience with a narrower Codex-li
8
8
  - preserves Pi's composed system prompt and applies a narrow Codex-oriented delta on top
9
9
  - renders exec activity with Codex-style command and background-terminal labels
10
10
  - renders `apply_patch` calls with Codex-style `Added` / `Edited` / `Deleted` diff blocks and Pi-style colored diff lines
11
+ - targets modern Pi tool/rendering APIs and is aligned with Pi `0.67.x`
11
12
 
12
13
  ![Available tools](./available-tools.png)
13
14
 
@@ -139,6 +140,7 @@ That keeps the prompt much closer to `pi-mono` while still steering the model to
139
140
  - `web_search` is exposed only for the `openai-codex` provider and is forwarded as the native OpenAI Codex Responses web search tool.
140
141
  - `apply_patch` paths stay restricted to the current working directory.
141
142
  - partial `apply_patch` failures stay in the original patch block and highlight the failed entry instead of adding a second warning row.
143
+ - `apply_patch` uses Pi's self-rendered tool shell mode for more stable large patch previews on current Pi versions.
142
144
  - `exec_command` / `write_stdin` use a custom PTY-backed session manager via `node-pty` for interactive sessions.
143
145
  - tiny `exec_command` waits are clamped for non-interactive commands so short runs do not burn an avoidable follow-up tool call.
144
146
  - empty `write_stdin` polls are clamped to a meaningful minimum wait so long-running processes are not repolled too aggressively.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@howaboua/pi-codex-conversion",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "description": "Codex-oriented tool and prompt adapter for pi coding agent",
5
5
  "type": "module",
6
6
  "repository": {
@@ -51,11 +51,13 @@
51
51
  "access": "public"
52
52
  },
53
53
  "peerDependencies": {
54
- "@mariozechner/pi-coding-agent": "^0.62.0",
55
- "@mariozechner/pi-tui": "^0.62.0",
54
+ "@mariozechner/pi-coding-agent": "^0.67.0",
55
+ "@mariozechner/pi-tui": "^0.67.0",
56
56
  "@sinclair/typebox": "*"
57
57
  },
58
58
  "devDependencies": {
59
+ "@mariozechner/pi-coding-agent": "^0.67.3",
60
+ "@mariozechner/pi-tui": "^0.67.3",
59
61
  "tsx": "^4.20.5",
60
62
  "typescript": "^5.9.3"
61
63
  },
@@ -56,6 +56,21 @@ function parseApplyPatchParams(params: unknown): { patchText: string } {
56
56
  return { patchText: params.input };
57
57
  }
58
58
 
59
+ function prepareApplyPatchArguments(args: unknown): { input: string } {
60
+ if (args && typeof args === "object") {
61
+ if ("input" in args && typeof args.input === "string") {
62
+ return { input: args.input };
63
+ }
64
+ if ("patchText" in args && typeof args.patchText === "string") {
65
+ return { input: args.patchText };
66
+ }
67
+ if ("patch" in args && typeof args.patch === "string") {
68
+ return { input: args.patch };
69
+ }
70
+ }
71
+ return args as { input: string };
72
+ }
73
+
59
74
  function isApplyPatchToolDetails(details: unknown): details is ApplyPatchToolDetails {
60
75
  return typeof details === "object" && details !== null && "status" in details && "result" in details;
61
76
  }
@@ -272,6 +287,8 @@ export function registerApplyPatchTool(pi: ExtensionAPI): void {
272
287
  "When one task needs coordinated edits across multiple files, send them in a single apply_patch call when one coherent patch will do.",
273
288
  ],
274
289
  parameters: APPLY_PATCH_PARAMETERS,
290
+ renderShell: "self",
291
+ prepareArguments: prepareApplyPatchArguments,
275
292
  async execute(toolCallId, params, signal, _onUpdate, ctx) {
276
293
  if (signal?.aborted) {
277
294
  throw new Error("apply_patch aborted");
@@ -30,6 +30,26 @@ interface ExecCommandParams {
30
30
  login?: boolean;
31
31
  }
32
32
 
33
+ function prepareExecCommandArguments(args: unknown): ExecCommandParams {
34
+ if (!args || typeof args !== "object") {
35
+ return args as ExecCommandParams;
36
+ }
37
+
38
+ const record = args as Record<string, unknown>;
39
+ const prepared: Record<string, unknown> = { ...record };
40
+ if (!("cmd" in prepared) && "command" in prepared) {
41
+ prepared.cmd = prepared.command;
42
+ }
43
+ if (!("workdir" in prepared)) {
44
+ if ("cwd" in prepared) {
45
+ prepared.workdir = prepared.cwd;
46
+ } else if ("working_directory" in prepared) {
47
+ prepared.workdir = prepared.working_directory;
48
+ }
49
+ }
50
+ return prepared as unknown as ExecCommandParams;
51
+ }
52
+
33
53
  function parseExecCommandParams(params: unknown): ExecCommandParams {
34
54
  if (!params || typeof params !== "object") {
35
55
  throw new Error("exec_command requires an object parameter");
@@ -125,6 +145,7 @@ export function registerExecCommandTool(pi: ExtensionAPI, tracker: ExecCommandTr
125
145
  "Keep tty disabled unless the command truly needs interactive terminal behavior.",
126
146
  ],
127
147
  parameters: EXEC_COMMAND_PARAMETERS,
148
+ prepareArguments: prepareExecCommandArguments,
128
149
  async execute(toolCallId, params, signal, _onUpdate, ctx) {
129
150
  if (signal?.aborted) {
130
151
  throw new Error("exec_command aborted");
@@ -68,6 +68,23 @@ export function parseViewImageParams(params: unknown): ViewImageParams {
68
68
  return { path: params.path, detail };
69
69
  }
70
70
 
71
+ function prepareViewImageArguments(args: unknown): Record<string, unknown> {
72
+ if (!args || typeof args !== "object") {
73
+ return args as Record<string, unknown>;
74
+ }
75
+
76
+ const record = args as Record<string, unknown>;
77
+ const prepared: Record<string, unknown> = { ...record };
78
+ if (!("path" in prepared)) {
79
+ if ("file_path" in prepared) {
80
+ prepared.path = prepared.file_path;
81
+ } else if ("image_path" in prepared) {
82
+ prepared.path = prepared.image_path;
83
+ }
84
+ }
85
+ return prepared;
86
+ }
87
+
71
88
  function resolveViewImagePath(path: string, cwd: string): string {
72
89
  return isAbsolute(path) ? path : resolve(cwd, path);
73
90
  }
@@ -131,6 +148,7 @@ export function createViewImageTool(options: CreateViewImageToolOptions = {}): T
131
148
  promptSnippet: "View a local image from the filesystem.",
132
149
  promptGuidelines: ["Use view_image only for image files. Use exec_command for text-file inspection."],
133
150
  parameters,
151
+ prepareArguments: prepareViewImageArguments,
134
152
  async execute(toolCallId, params, signal, _onUpdate, ctx) {
135
153
  if (!supportsImageInputs(ctx.model)) {
136
154
  throw new Error(VIEW_IMAGE_UNSUPPORTED_MESSAGE);
@@ -106,6 +106,7 @@ export function createWebSearchTool(): ToolDefinition<typeof WEB_SEARCH_PARAMETE
106
106
  promptSnippet:
107
107
  "Search the web for sources relevant to the current task. Use it when you need up-to-date information, external references, or broader context beyond the workspace.",
108
108
  parameters: WEB_SEARCH_PARAMETERS,
109
+ prepareArguments: () => ({}),
109
110
  async execute(_toolCallId, _params, _signal, _onUpdate, ctx) {
110
111
  if (!supportsNativeWebSearch(ctx.model)) {
111
112
  throw new Error(WEB_SEARCH_UNSUPPORTED_MESSAGE);