1b279d4d10
Lua CI / lua-language-server type check (push) Failing after 1s
Lua CI / luacheck lint (push) Failing after 1s
Python CI / Python bindings (ubuntu-latest) (push) Failing after 1s
Build & Publish / Build Neovim aarch64-linux-android (push) Failing after 3s
Build & Publish / Build Neovim aarch64-unknown-linux-gnu (push) Failing after 0s
Build & Publish / Build Neovim aarch64-unknown-linux-musl (push) Failing after 1s
Build & Publish / Build Neovim x86_64-unknown-linux-gnu (push) Failing after 1s
Build & Publish / Build Neovim x86_64-unknown-linux-musl (push) Failing after 1s
Build & Publish / Build C FFI aarch64-linux-android (push) Failing after 1s
Build & Publish / Build C FFI aarch64-unknown-linux-gnu (push) Failing after 1s
Build & Publish / Build C FFI aarch64-unknown-linux-musl (push) Failing after 0s
Build & Publish / Build C FFI x86_64-unknown-linux-gnu (push) Failing after 1s
Build & Publish / Build C FFI x86_64-unknown-linux-musl (push) Failing after 3s
Build & Publish / Build MCP aarch64-unknown-linux-gnu (push) Failing after 1s
Build & Publish / Build MCP aarch64-unknown-linux-musl (push) Failing after 0s
Build & Publish / Build MCP x86_64-unknown-linux-gnu (push) Failing after 2s
Rust CI / Fuzz Tests (ubuntu-latest) (push) Failing after 1s
Rust CI / Build i686-unknown-linux-gnu (push) Failing after 1s
Rust CI / cargo fmt (push) Failing after 1s
Build & Publish / Build MCP x86_64-unknown-linux-musl (push) Failing after 4s
Build & Publish / Build Python wheels aarch64 (ubuntu-latest) (push) Failing after 1s
Build & Publish / Build Python wheels x86_64 (ubuntu-latest) (push) Failing after 1s
Build & Publish / Build Python sdist (push) Failing after 0s
Rust CI / Test (ubuntu-latest) (push) Failing after 1s
Rust CI / cargo clippy (push) Failing after 1s
Spelling / Spell Check with Typos (push) Failing after 1s
Stylua / Check lua files using Stylua (push) Failing after 1s
e2e Tests / e2e (ubuntu-latest) (push) Failing after 4s
e2e Tests / e2e (alpine-musl) (push) Successful in 58m54s
Build & Publish / Build C FFI aarch64-apple-darwin (push) Has been cancelled
Build & Publish / Build C FFI aarch64-pc-windows-msvc (push) Has been cancelled
Build & Publish / Build C FFI x86_64-apple-darwin (push) Has been cancelled
Build & Publish / Build C FFI x86_64-pc-windows-msvc (push) Has been cancelled
e2e Tests / e2e (macos-latest) (push) Has been cancelled
e2e Tests / e2e (windows-latest) (push) Has been cancelled
Nix CI / check (push) Has been cancelled
Python CI / Python bindings (macos-latest) (push) Has been cancelled
Python CI / Python bindings (windows-latest) (push) Has been cancelled
Build & Publish / Build Neovim aarch64-apple-darwin (push) Has been cancelled
Build & Publish / Build Neovim aarch64-pc-windows-msvc (push) Has been cancelled
Build & Publish / Build Neovim x86_64-apple-darwin (push) Has been cancelled
Build & Publish / Build Neovim x86_64-pc-windows-msvc (push) Has been cancelled
Build & Publish / Build MCP aarch64-apple-darwin (push) Has been cancelled
Build & Publish / Build MCP aarch64-pc-windows-msvc (push) Has been cancelled
Build & Publish / Build MCP x86_64-apple-darwin (push) Has been cancelled
Build & Publish / Build MCP x86_64-pc-windows-msvc (push) Has been cancelled
Build & Publish / Build Python wheels aarch64 (macos-latest) (push) Has been cancelled
Build & Publish / Build Python wheels x86_64 (macos-latest) (push) Has been cancelled
Build & Publish / Build Python wheels x86_64 (windows-latest) (push) Has been cancelled
Build & Publish / Release (push) Has been cancelled
Build & Publish / Publish Python wheels to PyPI (push) Has been cancelled
Build & Publish / Publish Rust crates (push) Has been cancelled
Build & Publish / Publish npm packages (push) Has been cancelled
Rust CI / Test (macos-latest) (push) Has been cancelled
Rust CI / Test (windows-latest) (push) Has been cancelled
Rust CI / Fuzz Tests (macos-latest) (push) Has been cancelled
Rust CI / Fuzz Tests (windows-latest) (push) Has been cancelled
72 lines
2.8 KiB
TypeScript
72 lines
2.8 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { buildQuery, normalizePathConstraint } from "../src/query";
|
|
|
|
const cwd = "/tmp/workspace";
|
|
|
|
describe("path constraint normalization", () => {
|
|
test("converts absolute in-workspace paths to repo-relative constraints", () => {
|
|
expect(normalizePathConstraint("/tmp/workspace/.agents/**", cwd)).toBe(".agents/");
|
|
expect(normalizePathConstraint("/tmp/workspace/.agents/plans/**", cwd)).toBe(
|
|
".agents/plans/",
|
|
);
|
|
});
|
|
|
|
test("rejects absolute paths outside the workspace", () => {
|
|
expect(() => normalizePathConstraint("/tmp/other/.agents/**", cwd)).toThrow(
|
|
"Path constraint must be relative to the workspace",
|
|
);
|
|
});
|
|
|
|
test("collapses only simple trailing recursive directory globs", () => {
|
|
expect(normalizePathConstraint(".agents/**", cwd)).toBe(".agents/");
|
|
expect(normalizePathConstraint("src/**/*", cwd)).toBe("src/");
|
|
expect(normalizePathConstraint("src/**/*.ts", cwd)).toBe("src/**/*.ts");
|
|
expect(normalizePathConstraint("{src,lib}/**", cwd)).toBe("{src,lib}/**");
|
|
});
|
|
|
|
test("builds find queries with normalized include and exclude constraints", () => {
|
|
expect(
|
|
buildQuery("/tmp/workspace/.agents/**", "*", "/tmp/workspace/test/**", cwd),
|
|
).toBe(".agents/ !test/ *");
|
|
});
|
|
|
|
test("treats path='.' as workspace root (no constraint)", () => {
|
|
expect(normalizePathConstraint(".", cwd)).toBeNull();
|
|
expect(normalizePathConstraint("./", cwd)).toBeNull();
|
|
expect(buildQuery(".", "needle", undefined, cwd)).toBe("needle");
|
|
});
|
|
|
|
test("treats absolute workspace root as no constraint", () => {
|
|
expect(normalizePathConstraint(cwd, cwd)).toBeNull();
|
|
expect(buildQuery(cwd, "needle", undefined, cwd)).toBe("needle");
|
|
});
|
|
|
|
test("bare directory path without trailing slash becomes PathSegment", () => {
|
|
expect(normalizePathConstraint("app", cwd)).toBe("app/");
|
|
expect(normalizePathConstraint("src/nested", cwd)).toBe("src/nested/");
|
|
expect(buildQuery("app", "needle", undefined, cwd)).toBe("app/ needle");
|
|
});
|
|
|
|
test("converts absolute in-workspace file path to repo-relative", () => {
|
|
expect(normalizePathConstraint("/tmp/workspace/src/main.rs", cwd)).toBe(
|
|
"src/main.rs",
|
|
);
|
|
expect(buildQuery("/tmp/workspace/src/main.rs", "needle", undefined, cwd)).toBe(
|
|
"src/main.rs needle",
|
|
);
|
|
});
|
|
|
|
test("converts absolute in-workspace directory (without trailing slash) to repo-relative", () => {
|
|
expect(normalizePathConstraint("/tmp/workspace/src", cwd)).toBe("src/");
|
|
expect(buildQuery("/tmp/workspace/src", "needle", undefined, cwd)).toBe(
|
|
"src/ needle",
|
|
);
|
|
});
|
|
|
|
test("converts absolute in-workspace glob path to repo-relative glob", () => {
|
|
expect(normalizePathConstraint("/tmp/workspace/src/**/*.ts", cwd)).toBe(
|
|
"src/**/*.ts",
|
|
);
|
|
});
|
|
});
|