contextfiles

package
v1.1.60 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultRuleContent = `` /* 2164-byte string literal not displayed */

DefaultRuleContent is the default restrictive project rule template written by /rule.

View Source
const RuleFile = config.ProjectDirName + "/rule.md"

RuleFile is the path to the project-level rule file relative to the working directory.

Variables

This section is empty.

Functions

func BuildContextString

func BuildContextString(result *LoadResult) string

BuildContextString concatenates all context files into a single string suitable for appending to the system prompt. Order: global -> parent (root to cwd) -> project (current dir)

func EnsureRuleFile added in v1.1.59

func EnsureRuleFile(cwd string, overwrite bool) (path string, content string, written bool, err error)

EnsureRuleFile creates .mothx/rule.md with DefaultRuleContent. Existing files are preserved unless overwrite is true.

func LoadRuleFile added in v1.1.59

func LoadRuleFile(cwd string) string

LoadRuleFile loads .mothx/rule.md from the given working directory. Missing or unreadable files are ignored.

func RuleFilePath added in v1.1.59

func RuleFilePath(cwd string) string

RuleFilePath returns the rule file path for cwd.

Types

type FileContent

type FileContent struct {
	Path    string // absolute path
	Name    string // file name
	Content string // file content
}

FileContent represents a loaded context file.

type LoadResult

type LoadResult struct {
	GlobalFiles  []FileContent // files from ~/.mothx/
	ParentFiles  []FileContent // files from parent directories
	ProjectFiles []FileContent // files from current directory
}

LoadResult contains the loaded context files.

func LoadContextFiles

func LoadContextFiles(cwd string, globalConfigDir string, extraFiles []string) *LoadResult

LoadContextFiles discovers and loads context files from all relevant locations. It walks up from cwd to the root, then checks the global config directory.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL