Skip to content

feat: Add repo indexer - #502

Open
sonikagutha wants to merge 2 commits into
usemoss:mainfrom
sonikagutha:feat/add-repo-indexer
Open

feat: Add repo indexer#502
sonikagutha wants to merge 2 commits into
usemoss:mainfrom
sonikagutha:feat/add-repo-indexer

Conversation

@sonikagutha

@sonikagutha sonikagutha commented Jul 30, 2026

Copy link
Copy Markdown

Pull Request Checklist

Please ensure that your PR meets the following requirements:

  • I have read the CONTRIBUTING guide.
  • I have updated the documentation (if applicable).
  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

Description

Adds library packages that clone or walk a repository, chunk Markdown and source code, and upload DocumentInfo rows to a Moss index for semantic codebase search.

Packages

packages/moss-repo-indexer (Python)
packages/moss-repo-indexer-js (@moss-tools/repo-indexer, TypeScript)
Behavior

Resolve a local path or shallow-clone a git URL
Discover files with include globs / exclude dirs (respects git ls-files when present)
Chunk Markdown (heading-aware) and code (sliding window + symbol heuristics)
build_documents / sync with dry-run, recreate, or upsert upload
Shared document metadata contract (path, language, type, start_line, end_line, symbol, navigation, etc.)

Fixes #382

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Review in cubic

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codex review

The new repo indexers are generally coherent, but clone errors can leak credentials and git-backed discovery/chunk metadata have correctness gaps.

@sonikagutha sonikagutha changed the title Add repo indexer feat: Add repo indexer Jul 30, 2026
const result = spawnSync('git', args, { encoding: 'utf8' })
if (result.status !== 0) {
const detail = (result.stderr || result.stdout || 'git clone failed').trim()
throw new Error(`Failed to clone ${url}: ${detail}`)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BLOCKING ```ts
throw new Error(Failed to clone ${url}: ${detail})

This formats the raw remote URL into exceptions. Private-repo callers often use tokenized HTTPS remotes, so a clone failure would put credentials in logs. Redact `username/password` from the URL before building the error, scrub the git stderr/stdout detail as well, and mirror that in the Python clone helper.

if (options.respectGitignore && isGitWorkTree(root)) {
const tracked = gitListFiles(root)
if (tracked !== null) {
return tracked

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CONSIDER ```ts
if (tracked !== null) {
return tracked
}

In git worktrees this returns `git ls-files` results before applying `excludeDirs`, so defaults like `node_modules`, `dist`, and `vendor` are ignored whenever those paths are unignored or tracked. Filter tracked paths by path components against `options.excludeDirs` before returning, or apply the exclusion after candidate collection; the Python `_list_candidates` path needs the same fix.

}

export function splitLines(content: string): string[] {
return content.split(/\r?\n/)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CONSIDER ```ts
return content.split(/\r?\n/)

For files ending with a newline, this adds a synthetic final empty line, so line metadata can extend past the last real line and diverges from the Python `splitlines()` behavior. Return `[]` for empty content and drop exactly one trailing empty element after splitting while preserving interior blank lines.

def _is_git_work_tree(root: Path) -> bool:
if not (root / ".git").exists():
return False
result = subprocess.run(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CONSIDER ```py
result = subprocess.run(
["git", "-C", str(root), "rev-parse", "--is-inside-work-tree"],

This probe raises `FileNotFoundError` when a local repo has a `.git` entry but the runtime image does not include `git`, so `discover_files()` fails instead of falling back to `_walk_filesystem`. Check `shutil.which("git")` or catch `FileNotFoundError` in the git probes and return `False`/`None`.

@samanyugoyal2010

Copy link
Copy Markdown
Contributor

@sonikagutha looks good just fix the GitHub actions and then also sign the CLA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Connector: GitHub repository / codebase indexer

3 participants