├── client ├── browser │ ├── .gitignore │ ├── public │ │ ├── icon-128.png │ │ ├── icon-32.png │ │ └── icon-48.png │ ├── src │ │ ├── globals.d.ts │ │ ├── shared │ │ │ ├── platform.ts │ │ │ ├── polyfills.ts │ │ │ ├── util │ │ │ │ ├── toLineRangeStrings.test.ts │ │ │ │ └── toLineRangeStrings.ts │ │ │ └── env.ts │ │ ├── browser-extension │ │ │ └── web-extension-api │ │ │ │ ├── runtime.ts │ │ │ │ ├── README.md │ │ │ │ ├── fromBrowserEvent.ts │ │ │ │ └── types.ts │ │ ├── options │ │ │ ├── options.main.tsx │ │ │ ├── options.html │ │ │ └── OptionsPage.module.css │ │ └── contentScript │ │ │ ├── debug.ts │ │ │ ├── contentScript.main.css │ │ │ └── openCtxUtil.ts │ ├── CHANGELOG.md │ ├── dev │ │ └── create-icons.sh │ ├── tsconfig.json │ ├── CONTRIBUTING.md │ └── vite.config.ts ├── web-playground │ ├── README.md │ ├── src │ │ ├── index.ts │ │ ├── globals.d.ts │ │ ├── demo │ │ │ ├── main.css │ │ │ ├── main.tsx │ │ │ └── DemoMentionsConsole.tsx │ │ ├── demo.tsx │ │ ├── EditorHeader.module.css │ │ ├── codemirror.ts │ │ ├── promptEditorConfig.ts │ │ ├── EditorHeader.tsx │ │ └── MentionsConsole.module.css │ ├── index.html │ ├── tsconfig.json │ └── package.json ├── codemirror │ ├── demo │ │ ├── globals.d.ts │ │ ├── tsconfig.json │ │ ├── README.md │ │ ├── index.html │ │ ├── package.json │ │ └── vite.config.ts │ ├── src │ │ └── index.ts │ ├── tsconfig.json │ └── package.json ├── vscode │ ├── resources │ │ ├── icons.woff │ │ └── logomark-v0.png │ ├── test │ │ ├── fixtures │ │ │ └── workspace │ │ │ │ ├── package.json │ │ │ │ ├── foo.ts │ │ │ │ ├── globals.d.ts │ │ │ │ ├── tsconfig.json │ │ │ │ ├── eventLogger.ts │ │ │ │ ├── Label.tsx │ │ │ │ └── Label.story.tsx │ │ └── integration │ │ │ ├── tsconfig.json │ │ │ └── index.cts │ ├── vite.config.ts │ ├── .vscodeignore │ ├── dev │ │ └── tsconfig.json │ ├── tsconfig.json │ ├── CHANGELOG.md │ └── src │ │ └── extension.ts ├── monaco-editor │ ├── demo │ │ ├── globals.d.ts │ │ ├── README.md │ │ ├── tsconfig.json │ │ ├── index.html │ │ ├── package.json │ │ ├── vite.config.ts │ │ └── demo.ts │ ├── tsconfig.json │ └── package.json └── vscode-lib │ ├── src │ ├── index.ts │ ├── testing.ts │ ├── util │ │ ├── importHelpers.test.ts │ │ ├── observable.ts │ │ └── vscode.test.ts │ ├── controller.test.ts │ ├── global.ts │ └── ui │ │ └── statusBarItem.ts │ ├── vitest.config.ts │ ├── tsconfig.json │ └── package.json ├── .tool-versions ├── doc ├── resources │ ├── logomark-v0.svg │ ├── logotext-horiz-color-dark-v0.svg │ ├── logotext-horiz-color-light-v0.svg │ └── logomark-v0.png ├── index.md └── dev │ └── index.md ├── lib ├── schema │ ├── src │ │ └── index.ts │ ├── vitest.config.ts │ ├── README.md │ ├── tsconfig.json │ ├── dev │ │ ├── tsconfig.json │ │ └── generateJsonSchemaTypes.ts │ └── package.json ├── protocol │ ├── src │ │ └── index.ts │ ├── vitest.config.ts │ ├── README.md │ ├── tsconfig.json │ └── package.json ├── client │ ├── src │ │ ├── providerClient │ │ │ ├── testdata │ │ │ │ ├── topLevelThrow.js │ │ │ │ ├── metaThrow.js │ │ │ │ ├── methodsThrow.js │ │ │ │ ├── transportReuse.js │ │ │ │ └── provider.js │ │ │ └── transport │ │ │ │ ├── testdata │ │ │ │ ├── emoji.js │ │ │ │ ├── esmProvider.js │ │ │ │ ├── commonjsProvider.js │ │ │ │ ├── esmExtProvider.mjs │ │ │ │ ├── commonjsExtProvider.cjs │ │ │ │ └── esmProvider.ts │ │ │ │ └── module.test.ts │ │ ├── client │ │ │ └── testdata │ │ │ │ ├── simpleMeta.js │ │ │ │ └── simple.js │ │ ├── logger.ts │ │ ├── index.ts │ │ └── configuration.test.ts │ ├── README.md │ ├── vitest.config.ts │ ├── tsconfig.json │ └── package.json ├── provider │ ├── vitest.config.ts │ ├── README.md │ ├── tsconfig.json │ ├── src │ │ ├── index.ts │ │ ├── helpers │ │ │ └── position.ts │ │ └── provider.ts │ └── package.json ├── ui-common │ ├── vitest.config.ts │ ├── src │ │ ├── index.ts │ │ ├── ui.ts │ │ └── hover.ts │ ├── README.md │ ├── tsconfig.json │ └── package.json ├── ui-react │ ├── README.md │ ├── src │ │ ├── globals.d.ts │ │ ├── chip │ │ │ ├── ChipList.module.css │ │ │ ├── Popover.module.css │ │ │ ├── BaseChip.module.css │ │ │ ├── ChipList.tsx │ │ │ ├── ChipList.story.tsx │ │ │ └── Chip.tsx │ │ ├── index.ts │ │ └── indentationWrapper │ │ │ ├── IndentationWrapper.tsx │ │ │ └── IndentationWrapper.story.tsx │ ├── tsconfig.json │ ├── .storybook │ │ └── main.ts │ └── package.json └── ui-standalone │ ├── src │ ├── globals.d.ts │ ├── chip │ │ ├── ChipList.module.css │ │ ├── ChipList.ts │ │ ├── BaseChip.module.css │ │ ├── Chip.ts │ │ └── ChipList.story.ts │ ├── index.ts │ └── indentationWrapper │ │ ├── IndentationWrapper.ts │ │ └── IndentationWrapper.story.ts │ ├── vite.config.ts │ ├── README.md │ ├── .storybook │ └── main.ts │ ├── tsconfig.json │ └── package.json ├── provider ├── devdocs │ ├── .gitattributes │ ├── vitest.config.ts │ ├── tsconfig.json │ ├── cache.ts │ ├── README.md │ └── package.json ├── linear-docs │ ├── .gitignore │ ├── vitest.config.ts │ ├── tsconfig.json │ └── package.json ├── linear-issues │ ├── .gitignore │ ├── vitest.config.ts │ ├── tsconfig.json │ └── package.json ├── notion │ ├── parse-text-from-any-block-type.d.ts │ ├── vitest.config.ts │ ├── tsconfig.json │ ├── index.test.ts │ ├── package.json │ └── README.md ├── github │ ├── index.ts │ ├── vitest.config.ts │ ├── settings.ts │ ├── tsconfig.json │ ├── package.json │ └── client.ts ├── jira │ ├── vitest.config.js │ ├── tsconfig.json │ ├── package.json │ └── README.md ├── links │ ├── vitest.config.ts │ ├── tsconfig.json │ └── package.json ├── semgrep │ ├── vitest.config.ts │ ├── tsconfig.json │ ├── api.test.ts │ ├── README.md │ └── package.json ├── sentry │ ├── vitest.config.ts │ ├── index.ts │ ├── settings.ts │ ├── tsconfig.json │ ├── auth.ts │ ├── auth.test.ts │ └── package.json ├── slack │ ├── vitest.config.ts │ ├── tsconfig.json │ ├── package.json │ └── README.md ├── web │ ├── vitest.config.ts │ ├── tsconfig.json │ ├── README.md │ └── package.json ├── confluence │ ├── vitest.config.js │ ├── tsconfig.json │ └── package.json ├── google-docs │ ├── vitest.config.ts │ ├── tsconfig.json │ ├── utils.ts │ └── package.json ├── hello-world │ ├── vitest.config.ts │ ├── tsconfig.json │ ├── README.md │ └── package.json ├── prometheus │ ├── vitest.config.ts │ ├── tsconfig.json │ └── package.json ├── storybook │ ├── vitest.config.ts │ ├── tsconfig.json │ └── package.json ├── sourcegraph-refs │ ├── vitest.config.ts │ ├── tsconfig.json │ ├── README.md │ ├── package.json │ └── graphql_blobs.ts ├── azure-devops-workitems │ ├── vitest.config.js │ ├── tsconfig.json │ ├── types.ts │ └── package.json ├── modelcontextprotocol │ ├── vitest.config.ts │ ├── tsconfig.json │ └── package.json ├── modelcontextprotocoltools │ ├── .gitignore │ ├── tsconfig.json │ ├── README.md │ └── package.json └── sourcegraph-search │ ├── vitest.config.ts │ ├── tsconfig.json │ ├── README.md │ ├── package.json │ └── graphql.ts ├── web ├── public │ ├── favicon.ico │ ├── FiraCode.woff2 │ ├── Inter-italic.var.woff2 │ └── Inter-roman.var.woff2 ├── src │ ├── globals.d.ts │ ├── layout │ │ ├── config.ts │ │ ├── logo.tsx │ │ └── Head.tsx │ ├── lib │ │ └── utils.ts │ ├── server │ │ ├── tsconfig.json │ │ └── root.ts │ ├── components │ │ ├── content │ │ │ └── MdxComponents.tsx │ │ ├── ClientOnlySync.tsx │ │ ├── codemirror │ │ │ └── defaults.ts │ │ ├── ClientOnlyLazy.tsx │ │ └── Link.tsx │ └── content │ │ └── ContentPage.tsx ├── README.md ├── pages │ ├── npm │ │ ├── +config.ts │ │ └── +onBeforeRender.ts │ ├── docs │ │ ├── +config.ts │ │ ├── +onBeforePrerenderStart.ts │ │ ├── +Page.tsx │ │ ├── +onBeforeRender.ts │ │ ├── content.ts │ │ └── components │ │ │ └── SourcegraphGettingStartedCommon.mdx │ ├── playground │ │ ├── +config.ts │ │ ├── +Page.tsx │ │ ├── text.mdx │ │ ├── Preload.tsx │ │ └── FakeEditorWindow.module.css │ └── _error │ │ └── +Page.tsx ├── content │ └── docs │ │ ├── clients │ │ ├── cli.mdx │ │ ├── codemirror.mdx │ │ ├── browser-extension.mdx │ │ ├── monaco-editor.mdx │ │ ├── sourcegraph.mdx │ │ ├── vscode.mdx │ │ └── cody.mdx │ │ ├── providers │ │ ├── jira.mdx │ │ ├── links.mdx │ │ ├── slack.mdx │ │ ├── web.mdx │ │ ├── github.mdx │ │ ├── notion.mdx │ │ ├── devdocs.mdx │ │ ├── semgrep.mdx │ │ ├── confluence.mdx │ │ ├── prometheus.mdx │ │ ├── storybook.mdx │ │ ├── google-docs.mdx │ │ ├── linear-docs.mdx │ │ ├── linear-issues.mdx │ │ ├── sourcegraph-search.mdx │ │ ├── modelcontextprotocol.mdx │ │ ├── hello-world.mdx │ │ └── azure-devops-workitems.mdx │ │ ├── community.mdx │ │ └── vision.mdx ├── tsconfig.node.json ├── postcss.config.js ├── components.json ├── tsconfig.json ├── renderer │ ├── types.ts │ └── +config.ts └── netlify.toml ├── pnpm-workspace.yaml ├── .gitattributes ├── .gitignore ├── bin ├── tsconfig.json ├── sample-config.json └── package.json ├── .vscode ├── extensions.json ├── tasks.json └── settings.json ├── vitest.workspace.ts ├── .config ├── tsconfig.base.json └── stylelintrc.json └── .npmrc /client/browser/.gitignore: -------------------------------------------------------------------------------- 1 | *.zip 2 | -------------------------------------------------------------------------------- /.tool-versions: -------------------------------------------------------------------------------- 1 | nodejs 22.2.0 2 | pnpm 8.12.1 3 | -------------------------------------------------------------------------------- /doc/resources/logomark-v0.svg: -------------------------------------------------------------------------------- 1 | ../../web/public/logomark-v0.svg -------------------------------------------------------------------------------- /lib/schema/src/index.ts: -------------------------------------------------------------------------------- 1 | export type * from './openctx.schema.js' 2 | -------------------------------------------------------------------------------- /provider/devdocs/.gitattributes: -------------------------------------------------------------------------------- 1 | **/__fixtures__/** linguist-generated=true -------------------------------------------------------------------------------- /lib/protocol/src/index.ts: -------------------------------------------------------------------------------- 1 | export type * from './openctx-protocol.schema.js' 2 | -------------------------------------------------------------------------------- /lib/client/src/providerClient/testdata/topLevelThrow.js: -------------------------------------------------------------------------------- 1 | throw new Error('topLevelThrow') 2 | -------------------------------------------------------------------------------- /client/web-playground/README.md: -------------------------------------------------------------------------------- 1 | # OpenCtx web playground 2 | 3 | To run: `pnpm run dev` 4 | 5 | -------------------------------------------------------------------------------- /doc/resources/logotext-horiz-color-dark-v0.svg: -------------------------------------------------------------------------------- 1 | ../../web/public/logotext-horiz-color-dark-v0.svg -------------------------------------------------------------------------------- /doc/resources/logotext-horiz-color-light-v0.svg: -------------------------------------------------------------------------------- 1 | ../../web/public/logotext-horiz-color-light-v0.svg -------------------------------------------------------------------------------- /provider/linear-docs/.gitignore: -------------------------------------------------------------------------------- 1 | linear_client_config.json 2 | linear_user_credentials.json 3 | -------------------------------------------------------------------------------- /provider/linear-issues/.gitignore: -------------------------------------------------------------------------------- 1 | linear_client_config.json 2 | linear_user_credentials.json 3 | -------------------------------------------------------------------------------- /web/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourcegraph/openctx/HEAD/web/public/favicon.ico -------------------------------------------------------------------------------- /provider/notion/parse-text-from-any-block-type.d.ts: -------------------------------------------------------------------------------- 1 | export function getTextFromBlock(block: any): string 2 | -------------------------------------------------------------------------------- /web/public/FiraCode.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourcegraph/openctx/HEAD/web/public/FiraCode.woff2 -------------------------------------------------------------------------------- /doc/index.md: -------------------------------------------------------------------------------- 1 | # OpenCtx documentation 2 | 3 | - [README.md](../README.md) 4 | - [Development](./dev/index.md) 5 | -------------------------------------------------------------------------------- /doc/resources/logomark-v0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourcegraph/openctx/HEAD/doc/resources/logomark-v0.png -------------------------------------------------------------------------------- /lib/provider/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | 3 | export default defineConfig({}) 4 | -------------------------------------------------------------------------------- /provider/github/index.ts: -------------------------------------------------------------------------------- 1 | import { githubProvider } from './provider.js' 2 | 3 | export default githubProvider 4 | -------------------------------------------------------------------------------- /client/browser/public/icon-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourcegraph/openctx/HEAD/client/browser/public/icon-128.png -------------------------------------------------------------------------------- /client/browser/public/icon-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourcegraph/openctx/HEAD/client/browser/public/icon-32.png -------------------------------------------------------------------------------- /client/browser/public/icon-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourcegraph/openctx/HEAD/client/browser/public/icon-48.png -------------------------------------------------------------------------------- /client/codemirror/demo/globals.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*?url' { 2 | const url: string 3 | export default url 4 | } 5 | -------------------------------------------------------------------------------- /client/vscode/resources/icons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourcegraph/openctx/HEAD/client/vscode/resources/icons.woff -------------------------------------------------------------------------------- /client/vscode/test/fixtures/workspace/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vscode-test-workspace", 3 | "private": true 4 | } 5 | -------------------------------------------------------------------------------- /lib/ui-common/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({}) 4 | -------------------------------------------------------------------------------- /provider/devdocs/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({}) 4 | -------------------------------------------------------------------------------- /provider/github/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({}) 4 | -------------------------------------------------------------------------------- /provider/jira/vitest.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({}) 4 | -------------------------------------------------------------------------------- /provider/links/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({}) 4 | -------------------------------------------------------------------------------- /provider/notion/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({}) 4 | -------------------------------------------------------------------------------- /provider/semgrep/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({}) 4 | -------------------------------------------------------------------------------- /provider/sentry/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({}) 4 | -------------------------------------------------------------------------------- /provider/slack/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({}) 4 | -------------------------------------------------------------------------------- /provider/web/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({}) 4 | -------------------------------------------------------------------------------- /web/public/Inter-italic.var.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourcegraph/openctx/HEAD/web/public/Inter-italic.var.woff2 -------------------------------------------------------------------------------- /web/public/Inter-roman.var.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourcegraph/openctx/HEAD/web/public/Inter-roman.var.woff2 -------------------------------------------------------------------------------- /client/monaco-editor/demo/globals.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*?url' { 2 | const url: string 3 | export default url 4 | } 5 | -------------------------------------------------------------------------------- /lib/client/README.md: -------------------------------------------------------------------------------- 1 | # OpenCtx client library 2 | 3 | The `@openctx/client` package is used to implement OpenCtx clients. 4 | -------------------------------------------------------------------------------- /provider/confluence/vitest.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({}) 4 | -------------------------------------------------------------------------------- /provider/google-docs/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({}) 4 | -------------------------------------------------------------------------------- /provider/hello-world/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({}) 4 | -------------------------------------------------------------------------------- /provider/linear-docs/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({}) 4 | -------------------------------------------------------------------------------- /provider/prometheus/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({}) 4 | -------------------------------------------------------------------------------- /provider/storybook/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({}) 4 | -------------------------------------------------------------------------------- /client/vscode/resources/logomark-v0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourcegraph/openctx/HEAD/client/vscode/resources/logomark-v0.png -------------------------------------------------------------------------------- /client/vscode/test/fixtures/workspace/foo.ts: -------------------------------------------------------------------------------- 1 | export function foo(name: string): string { 2 | return `Hello, ${name}` 3 | } 4 | -------------------------------------------------------------------------------- /client/vscode/test/fixtures/workspace/globals.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'react' { 2 | export type FunctionComponent = any 3 | } 4 | -------------------------------------------------------------------------------- /lib/schema/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | 3 | export default defineConfig({ 4 | test: {}, 5 | }) 6 | -------------------------------------------------------------------------------- /provider/linear-issues/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({}) 4 | -------------------------------------------------------------------------------- /provider/sentry/index.ts: -------------------------------------------------------------------------------- 1 | import { providerImplementation } from './provider.js' 2 | 3 | export default providerImplementation 4 | -------------------------------------------------------------------------------- /provider/sourcegraph-refs/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({}) 4 | -------------------------------------------------------------------------------- /lib/provider/README.md: -------------------------------------------------------------------------------- 1 | # OpenCtx provider library 2 | 3 | The `@openctx/provider` package is used to implement OpenCtx providers. 4 | -------------------------------------------------------------------------------- /provider/azure-devops-workitems/vitest.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({}) 4 | -------------------------------------------------------------------------------- /provider/modelcontextprotocol/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({}) 4 | -------------------------------------------------------------------------------- /provider/modelcontextprotocoltools/.gitignore: -------------------------------------------------------------------------------- 1 | index.test.ts 2 | package-lock.json 3 | dist/ 4 | vitest.config.ts 5 | vitest.config.t 6 | -------------------------------------------------------------------------------- /provider/sourcegraph-search/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({}) 4 | -------------------------------------------------------------------------------- /lib/client/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({ 4 | test: {}, 5 | }) 6 | -------------------------------------------------------------------------------- /lib/protocol/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({ 4 | test: {}, 5 | }) 6 | -------------------------------------------------------------------------------- /client/vscode-lib/src/index.ts: -------------------------------------------------------------------------------- 1 | export type { ExtensionApiForTesting } from './testing.js' 2 | export { createController } from './controller.js' 3 | -------------------------------------------------------------------------------- /client/vscode-lib/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config' 2 | 3 | export default defineConfig({ 4 | test: {}, 5 | }) 6 | -------------------------------------------------------------------------------- /web/src/globals.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.mdx' { 2 | const component: import('react').FunctionComponent 3 | export default component 4 | } 5 | -------------------------------------------------------------------------------- /client/web-playground/src/index.ts: -------------------------------------------------------------------------------- 1 | export { AnnotatedEditor } from './AnnotatedEditor.js' 2 | export { SettingsEditor } from './SettingsEditor.js' 3 | -------------------------------------------------------------------------------- /lib/ui-react/README.md: -------------------------------------------------------------------------------- 1 | # OpenCtx React UI library 2 | 3 | The `@openctx/ui-react` package contains OpenCtx UI components for use in React applications. 4 | -------------------------------------------------------------------------------- /client/browser/src/globals.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.module.css' { 2 | const classes: { readonly [key: string]: string } 3 | export default classes 4 | } 5 | -------------------------------------------------------------------------------- /lib/ui-react/src/globals.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.module.css' { 2 | const classes: { readonly [key: string]: string } 3 | export default classes 4 | } 5 | -------------------------------------------------------------------------------- /web/src/layout/config.ts: -------------------------------------------------------------------------------- 1 | export const layoutItemClassName = 'p-6 mx-auto' 2 | export const normalLayoutClassName = `max-w-screen-lg ${layoutItemClassName}` 3 | -------------------------------------------------------------------------------- /lib/schema/README.md: -------------------------------------------------------------------------------- 1 | # OpenCtx schema 2 | 3 | The `@openctx/schema` package contains the OpenCtx schema definition (JSON Schema and generated TypeScript types.) 4 | -------------------------------------------------------------------------------- /lib/ui-react/src/chip/ChipList.module.css: -------------------------------------------------------------------------------- 1 | .list { 2 | display: inline-flex; 3 | align-items: center; 4 | gap: 0.25rem; 5 | cursor: default; 6 | } 7 | -------------------------------------------------------------------------------- /lib/ui-standalone/src/globals.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.module.css' { 2 | const classes: { readonly [key: string]: string } 3 | export default classes 4 | } 5 | -------------------------------------------------------------------------------- /web/README.md: -------------------------------------------------------------------------------- 1 | # [openctx.org](https://openctx.org) 2 | 3 | This directory contains the [openctx.org](https://openctx.org) website. 4 | 5 | To run: `pnpm run dev` 6 | -------------------------------------------------------------------------------- /web/pages/npm/+config.ts: -------------------------------------------------------------------------------- 1 | import type { Config } from 'vike/types' 2 | 3 | const config: Config = { 4 | route: '/npm/*', 5 | } 6 | 7 | export default config 8 | -------------------------------------------------------------------------------- /client/codemirror/src/index.ts: -------------------------------------------------------------------------------- 1 | export { openCtxData, showOpenCtxDecorations } from './extension.js' 2 | export { useOpenCtxExtension } from './useOpenCtxExtension.js' 3 | -------------------------------------------------------------------------------- /client/vscode/test/fixtures/workspace/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "jsx": "preserve", 4 | "noEmit": true 5 | }, 6 | "include": ["*"] 7 | } 8 | -------------------------------------------------------------------------------- /client/web-playground/src/globals.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.module.css' { 2 | const classes: { readonly [key: string]: string } 3 | export default classes 4 | } 5 | -------------------------------------------------------------------------------- /lib/ui-standalone/src/chip/ChipList.module.css: -------------------------------------------------------------------------------- 1 | .list { 2 | display: inline-flex; 3 | align-items: center; 4 | gap: 0.25rem; 5 | cursor: default; 6 | } 7 | -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - bin 3 | - client/* 4 | - client/codemirror/demo 5 | - client/monaco-editor/demo 6 | - lib/* 7 | - provider/* 8 | - web 9 | -------------------------------------------------------------------------------- /client/vscode/test/fixtures/workspace/eventLogger.ts: -------------------------------------------------------------------------------- 1 | export const eventLogger = { 2 | log: (message: string, data?: Record) => console.log(message), 3 | } 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Ensure everything is checked out using \n even on Windows, because some test 2 | # code and snapshots assume this. 3 | * text=auto eol=lf 4 | CHANGELOG.md merge=union 5 | -------------------------------------------------------------------------------- /client/vscode/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | 3 | export default defineConfig({ 4 | test: { 5 | include: ['src/**/*.test.ts?(x)'], 6 | }, 7 | }) 8 | -------------------------------------------------------------------------------- /web/content/docs/clients/cli.mdx: -------------------------------------------------------------------------------- 1 | export const info = { 2 | title: 'CLI', 3 | group: 'clients', 4 | } 5 | 6 | import Readme from '../../../../bin/README.md' 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/ui-common/src/index.ts: -------------------------------------------------------------------------------- 1 | export { renderHoverToHTML } from './hover.js' 2 | export { 3 | prepareAnnotationsForPresentation, 4 | type AnnotationWithRichRange, 5 | } from './ui.js' 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .stylelintcache 3 | *.tsbuildinfo 4 | .DS_Store 5 | .env 6 | .idea/ 7 | out/ 8 | dist/ 9 | dist-ssr/ 10 | /coverage/ 11 | .vscode-test/ 12 | .vscode-test-web/ 13 | -------------------------------------------------------------------------------- /lib/schema/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist" 6 | }, 7 | "include": ["src"] 8 | } 9 | -------------------------------------------------------------------------------- /lib/ui-react/src/index.ts: -------------------------------------------------------------------------------- 1 | export { Chip } from './chip/Chip.js' 2 | export { ChipList } from './chip/ChipList.js' 3 | export { IndentationWrapper } from './indentationWrapper/IndentationWrapper.js' 4 | -------------------------------------------------------------------------------- /web/content/docs/providers/jira.mdx: -------------------------------------------------------------------------------- 1 | export const info = { 2 | title: 'Jira', 3 | group: 'providers', 4 | } 5 | 6 | import Readme from '../../../../provider/jira/README.md' 7 | 8 | 9 | -------------------------------------------------------------------------------- /web/content/docs/providers/links.mdx: -------------------------------------------------------------------------------- 1 | export const info = { 2 | title: 'Links', 3 | group: 'providers', 4 | } 5 | 6 | import Readme from '../../../../provider/links/README.md' 7 | 8 | 9 | -------------------------------------------------------------------------------- /web/content/docs/providers/slack.mdx: -------------------------------------------------------------------------------- 1 | export const info = { 2 | title: 'Slack', 3 | group: 'providers', 4 | } 5 | 6 | import Readme from '../../../../provider/slack/README.md' 7 | 8 | 9 | -------------------------------------------------------------------------------- /web/content/docs/providers/web.mdx: -------------------------------------------------------------------------------- 1 | export const info = { 2 | title: 'Web pages', 3 | group: 'providers', 4 | } 5 | 6 | import Readme from '../../../../provider/web/README.md' 7 | 8 | 9 | -------------------------------------------------------------------------------- /web/pages/docs/+config.ts: -------------------------------------------------------------------------------- 1 | import type { Config } from 'vike/types' 2 | 3 | const config: Config = { 4 | route: '/docs/*', 5 | layoutClassName: 'wide', 6 | } 7 | 8 | export default config 9 | -------------------------------------------------------------------------------- /lib/client/src/client/testdata/simpleMeta.js: -------------------------------------------------------------------------------- 1 | /** @type {import('@openctx/provider').Provider} */ 2 | export default { 3 | meta: (_, settings) => ({ name: `simpleMeta-${settings.nameSuffix}` }), 4 | } 5 | -------------------------------------------------------------------------------- /lib/protocol/README.md: -------------------------------------------------------------------------------- 1 | # OpenCtx client/provider protocol 2 | 3 | The `@openctx/protocol` package contains the OpenCtx client/provider protocol definition (JSON Schema and generated TypeScript types). 4 | -------------------------------------------------------------------------------- /web/content/docs/providers/github.mdx: -------------------------------------------------------------------------------- 1 | export const info = { 2 | title: 'GitHub', 3 | group: 'providers', 4 | } 5 | 6 | import Readme from '../../../../provider/github/README.md' 7 | 8 | 9 | -------------------------------------------------------------------------------- /web/content/docs/providers/notion.mdx: -------------------------------------------------------------------------------- 1 | export const info = { 2 | title: 'Notion', 3 | group: 'providers', 4 | } 5 | 6 | import Readme from '../../../../provider/notion/README.md' 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/ui-common/README.md: -------------------------------------------------------------------------------- 1 | # OpenCtx common UI library 2 | 3 | The `@openctx/ui-common` package contains OpenCtx UI utilities that can be used in any client UI (such as in both editor extensions and web pages). 4 | -------------------------------------------------------------------------------- /web/content/docs/providers/devdocs.mdx: -------------------------------------------------------------------------------- 1 | export const info = { 2 | title: 'DevDocs', 3 | group: 'providers', 4 | } 5 | 6 | import Readme from '../../../../provider/devdocs/README.md' 7 | 8 | 9 | -------------------------------------------------------------------------------- /web/content/docs/providers/semgrep.mdx: -------------------------------------------------------------------------------- 1 | export const info = { 2 | title: 'Semgrep', 3 | group: 'providers', 4 | } 5 | 6 | import Readme from '../../../../provider/semgrep/README.md' 7 | 8 | 9 | -------------------------------------------------------------------------------- /web/pages/playground/+config.ts: -------------------------------------------------------------------------------- 1 | import type { Config } from 'vike/types' 2 | 3 | const config: Config = { 4 | pageTitle: 'Playground', 5 | layoutClassName: 'wide', 6 | } 7 | 8 | export default config 9 | -------------------------------------------------------------------------------- /web/content/docs/providers/confluence.mdx: -------------------------------------------------------------------------------- 1 | export const info = { 2 | title: 'Confluence', 3 | group: 'providers', 4 | } 5 | 6 | import Readme from '../../../../provider/confluence/README.md' 7 | 8 | 9 | -------------------------------------------------------------------------------- /web/content/docs/providers/prometheus.mdx: -------------------------------------------------------------------------------- 1 | export const info = { 2 | title: 'Prometheus', 3 | group: 'providers', 4 | } 5 | 6 | import Readme from '../../../../provider/prometheus/README.md' 7 | 8 | 9 | -------------------------------------------------------------------------------- /web/content/docs/providers/storybook.mdx: -------------------------------------------------------------------------------- 1 | export const info = { 2 | title: 'Storybook', 3 | group: 'providers', 4 | } 5 | 6 | import Readme from '../../../../provider/storybook/README.md' 7 | 8 | 9 | -------------------------------------------------------------------------------- /client/browser/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to the OpenCtx browser extension will be documented in this file. 4 | 5 | ## (Unreleased) 6 | 7 | ## 0.0.0 8 | 9 | - Initial release. 10 | -------------------------------------------------------------------------------- /web/content/docs/providers/google-docs.mdx: -------------------------------------------------------------------------------- 1 | export const info = { 2 | title: 'Google Docs', 3 | group: 'providers', 4 | } 5 | 6 | import Readme from '../../../../provider/google-docs/README.md' 7 | 8 | 9 | -------------------------------------------------------------------------------- /web/content/docs/providers/linear-docs.mdx: -------------------------------------------------------------------------------- 1 | export const info = { 2 | title: 'Linear Docs', 3 | group: 'providers', 4 | } 5 | 6 | import Readme from '../../../../provider/linear-docs/README.md' 7 | 8 | 9 | -------------------------------------------------------------------------------- /web/src/lib/utils.ts: -------------------------------------------------------------------------------- 1 | import { type ClassValue, clsx } from 'clsx' 2 | import { twMerge } from 'tailwind-merge' 3 | 4 | export function cn(...inputs: ClassValue[]): string { 5 | return twMerge(clsx(inputs)) 6 | } 7 | -------------------------------------------------------------------------------- /web/content/docs/providers/linear-issues.mdx: -------------------------------------------------------------------------------- 1 | export const info = { 2 | title: 'Linear Issues', 3 | group: 'providers', 4 | } 5 | 6 | import Readme from '../../../../provider/linear-issues/README.md' 7 | 8 | 9 | -------------------------------------------------------------------------------- /client/browser/src/shared/platform.ts: -------------------------------------------------------------------------------- 1 | export type Platform = 'chrome-extension' | 'unknown' 2 | 3 | /** 4 | * The platform where the browser extension is running. 5 | */ 6 | export const platform: Platform = 'chrome-extension' 7 | -------------------------------------------------------------------------------- /client/vscode/.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | .vscode-test/ 3 | .vscode-test-web/ 4 | dist/tsc/ 5 | .gitignore 6 | src/**/*.test.ts 7 | vite.config.ts 8 | node_modules/ 9 | tsconfig.json 10 | test/ 11 | *.tsbuildinfo 12 | dev/** -------------------------------------------------------------------------------- /client/web-playground/src/demo/main.css: -------------------------------------------------------------------------------- 1 | :root { 2 | color-scheme: dark; 3 | } 4 | 5 | body { 6 | margin: 0; 7 | font-size: 14px; 8 | height: 100vh; 9 | } 10 | 11 | #root { 12 | height: 100%; 13 | } 14 | -------------------------------------------------------------------------------- /lib/schema/dev/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "noEmit": true 7 | }, 8 | "include": ["*.ts"] 9 | } 10 | -------------------------------------------------------------------------------- /web/content/docs/clients/codemirror.mdx: -------------------------------------------------------------------------------- 1 | export const info = { 2 | title: 'CodeMirror', 3 | group: 'clients', 4 | order: '901', 5 | } 6 | 7 | import Readme from '@openctx/codemirror-extension/README.md' 8 | 9 | 10 | -------------------------------------------------------------------------------- /web/content/docs/providers/sourcegraph-search.mdx: -------------------------------------------------------------------------------- 1 | export const info = { 2 | title: 'Sourcegraph search', 3 | group: 'providers', 4 | } 5 | 6 | import Readme from '../../../../provider/sourcegraph-search/README.md' 7 | 8 | 9 | -------------------------------------------------------------------------------- /web/content/docs/providers/modelcontextprotocol.mdx: -------------------------------------------------------------------------------- 1 | export const info = { 2 | title: 'Model Context Protocol', 3 | group: 'providers', 4 | } 5 | 6 | import Readme from '../../../../provider/modelcontextprotocol/README.md' 7 | 8 | -------------------------------------------------------------------------------- /web/content/docs/clients/browser-extension.mdx: -------------------------------------------------------------------------------- 1 | export const info = { 2 | title: 'Browser extension', 3 | group: 'clients', 4 | order: 10, 5 | } 6 | 7 | import Readme from '../../../../client/browser/README.md' 8 | 9 | 10 | -------------------------------------------------------------------------------- /web/content/docs/clients/monaco-editor.mdx: -------------------------------------------------------------------------------- 1 | export const info = { 2 | title: 'Monaco Editor', 3 | group: 'clients', 4 | order: '900', 5 | } 6 | 7 | import Readme from '@openctx/monaco-editor-extension/README.md' 8 | 9 | 10 | -------------------------------------------------------------------------------- /web/content/docs/providers/hello-world.mdx: -------------------------------------------------------------------------------- 1 | export const info = { 2 | title: 'Hello World', 3 | group: 'providers', 4 | order: 900, 5 | } 6 | 7 | import Readme from '../../../../provider/hello-world/README.md' 8 | 9 | 10 | -------------------------------------------------------------------------------- /web/content/docs/providers/azure-devops-workitems.mdx: -------------------------------------------------------------------------------- 1 | export const info = { 2 | title: 'Azure DevOps Work Items', 3 | group: 'providers', 4 | } 5 | 6 | import Readme from '../../../../provider/azure-devops-workitems/README.md' 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/protocol/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist" 6 | }, 7 | "include": ["src"], 8 | "references": [{ "path": "../schema" }] 9 | } 10 | -------------------------------------------------------------------------------- /provider/github/settings.ts: -------------------------------------------------------------------------------- 1 | export type Settings = { 2 | /** The accessToken to use to talk to the GitHub API. */ 3 | accessToken: string 4 | /** Optional URL of the GitHub instance, when not using GitHub.com. */ 5 | baseURL?: string 6 | } 7 | -------------------------------------------------------------------------------- /lib/client/src/providerClient/testdata/metaThrow.js: -------------------------------------------------------------------------------- 1 | /** @type {import('@openctx/provider').Provider} */ 2 | export default { 3 | meta() { 4 | throw new Error('metaThrow') 5 | }, 6 | items() { 7 | return [] 8 | }, 9 | } 10 | -------------------------------------------------------------------------------- /lib/client/src/providerClient/transport/testdata/emoji.js: -------------------------------------------------------------------------------- 1 | /** @type {import('@openctx/provider').Provider} */ 2 | export default { 3 | meta: () => ({ 4 | annotations: { selectors: [{ path: 'foo' }] }, 5 | name: 'foo', 6 | }), 7 | } 8 | // ✨ 9 | -------------------------------------------------------------------------------- /lib/client/src/providerClient/transport/testdata/esmProvider.js: -------------------------------------------------------------------------------- 1 | /** @type {import('@openctx/provider').Provider} */ 2 | export default { 3 | meta: () => ({ 4 | annotations: { selectors: [{ path: 'foo' }] }, 5 | name: 'foo', 6 | }), 7 | } 8 | -------------------------------------------------------------------------------- /lib/client/src/providerClient/transport/testdata/commonjsProvider.js: -------------------------------------------------------------------------------- 1 | /** @type {import('@openctx/provider').Provider} */ 2 | module.exports = { 3 | meta: () => ({ 4 | annotations: { selectors: [{ path: 'foo' }] }, 5 | name: 'foo', 6 | }), 7 | } 8 | -------------------------------------------------------------------------------- /lib/client/src/providerClient/transport/testdata/esmExtProvider.mjs: -------------------------------------------------------------------------------- 1 | /** @type {import('@openctx/provider').Provider} */ 2 | export default { 3 | meta: () => ({ 4 | annotations: { selectors: [{ path: 'foo' }] }, 5 | name: 'foo', 6 | }), 7 | } 8 | -------------------------------------------------------------------------------- /client/browser/src/shared/polyfills.ts: -------------------------------------------------------------------------------- 1 | // Polyfill global browser API for Chrome. The API is much nicer to use because it supports 2 | // Promises. The polyfill is also very simple. 3 | import browser from 'webextension-polyfill' 4 | 5 | Object.assign(self, { browser }) 6 | -------------------------------------------------------------------------------- /lib/ui-react/src/chip/Popover.module.css: -------------------------------------------------------------------------------- 1 | .popover { 2 | border: none; 3 | padding: 0; 4 | background-color: unset; 5 | max-width: min(80vw, 450px); 6 | } 7 | 8 | .popover:popover-open { 9 | position: absolute; 10 | inset: unset; 11 | } 12 | -------------------------------------------------------------------------------- /lib/ui-standalone/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | 3 | export default defineConfig({ 4 | css: { 5 | devSourcemap: true, 6 | modules: { 7 | localsConvention: 'camelCaseOnly', 8 | }, 9 | }, 10 | }) 11 | -------------------------------------------------------------------------------- /lib/client/src/providerClient/transport/testdata/commonjsExtProvider.cjs: -------------------------------------------------------------------------------- 1 | /** @type {import('@openctx/provider').OpenCtxProvider} */ 2 | module.exports = { 3 | meta: () => ({ 4 | annotations: { selectors: [{ path: 'foo' }] }, 5 | name: 'foo', 6 | }), 7 | } 8 | -------------------------------------------------------------------------------- /provider/sentry/settings.ts: -------------------------------------------------------------------------------- 1 | /** Settings for the Sentry provider. */ 2 | export type Settings = { 3 | /** Path to the API token. Will be read from the file. */ 4 | apiTokenPath?: string 5 | /** Inline definition of the API token. */ 6 | apiToken?: string 7 | } 8 | -------------------------------------------------------------------------------- /lib/ui-standalone/src/index.ts: -------------------------------------------------------------------------------- 1 | export { createChip } from './chip/Chip.js' 2 | export { createChipList } from './chip/ChipList.js' 3 | export { getPopoverDimensions } from './chip/popover.js' 4 | export { createIndentationWrapper } from './indentationWrapper/IndentationWrapper.js' 5 | -------------------------------------------------------------------------------- /lib/ui-standalone/README.md: -------------------------------------------------------------------------------- 1 | # OpenCtx standalone UI library 2 | 3 | The `@openctx/ui-standalone` package contains OpenCtx UI components that can be used on any web page and do not depend on any particular DOM framework. 4 | 5 | Use `@openctx/ui-react` for UI components implemented in React. 6 | -------------------------------------------------------------------------------- /bin/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "lib": ["ESNext"], 5 | "noEmit": true, 6 | "outDir": "dist" 7 | }, 8 | "include": ["*.mts"], 9 | "exclude": ["dist"], 10 | "references": [{ "path": "../lib/client" }] 11 | } 12 | -------------------------------------------------------------------------------- /client/vscode/dev/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "noEmit": true, 7 | "esModuleInterop": true 8 | }, 9 | "include": ["*.ts", "release.mts", "build.mts"] 10 | } 11 | -------------------------------------------------------------------------------- /lib/provider/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist" 6 | }, 7 | "include": ["src"], 8 | "exclude": ["dist"], 9 | "references": [{ "path": "../protocol" }, { "path": "../schema" }] 10 | } 11 | -------------------------------------------------------------------------------- /web/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "module": "ESNext", 5 | "moduleResolution": "bundler", 6 | "composite": true, 7 | "allowSyntheticDefaultImports": true 8 | }, 9 | "include": ["*.config.ts", "postcss.config.js"] 10 | } 11 | -------------------------------------------------------------------------------- /web/content/docs/clients/sourcegraph.mdx: -------------------------------------------------------------------------------- 1 | import SourcegraphGettingStartedCommon from '../../../pages/docs/components/SourcegraphGettingStartedCommon.mdx' 2 | 3 | export const info = { 4 | title: 'Sourcegraph', 5 | group: 'clients', 6 | } 7 | 8 | # Using OpenCtx in Sourcegraph 9 | 10 | 11 | -------------------------------------------------------------------------------- /web/src/server/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "module": "Node16", 5 | "moduleResolution": "Node16", 6 | "rootDir": ".", 7 | "outDir": "dist", 8 | "composite": true 9 | }, 10 | "include": ["*.ts"], 11 | "exclude": ["dist"] 12 | } 13 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "sourcegraph.openctx", 4 | "sourcegraph.cody-ai", 5 | "ecmel.vscode-html-css", 6 | "biomejs.biome", 7 | "stylelint.vscode-stylelint", 8 | "tamasfe.even-better-toml", 9 | "unifiedjs.vscode-mdx", 10 | "bradlc.vscode-tailwindcss" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /provider/devdocs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "lib": ["ESNext"] 7 | }, 8 | "include": ["*.ts"], 9 | "exclude": ["dist", "vitest.config.ts"], 10 | "references": [{ "path": "../../lib/provider" }] 11 | } 12 | -------------------------------------------------------------------------------- /provider/github/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "lib": ["ESNext"] 7 | }, 8 | "include": ["*.ts"], 9 | "exclude": ["dist", "vitest.config.ts"], 10 | "references": [{ "path": "../../lib/provider" }] 11 | } 12 | -------------------------------------------------------------------------------- /provider/jira/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "lib": ["ESNext"] 7 | }, 8 | "include": ["*.ts"], 9 | "exclude": ["dist", "vitest.config.ts"], 10 | "references": [{ "path": "../../lib/provider" }] 11 | } 12 | -------------------------------------------------------------------------------- /provider/links/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "lib": ["ESNext"] 7 | }, 8 | "include": ["*.ts"], 9 | "exclude": ["dist", "vitest.config.ts"], 10 | "references": [{ "path": "../../lib/provider" }] 11 | } 12 | -------------------------------------------------------------------------------- /provider/notion/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "lib": ["ESNext"] 7 | }, 8 | "include": ["*.ts"], 9 | "exclude": ["dist", "vitest.config.ts"], 10 | "references": [{ "path": "../../lib/provider" }] 11 | } 12 | -------------------------------------------------------------------------------- /provider/sentry/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "lib": ["ESNext"] 7 | }, 8 | "include": ["*.ts"], 9 | "exclude": ["dist", "vitest.config.ts"], 10 | "references": [{ "path": "../../lib/provider" }] 11 | } 12 | -------------------------------------------------------------------------------- /provider/slack/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "lib": ["ESNext"] 7 | }, 8 | "include": ["*.ts"], 9 | "exclude": ["dist", "vitest.config.ts"], 10 | "references": [{ "path": "../../lib/provider" }] 11 | } 12 | -------------------------------------------------------------------------------- /provider/web/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "lib": ["ESNext"] 7 | }, 8 | "include": ["*.ts"], 9 | "exclude": ["dist", "vitest.config.ts"], 10 | "references": [{ "path": "../../lib/provider" }] 11 | } 12 | -------------------------------------------------------------------------------- /web/pages/docs/+onBeforePrerenderStart.ts: -------------------------------------------------------------------------------- 1 | import type { OnBeforePrerenderStartSync } from 'vike/types' 2 | import { createOnBeforePrerenderStart } from '../../src/content/contentPages.tsx' 3 | import { content } from './content.ts' 4 | 5 | export const onBeforePrerenderStart: OnBeforePrerenderStartSync = createOnBeforePrerenderStart(content) 6 | -------------------------------------------------------------------------------- /web/postcss.config.js: -------------------------------------------------------------------------------- 1 | import autoprefixer from 'autoprefixer' 2 | // import type { Config } from 'postcss-load-config' 3 | import tailwindcss from 'tailwindcss' 4 | 5 | /** @type {import('postcss-load-config').Config} */ 6 | const config = { 7 | plugins: [tailwindcss(), autoprefixer()], 8 | } 9 | 10 | export default config 11 | -------------------------------------------------------------------------------- /provider/confluence/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "lib": ["ESNext"] 7 | }, 8 | "include": ["*.ts"], 9 | "exclude": ["dist", "vitest.config.ts"], 10 | "references": [{ "path": "../../lib/provider" }] 11 | } 12 | -------------------------------------------------------------------------------- /provider/google-docs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "lib": ["ESNext"] 7 | }, 8 | "include": ["*.ts"], 9 | "exclude": ["dist", "vitest.config.ts"], 10 | "references": [{ "path": "../../lib/provider" }] 11 | } 12 | -------------------------------------------------------------------------------- /provider/google-docs/utils.ts: -------------------------------------------------------------------------------- 1 | export function parseDocumentIDFromURL(urlStr: string): string | undefined { 2 | const url = new URL(urlStr) 3 | if (url.hostname !== 'docs.google.com') { 4 | return undefined 5 | } 6 | const match = url.pathname.match(/\/d\/([a-zA-Z0-9_-]+)/) 7 | return match ? match[1] : undefined 8 | } 9 | -------------------------------------------------------------------------------- /provider/hello-world/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "lib": ["ESNext"] 7 | }, 8 | "include": ["*.ts"], 9 | "exclude": ["dist", "vitest.config.ts"], 10 | "references": [{ "path": "../../lib/provider" }] 11 | } 12 | -------------------------------------------------------------------------------- /provider/linear-docs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "lib": ["ESNext"] 7 | }, 8 | "include": ["*.ts"], 9 | "exclude": ["dist", "vitest.config.ts"], 10 | "references": [{ "path": "../../lib/provider" }] 11 | } 12 | -------------------------------------------------------------------------------- /provider/prometheus/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "lib": ["ESNext"] 7 | }, 8 | "include": ["*.ts"], 9 | "exclude": ["dist", "vitest.config.ts"], 10 | "references": [{ "path": "../../lib/provider" }] 11 | } 12 | -------------------------------------------------------------------------------- /client/codemirror/demo/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "lib": ["DOM"] 7 | }, 8 | "include": ["*.ts"], 9 | "exclude": ["dist"], 10 | "references": [ 11 | { 12 | "path": "../" 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /lib/client/src/providerClient/transport/testdata/esmProvider.ts: -------------------------------------------------------------------------------- 1 | import type { Provider } from '@openctx/provider' 2 | 3 | const provider: Provider = { 4 | meta: () => ({ 5 | annotations: { selectors: [{ path: 'foo' }] }, 6 | name: 'foo', 7 | }), 8 | annotations: () => [], 9 | } 10 | 11 | export default provider 12 | -------------------------------------------------------------------------------- /provider/linear-issues/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "lib": ["ESNext"] 7 | }, 8 | "include": ["*.ts"], 9 | "exclude": ["dist", "vitest.config.ts"], 10 | "references": [{ "path": "../../lib/provider" }] 11 | } 12 | -------------------------------------------------------------------------------- /provider/sourcegraph-refs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "lib": ["ESNext"] 7 | }, 8 | "include": ["*.ts"], 9 | "exclude": ["dist", "vitest.config.ts"], 10 | "references": [{ "path": "../../lib/provider" }] 11 | } 12 | -------------------------------------------------------------------------------- /client/codemirror/demo/README.md: -------------------------------------------------------------------------------- 1 | # Demo: OpenCtx extension for CodeMirror 2 | 3 | This is a simple demo that uses the [`@openctx/codemirror-extension`](https://www.npmjs.com/package/@openctx/codemirror-extension) npm package to show OpenCtx items in a CodeMirror editor. 4 | 5 | ## Usage 6 | 7 | Run `pnpm run dev` and then visit http://localhost:5902. 8 | -------------------------------------------------------------------------------- /client/monaco-editor/demo/README.md: -------------------------------------------------------------------------------- 1 | # Demo: OpenCtx extension for Monaco Editor 2 | 3 | This is a simple demo that uses the [`@openctx/codemirror-extension`](https://www.npmjs.com/package/@openctx/codemirror-extension) npm package to show OpenCtx items in Monaco Editor. 4 | 5 | ## Usage 6 | 7 | Run `pnpm run dev` and then visit http://localhost:5901. 8 | -------------------------------------------------------------------------------- /client/monaco-editor/demo/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "lib": ["DOM"] 7 | }, 8 | "include": ["*.ts"], 9 | "exclude": ["dist"], 10 | "references": [ 11 | { 12 | "path": "../" 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /client/web-playground/src/demo.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactDOM from 'react-dom/client' 3 | import './demo.css' 4 | import { DemoApp } from './demo/DemoApp.js' 5 | 6 | ReactDOM.createRoot(document.querySelector('#root') as HTMLElement).render( 7 | 8 | 9 | , 10 | ) 11 | -------------------------------------------------------------------------------- /client/web-playground/src/demo/main.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactDOM from 'react-dom/client' 3 | import { DemoApp } from './DemoApp.js' 4 | import './main.css' 5 | 6 | ReactDOM.createRoot(document.querySelector('#root') as HTMLElement).render( 7 | 8 | 9 | , 10 | ) 11 | -------------------------------------------------------------------------------- /lib/ui-common/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist", 6 | "lib": ["DOM", "ESNext"] 7 | }, 8 | "include": ["src"], 9 | "exclude": ["dist"], 10 | "references": [ 11 | { 12 | "path": "../schema" 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /provider/azure-devops-workitems/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "lib": ["ESNext"] 7 | }, 8 | "include": ["*.ts"], 9 | "exclude": ["dist", "vitest.config.ts"], 10 | "references": [{ "path": "../../lib/provider" }] 11 | } 12 | -------------------------------------------------------------------------------- /provider/modelcontextprotocol/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "lib": ["ESNext"] 7 | }, 8 | "include": ["*.ts"], 9 | "exclude": ["dist", "vitest.config.ts"], 10 | "references": [{ "path": "../../lib/provider" }] 11 | } 12 | -------------------------------------------------------------------------------- /provider/sourcegraph-search/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "lib": ["ESNext"] 7 | }, 8 | "include": ["*.ts"], 9 | "exclude": ["dist", "vitest.config.ts"], 10 | "references": [{ "path": "../../lib/provider" }] 11 | } 12 | -------------------------------------------------------------------------------- /client/vscode/test/fixtures/workspace/Label.tsx: -------------------------------------------------------------------------------- 1 | import type { FunctionComponent } from 'react' 2 | import { eventLogger } from './eventLogger.js' 3 | 4 | export const Label: FunctionComponent<{ title: string; htmlFor?: string }> = ({ title, htmlFor }) => { 5 | eventLogger.log('Label', { title }) 6 | return 7 | } 8 | -------------------------------------------------------------------------------- /provider/modelcontextprotocoltools/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "lib": ["ESNext"] 7 | }, 8 | "include": ["*.ts"], 9 | "exclude": ["dist", "vitest.config.ts"], 10 | "references": [{ "path": "../../lib/provider" }] 11 | } 12 | -------------------------------------------------------------------------------- /client/vscode-lib/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist", 6 | "lib": ["ESNext", "DOM"] 7 | }, 8 | "include": ["src"], 9 | "exclude": ["dist"], 10 | "references": [ 11 | { 12 | "path": "../../lib/client" 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /lib/client/src/providerClient/testdata/methodsThrow.js: -------------------------------------------------------------------------------- 1 | /** @type {import('@openctx/provider').Provider} */ 2 | export default { 3 | meta() { 4 | return { annotations: {} } 5 | }, 6 | items() { 7 | throw new Error('itemsThrow') 8 | }, 9 | annotations() { 10 | throw new Error('annotationsThrow') 11 | }, 12 | } 13 | -------------------------------------------------------------------------------- /web/content/docs/clients/vscode.mdx: -------------------------------------------------------------------------------- 1 | export const info = { 2 | title: 'VS Code', 3 | group: 'clients', 4 | order: 0, 5 | } 6 | 7 | import Readme from '../../../../client/vscode/README.md' 8 | 9 | 10 | 11 | ## Notes 12 | 13 | - The extension is also published to the [Open VSX Registry](https://open-vsx.org/extension/sourcegraph/openctx). 14 | -------------------------------------------------------------------------------- /lib/ui-standalone/.storybook/main.ts: -------------------------------------------------------------------------------- 1 | import type { StorybookConfig } from '@storybook/html-vite' 2 | 3 | export default { 4 | stories: ['../src/**/*.story.@(js|jsx|ts|tsx)'], 5 | addons: ['@storybook/addon-essentials'], 6 | framework: { 7 | name: '@storybook/html-vite', 8 | options: {}, 9 | }, 10 | } satisfies StorybookConfig 11 | -------------------------------------------------------------------------------- /web/src/server/root.ts: -------------------------------------------------------------------------------- 1 | // https://stackoverflow.com/questions/46745014/alternative-for-dirname-in-node-when-using-the-experimental-modules-flag/50052194#50052194 2 | 3 | import { dirname } from 'node:path' 4 | import { fileURLToPath } from 'node:url' 5 | 6 | export { root } 7 | 8 | const __dirname = dirname(fileURLToPath(import.meta.url)) 9 | const root = `${__dirname}/..` 10 | -------------------------------------------------------------------------------- /client/web-playground/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | OpenCtx playground 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /provider/semgrep/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "esModuleInterop": true, 4 | "compilerOptions": { 5 | "rootDir": ".", 6 | "outDir": "dist", 7 | "lib": ["ESNext", "DOM"] 8 | }, 9 | "include": ["*.ts"], 10 | "exclude": ["dist", "mocks", "*.test.*", "vitest.config.ts"], 11 | "references": [{ "path": "../../lib/provider" }] 12 | } 13 | -------------------------------------------------------------------------------- /client/vscode-lib/src/testing.ts: -------------------------------------------------------------------------------- 1 | import type { Controller } from './controller.js' 2 | 3 | /** 4 | * The API exposed for this VS Code extension's tests. 5 | */ 6 | export interface ExtensionApiForTesting extends Pick {} 7 | 8 | export function createApiForTesting(controller: Controller): ExtensionApiForTesting { 9 | return controller 10 | } 11 | -------------------------------------------------------------------------------- /client/vscode/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "sourceMap": true, 5 | "rootDir": ".", 6 | "outDir": "dist/tsc", 7 | "lib": ["ESNext", "DOM"] 8 | }, 9 | "include": ["src"], 10 | "exclude": ["dist", "testadata"], 11 | "references": [ 12 | { 13 | "path": "../../lib/client" 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /web/pages/docs/+Page.tsx: -------------------------------------------------------------------------------- 1 | import type { FunctionComponent } from 'react' 2 | import { ContentPage } from '../../src/content/ContentPage.tsx' 3 | import { DocsLayout } from './components/DocsLayout.tsx' 4 | import { content } from './content.ts' 5 | 6 | export const Page: FunctionComponent = () => ( 7 | 8 | 9 | 10 | ) 11 | -------------------------------------------------------------------------------- /lib/ui-standalone/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist", 6 | "lib": ["DOM", "ESNext"] 7 | }, 8 | "include": ["src"], 9 | "exclude": ["dist"], 10 | "references": [ 11 | { 12 | "path": "../schema" 13 | }, 14 | { 15 | "path": "../ui-common" 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /web/components.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://ui.shadcn.com/schema.json", 3 | "style": "default", 4 | "rsc": true, 5 | "tsx": true, 6 | "tailwind": { 7 | "config": "tailwind.config.ts", 8 | "css": "src/global.css", 9 | "baseColor": "neutral", 10 | "cssVariables": true 11 | }, 12 | "aliases": { "utils": "/DELETE/../../lib/utils.ts", "components": "/DELETE/src/components" } 13 | } 14 | -------------------------------------------------------------------------------- /client/web-playground/src/demo/DemoMentionsConsole.tsx: -------------------------------------------------------------------------------- 1 | import type { ComponentProps, FunctionComponent } from 'react' 2 | import { MentionsConsole } from '../MentionsConsole.js' 3 | 4 | export const DemoMentionsConsole: FunctionComponent< 5 | Omit, 'resourceUri' | 'value' | 'onChange' | 'headerChildren'> 6 | > = ({ ...props }) => { 7 | return 8 | } 9 | -------------------------------------------------------------------------------- /client/vscode/test/integration/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "module": "CommonJS", 5 | "moduleResolution": "Node", 6 | "esModuleInterop": true, 7 | "rootDir": ".", 8 | "outDir": "../../dist/tsc/test/integration", 9 | "types": ["mocha", "node"] 10 | }, 11 | "include": ["*.cts"], 12 | "references": [{ "path": "../../" }] 13 | } 14 | -------------------------------------------------------------------------------- /client/codemirror/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist", 6 | "jsx": "react-jsx", 7 | "lib": ["DOM"] 8 | }, 9 | "include": ["src"], 10 | "exclude": ["dist"], 11 | "references": [ 12 | { 13 | "path": "../../lib/client" 14 | }, 15 | { 16 | "path": "../../lib/ui-react" 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /client/monaco-editor/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist", 6 | "jsx": "react-jsx", 7 | "lib": ["DOM"] 8 | }, 9 | "include": ["src"], 10 | "exclude": ["dist"], 11 | "references": [ 12 | { 13 | "path": "../../lib/client" 14 | }, 15 | { 16 | "path": "../../lib/ui-react" 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /client/browser/dev/create-icons.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eu 4 | INIT_CWD=$PWD 5 | cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 6 | 7 | INPUT_SVG=../../../web/public/logomark-v0.svg 8 | 9 | SIZES=( 10 | 32 11 | 48 12 | 128 13 | ) 14 | for size in "${SIZES[@]}"; do 15 | out=$(realpath ../public/icon-${size}.png) 16 | pnpx svgexport@0.4.2 "$INPUT_SVG" "$out" png 100% ${size}:${size} 17 | echo ${out/$INIT_CWD\//} 18 | done 19 | -------------------------------------------------------------------------------- /client/codemirror/demo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | OpenCtx CodeMirror extension demo 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /bin/sample-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "enable": true, 3 | "debug": true, 4 | "providers": { 5 | "../../provider/hello-world/dist/index.js": true, 6 | "../../provider/links/dist/index.js": { 7 | "links": [ 8 | { 9 | "title": "My link", 10 | "url": "https://example.com", 11 | "type": "docs", 12 | "preview": true, 13 | "path": "**" 14 | } 15 | ] 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /client/browser/src/browser-extension/web-extension-api/runtime.ts: -------------------------------------------------------------------------------- 1 | import { proxyBackgroundMethodReturningObservable } from './rpc.js' 2 | import type { BackgroundApi } from './types.js' 3 | 4 | /** 5 | * Functions invoked from content scripts that will be executed in the background service worker. 6 | */ 7 | export const background: BackgroundApi = { 8 | annotationsChanges: proxyBackgroundMethodReturningObservable('annotationsChanges'), 9 | } 10 | -------------------------------------------------------------------------------- /client/monaco-editor/demo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | OpenCtx Monaco editor extension demo 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /provider/semgrep/api.test.ts: -------------------------------------------------------------------------------- 1 | import { describe, expect, test } from 'vitest' 2 | 3 | import { urlfor } from './api.js' 4 | 5 | describe('api urlfor', () => { 6 | test('url parameters', () => { 7 | expect(urlfor('depl', 'repo')).toEqual('https://semgrep.dev/orgs/depl/findings?repo=repo') 8 | expect(urlfor('depl', 'repo', 123)).toEqual( 9 | 'https://semgrep.dev/orgs/depl/findings/123?repo=repo', 10 | ) 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /client/browser/src/options/options.main.tsx: -------------------------------------------------------------------------------- 1 | import '../shared/polyfills' 2 | // ^^ import polyfills first 3 | 4 | import React from 'react' 5 | import ReactDOM from 'react-dom/client' 6 | import { OptionsPage } from './OptionsPage.js' 7 | 8 | const root = document.createElement('div') 9 | root.id = 'root' 10 | document.body.append(root) 11 | 12 | ReactDOM.createRoot(root).render( 13 | 14 | 15 | , 16 | ) 17 | -------------------------------------------------------------------------------- /client/browser/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "jsx": "react-jsx", 7 | "lib": ["ESNext", "DOM"], 8 | "types": ["vite/client", "chrome"], 9 | "resolveJsonModule": true 10 | }, 11 | "include": ["src", "*.config.ts", "package.json"], 12 | "exclude": ["dist"], 13 | "references": [{ "path": "../../lib/client" }, { "path": "../../lib/ui-react" }] 14 | } 15 | -------------------------------------------------------------------------------- /lib/ui-react/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist", 6 | "jsx": "react-jsx", 7 | "lib": ["DOM", "ESNext"] 8 | }, 9 | "include": ["src"], 10 | "exclude": ["dist"], 11 | "references": [ 12 | { 13 | "path": "../schema" 14 | }, 15 | { 16 | "path": "../ui-standalone" 17 | }, 18 | { 19 | "path": "../ui-common" 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /web/pages/_error/+Page.tsx: -------------------------------------------------------------------------------- 1 | import { usePageContext } from 'vike-react/usePageContext' 2 | 3 | export function Page() { 4 | const pageContext = usePageContext() 5 | 6 | return pageContext.is404 ? ( 7 | <> 8 |

