Skip to content

fix: enhance wiki search tool to include repository path and pagePath… - #1700

Open
Dan Hellem (danhellem) wants to merge 1 commit into
mainfrom
users/danhellem/wiki-search-fix-1
Open

Dan Hellem (danhellem) wants to merge 1 commit into
mainfrom
users/danhellem/wiki-search-fix-1

Conversation

@danhellem

@danhellem Dan Hellem (danhellem) commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

This pull request enhances the Azure DevOps Wiki search tool by enriching search results with a wiki-relative pagePath for each result, improving downstream usability. It also introduces comprehensive tests to ensure the new behavior works correctly and maintains compatibility with responses that lack results.

Wiki Search Result Enrichment:

  • Added a new function addWikiPagePath in src/tools/search.ts to compute and attach a pagePath property to each wiki search result, making it easier to reference wiki pages relative to their mapped paths.
  • Updated the search tool handler to parse the API response as JSON, enrich results with pagePath, and return the modified result as a stringified JSON object.
  • Improved the documentation for the SEARCH_TOOLS.search_wiki tool to clarify that results include both repository paths and wiki-relative pagePath values.

Testing Improvements:

  • Added and updated tests in test/src/tools/search.test.ts to verify that:
    • Responses without results are preserved unmodified.
    • The enrichment logic correctly adds pagePath to various wiki search results, including edge cases.
  • Enhanced the test mock to support both .text() and .json() fetch responses for more accurate simulation.

GitHub issue number

#1695

Associated Risks

None

✅ PR Checklist

  • I have read the contribution guidelines
  • I have read the code of conduct guidelines
  • Title of the pull request is clear and informative.
  • 👌 Code hygiene
  • 🔭 Telemetry added, updated, or N/A
  • 📄 Documentation added, updated, or N/A
  • 🛡️ Automated tests added, or N/A

🧪 How did you test it?

Ran thru several manual tests and updated auto tests

@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation satisfies the linked issue and includes appropriate edge-case coverage.

0 open findings

What changed in this PR

Enriches wiki search results with paths consumable by the wiki tool.

Changes:

  • Derives pagePath from repository paths and wiki mappings.
  • Clarifies tool documentation.
  • Adds coverage for enrichment and empty responses.
File Description
src/​tools/​search.ts Adds wiki-relative path enrichment.
test/​src/​tools/​search.test.ts Tests enrichment and response preservation.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left nit comments and approved

Comment thread src/tools/search.ts
return result;
}

const relativePath = decodeURIComponent(result.path.slice(mappedPath.length).replace(/\.md$/i, ""));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

decodeURIComponent can throw URIError when result.path contains malformed encoding

Comment thread src/tools/search.ts
type CombinedResult = { gitItem: GitItem } | { error: string };

function addWikiPagePath(result: WikiSearchResult): WikiSearchResult {
if (result.pagePath || !result.path || !result.wiki?.mappedPath) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we have null check for result
if (!result || result.pagePath || !result.path || !result.wiki?.mappedPath) {
return result;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REMOTE] search_wiki results do not include pagePath

3 participants