Skip to content

Commit 0e15654

Browse files
author
Frank
committed
wip: vscode extension
1 parent f9a47fe commit 0e15654

18 files changed

Lines changed: 1005 additions & 2 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: publish-vscode
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- "vscode-v*.*.*"
8+
9+
concurrency: ${{ github.workflow }}-${{ github.ref }}
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
publish:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
22+
- uses: oven-sh/setup-bun@v2
23+
with:
24+
bun-version: 1.2.17
25+
26+
- run: git fetch --force --tags
27+
- run: bun install
28+
- run: bun install -g @vscode/vsce
29+
30+
- name: Publish
31+
run: ./script/publish
32+
working-directory: ./packages/opencode

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
branches:
77
- dev
88
tags:
9-
- "*"
9+
- "v*.*.*"
1010

1111
concurrency: ${{ github.workflow }}-${{ github.ref }}
1212

scripts/release

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ done
1212
git fetch --force --tags
1313

1414
# Get the latest Git tag
15-
latest_tag=$(git tag --sort=committerdate | grep -E '[0-9]' | tail -1)
15+
latest_tag=$(git tag --sort=committerdate | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | tail -1)
1616

1717
# If there is no tag, exit the script
1818
if [ -z "$latest_tag" ]; then

sdks/github/script/release.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bun
2+
3+
import { $ } from "bun"
4+
5+
try {
6+
await $`git tag -d github-v1`
7+
await $`git push origin :refs/tags/github-v1`
8+
} catch (e: any) {
9+
if (e instanceof $.ShellError && e.stderr.toString().match(/tag \S+ not found/)) {
10+
console.log("tag not found, continuing...")
11+
} else {
12+
throw e
13+
}
14+
}
15+
await $`git tag -a github-v1 -m "Update github-v1 to latest"`
16+
await $`git push origin github-v1`

sdks/vscode/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

sdks/vscode/.vscode-test.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { defineConfig } from '@vscode/test-cli';
2+
3+
export default defineConfig({
4+
files: 'out/test/**/*.test.js',
5+
});

sdks/vscode/.vscodeignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.vscode/**
2+
.vscode-test/**
3+
out/**
4+
node_modules/**
5+
src/**
6+
script/**
7+
.gitignore
8+
.yarnrc
9+
bun.lock
10+
esbuild.js
11+
vsc-extension-quickstart.md
12+
**/tsconfig.json
13+
**/eslint.config.mjs
14+
**/*.map
15+
**/*.ts
16+
**/.vscode-test.*

sdks/vscode/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# opencode VS Code Extension
2+
3+
A VS Code extension that integrates [opencode](https://opencode.ai) directly into your development environment.
4+
5+
## Prerequisites
6+
7+
This extension requires [opencode](https://opencode.ai) to be installed on your system. Visit [opencode.ai](https://opencode.ai) for installation instructions.
8+
9+
## Features
10+
11+
- **Cmd+Escape**: Launch opencode in a split terminal view
12+
- **Alt+Cmd+K**: Send selected code to opencode's prompt
13+
- **Tab awareness**: opencode automatically detects which files you have open
14+
15+
## Support
16+
17+
This is an early release. If you encounter issues or have feedback, please create an issue at https://github.com/sst/opencode/issues.

sdks/vscode/bun.lock

Lines changed: 589 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdks/vscode/esbuild.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
const esbuild = require("esbuild");
2+
3+
const production = process.argv.includes('--production');
4+
const watch = process.argv.includes('--watch');
5+
6+
/**
7+
* @type {import('esbuild').Plugin}
8+
*/
9+
const esbuildProblemMatcherPlugin = {
10+
name: 'esbuild-problem-matcher',
11+
12+
setup(build) {
13+
build.onStart(() => {
14+
console.log('[watch] build started');
15+
});
16+
build.onEnd((result) => {
17+
result.errors.forEach(({ text, location }) => {
18+
console.error(`✘ [ERROR] ${text}`);
19+
console.error(` ${location.file}:${location.line}:${location.column}:`);
20+
});
21+
console.log('[watch] build finished');
22+
});
23+
},
24+
};
25+
26+
async function main() {
27+
const ctx = await esbuild.context({
28+
entryPoints: [
29+
'src/extension.ts'
30+
],
31+
bundle: true,
32+
format: 'cjs',
33+
minify: production,
34+
sourcemap: !production,
35+
sourcesContent: false,
36+
platform: 'node',
37+
outfile: 'dist/extension.js',
38+
external: ['vscode'],
39+
logLevel: 'silent',
40+
plugins: [
41+
/* add to the end of plugins array */
42+
esbuildProblemMatcherPlugin,
43+
],
44+
});
45+
if (watch) {
46+
await ctx.watch();
47+
} else {
48+
await ctx.rebuild();
49+
await ctx.dispose();
50+
}
51+
}
52+
53+
main().catch(e => {
54+
console.error(e);
55+
process.exit(1);
56+
});

0 commit comments

Comments
 (0)