diff --git a/README.md b/README.md index 4135ddea8c6209f05989e64ddc356a2244efbb03..43effa7820c90b7b0f1903fbb7346ffc20a8d818 100644 --- a/README.md +++ b/README.md @@ -311,6 +311,31 @@ using `$(echo $VAR)` syntax. } ``` +### Memory files + +Crush automatically includes two files for cross-project instructions. + +- `~/.config/crush/CRUSH.md`: Crush-specific rules that would confuse other + agentic coding tools. If you only use Crush, this is the only one you need to + edit. +- `~/.config/AGENTS.md`: generic instructions that other coding tools might + read. Avoid referring to Crush-specific tools or workflows here. + +You can customize these paths using the `memory_paths` option in your +configuration: + +```jsonc +{ + "$schema": "https://charm.land/crush.json", + "options": { + "memory_paths": [ + "~/path/to/custom/memory/file.md", + "/full/path/to/folder/of/files/" // recursively load all .md files in folder + ] + } +} +``` + ### Ignoring Files Crush respects `.gitignore` files by default, but you can also create a diff --git a/internal/config/config.go b/internal/config/config.go index 901562420e61fe3950886bebba7ff094eb8c91b6..f482a1402433821d282805bde1cc9fe515a5c5a1 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -240,6 +240,7 @@ func (Attribution) JSONSchemaExtend(schema *jsonschema.Schema) { type Options struct { ContextPaths []string `json:"context_paths,omitempty" jsonschema:"description=Paths to files containing context information for the AI,example=.cursorrules,example=CRUSH.md"` + MemoryPaths []string `json:"memory_paths,omitempty" jsonschema:"description=Paths to files containing memory information for the AI,default=~/.config/crush/CRUSH.md,default=~/.config/AGENTS.md"` SkillsPaths []string `json:"skills_paths,omitempty" jsonschema:"description=Paths to directories containing Agent Skills (folders with SKILL.md files),example=~/.config/crush/skills,example=./skills"` TUI *TUIOptions `json:"tui,omitempty" jsonschema:"description=Terminal user interface options"` Debug bool `json:"debug,omitempty" jsonschema:"description=Enable debug logging,default=false"` diff --git a/internal/config/load.go b/internal/config/load.go index 63904abc057e877c959991769c20f62a7ac8459a..585c1e3c3fef94058bc73a97fbb81a6c1ff94ee5 100644 --- a/internal/config/load.go +++ b/internal/config/load.go @@ -330,6 +330,14 @@ func (c *Config) setDefaults(workingDir, dataDir string) { if c.Options.ContextPaths == nil { c.Options.ContextPaths = []string{} } + if c.Options.MemoryPaths == nil { + crushConfigDir := filepath.Dir(GlobalConfig()) + c.Options.MemoryPaths = []string{ + filepath.Join(crushConfigDir, "CRUSH.md"), + filepath.Join(filepath.Dir(crushConfigDir), "AGENTS.md"), + } + } + c.Options.ContextPaths = append(c.Options.ContextPaths, c.Options.MemoryPaths...) if c.Options.SkillsPaths == nil { c.Options.SkillsPaths = []string{} } @@ -363,6 +371,7 @@ func (c *Config) setDefaults(workingDir, dataDir string) { // Add the default context paths if they are not already present c.Options.ContextPaths = append(defaultContextPaths, c.Options.ContextPaths...) + slices.Sort(c.Options.ContextPaths) c.Options.ContextPaths = slices.Compact(c.Options.ContextPaths) diff --git a/schema.json b/schema.json index a2d88bfd5f4be210534209694a9f0c0eb5c993c0..f9b44870373a8364cb6c4a0421d6054bc66e25aa 100644 --- a/schema.json +++ b/schema.json @@ -367,6 +367,17 @@ "type": "array", "description": "Paths to files containing context information for the AI" }, + "memory_paths": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Paths to files containing memory information for the AI", + "default": [ + "~/.config/crush/CRUSH.md", + "~/.config/AGENTS.md" + ] + }, "skills_paths": { "items": { "type": "string",