mirror of
https://github.com/sst/opencode.git
synced 2025-07-07 16:14:59 +00:00
feat: write to context.md by default
This commit is contained in:
parent
b2f24e38ed
commit
364cf5b429
5 changed files with 31 additions and 5 deletions
24
CONTEXT.md
Normal file
24
CONTEXT.md
Normal file
|
@ -0,0 +1,24 @@
|
|||
# OpenCode Development Context
|
||||
|
||||
## Build Commands
|
||||
- Build: `go build`
|
||||
- Run: `go run main.go`
|
||||
- Test: `go test ./...`
|
||||
- Test single package: `go test ./internal/package/...`
|
||||
- Test single test: `go test ./internal/package -run TestName`
|
||||
- Verbose test: `go test -v ./...`
|
||||
- Coverage: `go test -cover ./...`
|
||||
- Lint: `go vet ./...`
|
||||
- Format: `go fmt ./...`
|
||||
- Build snapshot: `./scripts/snapshot`
|
||||
|
||||
## Code Style
|
||||
- Use Go 1.24+ features
|
||||
- Follow standard Go formatting (gofmt)
|
||||
- Use table-driven tests with t.Parallel() when possible
|
||||
- Error handling: check errors immediately, return early
|
||||
- Naming: CamelCase for exported, camelCase for unexported
|
||||
- Imports: standard library first, then external, then internal
|
||||
- Use context.Context for cancellation and timeouts
|
||||
- Prefer interfaces for dependencies to enable testing
|
||||
- Use testify for assertions in tests
|
|
@ -102,6 +102,8 @@ var defaultContextPaths = []string{
|
|||
".cursor/rules/",
|
||||
"CLAUDE.md",
|
||||
"CLAUDE.local.md",
|
||||
"CONTEXT.md",
|
||||
"CONTEXT.local.md",
|
||||
"opencode.md",
|
||||
"opencode.local.md",
|
||||
"OpenCode.md",
|
||||
|
|
|
@ -81,7 +81,7 @@ If the current working directory contains a file called OpenCode.md, it will be
|
|||
2. Recording the user's code style preferences (naming conventions, preferred libraries, etc.)
|
||||
3. Maintaining useful information about the codebase structure and organization
|
||||
|
||||
When you spend time searching for commands to typecheck, lint, build, or test, you should ask the user if it's okay to add those commands to OpenCode.md. Similarly, when learning about code style preferences or important codebase information, ask if it's okay to add that to OpenCode.md so you can remember it for next time.
|
||||
When you spend time searching for commands to typecheck, lint, build, or test, you should ask the user if it's okay to add those commands to CONTEXT.md. Similarly, when learning about code style preferences or important codebase information, ask if it's okay to add that to CONTEXT.md so you can remember it for next time.
|
||||
|
||||
# Tone and style
|
||||
You should be concise, direct, and to the point. When you run a non-trivial bash command, you should explain what the command does and why you are running it, to make sure the user understands what you are doing (this is especially important when you are running a command that will make changes to the user's system).
|
||||
|
|
|
@ -110,7 +110,7 @@ func (m InitDialogCmp) View() string {
|
|||
Foreground(t.Text()).
|
||||
Width(maxWidth).
|
||||
Padding(0, 1).
|
||||
Render("Initialization generates a new OpenCode.md file that contains information about your codebase, this file serves as memory for each project, you can freely add to it to help the agents be better at their job.")
|
||||
Render("Initialization generates a new CONTEXT.md file that contains information about your codebase, this file serves as memory for each project, you can freely add to it to help the agents be better at their job.")
|
||||
|
||||
question := baseStyle.
|
||||
Foreground(t.Text()).
|
||||
|
|
|
@ -707,14 +707,14 @@ func New(app *app.App) tea.Model {
|
|||
model.RegisterCommand(dialog.Command{
|
||||
ID: "init",
|
||||
Title: "Initialize Project",
|
||||
Description: "Create/Update the OpenCode.md memory file",
|
||||
Description: "Create/Update the CONTEXT.md memory file",
|
||||
Handler: func(cmd dialog.Command) tea.Cmd {
|
||||
prompt := `Please analyze this codebase and create a OpenCode.md file containing:
|
||||
prompt := `Please analyze this codebase and create a CONTEXT.md file containing:
|
||||
1. Build/lint/test commands - especially for running a single test
|
||||
2. Code style guidelines including imports, formatting, types, naming conventions, error handling, etc.
|
||||
|
||||
The file you create will be given to agentic coding agents (such as yourself) that operate in this repository. Make it about 20 lines long.
|
||||
If there's already a opencode.md, improve it.
|
||||
If there's already a CONTEXT.md, improve it.
|
||||
If there are Cursor rules (in .cursor/rules/ or .cursorrules) or Copilot rules (in .github/copilot-instructions.md), make sure to include them.`
|
||||
return tea.Batch(
|
||||
util.CmdHandler(chat.SendMsg{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue