|
| 1 | +# W-23150428 — Include GitHub discussion/issue URLs from WI Details\_\_c in PR body |
| 2 | + |
| 3 | +## Context |
| 4 | + |
| 5 | +- SF strips external hrefs in rich-text `Details__c` → `<a href="">discussions/5867</a>` loses URL |
| 6 | +- Observed: W-23145031 / PR #7560 — `discussions/5867` link text, empty href |
| 7 | +- PRs from auto-build-wi never reference originating discussion/issue |
| 8 | +- Files: |
| 9 | + - `.claude/workflows/auto-build-wi.js` — `draftPrPrompt` (L893-932), helpers near `extractPrUrl`/`stripHtml` (L282-329), `chosen.details` available (L351 build, L827 already interpolated into `planPrompt`) |
| 10 | + - `.claude/skills/pr-draft/SKILL.md` — `## GitHub issues & discussions` (L52-61) |
| 11 | + - `.claude/skills/gus-cli/SKILL.md` — `Details__c formatting` (L99-105) |
| 12 | +- Workflow file = script, no exports/unit tests → verify via node REPL |
| 13 | + |
| 14 | +## Mechanism (load-bearing — addresses adversary findings) |
| 15 | + |
| 16 | +- `draftPrPrompt(chosen, identity, fixerResult)` = plain template string handed to `agent()`. No function calling — agent cannot call `extractDiscussionUrls` directly. Mechanism: run `extractDiscussionUrls(chosen.details)` in JS scope before prompt built, then string-interpolate output into template (same pattern as `chosen.details` at L827). |
| 17 | +- Insertion: `const reconstructedUrls = extractDiscussionUrls(chosen.details)` at top of `draftPrPrompt` body (after `pathsFor` destructure, L894). Interpolate joined list into step-4 `## Summary`/reference area — exact text in Phase 1. Empty → interpolate nothing (no placeholder, no instruction). |
| 18 | +- Reconstructed URLs = precomputed strings injected verbatim; agent copies into PR body, does not derive. |
| 19 | + |
| 20 | +## Regex / re-tick safety (load-bearing — addresses adversary findings) |
| 21 | + |
| 22 | +- L924 PR snippet: text=`#NNN`, href=populated URL → never matches empty-href filter; no re-tick ghost. Verify via fixture (see Verification). |
| 23 | +- "Empty href" covers all SF storage forms: `href=""`, `href=" "` / whitespace-only, entity-encoded `href=""`, absent `href`. |
| 24 | +- Populated-href anchors (real `href="https://..."`) EXCLUDED even when text matches `discussions/\d+` — user-authored live links; URL already present, reconstructing would risk overwriting correct host/path. |
| 25 | + |
| 26 | +## Phases |
| 27 | + |
| 28 | +### Phase 1 — `extractDiscussionUrls` + interpolate into `draftPrPrompt` |
| 29 | + |
| 30 | +- Add `extractDiscussionUrls(details)` near `extractPrUrl` (L289), arrow `const`, returns `string[]`: |
| 31 | + - match `<a ...>TEXT</a>` where TEXT matches `(discussions|issues)\/\d+` |
| 32 | + - INCLUDE only if href is empty/missing in ALL stored forms: no `href` attr, `href=""`, `href="<whitespace>"`, or entity-encoded `href=""`. EXCLUDE any anchor whose href holds a real value (e.g. `href="https://..."`). |
| 33 | + - reconstruct `https://github.com/forcedotcom/salesforcedx-vscode/${path}` from the matched `discussions/NNN`|`issues/NNN` |
| 34 | + - dedupe (Set); return array (empty when none) |
| 35 | +- `draftPrPrompt` (L894): `const reconstructedUrls = extractDiscussionUrls(chosen.details)` as first statement. Interpolate, ONLY when non-empty, into the body — add to step 4's reference area, e.g.: |
| 36 | + ``` |
| 37 | + ${reconstructedUrls.length ? `\n - ## References — the originating GitHub discussion/issue links (SF stripped their hrefs; reconstructed below). Include each verbatim in the body:\n${reconstructedUrls.map(u => ` ${u}`).join('\n')}` : ''} |
| 38 | + ``` |
| 39 | + Agent copies the precomputed strings; it does not derive them. Empty → nothing injected. |
| 40 | +- commit: `feat(auto-build-wi): reconstruct stripped discussion/issue URLs for PR body - W-23150428` |
| 41 | +- files: `.claude/workflows/auto-build-wi.js` |
| 42 | + |
| 43 | +### Phase 2 — pr-draft SKILL step |
| 44 | + |
| 45 | +- `## GitHub issues & discussions`: add step — scan WI `Details__c` for anchors w/ `discussions/`|`issues/` text whose href is empty/missing in any stored form (`href=""`, `href=""`, whitespace, absent); EXCLUDE anchors with a populated real href; auto-include reconstructed `https://github.com/forcedotcom/salesforcedx-vscode/<path>` URLs, no user prompt |
| 46 | +- concise style |
| 47 | +- commit: `docs(pr-draft): auto-include stripped discussion/issue URLs - W-23150428` |
| 48 | +- files: `.claude/skills/pr-draft/SKILL.md` |
| 49 | + |
| 50 | +### Phase 3 — gus-cli SKILL href-stripping note |
| 51 | + |
| 52 | +- `Details__c formatting` section: document SF strips external hrefs on save; advise always write full `href` even if stripped (text-preserved path lets auto-build reconstruct) |
| 53 | +- concise style |
| 54 | +- commit: `docs(gus-cli): note SF href-stripping in rich-text Details__c - W-23150428` |
| 55 | +- files: `.claude/skills/gus-cli/SKILL.md` |
| 56 | + |
| 57 | +## Skills to apply |
| 58 | + |
| 59 | +- concise (all `.md` + plan) |
| 60 | +- gus-cli, pr-draft (domain conventions) |
| 61 | +- typescript (auto-build-wi.js changes) |
| 62 | + |
| 63 | +## Verification |
| 64 | + |
| 65 | +- `node -e` load `extractDiscussionUrls`; assert each href-empty form maps to reconstructed URL and each excluded form is dropped: |
| 66 | + - `<a href="">discussions/5867</a>` → `https://github.com/forcedotcom/salesforcedx-vscode/discussions/5867` |
| 67 | + - `<a href="">discussions/42</a>` (entity-encoded empty) → reconstructed |
| 68 | + - `<a href=" ">issues/123</a>` (whitespace href) → reconstructed |
| 69 | + - `<a>issues/9</a>` (absent href) → reconstructed |
| 70 | + - `<a href="https://github.com/forcedotcom/salesforcedx-vscode/discussions/77">discussions/77</a>` (populated href) → EXCLUDED |
| 71 | + - workflow's own PR snippet `<p><strong>PR:</strong> <a href="https://github.com/forcedotcom/salesforcedx-vscode/pull/7382">#7382</a></p>` → EXCLUDED (text `#7382` not a path; guards re-tick ghost URL) |
| 72 | + - non-matching link text → excluded |
| 73 | + - duplicate empty-href anchors → single deduped entry |
| 74 | + - empty/null details → `[]` |
| 75 | +- `node --check .claude/workflows/auto-build-wi.js` |
| 76 | +- lint/prettier — CI-covered, skip manual |
| 77 | +- no e2e on branch (workflow script + skill docs) |
0 commit comments