config

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package config 处理应用配置与数据目录解析(AGENTS.md §0.5/§1.5)。

目录语义按各平台原生约定分流,让系统清理 / 备份 / 控制台各得其所:

  • DataDir 用户不可再生的数据(SQLite、配置)
  • LogsDir 诊断日志
  • CachesDir 可再生的缓存与运行期状态(worktree、pgid 跟踪)
  • StateDir 窗口/应用状态

每个平台的命名约定不同(对照业界成熟桌面应用):

  • macOS:Application Support/Monkey Deck、Logs/Monkey Deck、 Caches/com.jessonchan.monkeydeck、Saved Application State/<bundle-id>.savedState
  • Linux:~/.local/share/<slug>、~/.local/state/<slug>[/logs]、~/.cache/<slug>
  • Windows:%LOCALAPPDATA%\<App>\{Logs,Cache,State}

平台逻辑见 paths_*.go(build tags 分发)。

Index

Constants

View Source
const (
	AppName  = "Monkey Deck"
	BundleID = "com.jessonchan.monkeydeck"
	AppSlug  = "monkey-deck"
)

应用身份常量。三段命名(对照业界成熟应用):

  • AppName 用户可见名(Dock / 菜单 / Finder / Windows 目录)
  • BundleID 反向域名系统标识(macOS 签名 / 状态目录 / 沙盒)
  • AppSlug 技术 slug(Linux 目录 / 可执行文件 / 日志文件名 / release asset)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DataDir      string // 用户数据:SQLite、配置 —— 不可丢
	LogsDir      string // 日志:诊断日志,Console.app / journalctl / 事件查看器直接看
	CachesDir    string // 缓存:worktree、pgid 跟踪 —— 可再生
	StateDir     string // 应用状态:窗口几何
	DBPath       string // SQLite 文件路径(位于 DataDir)
	DefaultModel string // 默认 model(provider/model 格式)
}

Config 应用级配置(启动时确定的部分)。

func Default

func Default() *Config

Default 返回当前平台的默认配置。目录按平台约定分流(见包文档)。

func TestConfig

func TestConfig(dir string) *Config

TestConfig 返回所有目录均落在 dir 下的配置(测试用,与 Default 同构)。

func (*Config) EnsureDir

func (c *Config) EnsureDir() error

EnsureDir 创建全部所需目录(若不存在)。DataDir/LogsDir/CachesDir/StateDir 各归位。

Jump to

Keyboard shortcuts

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