| 
1 | 1 | ---  | 
2 | 2 | argument-hint: [corpus_slug]  | 
3 |  | -description: uses Playwright MCP and the `corpus:view` dev environment to help with parsing page elements  | 
 | 3 | +description: uses Playwright MCP and the `corpus:view` to parse page elements  | 
4 | 4 | ---  | 
5 | 5 | 
 
  | 
6 | 6 | - using Playwright MCP, navigate to `http://localhost:3001/corpus/$1/gitcasso`  | 
@@ -39,4 +39,19 @@ description: uses Playwright MCP and the `corpus:view` dev environment to help w  | 
39 | 39 | 
 
  | 
40 | 40 | If you make a change to the code of the enhancer, you can click the button with id `gitcasso-rebuild-btn`. It will trigger a rebuild of the browser extension, and then refresh the page. You'll be able to see the effects of your change in the `gitcasso-comment-spots` div described above.  | 
41 | 41 | 
 
  | 
42 |  | -When writing `tryToEnhance` methods, don't hedge your bets and write lots of fallback code or strings of `?.`. Have a specific piece of data you want to get, use non-null `!` assertions where necessary to be clear about getting. The data they are extracting is going to change over time, and it's easier to fix broken ones if you know exactly what used to work. If the code has lots of branching paths, it's harder to tell what it was doing.  | 
 | 42 | +## Common extraction workflow  | 
 | 43 | + | 
 | 44 | +If you see `"title": "TODO_TITLE"` or similar hardcoded `TODO` values in the JSON output, this indicates the enhancer needs some kind of extraction implemented:  | 
 | 45 | + | 
 | 46 | +1. **Find the enhancer**: Search for the `type` value (e.g., `GH_ISSUE_ADD_COMMENT`) in `src/lib/enhancers/`  | 
 | 47 | +2. **Implement extraction**: Replace hardcoded title with DOM extraction:  | 
 | 48 | +   ```javascript  | 
 | 49 | +   const title = document.querySelector('main h1')!.textContent.replace(/\s*#\d+$/, '').trim()  | 
 | 50 | +   ```  | 
 | 51 | +4. **Test with rebuild**: Click the 🔄 button to rebuild and verify the title appears correctly in the JSON  | 
 | 52 | + | 
 | 53 | +## Extraction code style  | 
 | 54 | + | 
 | 55 | +- Don't hedge your bets and write lots of fallback code or strings of `?.`. Have a specific piece of data you want to get, use non-null `!` assertions where necessary to be clear about getting.  | 
 | 56 | +- If a field is empty, represent it with an empty string. Don't use placeholders when extracting data.  | 
 | 57 | +- The pages we are scraping are going to change over time, and it's easier to fix broken ones if we know exactly what used to work. If the code has lots of branching paths, it's harder to tell what it was doing.  | 
0 commit comments