Skip to content

armgit / Ix

Public Imported from GitHub
0

Understand any codebase instantly. System intelligence for codebases, built for humans and AI.

fix(issue): specific names first; rank no website, playground or e2e code

KageBinaryb62b52488fde
diff --git a/ix-cli/src/cli/__tests__/context-from-issue.test.ts b/ix-cli/src/cli/__tests__/context-from-issue.test.ts
index a61672af..68189e52 100644
--- a/ix-cli/src/cli/__tests__/context-from-issue.test.ts
+++ b/ix-cli/src/cli/__tests__/context-from-issue.test.ts
@@ -71,6 +71,13 @@ describe("extractCandidates", () => {
}
});
+ it("tries a specific single word before a common one the issue mentions first", () => {
+ // Three names become starts. `repeat` came first in the issue and took a
+ // slot `Stylesheet` needed.
+ const { identifiers } = extractCandidates("`repeat` then `ignore` breaks `Stylesheet` and `Selector`");
+ expect(identifiers).toEqual(["Stylesheet", "Selector", "repeat", "ignore"]);
+ });
+
it("drops short backticked words and keeps a name once", () => {
const { identifiers } = extractCandidates("`id` and `run` then `listByKind` and listByKind again");
expect(identifiers).toEqual(["listByKind"]);
@@ -81,11 +88,19 @@ describe("isSourcePath", () => {
it("accepts code and refuses tests, fixtures, docs, build output, vendored and non-code files", () => {
expect(isSourcePath("src/cli/commands/rank.ts")).toBe(true);
expect(isSourcePath("keras/src/saving/saving_api.py")).toBe(true);
+ // Only the directory: a file named for one is code.
+ for (const code of ["src/website.ts", "lib/playground.js", "src/sites/a.ts", "src/benchmark/timer.ts"]) {
+ expect(isSourcePath(code), code).toBe(true);
+ }
for (const noise of [
"src/css/preflight.css", "CHANGELOG.md", "docs/api.ts", "package.json",
"src/__tests__/rank.test.ts", "tests/test_saving.py", "src/saving_test.py",
"test-fixtures/typescript/sample.ts", "__fixtures__/a.js", "examples/demo.js",
"vendor/lib.js", "dist/index.js", "build/out.js", "lib/jquery.min.js",
+ // A project's website, playground, test config, benchmarks, stories, e2e.
+ "site/src/routes/index.svelte", "website/static/worker.js", "packages/docs-site/a.ts",
+ "website/playground/markdown.js", "tests_config/run_spec.js", "test-config/setup.js",
+ "benchmarks/run.py", ".storybook/main.js", "packages/app/e2e/login.ts", "cypress/support/a.js",
]) {
expect(isSourcePath(noise), noise).toBe(false);
}
diff --git a/ix-cli/src/cli/explain/issue.ts b/ix-cli/src/cli/explain/issue.ts
index ee385ff5..dab75497 100644
--- a/ix-cli/src/cli/explain/issue.ts
+++ b/ix-cli/src/cli/explain/issue.ts
@@ -61,10 +61,17 @@ const CODE_FILE = new RegExp(`\\.(?:${CODE_EXTENSIONS.join("|")})$`);
/**
* Not code a fix edits: tests, test data, samples, docs, vendored or built
* output. The pilot's list, plus what `isTestPath` already knows.
+ *
+ * The second line is a project's website, playground, test configuration,
+ * benchmarks, stories and end-to-end suites. Svelte's `site/` alone was 40
+ * of the wrong files in Ix's top-10 rankings over two samples of issues; none
+ * of these directories holds any of the 932 files the 382 SWE-PolyBench
+ * Verified fixes change.
*/
const NOISE = new RegExp(
"(^|/)(__tests__|tests?|spec|specs|fixtures?|__fixtures__|test-fixtures|samples|examples?|vendor|"
- + "third_party|node_modules|dist|build|coverage|docs?|changelog_unreleased)/"
+ + "third_party|node_modules|dist|build|coverage|docs?|changelog_unreleased|"
+ + "site|website|docs-site|playground|tests?[_-]config|benchmarks|\\.?storybook|e2e|cypress|integration-tests)/"
+ "|\\.(test|spec)\\.[^/]+$|\\.min\\.js$|(^|/)test_[^/]+\\.py$|_test\\.(py|go)$",
);
@@ -107,9 +114,17 @@ export function extractCandidates(text: string): IssueCandidates {
const inTicks = [...prose.matchAll(BACKTICK)].flatMap((m) => [...m[1].matchAll(WORD)].map((w) => w[0]));
const multi = [...inTicks, ...[...prose.matchAll(IDENT)].map((m) => m[0])].filter((t) => IDENT_FULL.test(t));
const single = inTicks.filter((t) => !IDENT_FULL.test(t) && t.length >= 4);
+ // Only MAX_STARTS names become starts, so order decides: a short common
+ // word (`repeat`, `ignore`) mentioned first took a slot a specific one
+ // (`Stylesheet`) mentioned later needed. Common words still resolve, last.
+ const ordered = [
+ ...multi,
+ ...single.filter((t) => !isGenericIdentifier(t)),
+ ...single.filter((t) => isGenericIdentifier(t)),
+ ];
const seen = new Set(paths);
const identifiers: string[] = [];
- for (const token of [...multi, ...single]) {
+ for (const token of ordered) {
if (seen.has(token)) continue;
seen.add(token);
identifiers.push(token);