GeezerVison is showing github.com — ignore: rm STYLE_GUIDE, consolidate in AGENTS.md · bzbetty/opencode@9407a6f
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: .opencode/opencode.jsonc -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
|
4 | 4 | // "enterprise": { |
5 | 5 | // "url": "https://enterprise.dev.opencode.ai", |
6 | 6 | // }, |
7 | | - "instructions": ["STYLE_GUIDE.md"], |
8 | 7 | "provider": { |
9 | 8 | "opencode": { |
10 | 9 | "options": {}, |
|
Collapse file
Copy file name to clipboard +72-1Lines changed: 72 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | | -- To test opencode in `packages/opencode`, run `bun dev`. |
2 | 1 | - To regenerate the JavaScript SDK, run `./packages/sdk/js/script/build.ts`. |
3 | 2 | - ALWAYS USE PARALLEL TOOLS WHEN APPLICABLE. |
4 | 3 | - 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 | +``` |
Collapse file
Copy file name to clipboardExpand all lines: CONTRIBUTING.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -148,7 +148,7 @@ This runs `bun run --cwd packages/desktop build` automatically via Tauri’s `be |
148 | 148 | > [!NOTE] |
149 | 149 | > 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. |
150 | 150 |
|
151 | | -Please try to follow the [style guide](./STYLE_GUIDE.md) |
| 151 | +Please try to follow the [style guide](./AGENTS.md) |
152 | 152 |
|
153 | 153 | ### Setting up a Debugger |
154 | 154 |
|
|
Collapse file
Copy file name to clipboardExpand all lines: STYLE_GUIDE.md -71Lines changed: 0 additions & 71 deletions