Skip to content

v0.1.1: require explicit repo selection + safe, bounded tool responses - #1

Open
JonZavialov wants to merge 2 commits into
mainfrom
codex/add-explicit-repo-targeting-and-safety-features
Open

v0.1.1: require explicit repo selection + safe, bounded tool responses#1
JonZavialov wants to merge 2 commits into
mainfrom
codex/add-explicit-repo-targeting-and-safety-features

Conversation

@JonZavialov

Copy link
Copy Markdown
Owner

Motivation

  • Prevent Segmint from scanning arbitrary filesystem when launched outside a git repo and give clients an explicit, deterministic way to pick the repository to operate on.
  • Make tool outputs safe for large repos/clients by bounding returned arrays and providing deterministic truncation metadata.
  • Improve first-run UX and cross-client portability by documenting explicit repo selection and adding minimal helpers to resolve repo roots.

Description

  • Added two new Tier-1 tools: set_repo_root { path } which resolves a path to the git toplevel via git -C <path> rev-parse --show-toplevel and stores that repo root in server memory, and get_repo_root which returns the currently active repo root. (src/server.ts, src/exec-git.ts).
  • Enforced repo-safety across all git-backed tools by requiring an active repo root before executing git commands and returning a structured error { isError: true, code: "SEGMINT_NO_REPO", message: "..." } when none is set; server still allows a safe startup fallback only if process cwd is already inside a repo (no wild scanning). (src/server.ts, gating added to all tools).
  • Propagated explicit cwd/repo root into git helpers and read-only modules: execGit/tryExecGit accept cwd, added resolveGitRoot/tryResolveGitRoot, and history, show, diff, blame, changes pipelines accept cwd and use it consistently. (src/exec-git.ts, src/history.ts, src/show.ts, src/diff.ts, src/blame.ts, src/changes.ts).
  • Added deterministic response-size safety via src/limits.ts with truncateArray and capChanges, and surfaced truncated: boolean + omitted_count: number in affected tool outputs (files, changes, hunks, blame lines) with deterministic truncation at 200 entries. Tools now include repo_root where applicable. (src/limits.ts, updated src/server.ts outputs).
  • Added tests to prove the fix and maintain coverage: E2E regression for non-git startup + explicit set_repo_root flow, updated E2E tool listing, unit tests for truncation helpers and set_repo_root error handling, and an integration test for fresh repo HEAD edge case. (tests/e2e/repo-selection-safety.test.ts, updated tests/e2e/mcp-server.test.ts, tests/unit/limits.test.ts, tests/unit/server-repo-root.test.ts, tests/integration/status-empty-repo.test.ts).
  • Documentation and contract updates: README and CLAUDE.md updated with install/run, JSON-RPC examples for set_repo_root/get_repo_root, first-run verification steps, Claude Desktop example (cwd optional), and explicit anti-drift guidance; bumped package to 0.1.1.

Testing

  • Built the project with npm run build; successful.
  • Ran the E2E suite with npm run test:e2e; all E2E tests passed.
  • Ran full coverage with npm run test:coverage; test suite and coverage thresholds passed (build, E2E, integration and unit suites green and global branch coverage >= 95%).
  • New and updated tests exercised: repo_status, list_changes, log, show_commit, diff_between_refs, blame, group_changes against a configured repo root; SEGMINT_NO_REPO behavior when started outside a git repo; truncation helper behavior and fresh-repo HEAD edge case.

Codex Task

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant