Skip to content
This repository was archived by the owner on May 20, 2026. It is now read-only.

provider: sourcegraph search provider - #42

Merged
0xnmn merged 1 commit into
mainfrom
k/search
May 18, 2024
Merged

provider: sourcegraph search provider#42
0xnmn merged 1 commit into
mainfrom
k/search

Conversation

@keegancsmith

@keegancsmithkeegancsmith commented May 16, 2024

Copy link
Copy Markdown
Member

This is an initial Sourcegraph search provider which does unauthenticated searches against sourcegraph.com.

Test Plan: See tests done in #48

Comment threadpackage.json
Comment threadprovider/sourcegraph-search/index.test.ts Outdated
Comment threadprovider/sourcegraph-search/index.ts Outdated
Comment on lines +46 to +47
const url = `${graphqlClient.endpoint}/search?q=${encodeURIComponent(
query.sourcegraphQuery
)}&patternType=literal`

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I'm a big fan of this idea of encoding the information we need in the URL (and it works!) and then extracting again in items

Comment threadprovider/sourcegraph-search/index.ts Outdated
"scripts": {
"build": "tsc --build",
"test": "vitest",
"bundle": "esbuild --bundle --format=esm --outfile=dist/bundle.js index.ts"

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I'm not sure if we should ship with this sort of thing, but very useful during development for manual testing to have a bundler. Not sure common patterns for this in the JS world.

Comment threadprovider/sourcegraph-search/search.ts Outdated
@keegancsmith
keegancsmith requested review from 0xnmn and sqsMay 16, 2024 10:38
Comment threadprovider/sourcegraph-search/index.ts
This is an initial Sourcegraph search provider which does
unauthenticated searches against sourcegraph.com.
@keegancsmith

Copy link
Copy Markdown
MemberAuthor

@thenamankumar @sqs force pushed a rebase onto the new API. Ready for review.

@keegancsmithkeegancsmith left a comment

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Two other follow-up items for this PR which I'd like to tackle later:

  • authentication against non dot-com instances
  • unit tests

const graphqlClient = new SourcegraphGraphQLAPIClient()

/** Used to prefix context queries to indicate a sourcegraph search */
const QUERY_PREFIXES = ['?', 'src:']

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

This can probably be removed. I will follow-up after more testing when the cody integration is ready.

@keegancsmith
keegancsmith marked this pull request as ready for review May 17, 2024 14:26

@0xnmn0xnmn 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.

Merging this to test e2e.

@0xnmn
0xnmn merged commit 501e567 into mainMay 18, 2024
@0xnmn
0xnmn deleted the k/search branch May 18, 2024 09:06
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@keegancsmith@0xnmn