poe-code 4.0.11 → 4.0.13
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/dist/cli/commands/harness.js +41 -3
- package/dist/cli/commands/harness.js.map +1 -1
- package/dist/index.js +1050 -420
- package/dist/index.js.map +4 -4
- package/dist/metafile.json +1 -1
- package/package.json +2 -1
- package/packages/safejs/dist/cli.js +24 -1
- package/packages/safejs/dist/index.d.ts +2 -0
- package/packages/safejs/dist/index.js +1 -0
- package/packages/safejs/dist/interp/cancel.js +4 -0
- package/packages/safejs/dist/interp/host-bridge.js +32 -1
- package/packages/safejs/dist/interp/promise.d.ts +1 -0
- package/packages/safejs/dist/interp/promise.js +10 -2
- package/packages/safejs/dist/modules/canonical-path.d.ts +15 -0
- package/packages/safejs/dist/modules/canonical-path.js +161 -0
- package/packages/safejs/dist/modules/fs.conformance-cases.d.ts +99 -0
- package/packages/safejs/dist/modules/fs.conformance-cases.js +1293 -0
- package/packages/safejs/dist/modules/fs.d.ts +72 -0
- package/packages/safejs/dist/modules/fs.js +558 -0
- package/packages/safejs/dist/modules/git.js +13 -33
- package/packages/safejs/dist/run.js +2 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
|
-
import { mkdir, realpath, rm } from "node:fs/promises";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { mkdir, readlink, realpath, rm, stat } from "node:fs/promises";
|
|
3
|
+
import { dirname, isAbsolute, resolve } from "node:path";
|
|
4
|
+
import { containsPath, isSamePath, resolveCanonicalPath } from "./canonical-path.js";
|
|
5
5
|
const GIT_EXEC_MAX_BUFFER = 10 * 1024 * 1024;
|
|
6
6
|
const SAVEPOINT_REF_PREFIX = "refs/poe-code/checkpoints/";
|
|
7
7
|
export function makeGitModule(cwd) {
|
|
@@ -228,40 +228,20 @@ async function resolveWorktreePath(repoRoot, path, label) {
|
|
|
228
228
|
const resolvedRoot = resolve(repoRoot);
|
|
229
229
|
const resolvedPath = isAbsolute(path) ? resolve(path) : resolve(resolvedRoot, path);
|
|
230
230
|
const canonicalRoot = await realpath(resolvedRoot);
|
|
231
|
-
const canonicalPath = await resolveCanonicalPath(resolvedPath);
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
231
|
+
const canonicalPath = await resolveCanonicalPath({ realpath, readlink }, resolvedPath);
|
|
232
|
+
// A worktree lives somewhere under the repository, never at the repository root
|
|
233
|
+
// itself, so root-itself is rejected alongside anything outside it. Both answers
|
|
234
|
+
// come from the filesystem rather than the spelling: on a case-insensitive
|
|
235
|
+
// filesystem a differently cased path still names the repository root.
|
|
236
|
+
const [inside, isRootItself] = await Promise.all([
|
|
237
|
+
containsPath(stat, canonicalRoot, canonicalPath),
|
|
238
|
+
isSamePath(stat, canonicalPath, canonicalRoot)
|
|
239
|
+
]);
|
|
240
|
+
if (!inside || isRootItself) {
|
|
237
241
|
throw new Error(`${label} must be inside the git repository.`);
|
|
238
242
|
}
|
|
239
243
|
return canonicalPath;
|
|
240
244
|
}
|
|
241
|
-
async function resolveCanonicalPath(path) {
|
|
242
|
-
const missingSegments = [];
|
|
243
|
-
let current = path;
|
|
244
|
-
while (true) {
|
|
245
|
-
try {
|
|
246
|
-
const canonicalCurrent = await realpath(current);
|
|
247
|
-
return resolve(canonicalCurrent, ...missingSegments.reverse());
|
|
248
|
-
}
|
|
249
|
-
catch (error) {
|
|
250
|
-
if (!isNotFoundError(error)) {
|
|
251
|
-
throw error;
|
|
252
|
-
}
|
|
253
|
-
const parent = dirname(current);
|
|
254
|
-
if (parent === current) {
|
|
255
|
-
return resolve(path);
|
|
256
|
-
}
|
|
257
|
-
missingSegments.push(basename(current));
|
|
258
|
-
current = parent;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
function isNotFoundError(error) {
|
|
263
|
-
return hasOwnErrorCode(error, "ENOENT");
|
|
264
|
-
}
|
|
265
245
|
function isBranchAlreadyExistsError(error, branch) {
|
|
266
246
|
return (error instanceof Error &&
|
|
267
247
|
error.message.includes(branch) &&
|
|
@@ -16,7 +16,7 @@ import { createMiscGlobals } from "./interp/globals/misc.js";
|
|
|
16
16
|
import { createObjectArrayGlobals } from "./interp/globals/object-array.js";
|
|
17
17
|
import { wrapCallerInjectedBindings } from "./interp/host-bridge.js";
|
|
18
18
|
import { interpret, Scope } from "./interp/interpreter.js";
|
|
19
|
-
import { createPromiseGlobals } from "./interp/promise.js";
|
|
19
|
+
import { consumeSettledHostCall, createPromiseGlobals } from "./interp/promise.js";
|
|
20
20
|
import { deepCopyToSandbox, isSandboxClosure, isSandboxPromise } from "./interp/values.js";
|
|
21
21
|
import { resolveModuleImports } from "./modules/registry.js";
|
|
22
22
|
import { activateOtelSink, getActiveOtelSpan, safeAddEvent } from "./observability/otel.js";
|
|
@@ -239,9 +239,7 @@ async function throwIfReturnedPromiseRejected(result) {
|
|
|
239
239
|
await Promise.resolve();
|
|
240
240
|
await Promise.resolve();
|
|
241
241
|
if (rejected) {
|
|
242
|
-
|
|
243
|
-
result.returnValue.hostCallJournal?.consume(result.returnValue.hostCall);
|
|
244
|
-
}
|
|
242
|
+
consumeSettledHostCall(result.returnValue);
|
|
245
243
|
throw new UnhandledRejectionError(rejectionReason, result.returnValue.span);
|
|
246
244
|
}
|
|
247
245
|
}
|