404 Page Not Found

9 |

This page could not be found.

10 | 11 | ) : ( 12 | <> 13 |

500 Internal Error

14 |

Something went wrong.

15 | 16 | ) 17 | } 18 | -------------------------------------------------------------------------------- /web/pages/playground/+Page.tsx: -------------------------------------------------------------------------------- 1 | import type { FunctionComponent } from 'react' 2 | import { layoutItemClassName, normalLayoutClassName } from '../../src/layout/config.ts' 3 | import { Playground } from './Playground.tsx' 4 | import Text from './text.mdx' 5 | 6 | export const Page: FunctionComponent = () => ( 7 | <> 8 |
9 | 10 |
11 | 12 | 13 | ) 14 | -------------------------------------------------------------------------------- /client/vscode-lib/src/util/importHelpers.test.ts: -------------------------------------------------------------------------------- 1 | import { describe, expect, test, vi } from 'vitest' 2 | import { importESMFromString } from './importHelpers.js' 3 | 4 | vi.mock('vscode', () => ({ 5 | env: { uiKind: 1 }, 6 | UIKind: { Desktop: 1 }, 7 | })) 8 | 9 | describe('importESMFromString', () => { 10 | test('works', async () => 11 | expect({ ...((await importESMFromString('export default 123')) as any) }).toEqual({ 12 | default: 123, 13 | })) 14 | }) 15 | -------------------------------------------------------------------------------- /lib/client/src/logger.ts: -------------------------------------------------------------------------------- 1 | export type Logger = (message: string) => void 2 | 3 | export function scopedLogger(logger: Logger, prefix: string): Logger 4 | export function scopedLogger(logger: Logger | undefined, prefix: string): Logger | undefined 5 | export function scopedLogger(logger: Logger | undefined, prefix: string): Logger | undefined { 6 | return logger 7 | ? (message: string) => { 8 | logger(`[${prefix}]: ${message}`) 9 | } 10 | : undefined 11 | } 12 | -------------------------------------------------------------------------------- /lib/client/src/client/testdata/simple.js: -------------------------------------------------------------------------------- 1 | /** @type {import('@openctx/provider').Provider} */ 2 | export default { 3 | meta: () => ({ name:'simple', annotations: {} }), 4 | items: () => [ 5 | { 6 | title: 'A', 7 | }, 8 | ], 9 | annotations: params => [ 10 | { 11 | uri: params.uri, 12 | range: { start: { line: 1, character: 2 }, end: { line: 3, character: 4 } }, 13 | item: { title: 'A' }, 14 | }, 15 | ], 16 | } 17 | -------------------------------------------------------------------------------- /vitest.workspace.ts: -------------------------------------------------------------------------------- 1 | import { readFileSync } from 'node:fs' 2 | import path from 'node:path' 3 | import { load } from 'js-yaml' 4 | 5 | interface PnpmWorkspaceFile { 6 | packages: string[] 7 | } 8 | 9 | function fromPnpmWorkspaceFile(filePath: string): string[] { 10 | return (load(readFileSync(filePath, 'utf8')) as PnpmWorkspaceFile).packages.map( 11 | p => `${p}/{vitest,vite}.config.ts`, 12 | ) 13 | } 14 | 15 | export default fromPnpmWorkspaceFile(path.join(__dirname, 'pnpm-workspace.yaml')) 16 | -------------------------------------------------------------------------------- /web/pages/playground/text.mdx: -------------------------------------------------------------------------------- 1 | # OpenCtx playground 2 | 3 | The following code file has OpenCtx items. Hover over them. You can change the settings on the left to add new patterns or new providers, and you can change the file contents on the right to see new items show up. 4 | 5 | Of course, the real value of OpenCtx is when your editor and other code-viewing tools all fetch settings (contributed by your entire team) with a bunch of existing, helpful OpenCtx providers. This is just a toy demo showing a simple provider. 6 | -------------------------------------------------------------------------------- /client/web-playground/src/EditorHeader.module.css: -------------------------------------------------------------------------------- 1 | .header { 2 | display: flex; 3 | gap: calc(2 * var(--spacing)); 4 | align-items: baseline; 5 | } 6 | 7 | .header h1 { 8 | margin: 0; 9 | white-space: nowrap; 10 | font-size: unset; 11 | font-weight: semibold; 12 | } 13 | 14 | .status { 15 | white-space: nowrap; 16 | overflow: hidden; 17 | text-overflow: ellipsis; 18 | } 19 | 20 | .status--ok { 21 | color: green; 22 | } 23 | 24 | .status--error { 25 | color: red; 26 | } 27 | -------------------------------------------------------------------------------- /client/web-playground/src/codemirror.ts: -------------------------------------------------------------------------------- 1 | import type { ReactCodeMirrorProps } from '@uiw/react-codemirror' 2 | 3 | export function mergeCodeMirrorProps( 4 | defaults: Omit, 5 | props: Omit | undefined, 6 | ): Omit { 7 | return { 8 | ...defaults, 9 | ...props, 10 | extensions: [...(defaults.extensions ?? []), ...(props?.extensions ?? [])], 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/client/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist", 6 | "paths": { 7 | // Workaround for https://github.com/IanVS/vitest-fetch-mock/issues/10. 8 | "vitest-fetch-mock": ["./node_modules/vitest-fetch-mock/types/index.d.ts"] 9 | } 10 | }, 11 | "include": ["src"], 12 | "exclude": ["dist"], 13 | "references": [{ "path": "../protocol" }, { "path": "../provider" }, { "path": "../schema" }] 14 | } 15 | -------------------------------------------------------------------------------- /lib/provider/src/index.ts: -------------------------------------------------------------------------------- 1 | // Import from a subpackage because the main module calls `os.platform()`, which doesn't work on 2 | // non-Node engines. 3 | import matchGlob from 'picomatch/lib/picomatch.js' 4 | 5 | export type * from '@openctx/protocol' 6 | export type * from '@openctx/schema' 7 | export type { Provider } from './provider.js' 8 | 9 | export { createFilePositionCalculator, type PositionCalculator } from './helpers/position.js' 10 | 11 | // For convenience, since many providers need globs. 12 | export { matchGlob } 13 | -------------------------------------------------------------------------------- /client/browser/src/options/options.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | OpenCtx extension 6 | 7 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /provider/storybook/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../.config/tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "dist", 6 | "lib": ["ESNext"], 7 | "paths": { 8 | // Workaround for https://github.com/IanVS/vitest-fetch-mock/issues/10. 9 | "vitest-fetch-mock": ["./node_modules/vitest-fetch-mock/types/index.d.ts"] 10 | } 11 | }, 12 | "include": ["*.ts"], 13 | "exclude": ["dist", "vitest.config.ts"], 14 | "references": [{ "path": "../../lib/provider" }] 15 | } 16 | -------------------------------------------------------------------------------- /client/browser/src/contentScript/debug.ts: -------------------------------------------------------------------------------- 1 | import { tap } from '@openctx/client/observable' 2 | import { Observable, type ObservableLike } from 'observable-fns' 3 | 4 | /** 5 | * Additional debug logging. 6 | */ 7 | export const DEBUG = true 8 | 9 | /** 10 | * Like the standard Observable {@link tap}, but only run if {@link DEBUG} is true. 11 | */ 12 | export const debugTap: typeof tap = DEBUG 13 | ? tap 14 | : () => 15 | (source: ObservableLike): Observable => 16 | Observable.from(source) 17 | -------------------------------------------------------------------------------- /web/src/components/content/MdxComponents.tsx: -------------------------------------------------------------------------------- 1 | import '@code-hike/mdx/styles' 2 | import type { MDXComponents } from 'mdx/types.js' 3 | import styles from './MdxComponents.module.css' 4 | import './github-from-css.css' 5 | 6 | export const MDX_COMPONENTS: Readonly = { 7 | wrapper: ({ children }) =>
{children}
, 8 | a: ({ children, href, ...props }) => ( 9 | 10 | {children} 11 | 12 | ), 13 | } 14 | -------------------------------------------------------------------------------- /lib/client/src/providerClient/testdata/transportReuse.js: -------------------------------------------------------------------------------- 1 | global.__test__transportReuseInfo.moduleLoads++ 2 | 3 | /** @type {import('@openctx/provider').Provider} */ 4 | export default { 5 | meta() { 6 | global.__test__transportReuseInfo.metaCalls++ 7 | return { annotations: {} } 8 | }, 9 | items() { 10 | global.__test__transportReuseInfo.itemsCalls++ 11 | return [] 12 | }, 13 | annotations() { 14 | global.__test__transportReuseInfo.annotationsCalls++ 15 | return [] 16 | }, 17 | } 18 | -------------------------------------------------------------------------------- /lib/ui-react/.storybook/main.ts: -------------------------------------------------------------------------------- 1 | import type { StorybookConfig } from '@storybook/react-vite' 2 | import { mergeConfig } from 'vite' 3 | 4 | const config: StorybookConfig = { 5 | stories: ['../src/**/*.story.@(js|jsx|ts|tsx)'], 6 | addons: ['@storybook/addon-essentials'], 7 | framework: { 8 | name: '@storybook/react-vite', 9 | options: {}, 10 | }, 11 | async viteFinal(config) { 12 | return mergeConfig(config, { css: { modules: { localsConvention: 'camelCaseOnly' } } }) 13 | }, 14 | } 15 | export default config 16 | -------------------------------------------------------------------------------- /client/monaco-editor/demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "@openctx/monaco-editor-extension-demo", 4 | "type": "module", 5 | "sideEffects": false, 6 | "scripts": { 7 | "dev": "vite" 8 | }, 9 | "dependencies": { 10 | "@openctx/client": "workspace:*", 11 | "@openctx/monaco-editor-extension": "workspace:*", 12 | "monaco-editor": "^0.45.0", 13 | "@openctx/provider-hello-world": "workspace:*" 14 | }, 15 | "devDependencies": { 16 | "vite-plugin-monaco-editor": "^1.1.0" 17 | }, 18 | "version": "0.0.11" 19 | } 20 | -------------------------------------------------------------------------------- /web/src/components/ClientOnlySync.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | type ComponentType, 3 | type FunctionComponent, 4 | type ReactElement, 5 | useEffect, 6 | useState, 7 | } from 'react' 8 | 9 | export const ClientOnlySync: FunctionComponent<{ 10 | component: ComponentType 11 | initial: ReactElement 12 | }> = ({ component, initial }) => { 13 | const [Component, setComponent] = useState() 14 | 15 | useEffect(() => { 16 | setComponent(() => component) 17 | }, [component]) 18 | 19 | return Component ? : initial 20 | } 21 | -------------------------------------------------------------------------------- /web/src/components/codemirror/defaults.ts: -------------------------------------------------------------------------------- 1 | import { EditorView } from '@codemirror/view' 2 | import type { SettingsEditor } from '@openctx/web-playground' 3 | import { octxDarkTheme, octxHighlightStyle } from './colorTheme.ts' 4 | 5 | const makeChipTextSmaller = EditorView.theme({ 6 | '.octx-chip': { 7 | fontSize: '78%', 8 | }, 9 | }) 10 | 11 | export const DEFAULT_CODEMIRROR_PROPS: React.ComponentProps['codeMirrorProps'] = { 12 | extensions: [octxHighlightStyle, makeChipTextSmaller], 13 | theme: octxDarkTheme, 14 | style: { fontSize: '90%' }, 15 | } 16 | -------------------------------------------------------------------------------- /client/codemirror/demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "@openctx/codemirror-extension-demo", 4 | "type": "module", 5 | "sideEffects": false, 6 | "scripts": { 7 | "dev": "vite" 8 | }, 9 | "dependencies": { 10 | "@codemirror/commands": "^6.3.2", 11 | "@codemirror/lang-javascript": "^6.2.1", 12 | "@codemirror/state": "^6.3.1", 13 | "@codemirror/view": "^6.22.0", 14 | "@openctx/client": "workspace:*", 15 | "@openctx/codemirror-extension": "workspace:*", 16 | "@openctx/provider-hello-world": "workspace:*" 17 | }, 18 | "version": "0.0.11" 19 | } 20 | -------------------------------------------------------------------------------- /provider/sentry/auth.ts: -------------------------------------------------------------------------------- 1 | import { readFile } from 'node:fs/promises' 2 | import type { Settings } from './settings.js' 3 | 4 | /** 5 | * getSentryAccessToken retrieves a sentry access token from the config, or null 6 | * if nothing was configured. 7 | */ 8 | export async function getSentryAccessToken(settings: Settings): Promise { 9 | if (settings.apiToken) { 10 | return settings.apiToken 11 | } 12 | 13 | if (settings.apiTokenPath) { 14 | const content = await readFile(settings.apiTokenPath, 'utf-8') 15 | return content 16 | } 17 | 18 | return null 19 | } 20 | -------------------------------------------------------------------------------- /client/vscode/test/fixtures/workspace/Label.story.tsx: -------------------------------------------------------------------------------- 1 | import type { Meta, StoryObj } from '@storybook/react' 2 | import { Label } from './Label.js' 3 | 4 | const meta: Meta = { 5 | title: 'Label', 6 | component: Label, 7 | decorators: [ 8 | story => ( 9 |
10 | {story()} 11 |
12 | ), 13 | ], 14 | } 15 | 16 | export default meta 17 | 18 | type Story = StoryObj 19 | 20 | export const Text: Story = { 21 | args: { title: 'Hello, world!' }, 22 | } 23 | -------------------------------------------------------------------------------- /lib/client/src/providerClient/testdata/provider.js: -------------------------------------------------------------------------------- 1 | /** @type {import('@openctx/provider').Provider} */ 2 | export default { 3 | meta: () => ({ 4 | annotations: { selectors: [{ path: 'foo' }] }, 5 | name: 'foo', 6 | }), 7 | items: (_params, settings) => [ 8 | { 9 | title: settings.myTitle, 10 | }, 11 | ], 12 | annotations: (params, settings) => [ 13 | { 14 | uri: params.uri, 15 | range: { start: { line: 1, character: 2 }, end: { line: 3, character: 4 } }, 16 | item: { title: settings.myTitle }, 17 | }, 18 | ], 19 | } 20 | -------------------------------------------------------------------------------- /provider/sentry/auth.test.ts: -------------------------------------------------------------------------------- 1 | import { describe, expect, test } from 'vitest' 2 | import { getSentryAccessToken } from './auth.js' 3 | 4 | describe('getSentryAccessToken', () => { 5 | test('returns apiToken when provided', async () => { 6 | const settings = { apiToken: 'abc123' } 7 | const token = await getSentryAccessToken(settings) 8 | expect(token).toBe('abc123') 9 | }) 10 | 11 | test('returns null when no apiToken or apiTokenPath provided', async () => { 12 | const settings = {} 13 | const token = await getSentryAccessToken(settings) 14 | expect(token).toBeNull() 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /provider/sourcegraph-refs/README.md: -------------------------------------------------------------------------------- 1 | # Sourcegraph refs context provider for OpenCtx 2 | 3 | This is a context provider for [OpenCtx](https://openctx.org) that fetches Sourcegraph references for use as context. 4 | 5 | ## Usage 6 | 7 | Add the following to your settings in any OpenCtx client: 8 | 9 | ```json 10 | "openctx.providers": { 11 | // ...other providers... 12 | "https://openctx.org/npm/@openctx/provider-sourcegraph-refs": { 13 | "sourcegraphEndpoint": "https://sourcegraph.com", 14 | "sourcegraphToken": "$YOUR_TOKEN", 15 | "repositoryNames": ["github.com/sourcegraph/cody"] 16 | } 17 | }, 18 | ``` 19 | -------------------------------------------------------------------------------- /client/vscode-lib/src/controller.test.ts: -------------------------------------------------------------------------------- 1 | import { type MockedObject, describe, expect, test, vi } from 'vitest' 2 | import type { Controller } from './controller.js' 3 | 4 | export function createMockController(): MockedObject { 5 | return { 6 | metaChanges: vi.fn(), 7 | meta: vi.fn(), 8 | mentionsChanges: vi.fn(), 9 | mentions: vi.fn(), 10 | itemsChanges: vi.fn(), 11 | items: vi.fn(), 12 | annotationsChanges: vi.fn(), 13 | annotations: vi.fn(), 14 | } 15 | } 16 | 17 | describe('dummy', () => 18 | test('dummy', () => { 19 | expect(true).toBe(true) 20 | })) 21 | -------------------------------------------------------------------------------- /provider/azure-devops-workitems/types.ts: -------------------------------------------------------------------------------- 1 | export interface WorkItemReference { 2 | id?: number 3 | url?: string 4 | } 5 | export interface WorkItemQueryResult { 6 | workItems?: WorkItemReference[] 7 | } 8 | export interface WorkItemRelation { 9 | attributes?: { 10 | [key: string]: any 11 | } 12 | rel?: string 13 | url?: string 14 | } 15 | 16 | export interface WorkItem { 17 | fields?: { 18 | [key: string]: any 19 | } 20 | id?: number 21 | relations?: WorkItemRelation[] 22 | rev?: number 23 | } 24 | 25 | export interface AzDevArrayResponse { 26 | count: number 27 | value: T[] 28 | } 29 | -------------------------------------------------------------------------------- /client/web-playground/src/promptEditorConfig.ts: -------------------------------------------------------------------------------- 1 | import type { PromptEditorConfig } from '@sourcegraph/prompt-editor' 2 | import { 3 | Command, 4 | CommandEmpty, 5 | CommandGroup, 6 | CommandInput, 7 | CommandItem, 8 | CommandList, 9 | CommandLoading, 10 | CommandSeparator, 11 | } from 'cmdk' 12 | 13 | export const PROMPT_EDITOR_CONFIG: PromptEditorConfig = { 14 | commandComponents: { 15 | Command: Command, 16 | CommandEmpty, 17 | CommandGroup, 18 | CommandInput, 19 | CommandItem, 20 | CommandSeparator, 21 | CommandList, 22 | CommandLoading, 23 | }, 24 | } 25 | -------------------------------------------------------------------------------- /client/vscode-lib/src/global.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode' 2 | 3 | // dynamic imports don't work in node + vscode due to 4 | // https://github.com/microsoft/vscode-loader/issues/36 5 | // 6 | // So vscode-lib sets a global so providers can optionally access vscode APIs. 7 | 8 | interface Global { 9 | openctx?: { 10 | vscode?: typeof vscode 11 | } 12 | } 13 | 14 | export function initializeOpenCtxGlobal() { 15 | initializeGlobal(global as Global) 16 | } 17 | 18 | function initializeGlobal(global: Global) { 19 | if (!global.openctx) { 20 | global.openctx = { vscode } 21 | } 22 | global.openctx.vscode = vscode 23 | } 24 | -------------------------------------------------------------------------------- /web/pages/docs/+onBeforeRender.ts: -------------------------------------------------------------------------------- 1 | import { redirect } from 'vike/abort' 2 | import type { OnBeforeRenderAsync } from 'vike/types' 3 | import { createOnBeforeRender, slugFromPageContext } from '../../src/content/contentPages.tsx' 4 | import { content } from './content.ts' 5 | 6 | const onBeforeRenderContent = createOnBeforeRender(content) 7 | 8 | export const onBeforeRender: OnBeforeRenderAsync = async ( 9 | pageContext, 10 | ): ReturnType => { 11 | const slug = slugFromPageContext(pageContext) 12 | if (slug === 'index') { 13 | throw redirect('/docs/start') 14 | } 15 | return onBeforeRenderContent(pageContext) 16 | } 17 | -------------------------------------------------------------------------------- /web/pages/playground/Preload.tsx: -------------------------------------------------------------------------------- 1 | import type { FunctionComponent } from 'react' 2 | import { PRELOAD_RESOURCES } from './data.ts' 3 | 4 | /** 5 | * Preloads the resources used in the playground so that the hovers are faster. 6 | */ 7 | export const Preload: FunctionComponent = () => ( 8 |
9 | {PRELOAD_RESOURCES.map(({ url, as }) => 10 | as === 'image' ? ( 11 | 12 | ) : as === 'script' ? ( 13 |