@howaboua/pi-codex-conversion 1.0.6 → 1.0.8
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/package.json
CHANGED
package/src/patch/paths.ts
CHANGED
|
@@ -8,20 +8,17 @@ export function normalizePatchPath({ path }: { path: string }): string {
|
|
|
8
8
|
return withoutAt.replace(/^['"]|['"]$/g, "");
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
//
|
|
12
|
-
//
|
|
11
|
+
// Relative patch paths stay anchored to ctx.cwd. Absolute patch paths are
|
|
12
|
+
// accepted as-is so the adapter can match Codex-style path usage.
|
|
13
13
|
export function resolvePatchPath({ cwd, patchPath }: { cwd: string; patchPath: string }): string {
|
|
14
14
|
const normalized = normalizePatchPath({ path: patchPath });
|
|
15
15
|
if (!normalized) {
|
|
16
16
|
throw new DiffError("Patch path cannot be empty");
|
|
17
17
|
}
|
|
18
|
-
if (isAbsolute(normalized)) {
|
|
19
|
-
throw new DiffError("We do not support absolute paths.");
|
|
20
|
-
}
|
|
21
18
|
|
|
22
|
-
const absolutePath = resolve(cwd, normalized);
|
|
19
|
+
const absolutePath = isAbsolute(normalized) ? normalized : resolve(cwd, normalized);
|
|
23
20
|
const rel = relative(cwd, absolutePath);
|
|
24
|
-
if (rel.startsWith("..") || isAbsolute(rel)) {
|
|
21
|
+
if (!isAbsolute(normalized) && (rel.startsWith("..") || isAbsolute(rel))) {
|
|
25
22
|
throw new DiffError(`Path escapes working directory: ${normalized}`);
|
|
26
23
|
}
|
|
27
24
|
return absolutePath;
|
|
@@ -5,6 +5,8 @@ export interface PromptSkill {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
const CODEX_GUIDELINES = [
|
|
8
|
+
"Prefer a single `apply_patch` call that updates all related files together when one coherent patch will do.",
|
|
9
|
+
"When multiple tool calls are independent, emit them together so they can execute in parallel instead of serializing them.",
|
|
8
10
|
"Use `parallel` only when tool calls are independent and can safely run at the same time.",
|
|
9
11
|
"Use `write_stdin` when an exec session returns `session_id`, and continue until `exit_code` is present.",
|
|
10
12
|
"Do not request `tty` unless interactive terminal behavior is required.",
|
|
@@ -65,7 +65,7 @@ export interface ExecSessionManager {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
const DEFAULT_EXEC_YIELD_TIME_MS = 10_000;
|
|
68
|
-
const DEFAULT_WRITE_YIELD_TIME_MS =
|
|
68
|
+
const DEFAULT_WRITE_YIELD_TIME_MS = 10_000;
|
|
69
69
|
const DEFAULT_MAX_OUTPUT_TOKENS = 10_000;
|
|
70
70
|
const MIN_YIELD_TIME_MS = 250;
|
|
71
71
|
const MAX_YIELD_TIME_MS = 30_000;
|
|
@@ -292,18 +292,24 @@ export function createExecSessionManager(): ExecSessionManager {
|
|
|
292
292
|
notify(session);
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
-
function
|
|
296
|
-
if (session.
|
|
295
|
+
function waitForExitOrTimeout(session: ExecSession, yieldTimeMs: number): Promise<number> {
|
|
296
|
+
if (session.exitCode !== undefined && session.exitCode !== null) {
|
|
297
297
|
return Promise.resolve(0);
|
|
298
298
|
}
|
|
299
299
|
|
|
300
300
|
const startedAt = Date.now();
|
|
301
301
|
return new Promise((resolvePromise) => {
|
|
302
302
|
const onWake = () => {
|
|
303
|
+
if (session.exitCode === undefined || session.exitCode === null) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
303
306
|
cleanup();
|
|
304
307
|
resolvePromise(Date.now() - startedAt);
|
|
305
308
|
};
|
|
306
|
-
const timeout = setTimeout(
|
|
309
|
+
const timeout = setTimeout(() => {
|
|
310
|
+
cleanup();
|
|
311
|
+
resolvePromise(Date.now() - startedAt);
|
|
312
|
+
}, yieldTimeMs);
|
|
307
313
|
const cleanup = () => {
|
|
308
314
|
clearTimeout(timeout);
|
|
309
315
|
session.listeners.delete(onWake);
|
|
@@ -432,7 +438,7 @@ export function createExecSessionManager(): ExecSessionManager {
|
|
|
432
438
|
sessions.set(session.id, session);
|
|
433
439
|
rememberCommand(session.id, session.command);
|
|
434
440
|
|
|
435
|
-
const waitedMs = await
|
|
441
|
+
const waitedMs = await waitForExitOrTimeout(session, clampYieldTime(input.yield_time_ms, DEFAULT_EXEC_YIELD_TIME_MS));
|
|
436
442
|
return makeResult(session, waitedMs, input.max_output_tokens);
|
|
437
443
|
},
|
|
438
444
|
write: async (input) => {
|
|
@@ -450,7 +456,7 @@ export function createExecSessionManager(): ExecSessionManager {
|
|
|
450
456
|
}
|
|
451
457
|
const waitedMs =
|
|
452
458
|
session.exitCode === undefined
|
|
453
|
-
? await
|
|
459
|
+
? await waitForExitOrTimeout(session, clampYieldTime(input.yield_time_ms, DEFAULT_WRITE_YIELD_TIME_MS))
|
|
454
460
|
: 0;
|
|
455
461
|
return makeResult(session, waitedMs, input.max_output_tokens);
|
|
456
462
|
},
|