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
feat(ingest): let a repo say which of its files are not the point (#699)
Ian Hock3e9269e89d00
diff --git a/ix-cli/src/cli/__tests__/ignore-globs.test.ts b/ix-cli/src/cli/__tests__/ignore-globs.test.tsnew file mode 100644index 00000000..e62c43ff--- /dev/null+++ b/ix-cli/src/cli/__tests__/ignore-globs.test.ts@@ -0,0 +1,97 @@+// Copyright 2026 Ix Infrastructure Inc.++import { describe, expect, it } from "vitest";++import { createIgnoreMatcher, parseIgnoreFile, parseIgnorePattern } from "../ignore-globs.js";++function matcher(...lines: string[]) {+ return createIgnoreMatcher(parseIgnoreFile(lines.join("\n")));+}++describe("parsing", () => {+ it("drops comments, blank lines and whitespace", () => {+ expect(parseIgnoreFile("# a comment\n\n fixtures/ \n").map((p) => p.source)).toEqual(["fixtures/"]);+ });++ it("drops a negation rather than pretending to honour it", () => {+ expect(parseIgnorePattern("!keep.ts")).toBeNull();+ });++ it("drops a line too long to be a glob", () => {+ expect(parseIgnorePattern("a".repeat(2000))).toBeNull();+ });++ it("records anchoring and directory-only", () => {+ expect(parseIgnorePattern("/docs/")).toMatchObject({ anchored: true, directoryOnly: true, segments: ["docs"] });+ expect(parseIgnorePattern("docs")).toMatchObject({ anchored: false, directoryOnly: false });+ });+});++describe("matching", () => {+ it("matches a bare name at any depth, as .gitignore does", () => {+ const m = matcher("fixtures/");+ expect(m.matches("tests/fixtures", true)).toBe(true);+ expect(m.matches("tests/fixtures/big.json")).toBe(true);+ expect(m.matches("src/fixtures/a.ts")).toBe(true);+ expect(m.matches("src/fixture-helpers.ts")).toBe(false);+ });++ it("anchors on a leading slash", () => {+ const m = matcher("/docs/");+ expect(m.matches("docs/a.md")).toBe(true);+ expect(m.matches("packages/docs/a.md")).toBe(false);+ });++ it("stops a * at a separator and lets ** cross one", () => {+ expect(matcher("src/*.test.ts").matches("src/a.test.ts")).toBe(true);+ expect(matcher("src/*.test.ts").matches("src/deep/a.test.ts")).toBe(false);+ expect(matcher("src/**/*.test.ts").matches("src/deep/nested/a.test.ts")).toBe(true);+ });++ it("matches ? against exactly one character", () => {+ expect(matcher("a?.ts").matches("ab.ts")).toBe(true);+ expect(matcher("a?.ts").matches("abc.ts")).toBe(false);+ expect(matcher("a?.ts").matches("a/b.ts")).toBe(false);+ });++ it("excludes what is under a directory pattern, not just the entry", () => {+ const m = matcher("django/tests/");+ expect(m.matches("django/tests", true)).toBe(true);+ expect(m.matches("django/tests/models/test_a.py")).toBe(true);+ expect(m.matches("django/db/models.py")).toBe(false);+ });++ it("treats a file pattern as a directory pattern when it matches a parent", () => {+ // `--exclude playground` should take the tree, not nothing.+ expect(matcher("playground").matches("packages/playground/src/main.ts")).toBe(true);+ });++ it("is a no-op with no patterns", () => {+ const m = matcher("", "# nothing");+ expect(m.size).toBe(0);+ expect(m.matches("anything/at/all.ts")).toBe(false);+ });++ it("reads a Windows-style path the same way", () => {+ expect(matcher("fixtures/").matches("tests\\fixtures\\a.json")).toBe(true);+ });+});++describe("no catastrophic backtracking", () => {+ it("answers a pathological pattern in linear time", () => {+ // `.ixignore` comes from the repository being ingested, which is untrusted+ // input. Compiled to a regex, this shape is the classic exponential blowup;+ // matched with two pointers it is not.+ const m = matcher("**a**a**a**a**a**a**a**a**b");+ const started = Date.now();+ expect(m.matches("a/".repeat(40) + "c.ts")).toBe(false);+ expect(Date.now() - started).toBeLessThan(500);+ });++ it("is equally unbothered inside one segment", () => {+ const m = matcher("*a*a*a*a*a*a*a*a*a*a*b.ts");+ const started = Date.now();+ expect(m.matches("a".repeat(2000) + "c.ts")).toBe(false);+ expect(Date.now() - started).toBeLessThan(500);+ });+});diff --git a/ix-cli/src/cli/__tests__/ingest-exclude.test.ts b/ix-cli/src/cli/__tests__/ingest-exclude.test.tsnew file mode 100644index 00000000..f2566fa0--- /dev/null+++ b/ix-cli/src/cli/__tests__/ingest-exclude.test.ts@@ -0,0 +1,100 @@+// Copyright 2026 Ix Infrastructure Inc.++import { afterEach, beforeEach, describe, expect, it } from "vitest";+import { execFileSync } from "node:child_process";+import { mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from "node:fs";+import { tmpdir } from "node:os";+import { join, relative, sep } from "node:path";++import { collectExcludePatterns, tryGitLsFiles, walkFiles } from "../commands/ingest.js";+import { createIgnoreMatcher } from "../ignore-globs.js";++/**+ * A fixture-heavy repository shape: real source, a test tree, and a playground.+ * `IGNORE_DIRS` covers `tests/` on the filesystem walk and nowhere else —+ * `git ls-files`, the discovery path in any git repository, never saw it.+ */+describe("ingest --exclude and .ixignore", () => {+ let root: string;++ beforeEach(() => {+ root = mkdtempSync(join(tmpdir(), "ix-exclude-"));+ for (const dir of ["src", "packages/playground/src", "docs/generated"]) {+ mkdirSync(join(root, dir), { recursive: true });+ }+ writeFileSync(join(root, "src", "a.ts"), "export const a = 1;\n");+ writeFileSync(join(root, "src", "a.test.ts"), "export const t = 1;\n");+ writeFileSync(join(root, "packages/playground/src", "main.ts"), "export const p = 1;\n");+ writeFileSync(join(root, "docs/generated", "api.ts"), "export const d = 1;\n");+ });++ afterEach(() => rmSync(root, { recursive: true, force: true }));++ function walked(patterns: string[] = []): string[] {+ const matcher = createIgnoreMatcher(collectExcludePatterns(root, patterns));+ const exclude = matcher.size > 0 ? { matcher, root } : undefined;+ return [...walkFiles(root, true, exclude)]+ .map((p) => relative(root, p).split(sep).join("/"))+ .sort();+ }++ it("walks everything when nothing is excluded", () => {+ expect(walked()).toEqual([+ "docs/generated/api.ts",+ "packages/playground/src/main.ts",+ "src/a.test.ts",+ "src/a.ts",+ ]);+ });++ it("takes patterns from --exclude", () => {+ expect(walked(["playground", "*.test.ts"])).toEqual([+ "docs/generated/api.ts",+ "src/a.ts",+ ]);+ });++ it("takes patterns from .ixignore at the root", () => {+ writeFileSync(join(root, ".ixignore"), "# generated API surface\ndocs/generated/\n*.test.ts\n");+ expect(walked()).toEqual([+ "packages/playground/src/main.ts",+ "src/a.ts",+ ]);+ });++ it("counts what it skipped, so an exclusion is not mistaken for a miss", () => {+ const matcher = createIgnoreMatcher(collectExcludePatterns(root, ["playground"]));+ let skipped = 0;+ void [...walkFiles(root, true, { matcher, root, onSkip: () => { skipped += 1; } })].length;+ // One skip for the excluded directory, not one per file inside it.+ expect(skipped).toBe(1);+ });++ it("applies to git ls-files too, which is the real discovery path", () => {+ try {+ execFileSync("git", ["init", "-q"], { cwd: root });+ execFileSync("git", ["config", "user.email", "[email protected]"], { cwd: root });+ execFileSync("git", ["config", "user.name", "t"], { cwd: root });+ } catch {+ return; // no git on this machine; the walk path above still covers it+ }+ const matcher = createIgnoreMatcher(collectExcludePatterns(root, ["playground", "docs/"]));+ const files = tryGitLsFiles(root, true, { matcher, root })!;+ // Against the canonical root, resolved the same way the code resolves the+ // files: `tryGitLsFiles` returns `realpathSync.native` paths (the+ // symlink-containment guard), so relativising against the raw root yields+ // a `../../..` chain on both platforms where the two disagree — macOS+ // resolves `/var` to `/private/var`, and Windows expands the `RUNNER~1`+ // 8.3 short name that `os.tmpdir()` hands back. `.native` matters: the JS+ // `realpathSync` follows links but leaves a short name alone.+ // `discoverIngestFilePaths` canonicalises the root for exactly this+ // reason; the test has to as well.+ const canonicalRoot = realpathSync.native(root);+ const rel = files.map((p) => relative(canonicalRoot, p).split(sep).join("/")).sort();+ expect(rel).toEqual(["src/a.test.ts", "src/a.ts"]);+ });++ it("has no patterns, and so no cost, when neither source has any", () => {+ expect(collectExcludePatterns(root, [])).toEqual([]);+ });+});diff --git a/ix-cli/src/cli/commands/ingest.ts b/ix-cli/src/cli/commands/ingest.tsindex 57fa0dd7..b4842dd5 100644--- a/ix-cli/src/cli/commands/ingest.ts+++ b/ix-cli/src/cli/commands/ingest.ts@@ -31,6 +31,10 @@ import {} from '../commit-breaker.js';import { readBackendHealth } from './upgrade.js';import { SUPPORTED_EXTENSIONS } from '../supported-extensions.js';+import {+ createIgnoreMatcher, parseIgnoreFile, parseIgnorePattern,+ type IgnoreMatcher, type IgnorePattern,+} from '../ignore-globs.js';import { canRenderProgress } from '../stderr.js';import { createTypeScriptModuleResolver } from '../ts-module-resolution.js';import {@@ -167,9 +171,10 @@ function parsePositiveIntEnv(name: string, fallback: number): number {return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;}-function* walkFiles(+export function* walkFiles(dir: string,recursive: boolean,+ exclude?: { matcher: IgnoreMatcher; root: string; onSkip?: () => void },): Generator<string> {let entries: fs.Dirent[];try { entries = fs.readdirSync(dir, { withFileTypes: true }); }@@ -179,14 +184,41 @@ function* walkFiles(if (entry.isDirectory() && entry.name.startsWith('.') && entry.name !== '.') continue;if (IGNORE_DIRS.has(entry.name)) continue;const full = nodePath.join(dir, entry.name);+ // Directories are tested before descending, so an excluded tree costs one+ // check rather than one per file inside it.+ if (exclude && exclude.matcher.matches(nodePath.relative(exclude.root, full), entry.isDirectory())) {+ exclude.onSkip?.();+ continue;+ }if (entry.isDirectory()) {- if (recursive) yield* walkFiles(full, true);+ if (recursive) yield* walkFiles(full, true, exclude);} else if (entry.isFile()) {if (isSupportedSourceFile(entry.name) && !isGeneratedFile(entry.name)) yield full;}}}+/**+ * The patterns in force for this ingest: `--exclude` flags first, then the+ * `.ixignore` at the root.+ *+ * `.ixignore` is read from the ingest root only. A per-directory cascade is+ * what `.gitignore` does and it is a lot of stat calls for a file almost+ * nobody will write twice in one repository.+ */+export function collectExcludePatterns(root: string, cliPatterns: string[] = []): IgnorePattern[] {+ const patterns = cliPatterns+ .map((p) => parseIgnorePattern(p))+ .filter((p): p is IgnorePattern => p !== null);+ try {+ const text = fs.readFileSync(nodePath.join(root, '.ixignore'), 'utf-8');+ patterns.push(...parseIgnoreFile(text));+ } catch {+ // No .ixignore is the ordinary case.+ }+ return patterns;+}+function canonicalizeDiscoveredFilePath(filePath: string): string {try {return fs.realpathSync.native(filePath);@@ -276,7 +308,11 @@ export function discoverIngestFilePaths(* looks fine alone. A test that cannot run the real listing cannot show that a* committed symlink escapes in the first place.*/-export function tryGitLsFiles(dir: string, recursive: boolean): string[] | null {+export function tryGitLsFiles(+ dir: string,+ recursive: boolean,+ exclude?: { matcher: IgnoreMatcher; root: string; onSkip?: () => void },+): string[] | null {try {const result = spawnSync('git',@@ -295,6 +331,14 @@ export function tryGitLsFiles(dir: string, recursive: boolean): string[] | nullif (!line) continue;const fullPath = nodePath.resolve(dir, line);if (!recursive && nodePath.dirname(fullPath) !== dir) continue;+ // Before the extension check, so the count reports what the caller+ // excluded rather than what they excluded and Ix would have skipped+ // anyway. `git ls-files` never saw IGNORE_DIRS either, which is why a+ // git repository's `tests/` tree reaches the graph today.+ if (exclude && exclude.matcher.matches(nodePath.relative(exclude.root, fullPath))) {+ exclude.onSkip?.();+ continue;+ }if (!isSupportedSourceFile(fullPath)) continue;if (isGeneratedFile(nodePath.basename(fullPath))) continue;try {@@ -893,10 +937,17 @@ export function registerIngestCommand(program: Command): void {.option('--root <dir>', 'Workspace root directory').option('--debug', 'Show phase timing breakdown', false).option('--lang <langs>', 'Comma-separated languages to include (e.g. cpp,c or typescript). Aliases: c++=cpp, c#=csharp, py=python, ts=typescript, js=javascript')+ .option(+ '--exclude <glob>',+ 'Exclude paths matching this glob (repeatable; same syntax as .ixignore)',+ (value: string, previous: string[] = []) => [...previous, value],+ [] as string[],+ ).addHelpText('after', '\nExamples:\n ix ingest ./src\n ix ingest --path ./src --force\n ix ingest --path ./rocksdb --lang cpp,c\n ix ingest --github owner/repo\n ix ingest --github owner/repo --since 2026-01-01 --limit 20 --format json\n ix ingest --github owner/repo --token ghp_xxxx').action(async (positionalPath: string | undefined, opts: {path?: string; recursive?: boolean; force?: boolean; github?: string; token?: string;since?: string; limit: string; format: string; root?: string; debug?: boolean; lang?: string;+ exclude?: string[];}) => {const effectivePath = positionalPath ?? opts.path;if (opts.github) {@@ -1368,7 +1419,7 @@ export function ingestCompletedCleanly(parseErrors: number, commitErrors: numberexport async function ingestFiles(path: string,- opts: { recursive?: boolean; force?: boolean; format: string; root?: string; debug?: boolean; printSummary?: boolean; suppressOutput?: boolean; lang?: string; mapMode?: boolean; deadlineSignal?: AbortSignal }+ opts: { recursive?: boolean; force?: boolean; format: string; root?: string; debug?: boolean; printSummary?: boolean; suppressOutput?: boolean; lang?: string; mapMode?: boolean; exclude?: string[]; deadlineSignal?: AbortSignal }): Promise<IngestFilesSummary> {const debug = opts.debug || process.env.IX_DEBUG === '1';const mapMode = opts.mapMode === true;@@ -1664,6 +1715,14 @@ export async function ingestFiles(}, 80) : null;let filesDiscovered = 0;+ /**+ * Paths `--exclude` or `.ixignore` kept out of discovery.+ *+ * Reported, because "that file is not in the graph" and "you excluded that+ * file" are different problems with different fixes, and an exclusion nobody+ * is told about is indistinguishable from an ingest that missed something.+ */+ let filesExcluded = 0;let filesChanged = 0;let patchesApplied = 0;let idempotentPatches = 0;@@ -1841,10 +1900,16 @@ export async function ingestFiles(throw new Error(`Path not found: ${resolvedPath}`);}const stat = fs.statSync(resolvedPath);+ const excludePatterns = collectExcludePatterns(resolvedPath, opts.exclude ?? []);+ const excludeMatcher = createIgnoreMatcher(excludePatterns);+ const exclude = excludeMatcher.size > 0+ ? { matcher: excludeMatcher, root: resolvedPath, onSkip: () => { filesExcluded += 1; } }+ : undefined;const discovery = discoverIngestFilePaths(stat.isFile()? (isSupportedSourceFile(resolvedPath) ? [resolvedPath] : [])- : (tryGitLsFiles(resolvedPath, opts.recursive ?? true) ?? Array.from(walkFiles(resolvedPath, opts.recursive ?? true))),+ : (tryGitLsFiles(resolvedPath, opts.recursive ?? true, exclude)+ ?? Array.from(walkFiles(resolvedPath, opts.recursive ?? true, exclude))),stat.isFile() ? undefined : resolvedPath,);const filePaths: string[] = discovery.files;@@ -3550,6 +3615,7 @@ export async function ingestFiles(if (opts.format === 'json') {printJson({filesProcessed: filesDiscovered,+ ...(filesExcluded > 0 ? { filesExcluded } : {}),filesChanged,patchesApplied,filesSkipped,@@ -3598,6 +3664,9 @@ export async function ingestFiles(console.log(chalk.bold('\nIngest summary'));console.log(` processed: ${patchesApplied} files (${elapsed}s)`);console.log(` discovered: ${filesDiscovered} files`);+ if (filesExcluded > 0) {+ console.log(` excluded: ${filesExcluded} paths (--exclude / .ixignore)`);+ }console.log(` changed: ${filesChanged} files`);// "skipped" without "unchanged": the count includes empty, minified-looking// and unparseable files, none of which were assumed unchanged. Splitting thediff --git a/ix-cli/src/cli/ignore-globs.ts b/ix-cli/src/cli/ignore-globs.tsnew file mode 100644index 00000000..c482f48c--- /dev/null+++ b/ix-cli/src/cli/ignore-globs.ts@@ -0,0 +1,200 @@+// Copyright 2026 Ix Infrastructure Inc.++/**+ * `.ixignore` and `ingest --exclude <glob>`.+ *+ * A fixture-heavy repository puts its fixtures in the graph, the map and every+ * search result: Django's test tree and Vite's playground are most of what+ * those repositories contain by file count, and none of it is what someone+ * asking about the repository means. `IGNORE_DIRS` covers the conventional+ * names, but only those, and only for the filesystem walk — `git ls-files`,+ * which is the discovery path in any git repository, never saw it.+ *+ * ## Matching, deliberately a subset of .gitignore+ *+ * Supported: `#` comments, blank lines, `*` (any run of characters except a+ * separator), `?` (one character except a separator), `**` (any run of path+ * segments), a leading `/` to anchor at the ingest root, and a trailing `/` to+ * mean directories only. A pattern with no separator matches at any depth, as+ * in `.gitignore` — `fixtures/` excludes every `fixtures` directory.+ *+ * Not supported, and the file is not silently pretending otherwise: `!`+ * negation and character classes. Both are answers to "I excluded too much",+ * and the honest fix for that is a narrower pattern.+ *+ * ## No regex+ *+ * Patterns arrive from a file inside the repository being ingested, which is+ * untrusted input on the one path in this CLI that parses arbitrary+ * repositories. Compiling a glob to a regex is where `**a**a**b` becomes a+ * catastrophic backtrack, so this matches directly: the classic two-pointer+ * wildcard walk, which remembers the last `*` it passed and resumes there+ * instead of recursing. Worst case is O(pattern x path) with no stack and no+ * exponential blowup.+ */++/** Longest a single pattern may be. A line past this is malformed, not a glob. */+const MAX_PATTERN_LENGTH = 1024;++export interface IgnorePattern {+ /** Segments of the pattern, `/`-split. */+ segments: string[];+ /** The pattern ended in `/`: it matches directories and what is under them. */+ directoryOnly: boolean;+ /** The pattern began with `/`: it matches from the ingest root only. */+ anchored: boolean;+ /** The text as written, for reporting. */+ source: string;+}++/**+ * One path segment against one pattern segment, with `*` and `?`.+ *+ * Two pointers and a remembered star position — no recursion, no regex. On a+ * mismatch after a `*`, the walk resumes one character further along the input+ * rather than re-entering the matcher.+ */+function segmentMatches(pattern: string, text: string): boolean {+ let p = 0;+ let t = 0;+ let starP = -1;+ let starT = 0;++ while (t < text.length) {+ if (p < pattern.length && (pattern[p] === "?" || pattern[p] === text[t])) {+ p += 1;+ t += 1;+ } else if (p < pattern.length && pattern[p] === "*") {+ starP = p;+ starT = t;+ p += 1;+ } else if (starP >= 0) {+ p = starP + 1;+ starT += 1;+ t = starT;+ } else {+ return false;+ }+ }+ while (p < pattern.length && pattern[p] === "*") p += 1;+ return p === pattern.length;+}++/**+ * Pattern segments against path segments, with `**`.+ *+ * Same shape one level up: `**` is the star, and a mismatch after one resumes+ * a segment further along.+ */+function segmentsMatch(pattern: string[], path: string[]): boolean {+ let p = 0;+ let t = 0;+ let starP = -1;+ let starT = 0;++ while (t < path.length) {+ if (p < pattern.length && pattern[p] !== "**" && segmentMatches(pattern[p], path[t])) {+ p += 1;+ t += 1;+ } else if (p < pattern.length && pattern[p] === "**") {+ starP = p;+ starT = t;+ p += 1;+ } else if (starP >= 0) {+ p = starP + 1;+ starT += 1;+ t = starT;+ } else {+ return false;+ }+ }+ while (p < pattern.length && pattern[p] === "**") p += 1;+ return p === pattern.length;+}++/** Parse one line. Returns null for a comment, a blank line, or an overlong one. */+export function parseIgnorePattern(line: string): IgnorePattern | null {+ const trimmed = line.trim();+ if (trimmed === "" || trimmed.startsWith("#")) return null;+ if (trimmed.length > MAX_PATTERN_LENGTH) return null;+ // `!` is not supported, and a pattern that starts with one is more likely a+ // caller expecting negation than a file literally named `!x`. Dropping it+ // beats excluding the opposite of what they meant.+ if (trimmed.startsWith("!")) return null;++ const directoryOnly = trimmed.endsWith("/");+ const body = directoryOnly ? trimmed.slice(0, -1) : trimmed;+ const anchored = body.startsWith("/");+ const normalized = (anchored ? body.slice(1) : body).replace(/\\/g, "/");+ const segments = normalized.split("/").filter((s) => s !== "" && s !== ".");+ if (segments.length === 0) return null;+ return { segments, directoryOnly, anchored, source: trimmed };+}++/** Every usable pattern in a `.ixignore`-shaped file. */+export function parseIgnoreFile(text: string): IgnorePattern[] {+ const out: IgnorePattern[] = [];+ for (const line of text.split(/\r?\n/)) {+ const parsed = parseIgnorePattern(line);+ if (parsed) out.push(parsed);+ }+ return out;+}++export interface IgnoreMatcher {+ /** True when this workspace-relative path is excluded. */+ matches(relativePath: string, isDirectory?: boolean): boolean;+ /** How many patterns are in force. Zero means the matcher is a no-op. */+ readonly size: number;+}++/**+ * A matcher over parsed patterns.+ *+ * An unanchored pattern matches at any depth, which is what makes `fixtures/`+ * mean every `fixtures` directory rather than only one at the root. A+ * directory-only pattern also excludes everything beneath it, because that is+ * the only reading of `fixtures/` anyone means.+ */+export function createIgnoreMatcher(patterns: IgnorePattern[]): IgnoreMatcher {+ return {+ size: patterns.length,+ matches(relativePath: string, isDirectory = false): boolean {+ const path = relativePath.replace(/\\/g, "/").replace(/^\.\//, "");+ const segments = path.split("/").filter((s) => s !== "");+ if (segments.length === 0) return false;++ for (const pattern of patterns) {+ if (pattern.directoryOnly && !isDirectory) {+ // A file is still excluded when a directory pattern matches one of+ // its parents — `fixtures/` means the tree, not the entry.+ if (matchesAnyPrefix(pattern, segments)) return true;+ continue;+ }+ if (matchesAt(pattern, segments)) return true;+ if (pattern.directoryOnly && matchesAnyPrefix(pattern, segments)) return true;+ // A file under an excluded directory, where the pattern had no+ // trailing slash: `docs/generated` excludes `docs/generated/a.ts`.+ if (!pattern.directoryOnly && matchesAnyPrefix(pattern, segments)) return true;+ }+ return false;+ },+ };+}++function matchesAt(pattern: IgnorePattern, segments: string[]): boolean {+ if (pattern.anchored) return segmentsMatch(pattern.segments, segments);+ // Unanchored: try every suffix, so a bare name matches at any depth.+ for (let i = 0; i < segments.length; i += 1) {+ if (segmentsMatch(pattern.segments, segments.slice(i))) return true;+ }+ return false;+}++/** True when the pattern matches some proper ancestor of this path. */+function matchesAnyPrefix(pattern: IgnorePattern, segments: string[]): boolean {+ for (let end = 1; end < segments.length; end += 1) {+ if (matchesAt(pattern, segments.slice(0, end))) return true;+ }+ return false;+}diff --git a/skills/ix/references/flags.md b/skills/ix/references/flags.mdindex 65cf3603..032b1ca3 100644--- a/skills/ix/references/flags.md+++ b/skills/ix/references/flags.md@@ -68,6 +68,13 @@ surfaces (#575).`truncated=true` means the node cap dropped nodes, `depth_limited=true` meansthe walk stopped descending and there may or may not be more. `--depth` and`--cap` take anything.+- **`ix ingest` honours `--exclude <glob>` and a `.ixignore` at the ingest+ root.** A deliberate subset of `.gitignore`: `#` comments, `*`, `?`, `**`, a+ leading `/` to anchor at the root, a trailing `/` for directories only, and a+ bare name matching at any depth. **No** `!` negation and no character+ classes — a pattern that starts with `!` is dropped rather than half-honoured.+ Excluded paths are counted in the ingest summary, so an exclusion is never+ mistaken for a missed file.- **`--pick <n>` is 1-based** everywhere it appears, and is how you resolve anambiguous target without re-running with a longer name.- **`--no-recursive` and `--no-open` negate a default-on behaviour**, so their@@ -373,6 +380,7 @@ Ingest source files or GitHub data into the knowledge graph.| `--root` | `<dir>` | — | Workspace root directory || `--debug` | — | `false` | Show phase timing breakdown || `--lang` | `<langs>` | — | Comma-separated languages to include (e.g. cpp,c or typescript). Aliases: c++=cpp, c#=csharp, py=python, ts=typescript, js=javascript |+| `--exclude` | `<glob>` | — | Exclude paths matching this glob (repeatable; same syntax as `.ixignore`) |### `ix init`