Skip to content

Commit d4fc904

Browse files
authored
Merge branch 'main' into fix/487-constant-nodes-edge-building
2 parents 8266b33 + ed2bf33 commit d4fc904

125 files changed

Lines changed: 7745 additions & 3325 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/hooks/enrich-context.sh

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,35 +39,47 @@ if ! command -v codegraph &>/dev/null && ! command -v npx &>/dev/null; then
3939
exit 0
4040
fi
4141

42-
# Run codegraph deps and capture output
43-
DEPS=""
42+
# Run codegraph brief and capture output (silent no-op on older installs without the brief command)
43+
BRIEF=""
4444
if command -v codegraph &>/dev/null; then
45-
DEPS=$(codegraph deps "$REL_PATH" --json -d "$DB_PATH" 2>/dev/null) || true
45+
BRIEF=$(codegraph brief "$REL_PATH" --json -d "$DB_PATH" 2>/dev/null) || true
4646
else
47-
DEPS=$(npx --yes @optave/codegraph deps "$REL_PATH" --json -d "$DB_PATH" 2>/dev/null) || true
47+
BRIEF=$(npx --yes @optave/codegraph brief "$REL_PATH" --json -d "$DB_PATH" 2>/dev/null) || true
4848
fi
4949

5050
# Guard: no output or error
51-
if [ -z "$DEPS" ] || [ "$DEPS" = "null" ]; then
51+
if [ -z "$BRIEF" ] || [ "$BRIEF" = "null" ]; then
5252
exit 0
5353
fi
5454

