Skip to content

feat: Implement github_repo_contents in read_tools.py + test#3

Merged
mabry1985 merged 1 commit into
mainfrom
feat/github-plugin-1ez.3
Jun 21, 2026
Merged

feat: Implement github_repo_contents in read_tools.py + test#3
mabry1985 merged 1 commit into
mainfrom
feat/github-plugin-1ez.3

Conversation

@mabry1985

Copy link
Copy Markdown
Contributor

I'll start by reading the key files to understand the codebase conventions.I'll start by reading the key files to understand the codebase conventions.Let me check the gh_cli.py helpers to confirm signatures.Let me check the ruff config to match line-length and formatting conventions.Now I'll implement github_repo_contents. Let me replace the stub body and clean its docstring.Now let me append the tests.Now append the test cases at the end of the file.Let me verify the package import setup and run the gate to confirm correctness.The async failures are environmental — pytest-asyncio isn't installed locally (the pre-existing tests fail identically). Let me install dev deps and re-run for a true verification.All 13 read_tools tests pass. Let me run the full gate.Full gate is green: 24 passed, ruff check clean, ruff format --check clean.

Summary

Implemented github_repo_contents in read_tools.py and added tests.

read_tools.py — replaced the stub body (kept the docstring as a plain string, dropped the TODO note):

  1. Validates repo via bad_repo() (early-return error string).
  2. Builds ["api", f"repos/{repo}/contents/{path}"], using repos/{repo}/contents (no trailing slash) when path is empty.
  3. Appends "-f", f"ref={ref}" when ref.strip() is non-empty.
  4. Runs run_gh, surfaces check_gh_error() failures.
  5. Parses JSON; on JSONDecodeError returns Error: could not parse gh output: ….
  6. Empty array → No contents in {repo}/{path or '.'}.
  7. Formats each entry as {type:4s} {size:>8s} {name} ({path}) with a file→FILE, dir→DIR , symlink→LINK, submodule→SUB map (dirs show size 0), under a {repo}/{path or '.'} — {n} item(s): header.

tests/test_read_tools.py — appended a _repo_contents_tool() helper and 7 tests covering the 5 required cases (success with FILE/DIR + sizes, empty dir, invalid repo with run_gh not called, gh error, bad JSON) plus root-endpoint-has-no-trailing-slash and ref-passed-to-args.

Only the two target files were touched; no other function in read_tools.py was modified.

@protoquinn

protoquinn Bot commented Jun 21, 2026

Copy link
Copy Markdown

👀 Quinn is reviewing — verdict (PASS / WARN / FAIL) + findings to follow.

@protoquinn protoquinn Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

QA Audit — PR #3 | feat: Implement github_repo_contents in read_tools.py + test

VERDICT: WARN (pending terminal CI — test still queued; re-evaluating to PASS on green)


CI Status

  • test: queued ⏳

Diff Review

  • read_tools.py: stub replaced with working github_repo_contentsbad_repo() gate, args build (no trailing slash at root), ref plumbing via -f, check_gh_error() surfacing, JSON parse guard, empty-array message, and compact {type:4s} {size:>8s} {name} ({path}) listing. Clean.
  • tests/test_read_tools.py: 7 new tests covering success (FILE+DIR), root path, ref arg, empty dir, bad repo, gh error, bad JSON. All mock run_gh — no network. Good coverage.

Observations

  • LOW: json.loads(out) can return a dict (single file) rather than a list (directory). Iterating a dict crashes on entry.get(). The tool is documented as a directory lister and github_read_file covers the file case, so this is a misuse path, but an isinstance(items, list) guard would produce a readable error instead of a traceback if an agent misroutes.

— Quinn, QA Engineer

@protoquinn

protoquinn Bot commented Jun 21, 2026

Copy link
Copy Markdown

Submitted COMMENT review on #3.

@mabry1985 mabry1985 merged commit 70b665e into main Jun 21, 2026
1 check passed
@mabry1985 mabry1985 deleted the feat/github-plugin-1ez.3 branch June 21, 2026 19:56
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.

1 participant