Skip to content

Commit 9407a6f

Browse files
committed
ignore: rm STYLE_GUIDE, consolidate in AGENTS.md
1 parent d75dca2 commit 9407a6f

4 files changed

Lines changed: 73 additions & 74 deletions

File tree

.opencode/opencode.jsonc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// "enterprise": {
55
// "url": "https://enterprise.dev.opencode.ai",
66
// },
7-
"instructions": ["STYLE_GUIDE.md"],
87
"provider": {
98
"opencode": {
109
"options": {},

AGENTS.md

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,75 @@
1-
- To test opencode in `packages/opencode`, run `bun dev`.
21
- To regenerate the JavaScript SDK, run `./packages/sdk/js/script/build.ts`.
32
- ALWAYS USE PARALLEL TOOLS WHEN APPLICABLE.
43
- The default branch in this repo is `dev`.
4+
5+
## Style Guide
6+
7+
- Keep things in one function unless composable or reusable
8+
- Avoid unnecessary destructuring. Instead of `const { a, b } = obj`, use `obj.a` and `obj.b` to preserve context
9+
- Avoid `try`/`catch` where possible
10+
- Avoid using the `any` type
11+
- Prefer single word variable names where possible
12+
- Use Bun APIs when possible, like `Bun.file()`
13+
14+
# Avoid let statements
15+
16+
We don't like `let` statements, especially combined with if/else statements.
17+
Prefer `const`.
18+
19+
Good:
20+
21+
```ts
22+
const foo = condition ? 1 : 2
23+
```
24+
25+
Bad:
26+
27+
```ts
28+
let foo
29+
30+
if (condition) foo = 1
31+
else foo = 2
32+
```
33+
34+
# Avoid else statements
35+
36+
Prefer early returns or using an `iife` to avoid else statements.
37+
38+
Good:
39+
40+
```ts
41+
function foo() {
42+
if (condition) return 1
43+
return 2
44+
}
45+
```
46+
47+
Bad:
48+
49+
```ts
50+
function foo() {
51+
if (condition) return 1
52+
else return 2
53+
}
54+
```
55+
56+
# Prefer single word naming
57+
58+
Try your best to find a single word name for your variables, functions, etc.
59+
Only use multiple words if you cannot.
60+
61+
Good:
62+
63+
```ts
64+
const foo = 1
65+
const bar = 2
66+
const baz = 3
67+
```
68+
69+
Bad:
70+
71+
```ts
72+
const fooBar = 1
73+
const barBaz = 2
74+
const bazFoo = 3
75+
```

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ This runs `bun run --cwd packages/desktop build` automatically via Tauri’s `be
148148
> [!NOTE]
149149
> If you make changes to the API or SDK (e.g. `packages/opencode/src/server/server.ts`), run `./script/generate.ts` to regenerate the SDK and related files.
150150
151-
Please try to follow the [style guide](./STYLE_GUIDE.md)
151+
Please try to follow the [style guide](./AGENTS.md)
152152

153153
### Setting up a Debugger
154154

STYLE_GUIDE.md

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)