rc

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package rc provides runtime configuration loading from .contextrc files.

Index

Constants

View Source
const DefaultArchiveAfterDays = 7

DefaultArchiveAfterDays is the default days before archiving.

View Source
const DefaultTokenBudget = 8000

DefaultTokenBudget is the default token budget when not configured.

Variables

This section is empty.

Functions

func AllowOutsideCwd added in v0.6.0

func AllowOutsideCwd() bool

AllowOutsideCwd returns whether boundary validation should be skipped.

Returns false (default) when the field is not set in .contextrc.

Returns:

  • bool: True if context directory is allowed outside the project root

func ArchiveAfterDays

func ArchiveAfterDays() int

ArchiveAfterDays returns the configured days before archiving.

Returns:

  • int: Number of days after which completed tasks are archived (default 7)

func AutoArchive

func AutoArchive() bool

AutoArchive returns whether auto-archiving is enabled.

Returns:

  • bool: True if completed tasks should be auto-archived

func ContextDir

func ContextDir() string

ContextDir returns the configured context directory.

Priority: CLI override > env var > .contextrc > default.

Returns:

  • string: The context directory path (e.g., ".context")

func FilePriority

func FilePriority(name string) int

FilePriority returns the priority of a context file.

If a priority_order is configured in .contextrc, that order is used. Otherwise, the default config.FileReadOrder is used.

Lower numbers indicate higher priority (1 = highest). Unknown files return 100.

Parameters:

  • name: Filename to look up (e.g., "TASKS.md")

Returns:

  • int: Priority value (1-9 for known files, 100 for unknown)

func OverrideContextDir

func OverrideContextDir(dir string)

OverrideContextDir sets a CLI-provided override for the context directory.

This takes precedence over all other configuration sources.

Parameters:

  • dir: Directory path to use as an override

func PriorityOrder

func PriorityOrder() []string

PriorityOrder returns the configured file priority order.

Returns:

  • []string: File names in priority order, or nil if not configured (callers should fall back to config.FileReadOrder)

func Reset

func Reset()

Reset clears the cached configuration, forcing reload on the next access. This is primarily useful for testing.

func ScratchpadEncrypt added in v0.6.0

func ScratchpadEncrypt() bool

ScratchpadEncrypt returns whether the scratchpad should be encrypted.

Returns true (default) when the field is not set in .contextrc.

Returns:

  • bool: True if scratchpad encryption is enabled (default true)

func TokenBudget

func TokenBudget() int

TokenBudget returns the configured default token budget.

Priority: env var > .contextrc > default (8000).

Returns:

  • int: The token budget for context assembly

Types

type CtxRC

type CtxRC struct {
	ContextDir        string   `yaml:"context_dir"`
	TokenBudget       int      `yaml:"token_budget"`
	PriorityOrder     []string `yaml:"priority_order"`
	AutoArchive       bool     `yaml:"auto_archive"`
	ArchiveAfterDays  int      `yaml:"archive_after_days"`
	ScratchpadEncrypt *bool    `yaml:"scratchpad_encrypt"`
	AllowOutsideCwd   bool     `yaml:"allow_outside_cwd"`
}

CtxRC represents the configuration from the .contextrc file.

Fields:

  • ContextDir: Name of the context directory (default ".context")
  • TokenBudget: Default token budget for context assembly (default 8000)
  • PriorityOrder: Custom file loading priority order
  • AutoArchive: Whether to auto-archive completed tasks (default true)
  • ArchiveAfterDays: Days before archiving completed tasks (default 7)
  • ScratchpadEncrypt: Whether to encrypt the scratchpad (default true)
  • AllowOutsideCwd: Skip boundary validation for external context dirs (default false)

func Default

func Default() *CtxRC

Default returns a new CtxRC with hardcoded default values.

Returns:

  • *CtxRC: Configuration with defaults (8000 token budget, 7-day archive, etc.)

func RC

func RC() *CtxRC

RC returns the loaded configuration, initializing it on the first call.

It loads from .contextrc if present, then applies environment overrides. The result is cached for subsequent calls.

Returns:

  • *CtxRC: The loaded and cached configuration

Jump to

Keyboard shortcuts

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