Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/skill-path-single-resolver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eve": patch
---

Resolve sandbox skill roots and seed-file paths through the same `$HOME` resolver the file tools use, so the skills location is spelled once instead of twice.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { dirname, join } from "node:path";

import { bufferToStream, streamToBuffer } from "#execution/sandbox/stream-utils.js";
import { WORKSPACE_ROOT } from "#runtime/workspace/types.js";
import { resolveSandboxSeedFilePath } from "#shared/skill-paths.js";
import { resolveSandboxModelPath } from "#shared/skill-paths.js";
import type { SandboxSeedFile } from "#shared/sandbox-backend.js";
import type {
InternalSandboxSession,
Expand Down Expand Up @@ -116,7 +116,7 @@ export async function writeSandboxSeedFiles(
seedFiles: ReadonlyArray<SandboxSeedFile>,
): Promise<void> {
for (const file of seedFiles) {
const path = await resolveSandboxSeedFilePath({
const path = await resolveSandboxModelPath({
path: file.path,
sandbox: session,
});
Expand Down
3 changes: 1 addition & 2 deletions packages/eve/src/shared/skill-paths.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
formatFallbackSkillPath,
formatSkillModelPath,
resolveSandboxModelPath,
resolveSandboxSeedFilePath,
resolveSandboxSkillReadPaths,
resolveSandboxSkillRoot,
} from "#shared/skill-paths.js";
Expand Down Expand Up @@ -126,7 +125,7 @@ describe("skill path helpers", () => {
});

await expect(
resolveSandboxSeedFilePath({
resolveSandboxModelPath({
path: `${MODEL_SKILL_ROOT}/research/references/catalog.md`,
sandbox: sandbox.session,
}),
Expand Down
28 changes: 8 additions & 20 deletions packages/eve/src/shared/skill-paths.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { SandboxSession } from "#shared/sandbox-session.js";

export const MODEL_SKILL_ROOT = "$HOME/.agents/skills";
const MODEL_HOME_ROOT = "$HOME";

export const MODEL_SKILL_ROOT = `${MODEL_HOME_ROOT}/.agents/skills`;
export const FALLBACK_SKILL_ROOT = "/workspace/skills";

const MODEL_HOME_ROOT = "$HOME";
const HOME_SKILL_SUFFIX = ".agents/skills";
const HOME_PROBE_COMMAND = `printf '%s\\n' "$HOME"`;
const sandboxHomeCache = new WeakMap<SandboxSession, Promise<string | null>>();

Expand All @@ -30,11 +30,14 @@ export function formatFallbackSkillPath(input: {
});
}

/**
* Resolves where skills live in the sandbox: under the probed home when it has
* one, and under {@link FALLBACK_SKILL_ROOT} when it does not.
*/
export async function resolveSandboxSkillRoot(input: {
readonly sandbox: SandboxSession;
}): Promise<string> {
const home = await resolveSandboxHome(input.sandbox);
return home === null ? FALLBACK_SKILL_ROOT : joinHomeSkillRoot(home);
return await resolveSandboxModelPath({ path: MODEL_SKILL_ROOT, sandbox: input.sandbox });
}

/**
Expand Down Expand Up @@ -90,17 +93,6 @@ export async function resolveSandboxSkillWritePath(input: {
});
}

export async function resolveSandboxSeedFilePath(input: {
readonly path: string;
readonly sandbox: SandboxSession;
}): Promise<string> {
if (!isModelSkillPath(input.path)) {
return input.path;
}

return await resolveSandboxModelPath(input);
}

function formatSkillPath(input: {
readonly name: string;
readonly relativePath: string;
Expand Down Expand Up @@ -156,10 +148,6 @@ function isUsableSandboxHome(path: string): boolean {
);
}

function joinHomeSkillRoot(home: string): string {
return `${home === "/" ? "" : home}/${HOME_SKILL_SUFFIX}`;
}

function normalizeSandboxHome(home: string): string {
return home === "/" ? home : home.replace(/\/+$/, "");
}
Loading