5555
# Output as additionalContext so it surfaces in Claude's context
56-
printf '%s' "$DEPS" | node -e "
56+
printf '%s' "$BRIEF" | node -e "
5757
let d='';
5858
process.stdin.on('data',c=>d+=c);
5959
process.stdin.on('end',()=>{
6060
try {
6161
const o=JSON.parse(d);
6262
const r=o.results?.[0]||{};
63-
const imports=(r.imports||[]).map(i=>i.file).join(', ');
64-
const importedBy=(r.importedBy||[]).map(i=>i.file).join(', ');
65-
const defs=(r.definitions||[]).map(d=>d.kind+' '+d.name).join(', ');
66-
const file=o.file||'unknown';
67-
let ctx='[codegraph] '+file;
63+
const file=r.file||o.file||'unknown';
64+
const risk=r.risk||'unknown';
65+
const imports=(r.imports||[]).join(', ');
66+
const importedBy=(r.importedBy||[]).join(', ');
67+
const transitive=r.totalImporterCount||0;
68+
const direct=(r.importedBy||[]).length;
69+
const extra=transitive-direct;
70+
const syms=(r.symbols||[]).map(s=>{
71+
const tags=[];
72+
if(s.role)tags.push(s.role);
73+
tags.push(s.callerCount+' caller'+(s.callerCount!==1?'s':''));
74+
return s.name+' ['+tags.join(', ')+']';
75+
}).join(', ');
76+
let ctx='[codegraph] '+file+' ['+risk.toUpperCase()+' RISK]';
77+
if(syms)ctx+='\n Symbols: '+syms;
6878
if(imports)ctx+='\n Imports: '+imports;
69-
if(importedBy)ctx+='\n Imported by: '+importedBy;
70-
if(defs)ctx+='\n Defines: '+defs;
79+
if(importedBy){
80+
const suffix=extra>0?' (+'+extra+' transitive)':'';
81+
ctx+='\n Imported by: '+importedBy+suffix;
82+
}
7183
console.log(JSON.stringify({
7284
hookSpecificOutput: {
7385
hookEventName: 'PreToolUse',

.claude/skills/dogfood/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Your goal is to install the published package, exercise every feature, compare e
2424
npm init -y && npm install @optave/codegraph@$ARGUMENTS
2525
```
2626

27-
**Dev build** (version contains `-dev.`, e.g. `2.5.33-dev.3c36ef7`):
27+
**Dev build** (version contains `-dev.`, e.g. `3.1.6-dev.12`):
2828
Dev builds are **not published to npm**. They are attached as tarballs to GitHub pre-releases. Install from the GitHub release:
2929
```bash
3030
npm init -y

.claude/skills/review/SKILL.md

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
---
2+
name: review
3+
description: Check all open PRs, resolve conflicts, update branches, address Claude and Greptile review concerns, fix CI failures, and retrigger reviewers until clean
4+
allowed-tools: Bash, Read, Write, Edit, Glob, Grep, Agent
5+
---
6+
7+
# PR Review Sweep
8+
9+
You are performing a full review sweep across all open PRs in this repository. Your goal is to bring every PR to a clean, mergeable state: no conflicts, CI passing, all reviewer comments addressed, and reviewers re-triggered until satisfied.
10+
11+
---
12+
13+
## Step 0: Worktree Isolation
14+
15+
Before doing anything else, run `/worktree` to get an isolated copy of the repo. CLAUDE.md mandates that every session starts with `/worktree` to prevent cross-session interference. All subsequent steps run inside the worktree.
16+
17+
---
18+
19+
## Step 1: Discover Open PRs
20+
21+
```bash
22+
gh pr list --repo optave/codegraph --state open --json number,title,headRefName,baseRefName,mergeable,statusCheckRollup,reviewDecision --limit 50
23+
```
24+
25+
Record each PR's number, branch, base, merge status, and CI state.
26+
27+
---
28+
29+
## Step 2: Process Each PR
30+
31+
For **each** open PR, perform the following steps in order. Process PRs one at a time to avoid cross-contamination.
32+
33+
### 2a. Switch to the PR branch
34+
35+
Ensure the working tree is clean before switching to avoid cross-PR contamination:
36+
37+
```bash
38+
if [ -n "$(git status --porcelain)" ]; then
39+
git stash push -m "pre-checkout stash"
40+
fi
41+
```
42+
43+
Then check out the PR branch:
44+
45+
```bash
46+
gh pr checkout <number>
47+
```
48+
49+
### 2b. Resolve merge conflicts
50+
51+
Check if the PR has conflicts with its base branch:
52+
53+
```bash
54+
gh pr view <number> --json mergeable --jq '.mergeable'
55+
```
56+
57+
If `CONFLICTING`:
58+
59+
1. Merge the base branch into the head branch (never rebase):
60+
```bash
61+
git merge origin/<base-branch>
62+
```
63+
2. **Do not assume which side to keep.** You must fully understand the context of both sides before resolving. If you don't know why a line was added — what feature it supports, what bug it fixes, what reviewer requested it — you cannot resolve the conflict correctly. Before touching any conflict:
64+
- Read the PR description and any linked issues (`gh pr view <number>`) to understand the PR's purpose and scope.
65+
- Check the PR's commit history (`git log --oneline origin/<base-branch>..HEAD -- <file>`) to understand *why* the conflicting line was changed on the PR side. Also check the base branch history (`git log --oneline HEAD..origin/<base-branch> -- <file>`) to understand *why* the base version exists.
66+
- Read Greptile and Claude review comments on the PR (`gh api repos/optave/codegraph/pulls/<number>/comments`, `gh api repos/optave/codegraph/issues/<number>/comments`) — a reviewer may have requested the change that caused the conflict.
67+
- Check what landed on main that introduced the other side (`git log --oneline HEAD..origin/<base-branch> -- <file>`) and read those PR descriptions too if needed.
68+
- Compare the PR's diff against its merge base (`git diff $(git merge-base origin/<base-branch> HEAD) HEAD -- <file>`) to see which side introduced an intentional change vs. which side carried stale code.
69+
- Only then choose the correct resolution. If the PR deliberately changed a line and main still has the old version, keep the PR's version. If main introduced a fix or new feature the PR doesn't have, keep main's version. If both sides made intentional changes, merge them together manually.
70+
3. After resolving, stage the resolved files by name (not `git add .`), commit with: `fix: resolve merge conflicts with <base-branch>`
71+
4. Push the updated branch.
72+
73+
### 2c. Check CI status
74+
75+
```bash
76+
gh pr checks <number>
77+
```
78+
79+
If any checks are failing:
80+
81+
1. Read the failing check logs:
82+
```bash
83+
gh run view <run-id> --log-failed
84+
```
85+
2. Diagnose the failure — read the relevant source files, understand the error.
86+
3. Fix the issue in code.
87+
4. Run tests locally to verify: `npm test`
88+
5. Run lint locally: `npm run lint`
89+
6. Commit the fix with a descriptive message: `fix: <what was broken and why>`
90+
7. Push and wait for CI to re-run. Check again:
91+
```bash
92+
gh pr checks <number>
93+
```
94+
8. Repeat until CI is green.
95+
96+
### 2d. Gather all review comments
97+
98+
Fetch **all** review comments from both Claude and Greptile:
99+
100+
```bash
101+
# PR review comments (inline code comments)
102+
gh api repos/optave/codegraph/pulls/<number>/comments --paginate --jq '.[] | {id: .id, user: .user.login, body: .body, path: .path, line: .line, created_at: .created_at}'
103+
104+
# PR reviews (top-level review bodies)
105+
gh api repos/optave/codegraph/pulls/<number>/reviews --paginate --jq '.[] | {id: .id, user: .user.login, body: .body, state: .state}'
106+
107+
# Issue-style comments (includes @greptileai trigger responses)
108+
gh api repos/optave/codegraph/issues/<number>/comments --paginate --jq '.[] | {id: .id, user: .user.login, body: .body, created_at: .created_at}'
109+
```
110+
111+
### 2e. Address every comment
112+
113+
For **each** review comment — including minor suggestions, nits, style feedback, and optional improvements:
114+
115+
1. **Read the comment carefully.** Understand what the reviewer is asking for.
116+
2. **Read the relevant code** at the file and line referenced.
117+
3. **Make the change.** Even if the comment is marked as "nit" or "suggestion" or "minor" — address it. The goal is zero outstanding comments.
118+
4. **If you disagree** with a suggestion (e.g., it would introduce a bug or contradicts project conventions), do NOT silently ignore it. Reply to the comment explaining why you chose a different approach.
119+
5. **Reply to each comment** explaining what you did:
120+
```bash
121+
gh api repos/optave/codegraph/pulls/<number>/comments/<comment-id>/replies \
122+
-f body="Fixed — <brief description of what was changed>"
123+
```
124+
For issue-style comments, reply on the issue:
125+
```bash
126+
gh api repos/optave/codegraph/issues/<number>/comments \
127+
-f body="Addressed: <summary of changes made>"
128+
```
129+
130+
### 2f. Commit and push fixes
131+
132+
After addressing all comments for a PR:
133+
134+
1. Stage only the files you changed.
135+
2. Group changes by concern — each logically distinct fix gets its own commit (e.g., one commit for a missing validation, another for a naming change). Do not lump all feedback into a single commit.
136+
3. Use descriptive messages per commit: `fix: <what this specific change does> (#<number>)`
137+
4. Push to the PR branch.
138+
139+
### 2g. Re-trigger reviewers
140+
141+
**Greptile:** Always re-trigger after pushing fixes. Post a comment:
142+
143+
```bash
144+
gh api repos/optave/codegraph/issues/<number>/comments \
145+
-f body="@greptileai"
146+
```
147+
148+
**Claude (claude-code-review / claude bot):** Only re-trigger if you addressed something Claude specifically suggested. If you did:
149+
150+
```bash
151+
gh api repos/optave/codegraph/issues/<number>/comments \
152+
-f body="@claude"
153+
```
154+
155+
If all changes were only in response to Greptile feedback, do NOT re-trigger Claude.
156+
157+
### 2h. Wait and re-check
158+
159+
After re-triggering:
160+
161+
1. Wait for the new reviews to come in (check after a reasonable interval).
162+
2. Fetch new comments again (repeat Step 2d).
163+
3. If there are **new** comments from Greptile or Claude, go back to Step 2e and address them.
164+
4. **Repeat this loop for a maximum of 3 rounds.** If after 3 rounds there are still actionable comments, mark the PR as "needs human review" in the summary table and move to the next PR.
165+
5. Verify CI is still green after all changes.
166+
167+
---
168+
169+
## Step 3: Summary
170+
171+
After processing all PRs, output a summary table:
172+
173+
```
174+
| PR | Branch | Conflicts | CI | Comments Addressed | Reviewers Re-triggered | Status |
175+
|----|--------|-----------|----|--------------------|----------------------|--------|
176+
| #N | branch | resolved/none | green/red | N comments | greptile, claude | ready/needs-work |
177+
```
178+
179+
---
180+
181+
## Rules
182+
183+
- **Never rebase.** Always `git merge <base>` to resolve conflicts.
184+
- **Never force-push** unless fixing a commit message that fails commitlint. Amend + force-push is the only way to fix a pushed commit title (messages are part of the SHA). This is safe on feature branches. For all other problems, fix with a new commit.
185+
- **Address ALL comments**, even minor/nit/optional ones. Leave zero unaddressed.
186+
- **Always reply to comments** explaining what was done. Don't just fix silently.
187+
- **Always re-trigger Greptile** after pushing fixes — it must confirm satisfaction.
188+
- **Only re-trigger Claude** if you addressed Claude's feedback specifically.
189+
- **No co-author lines** in commit messages.
190+
- **No Claude Code references** in commit messages or comments.
191+
- **Run tests and lint locally** before pushing any fix.
192+
- **One concern per commit** — don't lump conflict resolution with code fixes.
193+
- **Flag scope creep.** If a PR's diff contains files unrelated to its stated purpose (e.g., a docs PR carrying `src/` or test changes from a merged feature branch), flag it immediately. Split the unrelated changes into a separate branch and PR. Do not proceed with review until the PR is scoped correctly — scope creep is not acceptable.
194+
- If a PR is fundamentally broken beyond what review feedback can fix, note it in the summary and skip to the next PR.

0 commit comments

Comments
 (0)