fix: fix plan mode path resolution on Windows (#365)
Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { homedir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
|
||||
const adjectives = [
|
||||
"bold",
|
||||
@@ -113,5 +114,5 @@ export function generatePlanName(): string {
|
||||
|
||||
export function generatePlanFilePath(): string {
|
||||
const name = generatePlanName();
|
||||
return `${homedir()}/.letta/plans/${name}.md`;
|
||||
return join(homedir(), ".letta", "plans", `${name}.md`);
|
||||
}
|
||||
|
||||
28
src/tests/helpers/planName.test.ts
Normal file
28
src/tests/helpers/planName.test.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { sep } from "node:path";
|
||||
import {
|
||||
generatePlanFilePath,
|
||||
generatePlanName,
|
||||
} from "../../cli/helpers/planName";
|
||||
|
||||
test("generatePlanName returns valid format", () => {
|
||||
const name = generatePlanName();
|
||||
expect(name).toMatch(/^[a-z]+-[a-z]+-[a-z]+$/);
|
||||
});
|
||||
|
||||
test("generatePlanFilePath uses platform-specific path separator", () => {
|
||||
const path = generatePlanFilePath();
|
||||
expect(path).toContain(sep);
|
||||
expect(path).toMatch(/\.letta.+plans.+/);
|
||||
});
|
||||
|
||||
test("generatePlanFilePath ends with .md extension", () => {
|
||||
const path = generatePlanFilePath();
|
||||
expect(path).toMatch(/\.md$/);
|
||||
});
|
||||
|
||||
test("generatePlanFilePath contains valid plan name structure", () => {
|
||||
const path = generatePlanFilePath();
|
||||
const basename = path.split(sep).pop();
|
||||
expect(basename).toMatch(/^[a-z]+-[a-z]+-[a-z]+\.md$/);
|
||||
});
|
||||
Reference in New Issue
Block a user