{"modulePath":"github.com/memcode-ai/memcode","version":"v0.56.16","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package statedir\n\nPackage statedir decides where memcode keeps a project's state. memcode does not write into the user's folders: everything it records about a project (sessions, the index, approvals, jobs, checkpoints, worktrees) lives in the user-global home, one directory per project, keyed by the project's path:\n\n\t~/.memcode/projects/-Users-me-code-app/\n\nThe one thing that still lives in the project is \\\u003croot\u003e/.memcode/tasks: an autonomous task is a standing instruction a team reviews and commits like code, so it belongs with the code (see internal/task).\n\nLeaf package on purpose (stdlib only): everything that touches project state imports it, and config imports half the tree.\n\n## Constants\n\n```go\nconst EnvHome = \"MEMCODE_HOME\"\n```\nEnvHome overrides the user-global memcode home (default ~/.memcode).\n\n```go\nconst LegacyName = \".memcode\"\n```\nLegacyName is the per-project directory memcode used to create inside the project. Only tasks/ remains there; anything else is migrated out by Migrate.\n\n## Functions\n\n```go\nfunc For(root string) string\n```\nFor returns the state directory for the project at root. It is not created; writers MkdirAll as they always have. The first lookup for a root in a process silently moves any state an older memcode left in the project (Migrate), so every reader and writer sees the global directory, whatever the entry point.\n\n```go\nfunc Home() string\n```\nHome is the user-global memcode directory: $MEMCODE\\_HOME, else ~/.memcode. Under \\`go test\\` it never resolves to the developer's real home: a test that redirected HOME gets $HOME/.memcode, any other test a per-process temp dir.\n\n```go\nfunc Key(root string) string\n```\nKey turns a project root into its directory name under projects/: the absolute, cleaned path with separators (and a drive colon) replaced by '-', so it stays readable (\"-Users-me-code-app\").\n\n```go\nfunc Migrate(root string)\n```\nMigrate moves state an older memcode left inside the project (\\\u003croot\u003e/.memcode/\\*) into For(root), once per process (For does this itself). tasks/ stays in the project. It is idempotent and best-effort: a failure leaves the old directory in place and memcode simply starts fresh state in the global directory. Nothing is deleted unless it was moved first.\n\n","path":"github.com/memcode-ai/memcode/internal/statedir","name":"statedir","synopsis":"Package statedir decides where memcode keeps a project's state.","isRedistributable":true}
