npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sourcegraph/sourcegraph.proposed

v12.0.2

Published

Sourcegraph extension API: build extensions that enhance reading and reviewing code in your existing tools

Downloads

14

Readme

Sourcegraph extension API

build codecov code style: prettier sourcegraph: search semantic-release

Status: Alpha (docs update and rename in progress)

Build extensions that enhance reading and reviewing code in your existing tools.

Sourcegraph extensions show useful info from services such as Codecov (for test coverage), logging/monitoring/performance tools, and more on GitHub (more code hosts coming soon) and Sourcegraph. It's like being able to use editor extensions when viewing and reviewing code on GitHub and your other favorite tools.

🎥 Demo video.

Usage

Sourcegraph extensions are in alpha. Please file issues for problems and feedback.

On Sourcegraph.com

Try the sourcegraph-codecov extension by visiting any file that has Codecov code coverage, such as tuf_store.go.

On GitHub using the Chrome extension

See demo video.

  1. Install Sourcegraph for Chrome
  2. Open the Sourcegraph Chrome extension options page (by clicking the Sourcegraph icon in the Chrome toolbar)
  3. Check the box labeled Use Sourcegraph extensions to enable this alpha feature
  4. Visit tuf_store.go on GitHub
  5. Click the Coverage: N% button to show Codecov test coverage background colors on the file sourcegraph-codecov, and scroll down to see them

Support for more tools will be added soon.

Background

Sourcegraph provides IDE-like code intelligence (definitions, references, hover tooltips, and search) anywhere you view and review code, such as in GitHub files and pull requests. To do this, we built a way to show information from language servers (for 20+ languages) in the places you view and review code.

Sometimes that info is enough. But sometimes you need to see other kinds of info: error logs, test coverage, performance, authorship, reachability, lint warnings, etc. For example, if you're reviewing a PR that changes code for which there is OpenTracing trace information or that adds calls to untested code, you should be aware of that while reviewing without having to check an external system.

Existing APIs for code hosts and editors don't make this easy or possible.

The state of extension APIs for code hosts

The APIs of code hosts and review tools don't generally provide the necessary hooks to customize the code/diff view and other parts of the UI and workflow. Commit statuses, bot comments, and pipelines are fantastic, but they are solving other problems. Developers need more information and code actions while viewing and reviewing code (just as they do while editing code), and that means providing deeper extensibility.

Even if a single code host implemented a comprehensive extension API, it would be tied to that single code host. Extensions would only be usable by a fraction of developers unless the author created separate extensions for many popular code hosts: GitHub, GitHub Enterprise, Bitbucket, Bitbucket Server, GitLab, Phabricator, etc.

The state of extension APIs for editors

Editors generally have comprehensive extension APIs, but they are each tied to a single editor. Initiatives like Language Server Protocol (LSP) are partial solutions, but LSP still requires an editor extension for each editor (such as vscode-go).

As a result, all of the great work that goes into building editor extensions is fragmented among 10+ editors. That makes it less likely that your favorite dev tools have great extensions for your editor of choice. It also makes it difficult to get your entire team using the same editor extensions and configuring them consistently (if your teammates use a variety of editors).

How Sourcegraph extensions work

To solve this problem (of seeing important contextual info when you're viewing and reviewing code), we made a way for you to write something like an editor extension--except that it can be used on GitHub, Sourcegraph, and (soon) other tools. Check out the code for an example extension that shows a hello message in hover tooltips.

After writing and publishing an extension (using src extensions publish in the src CLI tool), anyone can add it and use it on GitHub or Sourcegraph. Behind the scenes (but in open source), 2 other components make this possible:

Sourcegraph extension API

The Sourcegraph extension API (this repository) is the open-source extension API that Sourcegraph extensions are written against. It exposes concepts present in all clients, such as notifications of opened/closed documents, adding buttons to toolbars, changing the background or gutter color of lines, showing hover tooltips, etc.

The (temporarily named) @sourcegraph/sourcegraph.proposed npm package (published from this repository) exposes this as a TypeScript/JavaScript API that is familiar to anyone who has written a VS Code extension.

Adapters to "polyfill" existing tools to run Sourcegraph extensions

Adapters make it so that Sourcegraph extensions can modify the UI of existing tools, such as GitHub. They run Sourcegraph extensions and know how to detect when the user hovers over a specific line and column in a file, how to insert buttons and actions seamlessly in the tool's UI, etc. All Sourcegraph client adapters are open source.

  • The open-source Sourcegraph for Chrome supports using Sourcegraph extensions on GitHub (support for other code hosts and browsers coming soon). It runs extensions by executing their JavaScript code on the client in a Web Worker.
  • Support for GitHub PRs and diffs, other code hosts, other code review tools, and more browsers is coming soon.
  • Sourcegraph for $EDITOR is coming soon (for VS Code, Vim, Emacs, Atom, Sublime, JetBrains, etc.).

Examples

TODO

Development

npm install
npm test

Acknowledgments

The Sourcegraph extension API and architecture is inspired by the VS Code extension API and the Language Server Protocol (LSP).