Skip to content

Commit be78bd1

Browse files
first!
1 parent 1011f9e commit be78bd1

7 files changed

Lines changed: 756 additions & 0 deletions

File tree

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# dependencies (bun install)
2+
node_modules
3+
4+
# output
5+
out
6+
dist
7+
*.tgz
8+
9+
# code coverage
10+
coverage
11+
*.lcov
12+
13+
# logs
14+
logs
15+
_.log
16+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
17+
18+
# dotenv environment variable files
19+
.env
20+
.env.development.local
21+
.env.test.local
22+
.env.production.local
23+
.env.local
24+
25+
# caches
26+
.eslintcache
27+
.cache
28+
*.tsbuildinfo
29+
30+
# IntelliJ based IDEs
31+
.idea
32+
33+
# Finder (MacOS) folder config
34+
.DS_Store

CLAUDE.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
2+
Default to using Bun instead of Node.js.
3+
4+
- Use `bun <file>` instead of `node <file>` or `ts-node <file>`
5+
- Use `bun test` instead of `jest` or `vitest`
6+
- Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`
7+
- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
8+
- Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>`
9+
- Use `bunx <package> <command>` instead of `npx <package> <command>`
10+
- Bun automatically loads .env, so don't use dotenv.
11+
12+
## APIs
13+
14+
- `Bun.serve()` supports WebSockets, HTTPS, and routes. Don't use `express`.
15+
- `bun:sqlite` for SQLite. Don't use `better-sqlite3`.
16+
- `Bun.redis` for Redis. Don't use `ioredis`.
17+
- `Bun.sql` for Postgres. Don't use `pg` or `postgres.js`.
18+
- `WebSocket` is built-in. Don't use `ws`.
19+
- Prefer `Bun.file` over `node:fs`'s readFile/writeFile
20+
- Bun.$`ls` instead of execa.
21+
22+
## Testing
23+
24+
Use `bun test` to run tests.
25+
26+
```ts#index.test.ts
27+
import { test, expect } from "bun:test";
28+
29+
test("hello world", () => {
30+
expect(1).toBe(1);
31+
});
32+
```
33+
34+
## Frontend
35+
36+
Use HTML imports with `Bun.serve()`. Don't use `vite`. HTML imports fully support React, CSS, Tailwind.
37+
38+
Server:
39+
40+
```ts#index.ts
41+
import index from "./index.html"
42+
43+
Bun.serve({
44+
routes: {
45+
"/": index,
46+
"/api/users/:id": {
47+
GET: (req) => {
48+
return new Response(JSON.stringify({ id: req.params.id }));
49+
},
50+
},
51+
},
52+
// optional websocket support
53+
websocket: {
54+
open: (ws) => {
55+
ws.send("Hello, world!");
56+
},
57+
message: (ws, message) => {
58+
ws.send(message);
59+
},
60+
close: (ws) => {
61+
// handle close
62+
}
63+
},
64+
development: {
65+
hmr: true,
66+
console: true,
67+
}
68+
})
69+
```
70+
71+
HTML files can import .tsx, .jsx or .js files directly and Bun's bundler will transpile & bundle automatically. `<link>` tags can point to stylesheets and Bun's CSS bundler will bundle.
72+
73+
```html#index.html
74+
<html>
75+
<body>
76+
<h1>Hello, world!</h1>
77+
<script type="module" src="./frontend.tsx"></script>
78+
</body>
79+
</html>
80+
```
81+
82+
With the following `frontend.tsx`:
83+
84+
```tsx#frontend.tsx
85+
import React from "react";
86+
import { createRoot } from "react-dom/client";
87+
88+
// import .css files directly and it works
89+
import './index.css';
90+
91+
const root = createRoot(document.body);
92+
93+
export default function Frontend() {
94+
return <h1>Hello, world!</h1>;
95+
}
96+
97+
root.render(<Frontend />);
98+
```
99+
100+
Then, run index.ts
101+
102+
```sh
103+
bun --hot ./index.ts
104+
```
105+
106+
For more information, read the Bun API docs in `node_modules/bun-types/docs/**.mdx`.

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# opencode-plugin-otel
2+
3+
To install dependencies:
4+
5+
```bash
6+
bun install
7+
```
8+
9+
To run:
10+
11+
```bash
12+
bun run index.ts
13+
```
14+
15+
This project was created using `bun init` in bun v1.3.10. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.

bun.lock

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

package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "opencode-plugin-otel",
3+
"module": "src/index.ts",
4+
"type": "module",
5+
"devDependencies": {
6+
"@types/bun": "latest"
7+
},
8+
"scripts": {
9+
"build": "bun build src/index.ts --outdir dist --target bun --format esm && tsc --emitDeclarationOnly",
10+
"clean": "rm -rf dist",
11+
"prepublishOnly": "bun run clean && bun run build",
12+
"release:patch": "npm version patch && npm publish",
13+
"release:minor": "npm version minor && npm publish",
14+
"release:major": "npm version major && npm publish",
15+
"typecheck": "tsc --noEmit"
16+
},
17+
"dependencies": {
18+
"@opencode-ai/plugin": "^1.2.23",
19+
"@opencode-ai/sdk": "^1.2.23",
20+
"@opentelemetry/api": "^1.9.0",
21+
"@opentelemetry/exporter-logs-otlp-grpc": "^0.213.0",
22+
"@opentelemetry/exporter-metrics-otlp-grpc": "^0.213.0",
23+
"@opentelemetry/resources": "^2.6.0",
24+
"@opentelemetry/sdk-logs": "^0.213.0",
25+
"@opentelemetry/sdk-metrics": "^2.6.0",
26+
"@opentelemetry/sdk-node": "^0.213.0",
27+
"@opentelemetry/semantic-conventions": "^1.40.0",
28+
"typescript": "^5.9.3"
29+
}
30+
}

0 commit comments

Comments
 (0)