fix(coding-agent): centralize package source normalization and local path parsing fixes #1304

This commit is contained in:
Mario Zechner 2026-02-06 00:20:52 +01:00
parent 8792ee2a66
commit 6b0f1fefdb
5 changed files with 178 additions and 121 deletions

View file

@ -1,4 +1,4 @@
import { mkdirSync, readFileSync, rmSync } from "node:fs";
import { mkdirSync, readFileSync, realpathSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { afterEach, beforeEach, describe, expect, it } from "vitest";
@ -38,6 +38,20 @@ describe("package commands", () => {
rmSync(tempDir, { recursive: true, force: true });
});
it("should persist global relative local package paths relative to settings.json", async () => {
const relativePkgDir = join(projectDir, "packages", "local-package");
mkdirSync(relativePkgDir, { recursive: true });
await main(["install", "./packages/local-package"]);
const settingsPath = join(agentDir, "settings.json");
const settings = JSON.parse(readFileSync(settingsPath, "utf-8")) as { packages?: string[] };
expect(settings.packages?.length).toBe(1);
const stored = settings.packages?.[0] ?? "";
const resolvedFromSettings = realpathSync(join(agentDir, stored));
expect(resolvedFromSettings).toBe(realpathSync(relativePkgDir));
});
it("should remove local packages using a path with a trailing slash", async () => {
await main(["install", `${packageDir}/`]);