Understand any codebase instantly. System intelligence for codebases, built for humans and AI.
TypeScript aiai-memoryclaude-codeclicode-analysiscode-mappingcode-memorycodebase-understandingcodexdeveloper-toolsllmopenclawpersistent-memoryprogram-analysissoftware-architecturesystem-intelligencesystem-mapping
fix(around): compare the target and the workspace root in one spelling
KageBinary2b065ddcbfbc
diff --git a/ix-cli/src/cli/__tests__/around.test.ts b/ix-cli/src/cli/__tests__/around.test.tsindex 873f7bfa..19d2ee1d 100644--- a/ix-cli/src/cli/__tests__/around.test.ts+++ b/ix-cli/src/cli/__tests__/around.test.ts@@ -1,6 +1,6 @@// Copyright 2026 Ix Infrastructure Inc.-import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";+import { mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from "node:fs";import { tmpdir } from "node:os";import { join } from "node:path";import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";@@ -16,6 +16,7 @@ import {} from "../around.js";import { aroundJson, renderAroundLlm, renderAroundText } from "../around-render.js";import { SourceFiles } from "../edge-sites.js";+import { aroundRelPath } from "../commands/around.js";describe("parseAroundTarget", () => {it("reads a path, a line, and a range", () => {@@ -31,6 +32,23 @@ describe("parseAroundTarget", () => {});});+describe("aroundRelPath", () => {+ it("places an absolute path reached through a link inside the workspace", () => {+ const base = mkdtempSync(join(tmpdir(), "ix-around-link-"));+ try {+ const root = join(base, "repo");+ mkdirSync(join(root, "src"), { recursive: true });+ writeFileSync(join(root, "src/a.ts"), "export const a = 1;\n");+ symlinkSync(root, join(base, "link"), "dir");+ expect(aroundRelPath(join(base, "link/src/a.ts"), root)).toBe("src/a.ts");+ expect(aroundRelPath(join(root, "src/a.ts"), join(base, "link"))).toBe("src/a.ts");+ expect(aroundRelPath(join(base, "elsewhere.ts"), root)).toBeUndefined();+ } finally {+ rmSync(base, { recursive: true, force: true });+ }+ });+});+describe("isTestFile", () => {it("knows the test layouts of the benchmark languages", () => {for (const p of [diff --git a/ix-cli/src/cli/commands/around.ts b/ix-cli/src/cli/commands/around.tsindex e928c178..5c49682d 100644--- a/ix-cli/src/cli/commands/around.ts+++ b/ix-cli/src/cli/commands/around.ts@@ -12,6 +12,7 @@ import { parseBudgetOption } from "../options.js";import { isQuiet } from "../output-shape.js";import { stderr } from "../stderr.js";import { SourceFiles } from "../edge-sites.js";+import { canonicalPath } from "../hook/session.js";import {AroundError, DEFAULT_CAPS, DEFAULT_TOKEN_BUDGET, fitToBudget, gatherAround, parseAroundTarget,type AroundCaps, type AroundResult,@@ -52,6 +53,17 @@ export function resolveAroundFile(file: string, root: string, cwd = process.cwd(return fs.existsSync(fromCwd) ? fromCwd : fromRoot;}+/**+ * `abs` relative to the workspace root, `/`-separated, or undefined when it is+ * outside it. Both sides in their canonical spelling: an absolute path through+ * a link (macOS's /tmp, a symlinked checkout) names a file inside a root+ * registered under the other spelling.+ */+export function aroundRelPath(abs: string, root: string): string | undefined {+ const rel = path.relative(canonicalPath(root), canonicalPath(abs)).split(path.sep).join("/");+ return rel.startsWith("..") || path.isAbsolute(rel) ? undefined : rel;+}+export function capsFor(limit: number): AroundCaps {return {...DEFAULT_CAPS,@@ -86,8 +98,8 @@ Examples:}const root = resolveWorkspaceRoot();const abs = resolveAroundFile(parsed.file, root);- const relPath = path.relative(root, abs).split(path.sep).join("/");- if (relPath.startsWith("..") || path.isAbsolute(relPath)) {+ const relPath = aroundRelPath(abs, root);+ if (relPath === undefined) {reportError("path_outside_workspace", `${abs} is outside the workspace root ${root}.`, opts.format);return;}