mirror of
https://github.com/anomalyco/opencode.git
synced 2026-02-01 22:48:16 +00:00
ignore: rm STYLE_GUIDE, consolidate in AGENTS.md
This commit is contained in:
@@ -4,7 +4,6 @@
|
|||||||
// "enterprise": {
|
// "enterprise": {
|
||||||
// "url": "https://enterprise.dev.opencode.ai",
|
// "url": "https://enterprise.dev.opencode.ai",
|
||||||
// },
|
// },
|
||||||
"instructions": ["STYLE_GUIDE.md"],
|
|
||||||
"provider": {
|
"provider": {
|
||||||
"opencode": {
|
"opencode": {
|
||||||
"options": {},
|
"options": {},
|
||||||
|
|||||||
73
AGENTS.md
73
AGENTS.md
@@ -1,4 +1,75 @@
|
|||||||
- To test opencode in `packages/opencode`, run `bun dev`.
|
|
||||||
- To regenerate the JavaScript SDK, run `./packages/sdk/js/script/build.ts`.
|
- To regenerate the JavaScript SDK, run `./packages/sdk/js/script/build.ts`.
|
||||||
- ALWAYS USE PARALLEL TOOLS WHEN APPLICABLE.
|
- ALWAYS USE PARALLEL TOOLS WHEN APPLICABLE.
|
||||||
- The default branch in this repo is `dev`.
|
- The default branch in this repo is `dev`.
|
||||||
|
|
||||||
|
## Style Guide
|
||||||
|
|
||||||
|
- Keep things in one function unless composable or reusable
|
||||||
|
- Avoid unnecessary destructuring. Instead of `const { a, b } = obj`, use `obj.a` and `obj.b` to preserve context
|
||||||
|
- Avoid `try`/`catch` where possible
|
||||||
|
- Avoid using the `any` type
|
||||||
|
- Prefer single word variable names where possible
|
||||||
|
- Use Bun APIs when possible, like `Bun.file()`
|
||||||
|
|
||||||
|
# Avoid let statements
|
||||||
|
|
||||||
|
We don't like `let` statements, especially combined with if/else statements.
|
||||||
|
Prefer `const`.
|
||||||
|
|
||||||
|
Good:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const foo = condition ? 1 : 2
|
||||||
|
```
|
||||||
|
|
||||||
|
Bad:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
let foo
|
||||||
|
|
||||||
|
if (condition) foo = 1
|
||||||
|
else foo = 2
|
||||||
|
```
|
||||||
|
|
||||||
|
# Avoid else statements
|
||||||
|
|
||||||
|
Prefer early returns or using an `iife` to avoid else statements.
|
||||||
|
|
||||||
|
Good:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
function foo() {
|
||||||
|
if (condition) return 1
|
||||||
|
return 2
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Bad:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
function foo() {
|
||||||
|
if (condition) return 1
|
||||||
|
else return 2
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
# Prefer single word naming
|
||||||
|
|
||||||
|
Try your best to find a single word name for your variables, functions, etc.
|
||||||
|
Only use multiple words if you cannot.
|
||||||
|
|
||||||
|
Good:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const foo = 1
|
||||||
|
const bar = 2
|
||||||
|
const baz = 3
|
||||||
|
```
|
||||||
|
|
||||||
|
Bad:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const fooBar = 1
|
||||||
|
const barBaz = 2
|
||||||
|
const bazFoo = 3
|
||||||
|
```
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ This runs `bun run --cwd packages/desktop build` automatically via Tauri’s `be
|
|||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> 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.
|
> 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.
|
||||||
|
|
||||||
Please try to follow the [style guide](./STYLE_GUIDE.md)
|
Please try to follow the [style guide](./AGENTS.md)
|
||||||
|
|
||||||
### Setting up a Debugger
|
### Setting up a Debugger
|
||||||
|
|
||||||
|
|||||||
@@ -1,71 +0,0 @@
|
|||||||
## Style Guide
|
|
||||||
|
|
||||||
- Keep things in one function unless composable or reusable
|
|
||||||
- Avoid unnecessary destructuring. Instead of `const { a, b } = obj`, use `obj.a` and `obj.b` to preserve context
|
|
||||||
- Avoid `try`/`catch` where possible
|
|
||||||
- Avoid using the `any` type
|
|
||||||
- Prefer single word variable names where possible
|
|
||||||
- Use Bun APIs when possible, like `Bun.file()`
|
|
||||||
|
|
||||||
# Avoid let statements
|
|
||||||
|
|
||||||
We don't like `let` statements, especially combined with if/else statements.
|
|
||||||
Prefer `const`.
|
|
||||||
|
|
||||||
Good:
|
|
||||||
|
|
||||||
```ts
|
|
||||||
const foo = condition ? 1 : 2
|
|
||||||
```
|
|
||||||
|
|
||||||
Bad:
|
|
||||||
|
|
||||||
```ts
|
|
||||||
let foo
|
|
||||||
|
|
||||||
if (condition) foo = 1
|
|
||||||
else foo = 2
|
|
||||||
```
|
|
||||||
|
|
||||||
# Avoid else statements
|
|
||||||
|
|
||||||
Prefer early returns or using an `iife` to avoid else statements.
|
|
||||||
|
|
||||||
Good:
|
|
||||||
|
|
||||||
```ts
|
|
||||||
function foo() {
|
|
||||||
if (condition) return 1
|
|
||||||
return 2
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Bad:
|
|
||||||
|
|
||||||
```ts
|
|
||||||
function foo() {
|
|
||||||
if (condition) return 1
|
|
||||||
else return 2
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
# Prefer single word naming
|
|
||||||
|
|
||||||
Try your best to find a single word name for your variables, functions, etc.
|
|
||||||
Only use multiple words if you cannot.
|
|
||||||
|
|
||||||
Good:
|
|
||||||
|
|
||||||
```ts
|
|
||||||
const foo = 1
|
|
||||||
const bar = 2
|
|
||||||
const baz = 3
|
|
||||||
```
|
|
||||||
|
|
||||||
Bad:
|
|
||||||
|
|
||||||
```ts
|
|
||||||
const fooBar = 1
|
|
||||||
const barBaz = 2
|
|
||||||
const bazFoo = 3
|
|
||||||
```
|
|
||||||
Reference in New Issue
Block a user