winui-search: batched CLI, background refresh, ranking + Gallery/Toolkit fetch upgrades#83
Conversation
…kit fetch upgrades
There was a problem hiding this comment.
Pull request overview
This PR significantly upgrades the src/tools/winui-search CLI to be faster on the hot path (embedded-first), more resilient (background cache refresh), and more useful to agents (grouped/batched results plus richer scenario metadata extracted from Gallery/Toolkit sources).
Changes:
- Refactors Gallery/Toolkit fetching to serve embedded snapshots immediately and move GitHub refresh into an explicit
updatepath (and background refresh). - Adds batched CLI behavior (
search/get) and grouped ranking output with improved BM25 weighting, stopword/synonym handling, and scenario/metadata formatting. - Extends Toolkit metadata with curated
keywords(embedded resource + frontmatter extraction) and adds a unified cache schema version (CacheVersion.cs).
Reviewed changes
Copilot reviewed 19 out of 22 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tools/winui-search/Program.cs | Batched CLI commands, background refresh hook, updated update flow |
| src/tools/winui-search/BackgroundUpdater.cs | New stale-while-revalidate background refresh + lock/backoff/logging |
| src/tools/winui-search/SearchEngine.cs | Grouped search + ranking/formatting changes and new fallback behavior |
| src/tools/winui-search/GalleryFetcher.cs | Embedded-first load + GitHub refresh path; richer Gallery extraction incl. code-behind extraction |
| src/tools/winui-search/ToolkitFetcher.cs | Embedded-first load + GitHub refresh path; frontmatter keywords + description extraction |
| src/tools/winui-search/CacheVersion.cs | Single cache schema/version source of truth |
| src/tools/winui-search/DataLoader.cs | Loads embedded Toolkit keywords dictionary |
| src/tools/winui-search/Models.cs | Scenario schema extended with description/metadata fields |
| src/tools/winui-search/BM25.cs | Tokenization tweaks + coverage gate support (CountHits) |
| src/tools/winui-search/StopWords.cs | Expanded stopwords + tag-dictionary cleaning helpers |
| src/tools/winui-search/winui-search.csproj | Embeds new toolkit-keywords.json resource |
| src/tools/winui-search/Data/toolkit-keywords.json | New embedded curated keywords payload |
| src/tools/winui-search/README.md, DATA_SOURCES.md | Documentation updates for new behavior and data sources |
| plugins/winui/skills/winui-design/SKILL.md | Skill guidance updated to match new batched CLI usage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Coverage
Findings
DetailsH1 — Non-atomic cache writes
// GalleryFetcher.cs:107-123 (RefreshFromGitHub)
File.WriteAllText(scenarioCache, JsonSerializer.Serialize(scenarios, JsonContext.Default.ScenarioArray));
File.WriteAllText(tagCache, JsonSerializer.Serialize(tags, JsonContext.Default.DictionaryStringStringArray));
File.WriteAllText(timestampFile, DateTime.UtcNow.ToString("o"));
File.WriteAllText(versionFile, CacheVersion.Current);Recommendation: Use temp-file + H2 — Foreground
|
* run pr-validation on staging prs * winui-search: batched CLI, background refresh, ranking + Gallery/Toolkit fetch upgrades (#83) * winui-search: batched CLI, background refresh, ranking + Gallery/Toolkit fetch upgrades * fix comments * fix time * fix comments * change verions back * fix local pr review --------- Co-authored-by: Nikola Metulev <nmetulev@users.noreply.github.com> * deps: Bump coverlet.collector from 10.0.0 to 10.0.1 (#87) --- updated-dependencies: - dependency-name: coverlet.collector dependency-version: 10.0.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Nikola Metulev <nmetulev@users.noreply.github.com> * winui: window sizing rubric, screenshot validation, anti-self-delegation (#84) * winui: window sizing rubric, screenshot validation, anti-self-delegation Three connected improvements to the WinUI dev skills, motivated by repeated failure modes when building small apps: 1. winui-design SKILL.md - new Step 4 'Size the Window to the App' WinUI 3 has no SizeToContent, so apps default to ~1024x768 regardless of content - which makes utilities feel oversized. Adds an 8-step reasoning rubric (inventory rows, derive widest-row width, sum heights, round up, sanity-check ranges, prefer compact-but-not-clipping, aspect-ratio follows content, validate after running) and a worked example. Old 'Step 4: Design Anti-Patterns' renumbered to Step 5. 2. winui-ui-testing SKILL.md - new Step 3.5 'Look at the Screenshots' UIA assertions can't see clipping, overlap, cramped layout, or theming bugs. Adds explicit guidance to capture screenshots at multiple states (initial, post-interaction, per mode), view them after each run, and apply a visual checklist. Test-script template now creates a screenshots/ directory and captures intermediate state, not just a single final shot. 3. winui-dev.agent.md - 'Do The Work Yourself' section Agents kept re-delegating user requests to a fresh winui-dev sub-agent, wasting context and hiding progress. Adds an explicit prohibition against self-delegation while still permitting narrow helpers (explore for unfamiliar codebases, rubber-duck for plan critique). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * winui-design: replace PInvoke.User32 with framework DllImport; drop misleading fallback The DPI-aware snippet in Step 4 had two real correctness issues that surfaced in PR review and were confirmed by an empirical two-monitor test: 1. PInvoke.User32.GetDpiForWindow is a third-party NuGet not in the default WinUI 3 scaffold; agents copying the snippet hit "type or namespace PInvoke not found". Replace with a one-line [DllImport("user32.dll")] — no NuGet, no CsWin32 source-generator plumbing, works in the constructor. 2. SetTitleBar(AppTitleBar) referenced an XAML element the snippet never declares; orthogonal to sizing anyway. Removed. Also drop the "Simpler fallback if PInvoke.User32 isn't available (ignores DPI; fine for prototypes)" block — the empirical test showed AppWindow.Resize takes physical pixels, so Resize(new SizeInt32(460, 860)) on a 1.25-scale monitor (the default on many Windows laptops) produces only ~368x688 DIPs of usable space and guarantees the clipping the rubric is designed to prevent. The "fallback" was actively misleading. Replaced with a one-line "Why this shape" explaining why XamlRoot.RasterizationScale (the managed WinUI 3 API) isn't viable here (null in ctor, stale after AppWindow.Move). Strengthened the "Pattern" header with the concrete failure mode so future readers see why the DPI math is needed, not just that it's needed. Also fixes a small bug in winui-dev.agent.md: "rubber-duck" was named as if it were a real agent_type. Rephrased to "a general-purpose agent for a rubber-duck critique" so the named agent_type is valid. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * winui-design: extract worked example to references/, dedupe visual checklist with winui-ui-testing M2: The focus-timer walkthrough (460 x 860 derivation + 440 x 720 anti-pattern) moves out of SKILL.md prose and into references/window-sizing-examples.md, with SKILL.md keeping only a 1-line schematic of the rubric and a pointer to the reference. Concrete worked numbers stay out of every loaded skill payload but remain on-demand when an agent wants a full example to anchor against. M6: Step 4 step 8's bulleted symptom list (5 bullets that were a strict subset of the 9-item visual checklist in winui-ui-testing Step 3.5) collapses to a 1-paragraph pointer with inline symptom hints. The authoritative checklist lives in winui-ui-testing, which is the skill that owns 'look at screenshots'. Net: -11 / +50 (the +50 is the new on-demand reference file, not loaded by default), with no change in covered guidance. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * winui: ultra-lean rewrite of window-sizing + screenshot-validation + anti-self-delegation prose Apply the Team Lead Test more aggressively across all three files. Cuts redundant enforcement, scenario-specific filler, and restated rubric positives. Preserves every operational imperative. winui-dev.agent.md (anti-self-delegation): 11 → 2 lines. The two banned sub-types collapse into one parenthetical; the scoped-helpers ✅ shrinks to one clause; the redundant closing 'if you catch yourself' paragraph drops (the rule above it already says it). winui-ui-testing/SKILL.md (Step 3.5): 33 → ~16 lines. Drops the duplicate script example (the State Screenshots block in the script template above already shows the pattern), the 3-bullet 'what counts as a state' list (one sentence covers it), and the 'How to view' paragraph (tool-agnostic: the agent picks its own view tool). Visual checklist trimmed from 9 → 9 items but with one merged pair (right-edge + overlap kept as separate bullets after all) and one new item added: 'Content uses the available width — no asymmetric dead zones' covers the bug where content gets pinned to one edge with empty space on the other. winui-design/SKILL.md (Step 4): 76 → ~30 lines. The 8-step rubric collapses to one paragraph + a sanity-check list — the formula Sigma(row heights) forces enumeration without needing a dedicated 'inventory' step, 'widest row' encodes max-not-average, and 'round up' speaks for itself. Drops the aspect-ratio step (tall→portrait is obvious), the 'compactness vs clipping' step (subsumed by 'round up — clipped is worse'), and the 6-bullet Anti-patterns section (5 of 6 restated the rubric's positives; the one novel trap — Width on root Grid clips, not sizes — folds into a one-line note after the snippet). The 3-line 'Pattern — apply the size you derived' intro collapses to one line. Snippet using-statement comments removed. Closing line goes tool-agnostic: 'Validate visually after build via winui-ui-testing Step 3.5' (no longer says 'capture a screenshot' — that's a layering violation, design owns the rubric, testing owns the validation mechanism). 'Iterate the size or layout' covers both grow-the-window and fix-asymmetric-padding failure modes. Net for default-loaded payloads: -58 lines on top of the previous M2+M6 commit, total PR addition shrinks from +176 to +88 lines (-50%). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * winui-design: drop window-sizing-examples reference, make ui-testing validation user-opt-in The reference file was 47 lines of one focus-timer instantiation of a 2-line formula. An LLM agent given the formula can derive any layout without seeing a worked example first — 'see one, do one' is human pedagogy, not LLM pedagogy. A single example also risks anchoring toward focus-timer-shaped solutions. Drop the file, drop the references-table row, drop the trailing 'See references/...' sentence in Step 4. The rubric stands on its own. Also reframe the Step 4 closing line: instead of prescribing 'validate visually after build' (which would auto-trigger the ui-testing pipeline — spawn the app, capture UIA, take screenshots, run the checklist), make it user-opt-in: 'If the user asks for UI validation, see winui-ui-testing Step 3.5'. This matches the policy already stated in winui-dev.agent.md that the user might ask for ui-testing 'if desired only'. The ui-testing skill is expensive to run; it shouldn't be the default follow-up to every window-sizing exercise. Net: -49 lines of repo (47 file + 2 default-loaded payload), no loss of operational guidance. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Nikola Metulev <711864+nmetulev@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Release 0.3.1 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Nikola Metulev <711864+nmetulev@users.noreply.github.com> Co-authored-by: leileizhang <leilzh@microsoft.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Release 0.3.1 (#90) * run pr-validation on staging prs * winui-search: batched CLI, background refresh, ranking + Gallery/Toolkit fetch upgrades (#83) * winui-search: batched CLI, background refresh, ranking + Gallery/Toolkit fetch upgrades * fix comments * fix time * fix comments * change verions back * fix local pr review --------- Co-authored-by: Nikola Metulev <nmetulev@users.noreply.github.com> * deps: Bump coverlet.collector from 10.0.0 to 10.0.1 (#87) --- updated-dependencies: - dependency-name: coverlet.collector dependency-version: 10.0.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Nikola Metulev <nmetulev@users.noreply.github.com> * winui: window sizing rubric, screenshot validation, anti-self-delegation (#84) * winui: window sizing rubric, screenshot validation, anti-self-delegation Three connected improvements to the WinUI dev skills, motivated by repeated failure modes when building small apps: 1. winui-design SKILL.md - new Step 4 'Size the Window to the App' WinUI 3 has no SizeToContent, so apps default to ~1024x768 regardless of content - which makes utilities feel oversized. Adds an 8-step reasoning rubric (inventory rows, derive widest-row width, sum heights, round up, sanity-check ranges, prefer compact-but-not-clipping, aspect-ratio follows content, validate after running) and a worked example. Old 'Step 4: Design Anti-Patterns' renumbered to Step 5. 2. winui-ui-testing SKILL.md - new Step 3.5 'Look at the Screenshots' UIA assertions can't see clipping, overlap, cramped layout, or theming bugs. Adds explicit guidance to capture screenshots at multiple states (initial, post-interaction, per mode), view them after each run, and apply a visual checklist. Test-script template now creates a screenshots/ directory and captures intermediate state, not just a single final shot. 3. winui-dev.agent.md - 'Do The Work Yourself' section Agents kept re-delegating user requests to a fresh winui-dev sub-agent, wasting context and hiding progress. Adds an explicit prohibition against self-delegation while still permitting narrow helpers (explore for unfamiliar codebases, rubber-duck for plan critique). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * winui-design: replace PInvoke.User32 with framework DllImport; drop misleading fallback The DPI-aware snippet in Step 4 had two real correctness issues that surfaced in PR review and were confirmed by an empirical two-monitor test: 1. PInvoke.User32.GetDpiForWindow is a third-party NuGet not in the default WinUI 3 scaffold; agents copying the snippet hit "type or namespace PInvoke not found". Replace with a one-line [DllImport("user32.dll")] — no NuGet, no CsWin32 source-generator plumbing, works in the constructor. 2. SetTitleBar(AppTitleBar) referenced an XAML element the snippet never declares; orthogonal to sizing anyway. Removed. Also drop the "Simpler fallback if PInvoke.User32 isn't available (ignores DPI; fine for prototypes)" block — the empirical test showed AppWindow.Resize takes physical pixels, so Resize(new SizeInt32(460, 860)) on a 1.25-scale monitor (the default on many Windows laptops) produces only ~368x688 DIPs of usable space and guarantees the clipping the rubric is designed to prevent. The "fallback" was actively misleading. Replaced with a one-line "Why this shape" explaining why XamlRoot.RasterizationScale (the managed WinUI 3 API) isn't viable here (null in ctor, stale after AppWindow.Move). Strengthened the "Pattern" header with the concrete failure mode so future readers see why the DPI math is needed, not just that it's needed. Also fixes a small bug in winui-dev.agent.md: "rubber-duck" was named as if it were a real agent_type. Rephrased to "a general-purpose agent for a rubber-duck critique" so the named agent_type is valid. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * winui-design: extract worked example to references/, dedupe visual checklist with winui-ui-testing M2: The focus-timer walkthrough (460 x 860 derivation + 440 x 720 anti-pattern) moves out of SKILL.md prose and into references/window-sizing-examples.md, with SKILL.md keeping only a 1-line schematic of the rubric and a pointer to the reference. Concrete worked numbers stay out of every loaded skill payload but remain on-demand when an agent wants a full example to anchor against. M6: Step 4 step 8's bulleted symptom list (5 bullets that were a strict subset of the 9-item visual checklist in winui-ui-testing Step 3.5) collapses to a 1-paragraph pointer with inline symptom hints. The authoritative checklist lives in winui-ui-testing, which is the skill that owns 'look at screenshots'. Net: -11 / +50 (the +50 is the new on-demand reference file, not loaded by default), with no change in covered guidance. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * winui: ultra-lean rewrite of window-sizing + screenshot-validation + anti-self-delegation prose Apply the Team Lead Test more aggressively across all three files. Cuts redundant enforcement, scenario-specific filler, and restated rubric positives. Preserves every operational imperative. winui-dev.agent.md (anti-self-delegation): 11 → 2 lines. The two banned sub-types collapse into one parenthetical; the scoped-helpers ✅ shrinks to one clause; the redundant closing 'if you catch yourself' paragraph drops (the rule above it already says it). winui-ui-testing/SKILL.md (Step 3.5): 33 → ~16 lines. Drops the duplicate script example (the State Screenshots block in the script template above already shows the pattern), the 3-bullet 'what counts as a state' list (one sentence covers it), and the 'How to view' paragraph (tool-agnostic: the agent picks its own view tool). Visual checklist trimmed from 9 → 9 items but with one merged pair (right-edge + overlap kept as separate bullets after all) and one new item added: 'Content uses the available width — no asymmetric dead zones' covers the bug where content gets pinned to one edge with empty space on the other. winui-design/SKILL.md (Step 4): 76 → ~30 lines. The 8-step rubric collapses to one paragraph + a sanity-check list — the formula Sigma(row heights) forces enumeration without needing a dedicated 'inventory' step, 'widest row' encodes max-not-average, and 'round up' speaks for itself. Drops the aspect-ratio step (tall→portrait is obvious), the 'compactness vs clipping' step (subsumed by 'round up — clipped is worse'), and the 6-bullet Anti-patterns section (5 of 6 restated the rubric's positives; the one novel trap — Width on root Grid clips, not sizes — folds into a one-line note after the snippet). The 3-line 'Pattern — apply the size you derived' intro collapses to one line. Snippet using-statement comments removed. Closing line goes tool-agnostic: 'Validate visually after build via winui-ui-testing Step 3.5' (no longer says 'capture a screenshot' — that's a layering violation, design owns the rubric, testing owns the validation mechanism). 'Iterate the size or layout' covers both grow-the-window and fix-asymmetric-padding failure modes. Net for default-loaded payloads: -58 lines on top of the previous M2+M6 commit, total PR addition shrinks from +176 to +88 lines (-50%). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * winui-design: drop window-sizing-examples reference, make ui-testing validation user-opt-in The reference file was 47 lines of one focus-timer instantiation of a 2-line formula. An LLM agent given the formula can derive any layout without seeing a worked example first — 'see one, do one' is human pedagogy, not LLM pedagogy. A single example also risks anchoring toward focus-timer-shaped solutions. Drop the file, drop the references-table row, drop the trailing 'See references/...' sentence in Step 4. The rubric stands on its own. Also reframe the Step 4 closing line: instead of prescribing 'validate visually after build' (which would auto-trigger the ui-testing pipeline — spawn the app, capture UIA, take screenshots, run the checklist), make it user-opt-in: 'If the user asks for UI validation, see winui-ui-testing Step 3.5'. This matches the policy already stated in winui-dev.agent.md that the user might ask for ui-testing 'if desired only'. The ui-testing skill is expensive to run; it shouldn't be the default follow-up to every window-sizing exercise. Net: -49 lines of repo (47 file + 2 default-loaded payload), no loss of operational guidance. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Nikola Metulev <711864+nmetulev@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Release 0.3.1 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Nikola Metulev <711864+nmetulev@users.noreply.github.com> Co-authored-by: leileizhang <leilzh@microsoft.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * release: introduce backmerge/* convention and fix CI for back-merge PRs - version-sync skips backmerge/* (legitimately carries main's version-bump commit forward into staging). - staging-up-to-date now checks PR head contains every commit on main, not current staging — strictly stronger, and passes naturally for backmerge PRs (the chicken-and-egg before required staging to already contain main before the very PR that would bring it there could merge). - Document backmerge/* branch convention in CONTRIBUTING.md and RELEASING.md. - Update hotfix back-merge reminder issue body to use the new convention. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: force re-run on backmerge/0.3.1 (stale check from pre-rename) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Nikola Metulev <711864+nmetulev@users.noreply.github.com> Co-authored-by: leileizhang <leilzh@microsoft.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Description
search/gettake multiple args; results grouped by control with up to 3 scenarios each..xaml.csand emits per-example code-behind (event handlers,x:Bindtargets,x:DataType) instead of empty stubs.keywordsfield from.mdfrontmatter,#if WINAPPSDKfolding, per-sample header/description extraction.BackgroundUpdater.cs): hot-path commands never block on GitHub. Detached child refreshes if cache > 7 d; atomic lock, 10-min TTL, 1-h failure backoff.WINUI_SEARCH_NO_BACKGROUND=1to opt out.CacheVersion.cs: single source of truth; mismatch → embedded JSON.Type of Change
Affected area
Checklist
README.mdupdatedAdditional Notes
AI Description
This section is auto-generated by AI when the PR is opened or updated. To opt out, delete this entire section including the marker comments.