mirror of
https://github.com/colbymchenry/codegraph.git
synced 2026-11-14 16:52:09 +08:00
The warning for a git worktree answered from another checkout's index
still said to run "codegraph init -i", a flag that has done nothing
since init started indexing by default. Its one-line form is prepended
to every read-tool result and codegraph_status embeds the long form, so
both told the agent to build the index, which the server instructions
rule out ("Indexing is the user's decision ... don't run it yourself").
The CLI's codegraph status now says: Run "codegraph init" in this
worktree. What an agent reads (the read-tool notice, which also reaches
it through the prompt hook and the explore/node CLI, and
codegraph_status) says the user can run "codegraph init" there.
Docs that no longer matched the code:
- AGENTS.md listed 4 of the 11 installer targets, called a new one "a
5th agent", said the contract suite covers "all 4" targets, and listed
11 of the 24 subcommands. It now lists every target and subcommand,
and names the hidden ones (serve --mcp, prompt-hook, and ui/web unless
CODEGRAPH_UI=1).
- README's Supported Agents section said no instructions file is
written, but Claude Code, Codex CLI, Gemini CLI and opencode get the
short CodeGraph section. Its Codex entry now says the Codex IDE
extension reads the same config: $CODEX_HOME/config.toml (default
~/.codex/config.toml) for a global install, and .codex/config.toml,
used only in a trusted project, for a local one.
- README's WSL2 "Transport closed" entry named only the in-process
fallback. The daemon also moves its socket to the temp directory when
the project's filesystem can't host one.
- init -i and -iv leftovers in internal docs, scripts, the add-lang
skill and the repo's own Cursor rule, which now also leaves indexing
to the user. Two stay on purpose: scripts/agent-eval/audit.sh can
audit a published version older than 0.9.8, where init built the
index only with -i (now commented there), and
docs/benchmarks/codegraph-ab-matrix.md records a 0.9.4 run.
Validation:
- worktree-detection.test.ts: on main 61776927's worktree.ts and
tools.ts, 4 of its 20 tests fail (the CLI wording, the agent wording,
the read-tool notice and codegraph_status). With only the worktree.ts
fix, the codegraph_status test still fails. All 20 pass here, and so
do mcp-nested-repo-projectpath.test.ts's 13.
- Full suite on this patch over 61776927 (CODEGRAPH_KERNEL_EXPECT=1,
4 workers): 815 files (809 passed, 6 skipped), 9608 tests passed,
0 failed, 86 skipped.
- Rebased unchanged onto f67eafcb. Its three new commits share only
CHANGELOG.md with this PR, in other bullets. On the rebased tree these
pass (81 tests): worktree-detection, mcp-nested-repo-projectpath, and
the new commits' default-export-declaration,
rust-path-attribute-modules, rust-path-super-glob,
search-special-characters and strip-comments.
Reimplements #549 by @ashishpatel26, #651 by @GaoSSR, #885 and #886 by @Dashsoap, and #1083 by @zengwenliang416.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
80 lines
3.3 KiB
Bash
Executable File
80 lines
3.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Add-lang benchmark for ONE repo:
|
|
# clone -> wipe+index (with the codegraph on PATH) -> verify extraction ->
|
|
# with/without retrieval A/B (reuses scripts/agent-eval/run-all.sh).
|
|
#
|
|
# Assumes the codegraph dev build is already built + linked on PATH — the skill
|
|
# runs `npm run build && ./scripts/local-install.sh` ONCE before looping repos.
|
|
# The A/B is skipped if extraction fails its critical checks (don't burn $ on a
|
|
# broken extractor); set FORCE_AB=1 to run it anyway.
|
|
#
|
|
# Usage: bench.sh <lang> <repo-name> <repo-url> "<question>" [headless|tmux|all]
|
|
# Env: CORPUS corpus dir (default /tmp/codegraph-corpus, shared with agent-eval)
|
|
# CODEGRAPH_BIN index and verify with this codegraph instead of the one on
|
|
# PATH: a binary, or a build's dist/bin/codegraph.js (run with
|
|
# node). Exported, so verify-extraction.mjs uses it too. The A/B's
|
|
# MCP server is run-all.sh's own CG_BIN (default: codegraph on PATH).
|
|
set -uo pipefail
|
|
|
|
LANG_TOKEN="${1:?usage: bench.sh <lang> <repo-name> <repo-url> \"<question>\" [mode]}"
|
|
NAME="${2:?repo-name required}"
|
|
URL="${3:?repo-url required}"
|
|
Q="${4:?question required}"
|
|
MODE="${5:-headless}"
|
|
|
|
HARNESS="$(cd "$(dirname "$0")" && pwd)"
|
|
AGENT_EVAL="$(cd "$HARNESS/../agent-eval" && pwd)"
|
|
CORPUS="${CORPUS:-/tmp/codegraph-corpus}"
|
|
REPO="$CORPUS/$NAME"
|
|
|
|
if [ -n "${CODEGRAPH_BIN:-}" ]; then
|
|
# A path is made absolute, since indexing runs from inside the repo.
|
|
if [ -e "$CODEGRAPH_BIN" ]; then
|
|
CODEGRAPH_BIN="$(cd "$(dirname "$CODEGRAPH_BIN")" && pwd)/$(basename "$CODEGRAPH_BIN")"
|
|
else
|
|
command -v "$CODEGRAPH_BIN" >/dev/null || { echo "CODEGRAPH_BIN not found: $CODEGRAPH_BIN"; exit 1; }
|
|
fi
|
|
export CODEGRAPH_BIN
|
|
# Stands in for the PATH codegraph in this script's own calls.
|
|
case "$CODEGRAPH_BIN" in
|
|
*.js|*.mjs|*.cjs) codegraph() { node "$CODEGRAPH_BIN" "$@"; } ;;
|
|
*) codegraph() { "$CODEGRAPH_BIN" "$@"; } ;;
|
|
esac
|
|
else
|
|
command -v codegraph >/dev/null || { echo "no codegraph on PATH (build + ./scripts/local-install.sh first)"; exit 1; }
|
|
fi
|
|
|
|
echo "==================== add-lang bench: $NAME ($LANG_TOKEN) ===================="
|
|
echo "codegraph: ${CODEGRAPH_BIN:-$(command -v codegraph)} -> $(codegraph --version 2>/dev/null || echo '?')"
|
|
|
|
# 1. Ensure the repo (shallow clone, reuse if present).
|
|
mkdir -p "$CORPUS"
|
|
if [ -d "$REPO/.git" ]; then
|
|
echo "→ reusing checkout: $REPO"
|
|
else
|
|
echo "→ cloning $URL"
|
|
git clone --depth 1 "$URL" "$REPO" || { echo "git clone failed"; exit 1; }
|
|
fi
|
|
|
|
# 2. Wipe + index with the binary under test.
|
|
echo "→ wiping .codegraph and indexing"
|
|
rm -rf "$REPO/.codegraph"
|
|
( cd "$REPO" && codegraph init ) || { echo "indexing failed"; exit 1; }
|
|
|
|
# 3. Verify extraction (cheap guard before the paid A/B).
|
|
echo "→ verifying extraction"
|
|
node "$HARNESS/verify-extraction.mjs" "$REPO" "$LANG_TOKEN"
|
|
VERIFY=$?
|
|
|
|
# 4. Retrieval A/B (skipped if extraction is broken, unless FORCE_AB=1).
|
|
if [ "$VERIFY" -ne 0 ] && [ "${FORCE_AB:-0}" != "1" ]; then
|
|
echo "→ SKIPPING A/B — extraction failed critical checks (set FORCE_AB=1 to override)"
|
|
else
|
|
echo "→ retrieval A/B (mode=$MODE)"
|
|
bash "$AGENT_EVAL/run-all.sh" "$REPO" "$Q" "$MODE"
|
|
fi
|
|
|
|
echo "==================== bench complete: $NAME (verify exit=$VERIFY) ===================="
|
|
# Exit reflects extraction: 0 = pass/warn, 1 = critical fail, 2 = couldn't read status.
|
|
exit "$VERIFY"
|