mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-01 19:25:10 +02:00
feat: v0.3.2 — project-local state, diff-aware QA, Greptile integration (#36)
* fix: cookie import picker returns JSON instead of HTML jsonResponse() was defined at module scope but referenced `url` which only existed as a parameter of handleCookiePickerRoute(). Every API call crashed, the catch block also crashed, and Bun returned a default HTML page that the frontend couldn't parse as JSON. Thread port via corsOrigin() helper and options objects. Add route-level tests to prevent this class of bug from shipping again. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add help command to browse server Agents that don't have SKILL.md loaded (or misread flags) had no way to self-discover the CLI. The help command returns a formatted reference of all commands and snapshot flags. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: version-aware find-browse with META signal protocol Agents in other workspaces found stale browse binaries that were missing newer flags. find-browse now compares the local binary's git SHA against origin/main via git ls-remote (4hr cache), and emits META:UPDATE_AVAILABLE when behind. SKILL.md setup checks parse META signals and prompt the user to update. - New compiled binary: browse/dist/find-browse (TypeScript, testable) - Bash shim at browse/bin/find-browse delegates to compiled binary - .version file written at build time with git commit SHA - Build script compiles both browse and find-browse binaries - Graceful degradation: offline, missing .version, corrupt cache all skip check Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: clean up .bun-build temp files after compile bun build --compile leaves ~58MB temp files in the working directory. Add rm -f .*.bun-build to the build script to clean up after each build. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: make help command reachable by removing it from META_COMMANDS help was in META_COMMANDS, so it dispatched to handleMetaCommand() which threw "Unknown meta command: help". Removing it from the set lets the dedicated else-if handler in handleCommand() execute correctly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: bump version and changelog (v0.3.2) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add shared Greptile comment triage reference doc Shared reference for fetching, filtering, and classifying Greptile review comments on GitHub PRs. Used by both /review and /ship skills. Includes parallel API fetching, suppressions check, classification logic, reply APIs, and history file writes. * feat: make /review and /ship Greptile-aware /review: Step 2.5 fetches and classifies Greptile comments, Step 5 resolves them with AskUserQuestion for valid issues and false positives. /ship: Step 3.75 triages Greptile comments between pre-landing review and version bump. Adds Greptile Review section to PR body in Step 8. Re-runs tests if any Greptile fixes are applied. * feat: add Greptile batting average to /retro Reads ~/.gstack/greptile-history.md, computes signal ratio (valid catches vs false positives), includes in metrics table, JSON snapshot, and Code Quality Signals narrative. * docs: add Greptile integration section to README Personal endorsement, two-layer review narrative, full UX walkthrough transcript, skills table updates. Add Greptile training feedback loop to TODO.md future ideas. * feat: add local dev mode for testing skills from within the repo bin/dev-setup creates .claude/skills/gstack symlink to the working tree so Claude Code discovers skills locally. bin/dev-teardown cleans up. DEVELOPING_GSTACK.md documents the workflow. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: narrow gitignore to .claude/skills/ instead of all .claude/ Avoids ignoring legitimate Claude Code config like settings.json or CLAUDE.md. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: rename DEVELOPING_GSTACK.md to CONTRIBUTING.md Rewritten as a contributor-friendly guide instead of a dry plan doc. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: explain why dev-setup is needed in CONTRIBUTING.md quick start Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add browser interaction guidance to CLAUDE.md Prevents Claude from using mcp__claude-in-chrome__* tools instead of /browse. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add shared config module for project-local browse state Centralizes path resolution (git root detection, state dir, log paths) into config.ts. Both cli.ts and server.ts import from it, eliminating duplicated PORT_OFFSET/BROWSE_PORT/STATE_FILE logic. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: rewrite port selection to use random ports Replace CONDUCTOR_PORT magic offset and 9400-9409 scan with random port 10000-60000. Atomic state file writes, log paths from config module, binaryVersion field for auto-restart on update. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: move browse state from /tmp to project-local .gstack/ CLI now uses config module for state paths, passes BROWSE_STATE_FILE to spawned server. Adds version mismatch auto-restart, legacy /tmp cleanup with PID verification, and removes stale global install fallback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: update crash log path reference to .gstack/ Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * test: add config tests and update CLI lifecycle test 14 new tests for config resolution, ensureStateDir, readVersionHash, resolveServerScript, and version mismatch detection. Remove obsolete CONDUCTOR_PORT/BROWSE_PORT filtering from commands.test.ts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: update BROWSER.md and TODO.md for project-local state Replace /tmp paths with .gstack/, remove CONDUCTOR_PORT docs, document random port selection and per-project isolation. Add server bundling TODO. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: update README, CHANGELOG, and CONTRIBUTING for v0.3.2 - README: replace Conductor-aware language with project-local isolation, add Greptile setup note - CHANGELOG: comprehensive v0.3.2 entry with all state management changes - CONTRIBUTING: add instructions for testing branches in other repos Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add diff-aware mode to /qa — auto-tests affected pages from branch diff When on a feature branch, /qa now reads git diff main, identifies affected pages/routes from changed files, and tests them automatically. No URL required. The most natural flow: write code, /ship, /qa. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: update CHANGELOG for complete v0.3.2 coverage Add missing entries: diff-aware QA mode, Greptile integration, local dev mode, crash log path fix, README/SKILL.md updates. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -36,6 +36,16 @@ Read `.claude/skills/review/checklist.md`.
|
||||
|
||||
---
|
||||
|
||||
## Step 2.5: Check for Greptile review comments
|
||||
|
||||
Read `.claude/skills/review/greptile-triage.md` and follow the fetch, filter, and classify steps.
|
||||
|
||||
**If no PR exists, `gh` fails, API returns an error, or there are zero Greptile comments:** Skip this step silently. Greptile integration is additive — the review works without it.
|
||||
|
||||
**If Greptile comments are found:** Store the classifications (VALID & ACTIONABLE, VALID BUT ALREADY FIXED, FALSE POSITIVE, SUPPRESSED) — you will need them in Step 5.
|
||||
|
||||
---
|
||||
|
||||
## Step 3: Get the diff
|
||||
|
||||
Fetch the latest main to avoid false positives from a stale local main:
|
||||
@@ -68,6 +78,30 @@ Follow the output format specified in the checklist. Respect the suppressions
|
||||
- If only non-critical issues found: output findings. No further action needed.
|
||||
- If no issues found: output `Pre-Landing Review: No issues found.`
|
||||
|
||||
### Greptile comment resolution
|
||||
|
||||
After outputting your own findings, if Greptile comments were classified in Step 2.5:
|
||||
|
||||
**Include a Greptile summary in your output header:** `+ N Greptile comments (X valid, Y fixed, Z FP)`
|
||||
|
||||
1. **VALID & ACTIONABLE comments:** These are already included in your CRITICAL findings — they follow the same AskUserQuestion flow (A: Fix it now, B: Acknowledge, C: False positive). If the user chooses C (false positive), post a reply using the appropriate API from the triage doc and save the pattern to `~/.gstack/greptile-history.md` (type: fp).
|
||||
|
||||
2. **FALSE POSITIVE comments:** Present each one via AskUserQuestion:
|
||||
- Show the Greptile comment: file:line (or [top-level]) + body summary + permalink URL
|
||||
- Explain concisely why it's a false positive
|
||||
- Options:
|
||||
- A) Reply to Greptile explaining why this is incorrect (recommended if clearly wrong)
|
||||
- B) Fix it anyway (if low-effort and harmless)
|
||||
- C) Ignore — don't reply, don't fix
|
||||
|
||||
If the user chooses A, post a reply using the appropriate API from the triage doc and save the pattern to `~/.gstack/greptile-history.md` (type: fp).
|
||||
|
||||
3. **VALID BUT ALREADY FIXED comments:** Reply acknowledging the catch — no AskUserQuestion needed:
|
||||
- Post reply: `"Good catch — already fixed in <commit-sha>."`
|
||||
- Save to `~/.gstack/greptile-history.md` (type: already-fixed)
|
||||
|
||||
4. **SUPPRESSED comments:** Skip silently — these are known false positives from previous triage.
|
||||
|
||||
---
|
||||
|
||||
## Important Rules
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
# Greptile Comment Triage
|
||||
|
||||
Shared reference for fetching, filtering, and classifying Greptile review comments on GitHub PRs. Both `/review` (Step 2.5) and `/ship` (Step 3.75) reference this document.
|
||||
|
||||
---
|
||||
|
||||
## Fetch
|
||||
|
||||
Run these commands to detect the PR and fetch comments. Both API calls run in parallel.
|
||||
|
||||
```bash
|
||||
REPO=$(gh repo view --json nameWithOwner --jq '.nameWithOwner' 2>/dev/null)
|
||||
PR_NUMBER=$(gh pr view --json number --jq '.number' 2>/dev/null)
|
||||
```
|
||||
|
||||
**If either fails or is empty:** Skip Greptile triage silently. This integration is additive — the workflow works without it.
|
||||
|
||||
```bash
|
||||
# Fetch line-level review comments AND top-level PR comments in parallel
|
||||
gh api repos/$REPO/pulls/$PR_NUMBER/comments \
|
||||
--jq '.[] | select(.user.login == "greptile-apps[bot]") | select(.position != null) | {id: .id, path: .path, line: .line, body: .body, html_url: .html_url, source: "line-level"}' > /tmp/greptile_line.json &
|
||||
gh api repos/$REPO/issues/$PR_NUMBER/comments \
|
||||
--jq '.[] | select(.user.login == "greptile-apps[bot]") | {id: .id, body: .body, html_url: .html_url, source: "top-level"}' > /tmp/greptile_top.json &
|
||||
wait
|
||||
```
|
||||
|
||||
**If API errors or zero Greptile comments across both endpoints:** Skip silently.
|
||||
|
||||
The `position != null` filter on line-level comments automatically skips outdated comments from force-pushed code.
|
||||
|
||||
---
|
||||
|
||||
## Suppressions Check
|
||||
|
||||
Read `~/.gstack/greptile-history.md` if it exists. Each line records a previous triage outcome:
|
||||
|
||||
```
|
||||
<date> | <repo> | <type:fp|fix|already-fixed> | <file-pattern> | <category>
|
||||
```
|
||||
|
||||
**Categories** (fixed set): `race-condition`, `null-check`, `error-handling`, `style`, `type-safety`, `security`, `performance`, `correctness`, `other`
|
||||
|
||||
Match each fetched comment against entries where:
|
||||
- `type == fp` (only suppress known false positives, not previously fixed real issues)
|
||||
- `repo` matches the current repo
|
||||
- `file-pattern` matches the comment's file path
|
||||
- `category` matches the issue type in the comment
|
||||
|
||||
Skip matched comments as **SUPPRESSED**.
|
||||
|
||||
If the history file doesn't exist or has unparseable lines, skip those lines and continue — never fail on a malformed history file.
|
||||
|
||||
---
|
||||
|
||||
## Classify
|
||||
|
||||
For each non-suppressed comment:
|
||||
|
||||
1. **Line-level comments:** Read the file at the indicated `path:line` and surrounding context (±10 lines)
|
||||
2. **Top-level comments:** Read the full comment body
|
||||
3. Cross-reference the comment against the full diff (`git diff origin/main`) and the review checklist
|
||||
4. Classify:
|
||||
- **VALID & ACTIONABLE** — a real bug, race condition, security issue, or correctness problem that exists in the current code
|
||||
- **VALID BUT ALREADY FIXED** — a real issue that was addressed in a subsequent commit on the branch. Identify the fixing commit SHA.
|
||||
- **FALSE POSITIVE** — the comment misunderstands the code, flags something handled elsewhere, or is stylistic noise
|
||||
- **SUPPRESSED** — already filtered in the suppressions check above
|
||||
|
||||
---
|
||||
|
||||
## Reply APIs
|
||||
|
||||
When replying to Greptile comments, use the correct endpoint based on comment source:
|
||||
|
||||
**Line-level comments** (from `pulls/$PR/comments`):
|
||||
```bash
|
||||
gh api repos/$REPO/pulls/$PR_NUMBER/comments/$COMMENT_ID/replies \
|
||||
-f body="<reply text>"
|
||||
```
|
||||
|
||||
**Top-level comments** (from `issues/$PR/comments`):
|
||||
```bash
|
||||
gh api repos/$REPO/issues/$PR_NUMBER/comments \
|
||||
-f body="<reply text>"
|
||||
```
|
||||
|
||||
**If a reply POST fails** (e.g., PR was closed, no write permission): warn and continue. Do not stop the workflow for a failed reply.
|
||||
|
||||
---
|
||||
|
||||
## History File Writes
|
||||
|
||||
Before writing, ensure the directory exists:
|
||||
```bash
|
||||
mkdir -p ~/.gstack
|
||||
```
|
||||
|
||||
Append one line per triage outcome to `~/.gstack/greptile-history.md`:
|
||||
```
|
||||
<YYYY-MM-DD> | <owner/repo> | <type> | <file-pattern> | <category>
|
||||
```
|
||||
|
||||
Example entries:
|
||||
```
|
||||
2026-03-13 | garrytan/myapp | fp | app/services/auth_service.rb | race-condition
|
||||
2026-03-13 | garrytan/myapp | fix | app/models/user.rb | null-check
|
||||
2026-03-13 | garrytan/myapp | already-fixed | lib/payments.rb | error-handling
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Output Format
|
||||
|
||||
Include a Greptile summary in the output header:
|
||||
```
|
||||
+ N Greptile comments (X valid, Y fixed, Z FP)
|
||||
```
|
||||
|
||||
For each classified comment, show:
|
||||
- Classification tag: `[VALID]`, `[FIXED]`, `[FALSE POSITIVE]`, `[SUPPRESSED]`
|
||||
- File:line reference (for line-level) or `[top-level]` (for top-level)
|
||||
- One-line body summary
|
||||
- Permalink URL (the `html_url` field)
|
||||
Reference in New Issue
Block a user